mozilla-prefer_plugin_pref.patch
branchfirefox14
changeset 494 21aea6bec3cb
parent 492 c0088c242dab
equal deleted inserted replaced
492:c0088c242dab 494:21aea6bec3cb
     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 @@ -1581,19 +1581,47 @@ nsPluginHost::FindPluginForType(const ch
     7 @@ -1561,17 +1561,45 @@ 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    }
    18 +  mimetypePrefString.Append(aMimeType);
    18 +  mimetypePrefString.Append(aMimeType);
    19 +  const char *mimetypePrefChar = mimetypePrefString.get();
    19 +  const char *mimetypePrefChar = mimetypePrefString.get();
    20 +  nsAdoptingCString pluginPath = Preferences::GetCString(mimetypePrefChar);
    20 +  nsAdoptingCString pluginPath = Preferences::GetCString(mimetypePrefChar);
    21 +  preferredPluginPath = (char*) pluginPath.get();
    21 +  preferredPluginPath = (char*) pluginPath.get();
    22 +
    22 +
    23    InfallibleTArray<nsPluginTag*> matchingPlugins;
       
    24  
       
    25    nsPluginTag *plugin = mPlugins;
    23    nsPluginTag *plugin = mPlugins;
    26 +
    24 +
    27 +  if(preferredPluginPath) {
    25 +  if(preferredPluginPath) {
    28 +    while (nsnull != plugin) {
    26 +    while (nsnull != plugin) {
    29 +      if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) ||
    27 +      if (0 == PL_strcasecmp(plugin->mFileName.get(), preferredPluginPath) ||
    30 +          0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) {
    28 +          0 == PL_strcasecmp(plugin->mFullPath.get(), preferredPluginPath)) {
    31 +        matchingPlugins.AppendElement(plugin);
    29 +        return plugin;
    32 +      }
    30 +      }
    33 +      plugin = plugin->mNext;
    31 +      plugin = plugin->mNext;
    34 +    }
    32 +    }
    35 +
    33 +
    36 +    // now lets search for substrings
    34 +    // now lets search for substrings
    37 +    plugin = mPlugins;
    35 +    plugin = mPlugins;
    38 +    while (nsnull != plugin) {
    36 +    while (nsnull != plugin) {
    39 +      if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) ||
    37 +      if (nsnull != PL_strstr(plugin->mFileName.get(), preferredPluginPath) ||
    40 +          nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) {
    38 +          nsnull != PL_strstr(plugin->mFullPath.get(), preferredPluginPath)) {
    41 +        matchingPlugins.AppendElement(plugin);
    39 +        return plugin;
    42 +      }
    40 +      }
    43 +      plugin = plugin->mNext;
    41 +      plugin = plugin->mNext;
    44 +    }
    42 +    }
    45 +  }
    43 +  }
    46 +
    44 +
    47    while (plugin) {
    45    while (plugin) {
    48      if (!aCheckEnabled || plugin->IsEnabled()) {
    46      if (!aCheckEnabled || plugin->IsEnabled()) {
    49        PRInt32 mimeCount = plugin->mMimeTypes.Length();
    47        PRInt32 mimeCount = plugin->mMimeTypes.Length();
    50        for (PRInt32 i = 0; i < mimeCount; i++) {
    48        for (PRInt32 i = 0; i < mimeCount; i++) {
    51          if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) {
    49          if (0 == PL_strcasecmp(plugin->mMimeTypes[i].get(), aMimeType)) {
    52            matchingPlugins.AppendElement(plugin);
    50            return plugin;
    53            break;
       
    54          }
    51          }
       
    52        }