updated on Sun Jan 15 08:01:04 UTC 2012
[aur-mirror.git] / firefox-pgo-beta / plugin-for-mimetype-pref.patch
blob4643f02229518a677592dadcd2a98be4f67c970c
1 Description: We introduce a new preference that allows users to set a preferred
2 plugin for a given mime-type.
4 For example:
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
11 given the mime-type.
12 Author: Alexander Sack <asac@ubuntu.com>
13 Forwarded: no
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
20 if (aMimeType) {
21 + nsresult res;
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;
32 + plugins = mPlugins;
33 + if(preferredPluginPath) {
34 + while (nsnull != plugins) {
35 + if (0 == PL_strcasecmp(plugins->mFileName.get(), preferredPluginPath) ||
36 + 0 == PL_strcasecmp(plugins->mFullPath.get(), preferredPluginPath)) {
37 + return plugins;
38 + }
39 + plugins = plugins->mNext;
40 + }
42 + // now lets search for substrings
43 + plugins=mPlugins;
44 + while (nsnull != plugins) {
45 + if (nsnull != PL_strstr(plugins->mFileName.get(), preferredPluginPath) ||
46 + nsnull != PL_strstr(plugins->mFullPath.get(), preferredPluginPath)) {
47 + return plugins;
48 + }
49 + plugins = plugins->mNext;
50 + }
51 + }
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
55 plugins = mPlugins;
57 while (plugins) {