diff options
author | ibraaaa@google.com <ibraaaa@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 22:14:03 +0000 |
---|---|---|
committer | ibraaaa@google.com <ibraaaa@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 22:14:03 +0000 |
commit | 68b63bc6632b12c9aecec942b1e8594d720ceb11 (patch) | |
tree | 6d7a93d6a03449100194e8dd01e74ccde653a00e | |
parent | a9e0d14153a96db052928a6d7e6eb640bc61e375 (diff) | |
download | chromium_src-68b63bc6632b12c9aecec942b1e8594d720ceb11.zip chromium_src-68b63bc6632b12c9aecec942b1e8594d720ceb11.tar.gz chromium_src-68b63bc6632b12c9aecec942b1e8594d720ceb11.tar.bz2 |
1st CL in a series to remove PluginGroup. Updates PluginList.
This is the first CL in a series that aims at removing PluginGroup class and moving harded coded group definition data to .json config files. This CL updates PluginList class with new methods not relying on PluginGroup class, these methods are to be called by upper layer methods instead of PluginGroup dependent methods. Changes in upper layer will be introduced in upcoming CLs. The last CL in the series should remove PluginGroup class and all its dependencies.
BUG=124396
Review URL: https://chromiumcodereview.appspot.com/10860044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152399 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/plugins/npapi/mock_plugin_list.cc | 8 | ||||
-rw-r--r-- | webkit/plugins/npapi/mock_plugin_list.h | 5 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list.cc | 147 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list.h | 36 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list_mac.mm | 7 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list_posix.cc | 31 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list_win.cc | 104 |
7 files changed, 299 insertions, 39 deletions
diff --git a/webkit/plugins/npapi/mock_plugin_list.cc b/webkit/plugins/npapi/mock_plugin_list.cc index 4601101..8f46557 100644 --- a/webkit/plugins/npapi/mock_plugin_list.cc +++ b/webkit/plugins/npapi/mock_plugin_list.cc @@ -29,11 +29,19 @@ bool MockPluginList::GetPluginsNoRefresh( return true; } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 void MockPluginList::LoadPluginsInternal( ScopedVector<PluginGroup>* plugin_groups) { for (size_t i = 0; i < plugins_to_load_.size(); ++i) AddToPluginGroups(plugins_to_load_[i], plugin_groups); } +void MockPluginList::LoadPluginsIntoPluginListInternal( + std::vector<webkit::WebPluginInfo>* plugins) { + for (size_t i = 0; i < plugins_to_load_.size(); ++i) { + plugins->push_back(plugins_to_load_[i]); + } +} + } // npapi } // webkit diff --git a/webkit/plugins/npapi/mock_plugin_list.h b/webkit/plugins/npapi/mock_plugin_list.h index 302bc92..70891b5 100644 --- a/webkit/plugins/npapi/mock_plugin_list.h +++ b/webkit/plugins/npapi/mock_plugin_list.h @@ -29,8 +29,13 @@ class MockPluginList : public PluginList { std::vector<WebPluginInfo> plugins_to_load_; // PluginList methods: + + // TODO(ibraaaa): DELETE. http://crbug.com/124396 virtual void LoadPluginsInternal( ScopedVector<PluginGroup>* plugin_groups) OVERRIDE; + + virtual void LoadPluginsIntoPluginListInternal( + std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; }; } // npapi diff --git a/webkit/plugins/npapi/plugin_list.cc b/webkit/plugins/npapi/plugin_list.cc index c4b59d1..1ead724 100644 --- a/webkit/plugins/npapi/plugin_list.cc +++ b/webkit/plugins/npapi/plugin_list.cc @@ -53,6 +53,7 @@ bool AllowMimeTypeMismatch(const std::string& orig_mime_type, namespace webkit { namespace npapi { +// TODO(ibraaaa): DELETE all hardcoded definitions. http://crbug.com/124396 // Note: If you change the plug-in definitions here, also update // chrome/browser/resources/plugins_*.json correspondingly! // In particular, the identifier needs to be kept in sync. @@ -290,6 +291,7 @@ PluginList::PluginList() ARRAYSIZE_UNSAFE(kGroupDefinitions)); } +// TODO(ibraaaa): DELETE and add a different one. http://crbug.com/124396 PluginList::PluginList(const PluginGroupDefinition* definitions, size_t num_definitions) : @@ -301,6 +303,7 @@ PluginList::PluginList(const PluginGroupDefinition* definitions, AddHardcodedPluginGroups(definitions, num_definitions); } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 PluginGroup* PluginList::CreatePluginGroup( const webkit::WebPluginInfo& web_plugin_info) const { for (size_t i = 0; i < hardcoded_plugin_groups_.size(); ++i) { @@ -311,6 +314,7 @@ PluginGroup* PluginList::CreatePluginGroup( return PluginGroup::FromWebPluginInfo(web_plugin_info); } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 void PluginList::LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups) { base::Closure will_load_callback; { @@ -331,6 +335,27 @@ void PluginList::LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups) { } } +void PluginList::LoadPluginsIntoPluginListInternal( + std::vector<webkit::WebPluginInfo>* plugins) { + base::Closure will_load_callback; + { + base::AutoLock lock(lock_); + will_load_callback = will_load_plugins_callback_; + } + if (!will_load_callback.is_null()) + will_load_callback.Run(); + + std::vector<FilePath> plugin_paths; + GetPluginPathsToLoad(&plugin_paths); + + for (std::vector<FilePath>::const_iterator it = plugin_paths.begin(); + it != plugin_paths.end(); + ++it) { + WebPluginInfo plugin_info; + LoadPluginIntoPluginList(*it, plugins, &plugin_info); + } +} + void PluginList::LoadPlugins() { { base::AutoLock lock(lock_); @@ -340,18 +365,25 @@ void PluginList::LoadPlugins() { loading_state_ = LOADING_STATE_REFRESHING; } - ScopedVector<PluginGroup> new_plugin_groups; + ScopedVector<PluginGroup> new_plugin_groups; // TODO(ibraaaa): DELETE + // Do the actual loading of the plugins. + LoadPluginsInternal(&new_plugin_groups); // TODO(ibraaaa): DELETE + + std::vector<webkit::WebPluginInfo> new_plugins; // Do the actual loading of the plugins. - LoadPluginsInternal(&new_plugin_groups); + LoadPluginsIntoPluginListInternal(&new_plugins); base::AutoLock lock(lock_); - plugin_groups_.swap(new_plugin_groups); + plugin_groups_.swap(new_plugin_groups); // TODO(ibraaaa): DELETE + plugins_list_.swap(new_plugins); + // If we haven't been invalidated in the mean time, mark the plug-in list as // up-to-date. if (loading_state_ != LOADING_STATE_NEEDS_REFRESH) loading_state_ = LOADING_STATE_UP_TO_DATE; } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 bool PluginList::LoadPlugin(const FilePath& path, ScopedVector<PluginGroup>* plugin_groups, WebPluginInfo* plugin_info) { @@ -382,6 +414,37 @@ bool PluginList::LoadPlugin(const FilePath& path, return true; } +bool PluginList::LoadPluginIntoPluginList( + const FilePath& path, + std::vector<webkit::WebPluginInfo>* plugins, + WebPluginInfo* plugin_info) { + LOG_IF(ERROR, PluginList::DebugPluginLoading()) + << "Loading plugin " << path.value(); + const PluginEntryPoints* entry_points; + + if (!ReadPluginInfo(path, plugin_info, &entry_points)) + return false; + + if (!ShouldLoadPluginUsingPluginList(*plugin_info, plugins)) + return false; + +#if defined(OS_WIN) && !defined(NDEBUG) + if (path.BaseName().value() != L"npspy.dll") // Make an exception for NPSPY +#endif + { + for (size_t i = 0; i < plugin_info->mime_types.size(); ++i) { + // TODO: don't load global handlers for now. + // WebKit hands to the Plugin before it tries + // to handle mimeTypes on its own. + const std::string &mime_type = plugin_info->mime_types[i].mime_type; + if (mime_type == "*") + return false; + } + } + plugins->push_back(*plugin_info); + return true; +} + void PluginList::GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths) { // Don't want to hold the lock while loading new plugins, so we don't block // other methods if they're called on other threads. @@ -416,6 +479,7 @@ void PluginList::GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths) { #endif } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 const std::vector<PluginGroup*>& PluginList::GetHardcodedPluginGroups() const { return hardcoded_plugin_groups_.get(); } @@ -426,12 +490,16 @@ void PluginList::SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins) { DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_); loading_state_ = LOADING_STATE_UP_TO_DATE; + // TODO(ibraaaa): DELETE plugin_groups_.clear(); for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { AddToPluginGroups(*it, &plugin_groups_); - } + } // END OF DELETE + + plugins_list_.clear(); + plugins_list_.insert(plugins_list_.end(), plugins.begin(), plugins.end()); } void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { @@ -442,21 +510,14 @@ void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { LoadPlugins(); base::AutoLock lock(lock_); - for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<webkit::WebPluginInfo>& gr_plugins = - plugin_groups_[i]->web_plugin_infos(); - plugins->insert(plugins->end(), gr_plugins.begin(), gr_plugins.end()); - } + plugins->insert(plugins->end(), plugins_list_.begin(), plugins_list_.end()); } bool PluginList::GetPluginsNoRefresh( std::vector<webkit::WebPluginInfo>* plugins) { base::AutoLock lock(lock_); - for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<webkit::WebPluginInfo>& gr_plugins = - plugin_groups_[i]->web_plugin_infos(); - plugins->insert(plugins->end(), gr_plugins.begin(), gr_plugins.end()); - } + plugins->insert(plugins->end(), plugins_list_.begin(), plugins_list_.end()); + return loading_state_ == LOADING_STATE_UP_TO_DATE; } @@ -482,17 +543,13 @@ void PluginList::GetPluginInfoArray( std::set<FilePath> visited_plugins; // Add in plugins by mime type. - for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<webkit::WebPluginInfo>& plugins = - plugin_groups_[i]->web_plugin_infos(); - for (size_t i = 0; i < plugins.size(); ++i) { - if (SupportsType(plugins[i], mime_type, allow_wildcard)) { - FilePath path = plugins[i].path; - if (visited_plugins.insert(path).second) { - info->push_back(plugins[i]); - if (actual_mime_types) - actual_mime_types->push_back(mime_type); - } + for (size_t i = 0; i < plugins_list_.size(); ++i) { + if (SupportsType(plugins_list_[i], mime_type, allow_wildcard)) { + FilePath path = plugins_list_[i].path; + if (visited_plugins.insert(path).second) { + info->push_back(plugins_list_[i]); + if (actual_mime_types) + actual_mime_types->push_back(mime_type); } } } @@ -503,24 +560,21 @@ void PluginList::GetPluginInfoArray( if (last_dot != std::string::npos) { std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); std::string actual_mime_type; - for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<webkit::WebPluginInfo>& plugins = - plugin_groups_[i]->web_plugin_infos(); - for (size_t i = 0; i < plugins.size(); ++i) { - if (SupportsExtension(plugins[i], extension, &actual_mime_type)) { - FilePath path = plugins[i].path; - if (visited_plugins.insert(path).second && - AllowMimeTypeMismatch(mime_type, actual_mime_type)) { - info->push_back(plugins[i]); - if (actual_mime_types) - actual_mime_types->push_back(actual_mime_type); - } + for (size_t i = 0; i < plugins_list_.size(); ++i) { + if (SupportsExtension(plugins_list_[i], extension, &actual_mime_type)) { + FilePath path = plugins_list_[i].path; + if (visited_plugins.insert(path).second && + AllowMimeTypeMismatch(mime_type, actual_mime_type)) { + info->push_back(plugins_list_[i]); + if (actual_mime_types) + actual_mime_types->push_back(actual_mime_type); } } } } } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 void PluginList::GetPluginGroups( bool load_if_necessary, std::vector<PluginGroup>* plugin_groups) { @@ -536,6 +590,7 @@ void PluginList::GetPluginGroups( } } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 PluginGroup* PluginList::GetPluginGroup( const webkit::WebPluginInfo& web_plugin_info) { base::AutoLock lock(lock_); @@ -553,6 +608,7 @@ PluginGroup* PluginList::GetPluginGroup( return group; } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 string16 PluginList::GetPluginGroupName(const std::string& identifier) { for (size_t i = 0; i < plugin_groups_.size(); ++i) { if (plugin_groups_[i]->identifier() == identifier) @@ -561,6 +617,7 @@ string16 PluginList::GetPluginGroupName(const std::string& identifier) { return string16(); } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 void PluginList::AddHardcodedPluginGroups( const PluginGroupDefinition* group_definitions, size_t num_group_definitions) { @@ -570,6 +627,7 @@ void PluginList::AddHardcodedPluginGroups( } } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 PluginGroup* PluginList::AddToPluginGroups( const webkit::WebPluginInfo& web_plugin_info, ScopedVector<PluginGroup>* plugin_groups) { @@ -635,6 +693,21 @@ bool PluginList::SupportsExtension(const webkit::WebPluginInfo& plugin, return false; } +/*static*/ +bool PluginList::RemovePlugin(const FilePath& filename, + std::vector<webkit::WebPluginInfo>* plugins) { + bool did_remove = false; + for (size_t i = 0; i < plugins->size();) { + if ((*plugins)[i].path == filename) { + plugins->erase(plugins->begin() + i); + did_remove = true; + } else { + i++; + } + } + return did_remove; +} + PluginList::~PluginList() { } diff --git a/webkit/plugins/npapi/plugin_list.h b/webkit/plugins/npapi/plugin_list.h index ebd93d6..5720489 100644 --- a/webkit/plugins/npapi/plugin_list.h +++ b/webkit/plugins/npapi/plugin_list.h @@ -148,32 +148,43 @@ class WEBKIT_PLUGINS_EXPORT PluginList { std::vector<webkit::WebPluginInfo>* info, std::vector<std::string>* actual_mime_types); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Populates the given vector with all available plugin groups. If // |load_if_necessary| is true, this will potentially load the plugin list // synchronously. void GetPluginGroups(bool load_if_necessary, std::vector<PluginGroup>* plugin_groups); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Returns a copy of the PluginGroup corresponding to the given WebPluginInfo. // The caller takes ownership of the returned PluginGroup. PluginGroup* GetPluginGroup(const webkit::WebPluginInfo& web_plugin_info); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Returns the name of the PluginGroup with the given identifier. // If no such group exists, an empty string is returned. string16 GetPluginGroupName(const std::string& identifier); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Load a specific plugin with full path. Return true iff loading the plug-in // was successful. bool LoadPlugin(const FilePath& filename, ScopedVector<PluginGroup>* plugin_groups, webkit::WebPluginInfo* plugin_info); + // Load a specific plugin with full path. Return true iff loading the plug-in + // was successful. + bool LoadPluginIntoPluginList(const FilePath& filename, + std::vector<webkit::WebPluginInfo>* plugins, + webkit::WebPluginInfo* plugin_info); + // The following functions are used to support probing for WebPluginInfo // using a different instance of this class. // Computes a list of all plugins to potentially load from all sources. void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Returns the list of hardcoded plug-in groups for testing. const std::vector<PluginGroup*>& GetHardcodedPluginGroups() const; @@ -185,10 +196,12 @@ class WEBKIT_PLUGINS_EXPORT PluginList { virtual ~PluginList(); protected: + // TODO(ibraaaa): DELETE and add a different one. http://crbug.com/124396 // This constructor is used in unit tests to override the platform-dependent // real-world plugin group definitions with custom ones. PluginList(const PluginGroupDefinition* definitions, size_t num_definitions); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Adds the given WebPluginInfo to its corresponding group, creating it if // necessary, and returns the group. PluginGroup* AddToPluginGroups(const webkit::WebPluginInfo& web_plugin_info, @@ -213,11 +226,13 @@ class WEBKIT_PLUGINS_EXPORT PluginList { // Constructors are private for singletons. PluginList(); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Creates PluginGroups for the hardcoded group definitions, and stores them // in |hardcoded_plugin_groups_|. void AddHardcodedPluginGroups(const PluginGroupDefinition* group_definitions, size_t num_group_definitions); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Creates a new PluginGroup either from a hardcoded group definition, or from // the plug-in information. // Caller takes ownership of the returned PluginGroup. @@ -228,6 +243,11 @@ class WEBKIT_PLUGINS_EXPORT PluginList { // test classes can mock these out. virtual void LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups); + // Implements all IO dependent operations of the LoadPlugins method so that + // test classes can mock these out. + virtual void LoadPluginsIntoPluginListInternal( + std::vector<webkit::WebPluginInfo>* plugins); + // Load all plugins from the default plugins directory. void LoadPlugins(); @@ -235,12 +255,20 @@ class WEBKIT_PLUGINS_EXPORT PluginList { // load in that directory. void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins); + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Returns true if we should load the given plugin, or false otherwise. // |plugins| is the list of plugins we have crawled in the current plugin // loading run. bool ShouldLoadPlugin(const webkit::WebPluginInfo& info, ScopedVector<PluginGroup>* plugins); + // Returns true if we should load the given plugin, or false otherwise. + // |plugins| is the list of plugins we have crawled in the current plugin + // loading run. + bool ShouldLoadPluginUsingPluginList( + const webkit::WebPluginInfo& info, + std::vector<webkit::WebPluginInfo>* plugins); + // Returns true if the plugin supports |mime_type|. |mime_type| should be all // lower case. bool SupportsType(const webkit::WebPluginInfo& plugin, @@ -255,6 +283,10 @@ class WEBKIT_PLUGINS_EXPORT PluginList { const std::string& extension, std::string* actual_mime_type); + // Removes a plug-in from |plugins_list_| by its path. + static bool RemovePlugin(const FilePath& filename, + std::vector<webkit::WebPluginInfo>* plugins); + // // Platform functions // @@ -293,6 +325,7 @@ class WEBKIT_PLUGINS_EXPORT PluginList { // Holds information about internal plugins. std::vector<InternalPlugin> internal_plugins_; + // TODO(ibraaaa): DELETE. http://crbug.com/124396 // Holds the currently available plugin groups. ScopedVector<PluginGroup> plugin_groups_; @@ -300,6 +333,9 @@ class WEBKIT_PLUGINS_EXPORT PluginList { // This should only be modified during construction of the PluginList. ScopedVector<PluginGroup> hardcoded_plugin_groups_; + // A list holding all plug-ins. + std::vector<webkit::WebPluginInfo> plugins_list_; + // Callback that is invoked whenever the PluginList will reload the plugins. base::Closure will_load_plugins_callback_; diff --git a/webkit/plugins/npapi/plugin_list_mac.mm b/webkit/plugins/npapi/plugin_list_mac.mm index 199c8cf..74823b6 100644 --- a/webkit/plugins/npapi/plugin_list_mac.mm +++ b/webkit/plugins/npapi/plugin_list_mac.mm @@ -87,10 +87,17 @@ void PluginList::GetPluginsInDir( } } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, ScopedVector<PluginGroup>* plugin_groups) { return !IsBlacklistedPlugin(info); } +bool PluginList::ShouldLoadPluginUsingPluginList( + const WebPluginInfo& info, + std::vector<webkit::WebPluginInfo>* plugins) { + return !IsBlacklistedPlugin(info); +} + } // namespace npapi } // namespace webkit diff --git a/webkit/plugins/npapi/plugin_list_posix.cc b/webkit/plugins/npapi/plugin_list_posix.cc index ed475ff..974a423 100644 --- a/webkit/plugins/npapi/plugin_list_posix.cc +++ b/webkit/plugins/npapi/plugin_list_posix.cc @@ -266,6 +266,7 @@ void PluginList::GetPluginsInDir( } } +// TODO(ibraaaa): DELETE. http://crbug.com/124396 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, ScopedVector<PluginGroup>* plugin_groups) { LOG_IF(ERROR, PluginList::DebugPluginLoading()) @@ -300,5 +301,35 @@ bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, return true; } +bool PluginList::ShouldLoadPluginUsingPluginList( + const WebPluginInfo& info, std::vector<webkit::WebPluginInfo>* plugins) { + LOG_IF(ERROR, PluginList::DebugPluginLoading()) + << "Considering " << info.path.value() << " (" << info.name << ")"; + + if (IsUndesirablePlugin(info)) { + LOG_IF(ERROR, PluginList::DebugPluginLoading()) + << info.path.value() << " is undesirable."; + + // See if we have a better version of this plugin. + for (size_t j = 0; j < plugins->size(); ++j) { + if ((*plugins)[j].name == info.name && + !IsUndesirablePlugin((*plugins)[j])) { + // Skip the current undesirable one so we can use the better one + // we just found. + LOG_IF(ERROR, PluginList::DebugPluginLoading()) + << "Skipping " << info.path.value() << ", preferring " + << (*plugins)[j].path.value(); + return false; + } + } + } + + // TODO(evanm): prefer the newest version of flash, etc. here? + + VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); + + return true; +} + } // namespace npapi } // namespace webkit diff --git a/webkit/plugins/npapi/plugin_list_win.cc b/webkit/plugins/npapi/plugin_list_win.cc index a9b7193..a7e3d02 100644 --- a/webkit/plugins/npapi/plugin_list_win.cc +++ b/webkit/plugins/npapi/plugin_list_win.cc @@ -335,8 +335,10 @@ bool IsNewerVersion(const std::wstring& a, const std::wstring& b) { return false; } -bool PluginList::ShouldLoadPlugin(const webkit::WebPluginInfo& info, - ScopedVector<PluginGroup>* plugin_groups) { +// TODO(ibraaaa): DELETE. http://crbug.com/124396 +bool PluginList::ShouldLoadPlugin( + const webkit::WebPluginInfo& info, + ScopedVector<PluginGroup>* plugin_groups) { // Version check for (size_t i = 0; i < plugin_groups->size(); ++i) { @@ -442,5 +444,103 @@ bool PluginList::ShouldLoadPlugin(const webkit::WebPluginInfo& info, return load_plugin; } +bool PluginList::ShouldLoadPluginUsingPluginList( + const webkit::WebPluginInfo& info, + std::vector<webkit::WebPluginInfo>* plugins) { + // Version check + for (size_t j = 0; j < plugins->size(); ++j) { + FilePath::StringType plugin1 = + StringToLowerASCII((*plugins)[j].path.BaseName().value()); + FilePath::StringType plugin2 = + StringToLowerASCII(info.path.BaseName().value()); + if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) || + (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || + (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { + if (!IsNewerVersion((*plugins)[j].version, info.version)) + return false; // We have loaded a plugin whose version is newer. + PluginList::RemovePlugin((*plugins)[j].path, plugins); + break; + } + } + + // Troublemakers + + FilePath::StringType filename = + StringToLowerASCII(info.path.BaseName().value()); + // Depends on XPCOM. + if (filename == kMozillaActiveXPlugin) + return false; + + // Disable the Yahoo Application State plugin as it crashes the plugin + // process on return from NPObjectStub::OnInvoke. Please refer to + // http://b/issue?id=1372124 for more information. + if (filename == kYahooApplicationStatePlugin) + return false; + + // Disable the WangWang protocol handler plugin (npww.dll) as it crashes + // chrome during shutdown. Firefox also disables this plugin. + // Please refer to http://code.google.com/p/chromium/issues/detail?id=3953 + // for more information. + if (filename == kWanWangProtocolHandlerPlugin) + return false; + + // We only work with newer versions of the Java plugin which use NPAPI only + // and don't depend on XPCOM. + if (filename == kJavaPlugin1 || filename == kJavaPlugin2) { + std::vector<FilePath::StringType> ver; + base::SplitString(info.version, '.', &ver); + int major, minor, update; + if (ver.size() == 4 && + base::StringToInt(ver[0], &major) && + base::StringToInt(ver[1], &minor) && + base::StringToInt(ver[2], &update)) { + if (major == 6 && minor == 0 && update < 120) + return false; // Java SE6 Update 11 or older. + } + } + + if (base::win::IsMetroProcess()) { + // In metro mode we only allow pepper plugins. + if (info.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) + return false; + } + + // Special WMP handling + + // If both the new and old WMP plugins exist, only load the new one. + if (filename == kNewWMPPlugin) { + if (dont_load_new_wmp_) + return false; + + for (size_t j = 0; j < plugins->size(); ++j) { + if ((*plugins)[j].path.BaseName().value() == kOldWMPPlugin) { + PluginList::RemovePlugin((*plugins)[j].path, plugins); + break; + } + } + + } else if (filename == kOldWMPPlugin) { + for (size_t j = 0; j < plugins->size(); ++j) { + if ((*plugins)[j].path.BaseName().value() == kNewWMPPlugin) + return false; + } + } + + HMODULE plugin_dll = NULL; + bool load_plugin = true; + + // The plugin list could contain a 64 bit plugin which we cannot load. + for (size_t i = 0; i < internal_plugins_.size(); ++i) { + if (info.path == internal_plugins_[i].info.path) + continue; + + if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path))) + load_plugin = false; + break; + } + return load_plugin; +} + + } // namespace npapi } // namespace webkit |