1 Description: We introduce a new preference that allows users to set a preferred
2 plugin for a given mime-type.
6 pref ("modules.plugins.mimetype.application/x-shockwave-flash", "/usr/lib/firefox-3.0.1/plugins/libflashplayer.so")
8 would make the flashplyer installed in that location the preferred one to use.
10 In case the path is not valid, we just go ahead and search for the first match
12 Author: Alexander Sack <asac@ubuntu.com>
15 --- a/modules/plugin/base/src/nsPluginHost.cpp
16 +++ b/modules/plugin/base/src/nsPluginHost.cpp
17 @@ -1625,6 +1625,40 @@ nsPluginHost::FindPluginForType(const ch
18 // if we have a mimetype passed in, search the mPlugins
19 // linked list for a match
22 + nsCOMPtr<nsIPrefBranch> prefB (do_QueryInterface(mPrefService));
24 + char *preferredPluginPath = NULL;
25 + nsCAutoString mimetypePrefString ("modules.plugins.mimetype.");
26 + mimetypePrefString.Append(aMimeType);
27 + const char *mimetypePrefChar = mimetypePrefString.get();
28 + res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath);
30 + if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL;
33 + if(preferredPluginPath) {
34 + while (nsnull != plugins) {
35 + if (0 == PL_strcasecmp(plugins->mFileName.get(), preferredPluginPath) ||
36 + 0 == PL_strcasecmp(plugins->mFullPath.get(), preferredPluginPath)) {
39 + plugins = plugins->mNext;
42 + // now lets search for substrings
44 + while (nsnull != plugins) {
45 + if (nsnull != PL_strstr(plugins->mFileName.get(), preferredPluginPath) ||
46 + nsnull != PL_strstr(plugins->mFullPath.get(), preferredPluginPath)) {
49 + plugins = plugins->mNext;
53 + // if there is no pref for this mime-type, or if the plugin named in pref
54 + // isn't found, we pick the first that matches for this mime-type