diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 02:39:38 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 02:39:38 +0000 |
commit | 3a5180ae725c862c95fb782885935210b5e47b11 (patch) | |
tree | 7f9d336c98bdb5790940aa4fa3bed77088713f03 /content/browser/plugin_service.cc | |
parent | ff5ce2374012237cdf8e2c3ef24908b1a13106b7 (diff) | |
download | chromium_src-3a5180ae725c862c95fb782885935210b5e47b11.zip chromium_src-3a5180ae725c862c95fb782885935210b5e47b11.tar.gz chromium_src-3a5180ae725c862c95fb782885935210b5e47b11.tar.bz2 |
Create an API around PluginService and use it from Chrome.
BUG=98716
Review URL: http://codereview.chromium.org/9006036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/plugin_service.cc')
-rw-r--r-- | content/browser/plugin_service.cc | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc index 7e87513..c3ad8ce 100644 --- a/content/browser/plugin_service.cc +++ b/content/browser/plugin_service.cc @@ -97,7 +97,7 @@ class PluginDirWatcherDelegate : public FilePathWatcher::Delegate { webkit::npapi::PluginList::Singleton()->RefreshPlugins(); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&PluginService::PurgePluginListCache, + base::Bind(&content::PluginService::PurgePluginListCache, static_cast<content::BrowserContext*>(NULL), false)); } @@ -109,6 +109,24 @@ class PluginDirWatcherDelegate : public FilePathWatcher::Delegate { }; #endif +namespace content { +// static +PluginService* PluginService::GetInstance() { + return ::PluginService::GetInstance(); +} + +void PluginService::PurgePluginListCache(BrowserContext* browser_context, + bool reload_pages) { + for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); + !it.IsAtEnd(); it.Advance()) { + RenderProcessHost* host = it.GetCurrentValue(); + if (!browser_context || host->GetBrowserContext() == browser_context) + host->Send(new ViewMsg_PurgePluginListCache(reload_pages)); + } +} + +} // namespace content + // static PluginService* PluginService::GetInstance() { return Singleton<PluginService>::get(); @@ -139,12 +157,12 @@ void PluginService::Init() { if (!plugin_list_) plugin_list_ = webkit::npapi::PluginList::Singleton(); - plugin_list()->set_will_load_plugins_callback( + plugin_list_->set_will_load_plugins_callback( base::Bind(&WillLoadPluginsCallback)); RegisterPepperPlugins(); - content::GetContentClient()->AddNPAPIPlugins(plugin_list()); + content::GetContentClient()->AddNPAPIPlugins(plugin_list_); // Load any specified on the command line as well. const CommandLine* command_line = CommandLine::ForCurrentProcess(); @@ -153,7 +171,7 @@ void PluginService::Init() { AddExtraPluginPath(path); path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); if (!path.empty()) - plugin_list()->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 @@ -193,7 +211,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; - plugin_list()->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. @@ -438,8 +456,8 @@ bool PluginService::GetPluginInfoArray( std::vector<webkit::WebPluginInfo>* plugins, std::vector<std::string>* actual_mime_types) { bool use_stale = false; - plugin_list()->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; } @@ -486,7 +504,7 @@ bool PluginService::GetPluginInfo(int render_process_id, bool PluginService::GetPluginInfoByPath(const FilePath& plugin_path, webkit::WebPluginInfo* info) { std::vector<webkit::WebPluginInfo> plugins; - plugin_list()->GetPluginsIfNoRefreshNeeded(&plugins); + plugin_list_->GetPluginsIfNoRefreshNeeded(&plugins); for (std::vector<webkit::WebPluginInfo>::iterator it = plugins.begin(); it != plugins.end(); @@ -510,7 +528,7 @@ void PluginService::GetPlugins(const GetPluginsCallback& callback) { target_loop, callback)); #else std::vector<webkit::WebPluginInfo> cached_plugins; - if (plugin_list()->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)); @@ -536,7 +554,7 @@ void PluginService::GetPluginsInternal( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); std::vector<webkit::WebPluginInfo> plugins; - plugin_list()->GetPlugins(&plugins); + plugin_list_->GetPlugins(&plugins); target_loop->PostTask(FROM_HERE, base::Bind(&RunGetPluginsCallback, callback, plugins)); @@ -551,7 +569,7 @@ void PluginService::OnWaitableEventSignaled( hklm_key_.StartWatching(); } - plugin_list()->RefreshPlugins(); + plugin_list_->RefreshPlugins(); PurgePluginListCache(NULL, false); #else // This event should only get signaled on a Windows machine. @@ -572,18 +590,6 @@ void PluginService::Observe(int type, NOTREACHED(); } -void PluginService::PurgePluginListCache( - content::BrowserContext* browser_context, - bool reload_pages) { - for (content::RenderProcessHost::iterator it = - content::RenderProcessHost::AllHostsIterator(); - !it.IsAtEnd(); it.Advance()) { - content::RenderProcessHost* host = it.GetCurrentValue(); - if (!browser_context || host->GetBrowserContext() == browser_context) - host->Send(new ViewMsg_PurgePluginListCache(reload_pages)); - } -} - void PluginService::RegisterPepperPlugins() { // TODO(abarth): It seems like the PepperPluginRegistry should do this work. PepperPluginRegistry::ComputeList(&ppapi_plugins_); @@ -630,20 +636,28 @@ void PluginService::RegisterFilePathWatcher( } #endif +void PluginService::SetFilter(content::PluginServiceFilter* filter) { + filter_ = filter; +} + +content::PluginServiceFilter* PluginService::GetFilter() { + return filter_; +} + void PluginService::RefreshPlugins() { - plugin_list()->RefreshPlugins(); + plugin_list_->RefreshPlugins(); } void PluginService::AddExtraPluginPath(const FilePath& path) { - plugin_list()->AddExtraPluginPath(path); + plugin_list_->AddExtraPluginPath(path); } void PluginService::RemoveExtraPluginPath(const FilePath& path) { - plugin_list()->RemoveExtraPluginPath(path); + plugin_list_->RemoveExtraPluginPath(path); } void PluginService::UnregisterInternalPlugin(const FilePath& path) { - plugin_list()->UnregisterInternalPlugin(path); + plugin_list_->UnregisterInternalPlugin(path); } void PluginService::SetPluginListForTesting( @@ -652,9 +666,13 @@ void PluginService::SetPluginListForTesting( } void PluginService::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { - plugin_list()->RegisterInternalPlugin(info); + plugin_list_->RegisterInternalPlugin(info); } string16 PluginService::GetPluginGroupName(const std::string& plugin_name) { - return plugin_list()->GetPluginGroupName(plugin_name); + return plugin_list_->GetPluginGroupName(plugin_name); +} + +webkit::npapi::PluginList* PluginService::GetPluginList() { + return plugin_list_; } |