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