diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/plugin_service.cc | 60 | ||||
-rw-r--r-- | content/browser/plugin_service.h | 21 | ||||
-rw-r--r-- | content/browser/renderer_host/render_message_filter.cc | 2 | ||||
-rw-r--r-- | content/plugin/plugin_thread.cc | 4 | ||||
-rw-r--r-- | content/public/common/content_client.h | 10 | ||||
-rw-r--r-- | content/shell/shell_content_client.cc | 4 | ||||
-rw-r--r-- | content/shell/shell_content_client.h | 2 | ||||
-rw-r--r-- | content/test/test_content_client.cc | 4 | ||||
-rw-r--r-- | content/test/test_content_client.h | 2 |
9 files changed, 85 insertions, 24 deletions
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc index b59c64e..5e0e910 100644 --- a/content/browser/plugin_service.cc +++ b/content/browser/plugin_service.cc @@ -116,19 +116,21 @@ PluginService::PluginService() : ui_locale_( content::GetContentClient()->browser()->GetApplicationLocale()), filter_(NULL) { - webkit::npapi::PluginList::Singleton()->set_will_load_plugins_callback( + plugin_list()->set_will_load_plugins_callback( base::Bind(&WillLoadPluginsCallback)); RegisterPepperPlugins(); + content::GetContentClient()->AddNPAPIPlugins(plugin_list()); + // Load any specified on the command line as well. const CommandLine* command_line = CommandLine::ForCurrentProcess(); FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin); if (!path.empty()) - webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path); + AddExtraPluginPath(path); path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); if (!path.empty()) - webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(path); + plugin_list()->AddExtraPluginDir(path); #if defined(OS_MACOSX) // We need to know when the browser comes forward so we can bring modal plugin @@ -182,8 +184,7 @@ void PluginService::StartWatchingPlugins() { // Get the list of all paths for registering the FilePathWatchers // that will track and if needed reload the list of plugins on runtime. std::vector<FilePath> plugin_dirs; - webkit::npapi::PluginList::Singleton()->GetPluginDirectories( - &plugin_dirs); + plugin_list()->GetPluginDirectories(&plugin_dirs); for (size_t i = 0; i < plugin_dirs.size(); ++i) { // FilePathWatcher can not handle non-absolute paths under windows. @@ -428,8 +429,8 @@ bool PluginService::GetPluginInfoArray( std::vector<webkit::WebPluginInfo>* plugins, std::vector<std::string>* actual_mime_types) { bool use_stale = false; - webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( - url, mime_type, allow_wildcard, &use_stale, plugins, actual_mime_types); + plugin_list()->GetPluginInfoArray(url, mime_type, allow_wildcard, + &use_stale, plugins, actual_mime_types); return use_stale; } @@ -476,8 +477,7 @@ bool PluginService::GetPluginInfo(int render_process_id, bool PluginService::GetPluginInfoByPath(const FilePath& plugin_path, webkit::WebPluginInfo* info) { std::vector<webkit::WebPluginInfo> plugins; - webkit::npapi::PluginList::Singleton()->GetPluginsIfNoRefreshNeeded( - &plugins); + plugin_list()->GetPluginsIfNoRefreshNeeded(&plugins); for (std::vector<webkit::WebPluginInfo>::iterator it = plugins.begin(); it != plugins.end(); @@ -491,10 +491,6 @@ bool PluginService::GetPluginInfoByPath(const FilePath& plugin_path, return false; } -void PluginService::RefreshPluginList() { - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); -} - void PluginService::GetPlugins(const GetPluginsCallback& callback) { scoped_refptr<base::MessageLoopProxy> target_loop( MessageLoop::current()->message_loop_proxy()); @@ -505,8 +501,7 @@ void PluginService::GetPlugins(const GetPluginsCallback& callback) { target_loop, callback)); #else std::vector<webkit::WebPluginInfo> cached_plugins; - if (webkit::npapi::PluginList::Singleton()->GetPluginsIfNoRefreshNeeded( - &cached_plugins)) { + if (plugin_list()->GetPluginsIfNoRefreshNeeded(&cached_plugins)) { // Can't assume the caller is reentrant. target_loop->PostTask(FROM_HERE, base::Bind(&RunGetPluginsCallback, callback, cached_plugins)); @@ -532,7 +527,7 @@ void PluginService::GetPluginsInternal( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); std::vector<webkit::WebPluginInfo> plugins; - webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); + plugin_list()->GetPlugins(&plugins); target_loop->PostTask(FROM_HERE, base::Bind(&RunGetPluginsCallback, callback, plugins)); @@ -547,7 +542,7 @@ void PluginService::OnWaitableEventSignaled( hklm_key_.StartWatching(); } - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); + plugin_list()->RefreshPlugins(); PurgePluginListCache(NULL, false); #else // This event should only get signaled on a Windows machine. @@ -583,8 +578,7 @@ void PluginService::RegisterPepperPlugins() { // TODO(abarth): It seems like the PepperPluginRegistry should do this work. PepperPluginRegistry::ComputeList(&ppapi_plugins_); for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { - webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( - ppapi_plugins_[i].ToWebPluginInfo()); + RegisterInternalPlugin(ppapi_plugins_[i].ToWebPluginInfo()); } } @@ -625,3 +619,31 @@ void PluginService::RegisterFilePathWatcher( DCHECK(result); } #endif + +void PluginService::RefreshPlugins() { + plugin_list()->RefreshPlugins(); +} + +void PluginService::AddExtraPluginPath(const FilePath& path) { + plugin_list()->AddExtraPluginPath(path); +} + +void PluginService::RemoveExtraPluginPath(const FilePath& path) { + plugin_list()->RemoveExtraPluginPath(path); +} + +void PluginService::UnregisterInternalPlugin(const FilePath& path) { + plugin_list()->UnregisterInternalPlugin(path); +} + +webkit::npapi::PluginList* PluginService::plugin_list() { + return webkit::npapi::PluginList::Singleton(); +} + +void PluginService::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { + plugin_list()->RegisterInternalPlugin(info); +} + +string16 PluginService::GetPluginGroupName(const std::string& plugin_name) { + return plugin_list()->GetPluginGroupName(plugin_name); +} diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h index 2b2c69f..6be2c4f 100644 --- a/content/browser/plugin_service.h +++ b/content/browser/plugin_service.h @@ -54,6 +54,7 @@ namespace webkit { namespace npapi { class PluginGroup; class PluginList; +struct PluginEntryPoints; } } @@ -151,10 +152,6 @@ class CONTENT_EXPORT PluginService bool GetPluginInfoByPath(const FilePath& plugin_path, webkit::WebPluginInfo* info); - // Marks the plugin list as dirty and will cause the plugins to be reloaded - // on the next access through GetPlugins() or GetPluginGroups(). - void RefreshPluginList(); - // Asynchronously loads plugins if necessary and then calls back to the // provided function on the calling MessageLoop on completion. void GetPlugins(const GetPluginsCallback& callback); @@ -176,6 +173,22 @@ class CONTENT_EXPORT PluginService } content::PluginServiceFilter* filter() { return filter_; } + + // The following functions are wrappers around webkit::npapi::PluginList. + // These must be used instead of those in order to ensure that we have a + // single global list in the component build and so that we don't + // accidentally load plugins in the wrong process or thread. Refer to + // PluginList for further documentation of these functions. + void RefreshPlugins(); + void AddExtraPluginPath(const FilePath& path); + void RemoveExtraPluginPath(const FilePath& path); + void UnregisterInternalPlugin(const FilePath& path); + void RegisterInternalPlugin(const webkit::WebPluginInfo& info); + string16 GetPluginGroupName(const std::string& plugin_name); + + // TODO(dpranke): This should be private. + webkit::npapi::PluginList* plugin_list(); + private: friend struct DefaultSingletonTraits<PluginService>; diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 001c6b2..624af29 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -522,7 +522,7 @@ void RenderMessageFilter::OnGetPlugins( const base::TimeTicks now = base::TimeTicks::Now(); if (now - last_plugin_refresh_time_ >= threshold) { // Only refresh if the threshold hasn't been exceeded yet. - PluginService::GetInstance()->RefreshPluginList(); + PluginService::GetInstance()->RefreshPlugins(); last_plugin_refresh_time_ = now; } } diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc index 195bffe..7951a8f 100644 --- a/content/plugin/plugin_thread.cc +++ b/content/plugin/plugin_thread.cc @@ -27,6 +27,7 @@ #include "ipc/ipc_channel_handle.h" #include "webkit/glue/webkit_glue.h" #include "webkit/plugins/npapi/plugin_lib.h" +#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h" #if defined(TOOLKIT_USES_GTK) @@ -114,6 +115,9 @@ PluginThread::PluginThread() content::GetContentClient()->plugin()->PluginProcessStarted( plugin.get() ? plugin->plugin_info().name : string16()); + content::GetContentClient()->AddNPAPIPlugins( + webkit::npapi::PluginList::Singleton()); + // Certain plugins, such as flash, steal the unhandled exception filter // thus we never get crash reports when they fault. This call fixes it. message_loop()->set_exception_restoration(true); diff --git a/content/public/common/content_client.h b/content/public/common/content_client.h index 7386ef7..840e370 100644 --- a/content/public/common/content_client.h +++ b/content/public/common/content_client.h @@ -29,6 +29,12 @@ namespace sandbox { class TargetPolicy; } +namespace webkit { +namespace npapi { +class PluginList; +} +} + namespace content { class ContentBrowserClient; @@ -79,6 +85,10 @@ class CONTENT_EXPORT ContentClient { virtual void AddPepperPlugins( std::vector<content::PepperPluginInfo>* plugins) = 0; + // Gives the embedder a chance to register its own internal NPAPI plugins. + virtual void AddNPAPIPlugins( + webkit::npapi::PluginList* plugin_list) = 0; + // Returns whether the given message should be allowed to be sent from a // swapped out renderer. virtual bool CanSendWhileSwappedOut(const IPC::Message* msg) = 0; diff --git a/content/shell/shell_content_client.cc b/content/shell/shell_content_client.cc index bc98458..c6bf11f 100644 --- a/content/shell/shell_content_client.cc +++ b/content/shell/shell_content_client.cc @@ -22,6 +22,10 @@ void ShellContentClient::AddPepperPlugins( std::vector<content::PepperPluginInfo>* plugins) { } +void ShellContentClient::AddNPAPIPlugins( + webkit::npapi::PluginList* plugin_list) { +} + bool ShellContentClient::CanSendWhileSwappedOut(const IPC::Message* msg) { return false; } diff --git a/content/shell/shell_content_client.h b/content/shell/shell_content_client.h index 8494e99..388e200 100644 --- a/content/shell/shell_content_client.h +++ b/content/shell/shell_content_client.h @@ -19,6 +19,8 @@ class ShellContentClient : public ContentClient { virtual void SetGpuInfo(const GPUInfo& gpu_info) OVERRIDE; virtual void AddPepperPlugins( std::vector<content::PepperPluginInfo>* plugins) OVERRIDE; + virtual void AddNPAPIPlugins( + webkit::npapi::PluginList* plugin_list) OVERRIDE; virtual bool CanSendWhileSwappedOut(const IPC::Message* msg) OVERRIDE; virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; virtual std::string GetUserAgent(bool* overriding) const OVERRIDE; diff --git a/content/test/test_content_client.cc b/content/test/test_content_client.cc index 7f329f1..e1d6d43 100644 --- a/content/test/test_content_client.cc +++ b/content/test/test_content_client.cc @@ -23,6 +23,10 @@ void TestContentClient::AddPepperPlugins( std::vector<content::PepperPluginInfo>* plugins) { } +void TestContentClient::AddNPAPIPlugins( + webkit::npapi::PluginList* plugin_list) { +} + bool TestContentClient::CanSendWhileSwappedOut(const IPC::Message* msg) { return true; } diff --git a/content/test/test_content_client.h b/content/test/test_content_client.h index 0506b08..d4b27bf 100644 --- a/content/test/test_content_client.h +++ b/content/test/test_content_client.h @@ -19,6 +19,8 @@ class TestContentClient : public content::ContentClient { virtual void SetGpuInfo(const content::GPUInfo& gpu_info) OVERRIDE; virtual void AddPepperPlugins( std::vector<content::PepperPluginInfo>* plugins) OVERRIDE; + virtual void AddNPAPIPlugins( + webkit::npapi::PluginList* plugin_list) OVERRIDE; virtual bool CanSendWhileSwappedOut(const IPC::Message* msg) OVERRIDE; virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; virtual std::string GetUserAgent(bool* overriding) const OVERRIDE; |