2011-06-01 08:05:09 +02:00
|
|
|
From: Ubuntu
|
|
|
|
Subject: introduce a pref to prefer certain plugins for mime-types
|
|
|
|
|
2011-07-23 16:46:28 +02:00
|
|
|
diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp
|
|
|
|
--- a/dom/plugins/base/nsPluginHost.cpp
|
|
|
|
+++ b/dom/plugins/base/nsPluginHost.cpp
|
2013-01-07 21:49:28 +01:00
|
|
|
@@ -1543,17 +1543,51 @@ nsPluginHost::FindPluginForType(const ch
|
2011-07-23 16:46:28 +02:00
|
|
|
if (!aMimeType) {
|
2012-11-20 21:34:15 +01:00
|
|
|
return nullptr;
|
2011-07-23 16:46:28 +02:00
|
|
|
}
|
2011-06-01 08:05:09 +02:00
|
|
|
|
|
|
|
LoadPlugins();
|
|
|
|
|
2012-11-20 21:34:15 +01:00
|
|
|
InfallibleTArray<nsPluginTag*> matchingPlugins;
|
|
|
|
|
2011-07-23 16:46:28 +02:00
|
|
|
+ char *preferredPluginPath = NULL;
|
2013-01-07 21:49:28 +01:00
|
|
|
+ nsAutoCString mimetypePrefString ("modules.plugins.mimetype.");
|
2011-07-23 16:46:28 +02:00
|
|
|
+ mimetypePrefString.Append(aMimeType);
|
|
|
|
+ const char *mimetypePrefChar = mimetypePrefString.get();
|
2012-07-16 10:13:51 +02:00
|
|
|
+ nsAdoptingCString pluginPath = Preferences::GetCString(mimetypePrefChar);
|
|
|
|
+ preferredPluginPath = (char*) pluginPath.get();
|
2011-06-01 08:05:09 +02:00
|
|
|
+
|
2011-07-23 16:46:28 +02:00
|
|
|
nsPluginTag *plugin = mPlugins;
|
2012-07-16 10:13:51 +02:00
|
|
|
+
|
2011-07-23 16:46:28 +02:00
|
|
|
+ if(preferredPluginPath) {
|
2012-11-20 21:34:15 +01:00
|
|
|
+ while (plugin) {
|
|
|
|
+ if (!aCheckEnabled || plugin->IsEnabled()) {
|
|
|
|
+ if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) ||
|
|
|
|
+ 0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) {
|
|
|
|
+ matchingPlugins.AppendElement(plugin);
|
|
|
|
+ }
|
2011-06-01 08:05:09 +02:00
|
|
|
+ }
|
2011-07-23 16:46:28 +02:00
|
|
|
+ plugin = plugin->mNext;
|
|
|
|
+ }
|
2011-06-01 08:05:09 +02:00
|
|
|
+
|
2011-07-23 16:46:28 +02:00
|
|
|
+ // now lets search for substrings
|
|
|
|
+ plugin = mPlugins;
|
2012-11-20 21:34:15 +01:00
|
|
|
+ while (plugin) {
|
|
|
|
+ if (!aCheckEnabled || plugin->IsEnabled()) {
|
|
|
|
+ if (nullptr != PL_strstr(plugin->mFileName.get(), preferredPluginPath) ||
|
|
|
|
+ nullptr != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) {
|
|
|
|
+ matchingPlugins.AppendElement(plugin);
|
|
|
|
+ }
|
2011-06-01 08:05:09 +02:00
|
|
|
+ }
|
2011-07-23 16:46:28 +02:00
|
|
|
+ plugin = plugin->mNext;
|
2011-06-01 08:05:09 +02:00
|
|
|
+ }
|
2012-11-20 21:34:15 +01:00
|
|
|
+
|
|
|
|
+ return FindPreferredPlugin(matchingPlugins);
|
2011-07-23 16:46:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
while (plugin) {
|
|
|
|
if (!aCheckEnabled || plugin->IsEnabled()) {
|
2012-11-20 21:34:15 +01:00
|
|
|
int32_t mimeCount = plugin->mMimeTypes.Length();
|
|
|
|
for (int32_t i = 0; i < mimeCount; i++) {
|
2011-07-23 16:46:28 +02:00
|
|
|
if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) {
|
2012-11-20 21:34:15 +01:00
|
|
|
matchingPlugins.AppendElement(plugin);
|
|
|
|
break;
|
2011-07-23 16:46:28 +02:00
|
|
|
}
|