diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 18:05:15 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 18:05:15 +0000 |
commit | 4912595f15ad54608207cbacaeeb085cf542e539 (patch) | |
tree | 0d32785d543ed97e3999673eda92fe81323773ef /webkit | |
parent | 6c36f5e4b14f45fd54d60fa9abe7fc99c749eb49 (diff) | |
download | chromium_src-4912595f15ad54608207cbacaeeb085cf542e539.zip chromium_src-4912595f15ad54608207cbacaeeb085cf542e539.tar.gz chromium_src-4912595f15ad54608207cbacaeeb085cf542e539.tar.bz2 |
Move plugin loading out of process on Mac and Linux.
This creates a new set of IPC messages for the utility process to load plugins
to get the WebPluginInfo data in a separate process. Previously this was done
in the browser process, but that involves loading arbitrary third-party code
into the address space and then executing it.
BUG=17863,95114
TEST=Plugins work as before.
Review URL: http://codereview.chromium.org/7889025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/npapi/plugin_list.cc | 56 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list.h | 23 |
2 files changed, 79 insertions, 0 deletions
diff --git a/webkit/plugins/npapi/plugin_list.cc b/webkit/plugins/npapi/plugin_list.cc index a7f6dd4..a67aecd 100644 --- a/webkit/plugins/npapi/plugin_list.cc +++ b/webkit/plugins/npapi/plugin_list.cc @@ -218,6 +218,9 @@ void PluginList::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { // Newer registrations go earlier in the list so they can override the MIME // types of older registrations. internal_plugins_.insert(internal_plugins_.begin(), plugin); + + if (info.path.value() == kDefaultPluginLibraryName) + default_plugin_enabled_ = true; } void PluginList::RegisterInternalPlugin(const FilePath& filename, @@ -343,16 +346,21 @@ void PluginList::LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups) { std::vector<FilePath> extra_plugin_paths; std::vector<FilePath> extra_plugin_dirs; std::vector<InternalPlugin> internal_plugins; + base::Closure will_load_callback; { base::AutoLock lock(lock_); // Clear the refresh bit now, because it might get set again before we // reach the end of the method. plugins_need_refresh_ = false; + will_load_callback = will_load_plugins_callback_; extra_plugin_paths = extra_plugin_paths_; extra_plugin_dirs = extra_plugin_dirs_; internal_plugins = internal_plugins_; } + if (!will_load_callback.is_null()) + will_load_callback.Run(); + std::set<FilePath> visited_plugins; std::vector<FilePath> directories_to_scan; @@ -442,6 +450,40 @@ void PluginList::LoadPlugin(const FilePath& path, AddToPluginGroups(plugin_info, plugin_groups); } +void PluginList::GetPluginPathListsToLoad( + std::vector<FilePath>* extra_plugin_paths, + std::vector<FilePath>* extra_plugin_dirs, + std::vector<webkit::WebPluginInfo>* internal_plugins) { + base::AutoLock lock(lock_); + *extra_plugin_paths = extra_plugin_paths_; + *extra_plugin_dirs = extra_plugin_dirs_; + + *internal_plugins = std::vector<webkit::WebPluginInfo>(); + for (std::vector<InternalPlugin>::iterator it = internal_plugins_.begin(); + it != internal_plugins_.end(); + ++it) { + internal_plugins->push_back(it->info); + } +} + +void PluginList::SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins) { + base::AutoLock lock(lock_); + + plugins_need_refresh_ = false; + + plugin_groups_.reset(); + for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); + it != plugins.end(); + ++it) { + AddToPluginGroups(*it, &plugin_groups_); + } +} + +void PluginList::set_will_load_plugins_callback(const base::Closure& callback) { + base::AutoLock lock(lock_); + will_load_plugins_callback_ = callback; +} + void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { LoadPlugins(); base::AutoLock lock(lock_); @@ -452,6 +494,20 @@ void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { } } +bool PluginList::GetPluginsIfNoRefreshNeeded( + std::vector<webkit::WebPluginInfo>* plugins) { + base::AutoLock lock(lock_); + if (plugins_need_refresh_) + return false; + + 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()); + } + return true; +} + void PluginList::GetPluginInfoArray( const GURL& url, const std::string& mime_type, diff --git a/webkit/plugins/npapi/plugin_list.h b/webkit/plugins/npapi/plugin_list.h index 9d4214a..59ce1f0 100644 --- a/webkit/plugins/npapi/plugin_list.h +++ b/webkit/plugins/npapi/plugin_list.h @@ -11,6 +11,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/callback.h" #include "base/file_path.h" #include "base/memory/linked_ptr.h" #include "base/memory/scoped_vector.h" @@ -123,6 +124,10 @@ class PluginList { // Get all the plugins synchronously. void GetPlugins(std::vector<webkit::WebPluginInfo>* plugins); + // Returns true if the list of plugins is cached and is copied into the out + // pointer; returns false if the plugin list needs to be refreshed. + bool GetPluginsIfNoRefreshNeeded(std::vector<webkit::WebPluginInfo>* plugins); + // Returns a list in |info| containing plugins that are found for // the given url and mime type (including disabled plugins, for // which |info->enabled| is false). The mime type which corresponds @@ -173,6 +178,21 @@ class PluginList { void LoadPlugin(const FilePath& filename, ScopedVector<PluginGroup>* plugin_groups); + // The following functions are used to support probing for WebPluginInfo + // using a different instance of this class. + + // Returns the extra plugin paths, extra plugin directories, and internal + // plugin paths that should be loaded. + void GetPluginPathListsToLoad( + std::vector<FilePath>* extra_plugin_paths, + std::vector<FilePath>* extra_plugin_dirs, + std::vector<webkit::WebPluginInfo>* internal_plugins); + + // Clears the internal list of PluginGroups and copies them from the vector. + void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins); + + void set_will_load_plugins_callback(const base::Closure& callback); + virtual ~PluginList(); protected: @@ -282,6 +302,9 @@ class PluginList { // Holds the currently available plugin groups. ScopedVector<PluginGroup> plugin_groups_; + // Callback that is invoked whenever the PluginList will reload the plugins. + base::Closure will_load_plugins_callback_; + // Need synchronization for the above members since this object can be // accessed on multiple threads. base::Lock lock_; |