mozilla-prefer_plugin_pref.patch
branchfirefox13
changeset 489 f5ef195f348b
parent 367 3fabd9f66322
equal deleted inserted replaced
482:04ecaffc8f8d 489:f5ef195f348b
     2 Subject: introduce a pref to prefer certain plugins for mime-types
     2 Subject: introduce a pref to prefer certain plugins for mime-types
     3 
     3 
     4 diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp
     4 diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp
     5 --- a/dom/plugins/base/nsPluginHost.cpp
     5 --- a/dom/plugins/base/nsPluginHost.cpp
     6 +++ b/dom/plugins/base/nsPluginHost.cpp
     6 +++ b/dom/plugins/base/nsPluginHost.cpp
     7 @@ -1580,17 +1580,48 @@ nsPluginHost::FindPluginForType(const ch
     7 @@ -1642,19 +1642,51 @@ nsPluginHost::FindPluginForType(const ch
     8                                  bool aCheckEnabled)
     8                                  bool aCheckEnabled)
     9  {
     9  {
    10    if (!aMimeType) {
    10    if (!aMimeType) {
    11      return nsnull;
    11      return nsnull;
    12    }
    12    }
    22 +  const char *mimetypePrefChar = mimetypePrefString.get();
    22 +  const char *mimetypePrefChar = mimetypePrefString.get();
    23 +  res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath);
    23 +  res = prefB->GetCharPref(mimetypePrefChar, &preferredPluginPath);
    24 +
    24 +
    25 +  if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL;
    25 +  if(!NS_SUCCEEDED(res)) preferredPluginPath = NULL;
    26 +
    26 +
       
    27    InfallibleTArray<nsPluginTag*> matchingPlugins;
       
    28  
    27    nsPluginTag *plugin = mPlugins;
    29    nsPluginTag *plugin = mPlugins;
       
    30 +
    28 +  if(preferredPluginPath) {
    31 +  if(preferredPluginPath) {
    29 +    while (nsnull != plugin) {
    32 +    while (nsnull != plugin) {
    30 +      if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) ||
    33 +      if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) ||
    31 +          0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) {
    34 +          0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) {
    32 +        return plugin;
    35 +        matchingPlugins.AppendElement(plugin);
    33 +      }
    36 +      }
    34 +      plugin = plugin->mNext;
    37 +      plugin = plugin->mNext;
    35 +    }
    38 +    }
    36 +
    39 +
    37 +    // now lets search for substrings
    40 +    // now lets search for substrings
    38 +    plugin = mPlugins;
    41 +    plugin = mPlugins;
    39 +    while (nsnull != plugin) {
    42 +    while (nsnull != plugin) {
    40 +      if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) ||
    43 +      if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) ||
    41 +          nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) {
    44 +          nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) {
    42 +        return plugin;
    45 +        matchingPlugins.AppendElement(plugin);
    43 +      }
    46 +      }
    44 +      plugin = plugin->mNext;
    47 +      plugin = plugin->mNext;
    45 +    }
    48 +    }
    46 +  }
    49 +  }
    47 +
    50 +
    48    while (plugin) {
    51    while (plugin) {
    49      if (!aCheckEnabled || plugin->IsEnabled()) {
    52      if (!aCheckEnabled || plugin->IsEnabled()) {
    50        PRInt32 mimeCount = plugin->mMimeTypes.Length();
    53        PRInt32 mimeCount = plugin->mMimeTypes.Length();
    51        for (PRInt32 i = 0; i < mimeCount; i++) {
    54        for (PRInt32 i = 0; i < mimeCount; i++) {
    52          if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) {
    55          if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) {
    53            return plugin;
    56            matchingPlugins.AppendElement(plugin);
       
    57            break;
    54          }
    58          }
    55        }