author | Wolfgang Rosenauer <wr@rosenauer.org> |
Thu, 14 Jun 2012 09:20:26 +0200 | |
branch | firefox14 |
changeset 480 | f99d16f8b0f5 |
parent 439 | 7704a021055f |
child 490 | be017dcbd7af |
child 491 | 43deb5e6462d |
permissions | -rw-r--r-- |
8 | 1 |
From: Ubuntu |
439
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
2 |
Introduce a pref to prefer certain plugins for mime-types |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
3 |
|
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
4 |
For example: |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
5 |
pref ("modules.plugins.mimetype.application/x-shockwave-flash", "/usr/lib/firefox-3.0.1/plugins/libflashplayer.so") |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
6 |
|
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
7 |
would make the flashplyer installed in that location the preferred one to use. |
8 | 8 |
|
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
9 |
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
|
10 |
--- a/dom/plugins/base/nsPluginHost.cpp |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
11 |
+++ b/dom/plugins/base/nsPluginHost.cpp |
439
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
12 |
@@ -1556,17 +1556,45 @@ nsPluginHost::FindPluginForType(const ch |
367
3fabd9f66322
begin Firefox 10 cycle
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
289
diff
changeset
|
13 |
bool aCheckEnabled) |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
14 |
{ |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
15 |
if (!aMimeType) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
16 |
return nsnull; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
17 |
} |
123 | 18 |
|
19 |
LoadPlugins(); |
|
20 |
||
439
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
21 |
+ nsCAutoString mimetypePref("modules.plugins.mimetype."); |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
22 |
+ mimetypePref.Append(aMimeType); |
1 | 23 |
+ |
439
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
24 |
+ nsAdoptingCString preferred = Preferences::GetCString(mimetypePref.get()); |
1 | 25 |
+ |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
26 |
nsPluginTag *plugin = mPlugins; |
439
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
27 |
+ if(!preferred.IsEmpty()) { |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
28 |
+ nsCOMPtr<nsILocalFile> file; |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
29 |
+ nsresult rv = NS_NewNativeLocalFile(preferred, false, getter_AddRefs(file)); |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
30 |
+ bool isAbsolute = NS_SUCCEEDED(rv); |
1 | 31 |
+ |
439
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
32 |
+ while (plugin) { |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
33 |
+ if (((!isAbsolute && 0 == PL_strcasecmp(plugin->mFileName.get(), preferred.get())) || |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
34 |
+ (isAbsolute && 0 == PL_strcasecmp(plugin->mFullPath.get(), preferred.get()))) && |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
35 |
+ (!aCheckEnabled || plugin->IsEnabled())) { |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
36 |
+ PRInt32 mimeCount = plugin->mMimeTypes.Length(); |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
37 |
+ for (PRInt32 i = 0; i < mimeCount; i++) { |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
38 |
+ if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) { |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
39 |
+ return plugin; |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
40 |
+ } |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
41 |
+ } |
1 | 42 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
43 |
+ plugin = plugin->mNext; |
1 | 44 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
45 |
+ } |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
46 |
+ |
439
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
47 |
+ // if there is no pref for this mime-type, or if the plugin named in pref |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
48 |
+ // isn't found, we pick the first that matches for this mime-type |
7704a021055f
ported mozilla-prefer_plugin_pref.patch to latest sources
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
367
diff
changeset
|
49 |
+ plugin = mPlugins; |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
50 |
while (plugin) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
51 |
if (!aCheckEnabled || plugin->IsEnabled()) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
52 |
PRInt32 mimeCount = plugin->mMimeTypes.Length(); |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
53 |
for (PRInt32 i = 0; i < mimeCount; i++) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
54 |
if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
55 |
return plugin; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
56 |
} |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
57 |
} |