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