author | Wolfgang Rosenauer <wr@rosenauer.org> |
Sun, 16 Jun 2013 23:55:43 +0200 | |
branch | firefox22 |
changeset 651 | 19262ba479c4 |
parent 650 | e8c83b144fd1 |
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 |
650 | 7 |
@@ -1334,17 +1334,51 @@ nsPluginHost::FindPluginForType(const ch |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
8 |
if (!aMimeType) { |
541
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
9 |
return nullptr; |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
10 |
} |
123 | 11 |
|
12 |
LoadPlugins(); |
|
13 |
||
541
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
14 |
InfallibleTArray<nsPluginTag*> matchingPlugins; |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
15 |
|
650 | 16 |
+ char *preferredPluginPath = nullptr; |
568
2c74c5927ea2
first working Aurora 18 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
541
diff
changeset
|
17 |
+ nsAutoCString mimetypePrefString ("modules.plugins.mimetype."); |
491 | 18 |
+ mimetypePrefString.Append(aMimeType); |
19 |
+ const char *mimetypePrefChar = mimetypePrefString.get(); |
|
505 | 20 |
+ nsAdoptingCString pluginPath = Preferences::GetCString(mimetypePrefChar); |
21 |
+ preferredPluginPath = (char*) pluginPath.get(); |
|
491 | 22 |
+ |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
23 |
nsPluginTag *plugin = mPlugins; |
1 | 24 |
+ |
491 | 25 |
+ if(preferredPluginPath) { |
541
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
26 |
+ while (plugin) { |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
27 |
+ if (!aCheckEnabled || plugin->IsEnabled()) { |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
28 |
+ if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) || |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
29 |
+ 0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) { |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
30 |
+ matchingPlugins.AppendElement(plugin); |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
31 |
+ } |
491 | 32 |
+ } |
33 |
+ plugin = plugin->mNext; |
|
34 |
+ } |
|
35 |
+ |
|
36 |
+ // now lets search for substrings |
|
37 |
+ plugin = mPlugins; |
|
541
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
38 |
+ while (plugin) { |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
39 |
+ if (!aCheckEnabled || plugin->IsEnabled()) { |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
40 |
+ if (nullptr != PL_strstr(plugin->mFileName.get(), preferredPluginPath) || |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
41 |
+ nullptr != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) { |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
42 |
+ matchingPlugins.AppendElement(plugin); |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
43 |
+ } |
1 | 44 |
+ } |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
45 |
+ plugin = plugin->mNext; |
1 | 46 |
+ } |
541
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
47 |
+ |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
48 |
+ return FindPreferredPlugin(matchingPlugins); |
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) { |
650 | 52 |
if (!aCheckEnabled || plugin->IsActive()) { |
541
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
53 |
int32_t mimeCount = plugin->mMimeTypes.Length(); |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
54 |
for (int32_t i = 0; i < mimeCount; i++) { |
289
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)) { |
541
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
56 |
matchingPlugins.AppendElement(plugin); |
830e50bbfc79
working Aurora 17.0 build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
505
diff
changeset
|
57 |
break; |
289
3c0dff7ca9c4
Update to version 6.0b1
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
123
diff
changeset
|
58 |
} |