author | Wolfgang Rosenauer <wr@rosenauer.org> |
Mon, 25 Jun 2012 11:08:07 +0200 | |
branch | firefox13 |
changeset 489 | f5ef195f348b |
parent 367 | 3fabd9f66322 |
permissions | -rw-r--r-- |
8 | 1 |
From: Ubuntu |
2 |
Subject: introduce a pref to prefer certain plugins for mime-types |
|
3 |
||
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
4 |
diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
5 |
--- a/dom/plugins/base/nsPluginHost.cpp |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
6 |
+++ b/dom/plugins/base/nsPluginHost.cpp |
489
f5ef195f348b
13.0.2 with adopted mozilla-prefer_plugin_pref.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
7 |
@@ -1642,19 +1642,51 @@ nsPluginHost::FindPluginForType(const ch |
367
3fabd9f66322
begin Firefox 10 cycle
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
289
diff
changeset
|
8 |
bool aCheckEnabled) |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
9 |
{ |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
10 |
if (!aMimeType) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
11 |
return nsnull; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
12 |
} |
123 | 13 |
|
14 |
LoadPlugins(); |
|
15 |
||
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
16 |
+ nsresult res; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
17 |
+ nsCOMPtr<nsIPrefBranch> prefB (do_QueryInterface(mPrefService)); |
1 | 18 |
+ |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
19 |
+ char *preferredPluginPath = NULL; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
20 |
+ nsCAutoString mimetypePrefString ("modules.plugins.mimetype."); |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
21 |
+ mimetypePrefString.Append(aMimeType); |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
22 |
+ const char *mimetypePrefChar = mimetypePrefString.get(); |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
23 |
+ res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath); |
1 | 24 |
+ |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
25 |
+ if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL; |
1 | 26 |
+ |
489
f5ef195f348b
13.0.2 with adopted mozilla-prefer_plugin_pref.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
27 |
InfallibleTArray<nsPluginTag*> matchingPlugins; |
f5ef195f348b
13.0.2 with adopted mozilla-prefer_plugin_pref.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
28 |
|
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
29 |
nsPluginTag *plugin = mPlugins; |
489
f5ef195f348b
13.0.2 with adopted mozilla-prefer_plugin_pref.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
30 |
+ |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
31 |
+ if(preferredPluginPath) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
32 |
+ while (nsnull != plugin) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
33 |
+ if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) || |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
34 |
+ 0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) { |
489
f5ef195f348b
13.0.2 with adopted mozilla-prefer_plugin_pref.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
35 |
+ matchingPlugins.AppendElement(plugin); |
1 | 36 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
37 |
+ plugin = plugin->mNext; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
38 |
+ } |
1 | 39 |
+ |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
40 |
+ // now lets search for substrings |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
41 |
+ plugin = mPlugins; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
42 |
+ while (nsnull != plugin) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
43 |
+ if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) || |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
44 |
+ nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) { |
489
f5ef195f348b
13.0.2 with adopted mozilla-prefer_plugin_pref.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
45 |
+ matchingPlugins.AppendElement(plugin); |
1 | 46 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
47 |
+ plugin = plugin->mNext; |
1 | 48 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
49 |
+ } |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
50 |
+ |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
51 |
while (plugin) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
52 |
if (!aCheckEnabled || plugin->IsEnabled()) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
53 |
PRInt32 mimeCount = plugin->mMimeTypes.Length(); |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
54 |
for (PRInt32 i = 0; i < mimeCount; i++) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
55 |
if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) { |
489
f5ef195f348b
13.0.2 with adopted mozilla-prefer_plugin_pref.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
56 |
matchingPlugins.AppendElement(plugin); |
f5ef195f348b
13.0.2 with adopted mozilla-prefer_plugin_pref.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
57 |
break; |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
58 |
} |