1 From: Ubuntu |
|
2 Subject: introduce a pref to prefer certain plugins for mime-types |
|
3 |
|
4 diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp |
|
5 --- a/dom/plugins/base/nsPluginHost.cpp |
|
6 +++ b/dom/plugins/base/nsPluginHost.cpp |
|
7 @@ -1334,17 +1334,51 @@ nsPluginHost::FindPluginForType(const ch |
|
8 if (!aMimeType) { |
|
9 return nullptr; |
|
10 } |
|
11 |
|
12 LoadPlugins(); |
|
13 |
|
14 InfallibleTArray<nsPluginTag*> matchingPlugins; |
|
15 |
|
16 + char *preferredPluginPath = nullptr; |
|
17 + nsAutoCString mimetypePrefString ("modules.plugins.mimetype."); |
|
18 + mimetypePrefString.Append(aMimeType); |
|
19 + const char *mimetypePrefChar = mimetypePrefString.get(); |
|
20 + nsAdoptingCString pluginPath = Preferences::GetCString(mimetypePrefChar); |
|
21 + preferredPluginPath = (char*) pluginPath.get(); |
|
22 + |
|
23 nsPluginTag *plugin = mPlugins; |
|
24 + |
|
25 + if(preferredPluginPath) { |
|
26 + while (plugin) { |
|
27 + if (!aCheckEnabled || plugin->IsEnabled()) { |
|
28 + if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) || |
|
29 + 0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) { |
|
30 + matchingPlugins.AppendElement(plugin); |
|
31 + } |
|
32 + } |
|
33 + plugin = plugin->mNext; |
|
34 + } |
|
35 + |
|
36 + // now lets search for substrings |
|
37 + plugin = mPlugins; |
|
38 + while (plugin) { |
|
39 + if (!aCheckEnabled || plugin->IsEnabled()) { |
|
40 + if (nullptr != PL_strstr(plugin->mFileName.get(), preferredPluginPath) || |
|
41 + nullptr != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) { |
|
42 + matchingPlugins.AppendElement(plugin); |
|
43 + } |
|
44 + } |
|
45 + plugin = plugin->mNext; |
|
46 + } |
|
47 + |
|
48 + return FindPreferredPlugin(matchingPlugins); |
|
49 + } |
|
50 + |
|
51 while (plugin) { |
|
52 if (!aCheckEnabled || plugin->IsActive()) { |
|
53 int32_t mimeCount = plugin->mMimeTypes.Length(); |
|
54 for (int32_t i = 0; i < mimeCount; i++) { |
|
55 if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) { |
|
56 matchingPlugins.AppendElement(plugin); |
|
57 break; |
|
58 } |
|