mozilla-prefer_plugin_pref.patch
changeset 1 045edd78eceb
child 8 19a8c8d53349
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mozilla-prefer_plugin_pref.patch	Sat Nov 28 22:14:37 2009 +0100
@@ -0,0 +1,46 @@
+diff --git a/modules/plugin/base/src/nsPluginHost.cpp b/modules/plugin/base/src/nsPluginHost.cpp
+--- a/modules/plugin/base/src/nsPluginHost.cpp
++++ b/modules/plugin/base/src/nsPluginHost.cpp
+@@ -3929,8 +3929,41 @@ nsPluginHost::FindPluginForType(const ch
+   // if we have a mimetype passed in, search the mPlugins
+   // linked list for a match
+   if (nsnull != aMimeType) {
++    nsresult res;
++    nsCOMPtr<nsIPrefBranch> 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;
++
+     plugins = mPlugins;
+-
++    if(preferredPluginPath) {
++      while (nsnull != plugins) {
++        if (0 == PL_strcasecmp(plugins->mFileName.get(), preferredPluginPath) ||
++            0 == PL_strcasecmp(plugins->mFullPath.get(), preferredPluginPath)) {
++          return plugins;
++        }
++        plugins = plugins->mNext;
++      }
++
++      // now lets search for substrings
++      plugins=mPlugins;
++      while (nsnull != plugins) {
++        if (nsnull != PL_strstr(plugins->mFileName.get(), preferredPluginPath) ||
++            nsnull != PL_strstr(plugins->mFullPath.get(), preferredPluginPath)) {
++          return plugins;
++        }
++        plugins = plugins->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
++    plugins = mPlugins;
+     while (nsnull != plugins) {
+       variants = plugins->mVariants;
+       for (cnt = 0; cnt < variants; cnt++) {