equal
deleted
inserted
replaced
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/modules/plugin/base/src/nsPluginHost.cpp b/modules/plugin/base/src/nsPluginHost.cpp |
5 --- a/modules/plugin/base/src/nsPluginHost.cpp |
5 --- a/modules/plugin/base/src/nsPluginHost.cpp |
6 +++ b/modules/plugin/base/src/nsPluginHost.cpp |
6 +++ b/modules/plugin/base/src/nsPluginHost.cpp |
7 @@ -3929,8 +3929,41 @@ nsPluginHost::FindPluginForType(const ch |
7 @@ -1620,17 +1620,47 @@ nsPluginHost::FindPluginForType(const ch |
|
8 nsPluginTag *plugins = nsnull; |
|
9 PRInt32 variants, cnt; |
|
10 |
|
11 LoadPlugins(); |
|
12 |
8 // if we have a mimetype passed in, search the mPlugins |
13 // if we have a mimetype passed in, search the mPlugins |
9 // linked list for a match |
14 // linked list for a match |
10 if (nsnull != aMimeType) { |
15 if (aMimeType) { |
11 + nsresult res; |
16 + nsresult res; |
12 + nsCOMPtr<nsIPrefBranch> prefB (do_QueryInterface(mPrefService)); |
17 + nsCOMPtr<nsIPrefBranch> prefB (do_QueryInterface(mPrefService)); |
13 + |
18 + |
14 + char *preferredPluginPath = NULL; |
19 + char *preferredPluginPath = NULL; |
15 + nsCAutoString mimetypePrefString ("modules.plugins.mimetype."); |
20 + nsCAutoString mimetypePrefString ("modules.plugins.mimetype."); |
18 + res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath); |
23 + res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath); |
19 + |
24 + |
20 + if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL; |
25 + if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL; |
21 + |
26 + |
22 plugins = mPlugins; |
27 plugins = mPlugins; |
23 - |
|
24 + if(preferredPluginPath) { |
28 + if(preferredPluginPath) { |
25 + while (nsnull != plugins) { |
29 + while (nsnull != plugins) { |
26 + if (0 == PL_strcasecmp(plugins->mFileName.get(), preferredPluginPath) || |
30 + if (0 == PL_strcasecmp(plugins->mFileName.get(), preferredPluginPath) || |
27 + 0 == PL_strcasecmp(plugins->mFullPath.get(), preferredPluginPath)) { |
31 + 0 == PL_strcasecmp(plugins->mFullPath.get(), preferredPluginPath)) { |
28 + return plugins; |
32 + return plugins; |
38 + return plugins; |
42 + return plugins; |
39 + } |
43 + } |
40 + plugins = plugins->mNext; |
44 + plugins = plugins->mNext; |
41 + } |
45 + } |
42 + } |
46 + } |
43 + |
47 |
44 + // if there is no pref for this mime-type, or if the plugin named in pref |
48 while (plugins) { |
45 + // isn't found, we pick the first that matches for this mime-type |
|
46 + plugins = mPlugins; |
|
47 while (nsnull != plugins) { |
|
48 variants = plugins->mVariants; |
49 variants = plugins->mVariants; |
49 for (cnt = 0; cnt < variants; cnt++) { |
50 for (cnt = 0; cnt < variants; cnt++) { |
|
51 if ((!aCheckEnabled || plugins->IsEnabled()) && |
|
52 plugins->mMimeTypeArray[cnt] && |
|
53 (0 == PL_strcasecmp(plugins->mMimeTypeArray[cnt], aMimeType))) { |
|
54 return plugins; |