author | Wolfgang Rosenauer <wr@rosenauer.org> |
Mon, 25 Jun 2012 22:15:54 +0200 | |
changeset 491 | 43deb5e6462d |
parent 439 | 7704a021055f |
child 505 | edb0bc96e43b |
permissions | -rw-r--r-- |
8 | 1 |
From: Ubuntu |
491 | 2 |
Subject: introduce a pref to prefer certain plugins for mime-types |
8 | 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 |
491 | 7 |
@@ -1513,19 +1513,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 |
||
491 | 16 |
+ nsresult res; |
17 |
+ nsCOMPtr<nsIPrefBranch> prefB (do_QueryInterface(mPrefService)); |
|
1 | 18 |
+ |
491 | 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 |
InfallibleTArray<nsPluginTag*> matchingPlugins; |
|
28 |
||
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
29 |
nsPluginTag *plugin = mPlugins; |
1 | 30 |
+ |
491 | 31 |
+ if(preferredPluginPath) { |
32 |
+ while (nsnull != plugin) { |
|
33 |
+ if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) || |
|
34 |
+ 0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) { |
|
35 |
+ matchingPlugins.AppendElement(plugin); |
|
36 |
+ } |
|
37 |
+ plugin = plugin->mNext; |
|
38 |
+ } |
|
39 |
+ |
|
40 |
+ // now lets search for substrings |
|
41 |
+ plugin = mPlugins; |
|
42 |
+ while (nsnull != plugin) { |
|
43 |
+ if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) || |
|
44 |
+ nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) { |
|
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)) { |
491 | 56 |
matchingPlugins.AppendElement(plugin); |
57 |
break; |
|
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
58 |
} |