author | Wolfgang Rosenauer <wr@rosenauer.org> |
Tue, 20 Mar 2012 08:18:12 +0100 | |
changeset 413 | 974b8a3e2d55 |
parent 367 | 3fabd9f66322 |
child 439 | 7704a021055f |
child 489 | f5ef195f348b |
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 |
367
3fabd9f66322
begin Firefox 10 cycle
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
289
diff
changeset
|
7 |
@@ -1580,17 +1580,48 @@ nsPluginHost::FindPluginForType(const ch |
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 |
+ |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
27 |
nsPluginTag *plugin = mPlugins; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
28 |
+ if(preferredPluginPath) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
29 |
+ while (nsnull != plugin) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
30 |
+ if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) || |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
31 |
+ 0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
32 |
+ return plugin; |
1 | 33 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
34 |
+ plugin = plugin->mNext; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
35 |
+ } |
1 | 36 |
+ |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
37 |
+ // now lets search for substrings |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
38 |
+ plugin = mPlugins; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
39 |
+ while (nsnull != plugin) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
40 |
+ if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) || |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
41 |
+ nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
42 |
+ return plugin; |
1 | 43 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
44 |
+ plugin = plugin->mNext; |
1 | 45 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
46 |
+ } |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
47 |
+ |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
48 |
while (plugin) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
49 |
if (!aCheckEnabled || plugin->IsEnabled()) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
50 |
PRInt32 mimeCount = plugin->mMimeTypes.Length(); |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
51 |
for (PRInt32 i = 0; i < mimeCount; i++) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
52 |
if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) { |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
53 |
return plugin; |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
54 |
} |
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
55 |
} |