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.
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
bool aCheckEnabled)
{
if (!aMimeType) {
return nsnull;
}
LoadPlugins();
+ nsCAutoString mimetypePref("modules.plugins.mimetype.");
+ mimetypePref.Append(aMimeType);
+
+ nsAdoptingCString preferred = Preferences::GetCString(mimetypePref.get());
+
nsPluginTag *plugin = mPlugins;
+ if(!preferred.IsEmpty()) {
+ nsCOMPtr<nsILocalFile> 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;
+ }
+ }
+ }
+ 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;
}
}