diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 15:27:22 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 15:27:22 +0000 |
commit | 8da6475d297e9ebbc49312e16765390cacc295b4 (patch) | |
tree | 1fa82a94184e337894ad8fa902c1a9d11bed50f0 /webkit | |
parent | 04fc0d936b61feced3a2b232a251923f014733bc (diff) | |
download | chromium_src-8da6475d297e9ebbc49312e16765390cacc295b4.zip chromium_src-8da6475d297e9ebbc49312e16765390cacc295b4.tar.gz chromium_src-8da6475d297e9ebbc49312e16765390cacc295b4.tar.bz2 |
Restructure the Mac plugin blacklist code
Pulls out the generic structure for blacklisting plugins, since the list should be getting smaller and more specifically targeted from here on out.
Switches DivX blacklist to allow the older 1.4 versions, which don't crash. Adds an explicit entry for VLC, which was only covered before by the DivX MIME type.
BUG=25690,37072
TEST=DivX plugin 1.4 should load; other blacklisting should be unchanged.
Review URL: http://codereview.chromium.org/1564001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/plugins/plugin_list_mac.mm | 78 |
1 files changed, 37 insertions, 41 deletions
diff --git a/webkit/glue/plugins/plugin_list_mac.mm b/webkit/glue/plugins/plugin_list_mac.mm index ab82398..fe0d4da 100644 --- a/webkit/glue/plugins/plugin_list_mac.mm +++ b/webkit/glue/plugins/plugin_list_mac.mm @@ -8,6 +8,7 @@ #include "base/file_util.h" #include "base/mac_util.h" +#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "webkit/glue/plugins/plugin_lib.h" @@ -37,6 +38,41 @@ void GetPluginPrivateDirectory(std::vector<FilePath>* plugin_dirs) { plugin_dirs->push_back(FilePath([plugin_path fileSystemRepresentation])); } +// Returns true if the plugin should be prevented from loading. +bool IsBlacklistedPlugin(const WebPluginInfo& info) { + std::string plugin_name = WideToUTF8(info.name); + // Non-functional, so it's better to let PDFs be downloaded. + if (plugin_name == "PDF Browser Plugin") + return true; + + // Crashes immediately on videos; unblacklist once we've fixed the crash. + if (plugin_name == "VLC Multimedia Plug-in") + return true; + + // Newer versions crash immediately; unblacklist once we've fixed the crash. + if (plugin_name == "DivX Web Player" && + !StartsWith(info.version, L"1.4", false)) { + return true; + } + + // We blacklist a couple of plugins by included MIME type, since those are + // more stable than their names. Be careful about adding any more plugins to + // this list though, since it's easy to accidentally blacklist plugins that + // support lots of MIME types. + for (std::vector<WebPluginMimeType>::const_iterator i = + info.mime_types.begin(); i != info.mime_types.end(); ++i) { + // The Gears plugin is Safari-specific, so don't load it. + if (i->mime_type == "application/x-googlegears") + return true; + // The current version of O3D doesn't work (and overrealeases our dummy + // window). Waiting for a new release with recent fixes. + if (i->mime_type == "application/vnd.o3d.auto") + return true; + } + + return false; +} + } // namespace namespace NPAPI @@ -69,50 +105,10 @@ void PluginList::LoadPluginsFromDir(const FilePath &path, } } -// Returns true if |array| contains a string matching |test_string|. -static bool ArrayContainsString(const char** array, unsigned int array_size, - const std::string& test_string) { - // We're dealing with very small lists, so just walk in order; if we someday - // end up with very big blacklists or whitelists we can revisit the approach. - for (unsigned int i = 0; i < array_size; ++i) { - if (test_string == array[i]) - return true; - } - return false; -} - bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, std::vector<WebPluginInfo>* plugins) { - // Plugins that we know don't work at all. - const char* blacklisted_plugin_mimes[] = { - "application/x-googlegears", // Safari-specific. - "application/vnd.o3d.auto", // Doesn't render, and having it - // detected can prevent fallbacks. - "video/divx", // Crashes on 10.5. - }; - // In the case of plugins that share MIME types, we have to blacklist by name. - const char* blacklisted_plugin_names[] = { - // Blacklisted for now since having it non-functional but trying to handle - // PDFs is worse than not having it (PDF content would otherwise be - // downloaded or handled by QuickTime). - "PDF Browser Plugin", - }; - - // Start with names. - std::string plugin_name = WideToUTF8(info.name); - if (ArrayContainsString(blacklisted_plugin_names, - arraysize(blacklisted_plugin_names), plugin_name)) { + if (IsBlacklistedPlugin(info)) return false; - } - // Then check mime types. - for (std::vector<WebPluginMimeType>::const_iterator i = - info.mime_types.begin(); i != info.mime_types.end(); ++i) { - if (ArrayContainsString(blacklisted_plugin_mimes, - arraysize(blacklisted_plugin_mimes), - i->mime_type)) { - return false; - } - } // Hierarchy check // (we're loading plugins hierarchically from Library folders, so plugins we |