1 From: Ubuntu |
1 From: Ubuntu |
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/modules/plugin/base/src/nsPluginHost.cpp b/modules/plugin/base/src/nsPluginHost.cpp |
4 diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp |
5 --- a/modules/plugin/base/src/nsPluginHost.cpp |
5 --- a/dom/plugins/base/nsPluginHost.cpp |
6 +++ b/modules/plugin/base/src/nsPluginHost.cpp |
6 +++ b/dom/plugins/base/nsPluginHost.cpp |
7 @@ -1620,17 +1620,47 @@ nsPluginHost::FindPluginForType(const ch |
7 @@ -1637,17 +1637,48 @@ nsPluginHost::FindPluginForType(const ch |
8 nsPluginTag *plugins = nsnull; |
8 PRBool aCheckEnabled) |
9 PRInt32 variants, cnt; |
9 { |
|
10 if (!aMimeType) { |
|
11 return nsnull; |
|
12 } |
10 |
13 |
11 LoadPlugins(); |
14 LoadPlugins(); |
12 |
15 |
13 // if we have a mimetype passed in, search the mPlugins |
16 + nsresult res; |
14 // linked list for a match |
17 + nsCOMPtr<nsIPrefBranch> prefB (do_QueryInterface(mPrefService)); |
15 if (aMimeType) { |
|
16 + nsresult res; |
|
17 + nsCOMPtr<nsIPrefBranch> prefB (do_QueryInterface(mPrefService)); |
|
18 + |
18 + |
19 + char *preferredPluginPath = NULL; |
19 + char *preferredPluginPath = NULL; |
20 + nsCAutoString mimetypePrefString ("modules.plugins.mimetype."); |
20 + nsCAutoString mimetypePrefString ("modules.plugins.mimetype."); |
21 + mimetypePrefString.Append(aMimeType); |
21 + mimetypePrefString.Append(aMimeType); |
22 + const char *mimetypePrefChar = mimetypePrefString.get(); |
22 + const char *mimetypePrefChar = mimetypePrefString.get(); |
23 + res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath); |
23 + res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath); |
24 + |
24 + |
25 + if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL; |
25 + if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL; |
26 + |
26 + |
27 plugins = mPlugins; |
27 nsPluginTag *plugin = mPlugins; |
28 + if(preferredPluginPath) { |
28 + if(preferredPluginPath) { |
29 + while (nsnull != plugins) { |
29 + while (nsnull != plugin) { |
30 + if (0 == PL_strcasecmp(plugins->mFileName.get(), preferredPluginPath) || |
30 + if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) || |
31 + 0 == PL_strcasecmp(plugins->mFullPath.get(), preferredPluginPath)) { |
31 + 0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) { |
32 + return plugins; |
32 + return plugin; |
33 + } |
|
34 + plugins = plugins->mNext; |
|
35 + } |
33 + } |
|
34 + plugin = plugin->mNext; |
|
35 + } |
36 + |
36 + |
37 + // now lets search for substrings |
37 + // now lets search for substrings |
38 + plugins=mPlugins; |
38 + plugin = mPlugins; |
39 + while (nsnull != plugins) { |
39 + while (nsnull != plugin) { |
40 + if (nsnull != PL_strstr(plugins->mFileName.get(), preferredPluginPath) || |
40 + if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) || |
41 + nsnull != PL_strstr(plugins->mFullPath.get(), preferredPluginPath)) { |
41 + nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) { |
42 + return plugins; |
42 + return plugin; |
43 + } |
|
44 + plugins = plugins->mNext; |
|
45 + } |
43 + } |
|
44 + plugin = plugin->mNext; |
46 + } |
45 + } |
47 |
46 + } |
48 while (plugins) { |
47 + |
49 variants = plugins->mVariants; |
48 while (plugin) { |
50 for (cnt = 0; cnt < variants; cnt++) { |
49 if (!aCheckEnabled || plugin->IsEnabled()) { |
51 if ((!aCheckEnabled || plugins->IsEnabled()) && |
50 PRInt32 mimeCount = plugin->mMimeTypes.Length(); |
52 plugins->mMimeTypeArray[cnt] && |
51 for (PRInt32 i = 0; i < mimeCount; i++) { |
53 (0 == PL_strcasecmp(plugins->mMimeTypeArray[cnt], aMimeType))) { |
52 if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) { |
54 return plugins; |
53 return plugin; |
|
54 } |
|
55 } |