diff -r 62b8d7fa9144 -r 43deb5e6462d mozilla-prefer_plugin_pref.patch --- a/mozilla-prefer_plugin_pref.patch Tue Jun 19 10:13:07 2012 +0200 +++ b/mozilla-prefer_plugin_pref.patch Mon Jun 25 22:15:54 2012 +0200 @@ -1,15 +1,10 @@ From: Ubuntu -Introduce a pref to prefer certain plugins for mime-types - -For example: - pref ("modules.plugins.mimetype.application/x-shockwave-flash", "/usr/lib/firefox-3.0.1/plugins/libflashplayer.so") - - would make the flashplyer installed in that location the preferred one to use. +Subject: introduce a pref to prefer certain plugins for mime-types 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 -@@ -1556,17 +1556,45 @@ nsPluginHost::FindPluginForType(const ch +@@ -1513,19 +1513,51 @@ nsPluginHost::FindPluginForType(const ch bool aCheckEnabled) { if (!aMimeType) { @@ -18,40 +13,46 @@ LoadPlugins(); -+ nsCAutoString mimetypePref("modules.plugins.mimetype."); -+ mimetypePref.Append(aMimeType); -+ -+ nsAdoptingCString preferred = Preferences::GetCString(mimetypePref.get()); ++ nsresult res; ++ nsCOMPtr prefB (do_QueryInterface(mPrefService)); + ++ char *preferredPluginPath = NULL; ++ nsCAutoString mimetypePrefString ("modules.plugins.mimetype."); ++ mimetypePrefString.Append(aMimeType); ++ const char *mimetypePrefChar = mimetypePrefString.get(); ++ res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath); ++ ++ if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL; ++ + InfallibleTArray matchingPlugins; + nsPluginTag *plugin = mPlugins; -+ if(!preferred.IsEmpty()) { -+ nsCOMPtr file; -+ nsresult rv = NS_NewNativeLocalFile(preferred, false, getter_AddRefs(file)); -+ bool isAbsolute = NS_SUCCEEDED(rv); + -+ while (plugin) { -+ if (((!isAbsolute && 0 == PL_strcasecmp(plugin->mFileName.get(), preferred.get())) || -+ (isAbsolute && 0 == PL_strcasecmp(plugin->mFullPath.get(), preferred.get()))) && -+ (!aCheckEnabled || plugin->IsEnabled())) { -+ PRInt32 mimeCount = plugin->mMimeTypes.Length(); -+ for (PRInt32 i = 0; i < mimeCount; i++) { -+ if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) { -+ return plugin; -+ } -+ } ++ if(preferredPluginPath) { ++ while (nsnull != plugin) { ++ if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) || ++ 0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) { ++ matchingPlugins.AppendElement(plugin); ++ } ++ plugin = plugin->mNext; ++ } ++ ++ // now lets search for substrings ++ plugin = mPlugins; ++ while (nsnull != plugin) { ++ if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) || ++ nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) { ++ matchingPlugins.AppendElement(plugin); + } + plugin = plugin->mNext; + } + } + -+ // if there is no pref for this mime-type, or if the plugin named in pref -+ // isn't found, we pick the first that matches for this mime-type -+ plugin = mPlugins; while (plugin) { if (!aCheckEnabled || plugin->IsEnabled()) { PRInt32 mimeCount = plugin->mMimeTypes.Length(); for (PRInt32 i = 0; i < mimeCount; i++) { if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) { - return plugin; + matchingPlugins.AppendElement(plugin); + break; } - }