diff options
26 files changed, 149 insertions, 131 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index d1ef581..984e89f 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -61,7 +61,6 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/default_plugin.h" #include "chrome/common/extensions/extension_l10n_util.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/json_pref_store.h" @@ -90,7 +89,6 @@ #include "net/url_request/url_request_context_getter.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/l10n/l10n_util.h" -#include "webkit/plugins/npapi/plugin_list.h" #if defined(OS_WIN) #include "views/focus/view_storage.h" @@ -792,15 +790,12 @@ void BrowserProcessImpl::CreateIOThread() { plugin_service->set_filter(ChromePluginServiceFilter::GetInstance()); plugin_service->StartWatchingPlugins(); - // Add the Chrome specific plugins. - chrome::RegisterInternalDefaultPlugin(); - // Register the internal Flash if available. FilePath path; if (!CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableInternalFlash) && PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { - webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path); + plugin_service->AddExtraPluginPath(path); } #if defined(OS_POSIX) @@ -808,8 +803,7 @@ void BrowserProcessImpl::CreateIOThread() { // e.g. ~/.config/chromium/Plugins. FilePath user_data_dir; if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { - webkit::npapi::PluginList::Singleton()->AddExtraPluginDir( - user_data_dir.Append("Plugins")); + plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); } #endif diff --git a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc index eb14534..59aec7e 100644 --- a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc +++ b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc @@ -25,7 +25,6 @@ #include "net/url_request/url_request_test_job.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/plugins/npapi/plugin_list.h" using content::BrowserThread; @@ -116,7 +115,7 @@ class GViewRequestInterceptorTest : public testing::Test { handler_ = new content::DummyResourceHandler(); - PluginService::GetInstance()->RefreshPluginList(); + PluginService::GetInstance()->RefreshPlugins(); PluginService::GetInstance()->GetPlugins(base::Bind(&QuitMessageLoop)); MessageLoop::current()->RunAllPending(); } @@ -140,15 +139,15 @@ class GViewRequestInterceptorTest : public testing::Test { void RegisterPDFPlugin() { webkit::WebPluginInfo info; info.path = pdf_path_; - webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); + PluginService::GetInstance()->RegisterInternalPlugin(info); - PluginService::GetInstance()->RefreshPluginList(); + PluginService::GetInstance()->RefreshPlugins(); PluginService::GetInstance()->GetPlugins(base::Bind(&QuitMessageLoop)); MessageLoop::current()->RunAllPending(); } void UnregisterPDFPlugin() { - webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_); + PluginService::GetInstance()->UnregisterInternalPlugin(pdf_path_); PluginService::GetInstance()->RefreshPluginList(); PluginService::GetInstance()->GetPlugins(base::Bind(&QuitMessageLoop)); diff --git a/chrome/browser/component_updater/npapi_flash_component_installer.cc b/chrome/browser/component_updater/npapi_flash_component_installer.cc index 86c68a6..7b4d404 100644 --- a/chrome/browser/component_updater/npapi_flash_component_installer.cc +++ b/chrome/browser/component_updater/npapi_flash_component_installer.cc @@ -18,7 +18,6 @@ #include "chrome/common/chrome_paths.h" #include "content/browser/plugin_service.h" #include "content/public/browser/browser_thread.h" -#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/webplugininfo.h" using content::BrowserThread; @@ -107,7 +106,7 @@ bool NPAPIFlashComponentInstaller::Install(base::DictionaryValue* manifest, return false; // Installation is done. Now tell the rest of chrome. current_version_ = version; - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); + PluginService::GetInstance()->RefreshPlugins(); return true; } @@ -204,10 +203,9 @@ void StartFlashUpdateRegistration(ComponentUpdateService* cus, // the information for free. void RegisterNPAPIFlashComponent(ComponentUpdateService* cus) { #if !defined(OS_CHROMEOS) - webkit::npapi::PluginList* plugins = webkit::npapi::PluginList::Singleton(); FilePath path = GetNPAPIFlashBaseDirectory().Append(kFlashPluginFileName); - plugins->AddExtraPluginPath(path); - plugins->RefreshPlugins(); + PluginService::GetInstance()->AddExtraPluginPath(path); + PluginService::GetInstance()->RefreshPlugins(); // Post the task to the FILE thread because IO may be done once the plugins // are loaded. diff --git a/chrome/browser/component_updater/pepper_flash_component_installer.cc b/chrome/browser/component_updater/pepper_flash_component_installer.cc index 0cb8e5f..9dd2a9a 100644 --- a/chrome/browser/component_updater/pepper_flash_component_installer.cc +++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc @@ -20,10 +20,10 @@ #include "chrome/browser/component_updater/component_updater_service.h" #include "chrome/browser/plugin_prefs.h" #include "chrome/common/chrome_paths.h" +#include "content/browser/plugin_service.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/pepper_plugin_info.h" #include "ppapi/c/private/ppb_pdf.h" -#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/plugin_constants.h" #include "webkit/plugins/ppapi/plugin_module.h" @@ -167,9 +167,9 @@ void RegisterPepperFlashWithChrome(const FilePath& path, if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) return; PluginPrefs::EnablePluginGlobally(kEnablePepperFlash, plugin_info.path); - webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( + PluginService::GetInstance()->RegisterInternalPlugin( plugin_info.ToWebPluginInfo()); - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); + PluginService::GetInstance()->RefreshPlugins(); } } // namespace @@ -321,8 +321,8 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) { } // namespace void RegisterPepperFlashComponent(ComponentUpdateService* cus) { -//#if defined(GOOGLE_CHROME_BUILD) +// #if defined(GOOGLE_CHROME_BUILD) BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, NewRunnableFunction(&StartPepperFlashUpdateRegistration, cus)); -//#endif +// #endif } diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 04e028a..4a599a3 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -96,7 +96,6 @@ #include "net/base/registry_controlled_domain.h" #include "webkit/database/database_tracker.h" #include "webkit/database/database_util.h" -#include "webkit/plugins/npapi/plugin_list.h" #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/cros/cros_library.h" @@ -969,8 +968,8 @@ void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { bool plugins_changed = false; for (size_t i = 0; i < extension->plugins().size(); ++i) { const Extension::PluginInfo& plugin = extension->plugins()[i]; - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); - webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(plugin.path); + PluginService::GetInstance()->RefreshPlugins(); + PluginService::GetInstance()->AddExtraPluginPath(plugin.path); plugins_changed = true; ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); @@ -1068,9 +1067,8 @@ void ExtensionService::NotifyExtensionUnloaded( if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(&ForceShutdownPlugin, plugin.path))) NOTREACHED(); - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); - webkit::npapi::PluginList::Singleton()->RemoveExtraPluginPath( - plugin.path); + PluginService::GetInstance()->RefreshPlugins(); + PluginService::GetInstance()->RemoveExtraPluginPath(plugin.path); plugins_changed = true; ChromePluginServiceFilter::GetInstance()->UnrestrictPlugin(plugin.path); } @@ -2449,7 +2447,7 @@ void ExtensionService::UpdatePluginListWithNaClModules() { if (mime_iter->mime_type == kNaClPluginMimeType) { // This plugin handles "application/x-nacl". - webkit::npapi::PluginList::Singleton()-> + PluginService::GetInstance()-> UnregisterInternalPlugin(pepper_info->path); webkit::WebPluginInfo info = pepper_info->ToWebPluginInfo(); @@ -2468,8 +2466,8 @@ void ExtensionService::UpdatePluginListWithNaClModules() { info.mime_types.push_back(mime_type_info); } - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); - webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); + PluginService::GetInstance()->RefreshPlugins(); + PluginService::GetInstance()->RegisterInternalPlugin(info); // This plugin has been modified, no need to check the rest of its // types, but continue checking other plugins. break; diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 2342d74..7f2db89 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -181,7 +181,6 @@ #include "content/common/child_process_info.h" #include "content/public/browser/notification_service.h" #include "content/public/common/url_fetcher.h" -#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/webplugininfo.h" // TODO(port): port browser_distribution.h. diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index c909c69..4d81c68 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -22,7 +22,6 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/plugins/npapi/plugin_group.h" -#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/webplugininfo.h" namespace { diff --git a/chrome/browser/plugin_prefs.cc b/chrome/browser/plugin_prefs.cc index c20886e..340be8b 100644 --- a/chrome/browser/plugin_prefs.cc +++ b/chrome/browser/plugin_prefs.cc @@ -480,7 +480,7 @@ void PluginPrefs::SetPolicyEnforcedPluginPatterns( webkit::npapi::PluginList* PluginPrefs::GetPluginList() { if (plugin_list_) return plugin_list_; - return webkit::npapi::PluginList::Singleton(); + return PluginService::GetInstance()->GetPluginList(); } void PluginPrefs::GetPreferencesDataOnFileThread() { diff --git a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm index c969a4f..a821e1e 100644 --- a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm +++ b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm @@ -13,11 +13,11 @@ #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" #import "chrome/browser/ui/cocoa/info_bubble_view.h" #import "chrome/browser/ui/cocoa/l10n_util.h" +#include "content/browser/plugin_service.h" #include "grit/generated_resources.h" #include "skia/ext/skia_utils_mac.h" #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" #include "ui/base/l10n/l10n_util.h" -#include "webkit/plugins/npapi/plugin_list.h" namespace { @@ -245,7 +245,7 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) { for (std::set<std::string>::iterator it = plugins.begin(); it != plugins.end(); ++it) { NSString* name = SysUTF16ToNSString( - webkit::npapi::PluginList::Singleton()->GetPluginGroupName(*it)); + PluginService::GetInstance()->GetPluginGroupName(*it)); if ([name length] == 0) name = base::SysUTF8ToNSString(*it); [pluginArray addObject:name]; diff --git a/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc b/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc index 821bf32..b414230 100644 --- a/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc @@ -17,6 +17,7 @@ #include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/common/content_settings.h" +#include "content/browser/plugin_service.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" @@ -26,7 +27,6 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/text/text_elider.h" #include "ui/gfx/gtk_util.h" -#include "webkit/plugins/npapi/plugin_list.h" namespace { @@ -109,7 +109,7 @@ void ContentSettingBubbleGtk::BuildBubble() { for (std::set<std::string>::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { std::string name = UTF16ToUTF8( - webkit::npapi::PluginList::Singleton()->GetPluginGroupName(*it)); + PluginService::GetInstance()->GetPluginGroupName(*it)); if (name.empty()) name = *it; diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc index 00843db..a9e327b 100644 --- a/chrome/browser/ui/views/content_setting_bubble_contents.cc +++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc @@ -19,6 +19,7 @@ #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" #include "chrome/browser/ui/views/browser_dialogs.h" #include "chrome/browser/ui/views/bubble/bubble.h" +#include "content/browser/plugin_service.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" @@ -32,7 +33,6 @@ #include "views/controls/separator.h" #include "views/layout/grid_layout.h" #include "views/layout/layout_constants.h" -#include "webkit/plugins/npapi/plugin_list.h" #if defined(TOOLKIT_USES_GTK) #include "ui/gfx/gtk_util.h" @@ -217,7 +217,7 @@ void ContentSettingBubbleContents::InitControlLayout() { for (std::set<std::string>::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { string16 name = - webkit::npapi::PluginList::Singleton()->GetPluginGroupName(*it); + PluginService::GetInstance()->GetPluginGroupName(*it); if (name.empty()) name = UTF8ToUTF16(*it); layout->StartRow(0, single_column_set_id); diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index b7478fc..f8141db 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -100,8 +100,6 @@ 'common/content_settings_types.h', 'common/custom_handlers/protocol_handler.cc', 'common/custom_handlers/protocol_handler.h', - 'common/default_plugin.cc', - 'common/default_plugin.h', 'common/extensions/extension.cc', 'common/extensions/extension.h', 'common/extensions/extension_action.cc', diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc index a015b75..65b004b 100644 --- a/chrome/common/chrome_content_client.cc +++ b/chrome/common/chrome_content_client.cc @@ -12,17 +12,20 @@ #include "base/stringprintf.h" #include "base/string_split.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "base/win/windows_version.h" #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/render_messages.h" +#include "chrome/default_plugin/plugin_main.h" #include "content/public/common/pepper_plugin_info.h" #include "remoting/client/plugin/pepper_entrypoints.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/glue/user_agent.h" +#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/plugin_constants.h" #if defined(OS_WIN) @@ -266,6 +269,37 @@ void ChromeContentClient::AddPepperPlugins( AddOutOfProcessFlash(plugins); } +void ChromeContentClient::AddNPAPIPlugins( + webkit::npapi::PluginList* plugin_list) { +#if defined(OS_WIN) && !defined(USE_AURA) + // TODO(bauerb): On Windows the default plug-in can download and install + // missing plug-ins, which we don't support in the browser yet, so keep + // using the default plug-in on Windows until we do. + // Aura isn't going to support NPAPI plugins. + const webkit::npapi::PluginEntryPoints entry_points = { + default_plugin::NP_GetEntryPoints, + default_plugin::NP_Initialize, + default_plugin::NP_Shutdown + }; + + webkit::WebPluginInfo info; + info.path = FilePath(webkit::npapi::kDefaultPluginLibraryName); + info.name = ASCIIToUTF16("Default Plug-in"); + info.version = ASCIIToUTF16("1"); + info.desc = ASCIIToUTF16("Provides functionality for installing third-party " + "plug-ins"); + + webkit::WebPluginMimeType mimeType; + mimeType.mime_type = "*"; + info.mime_types.push_back(mimeType); + + webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( + info, + entry_points, + false); +#endif +} + bool ChromeContentClient::CanSendWhileSwappedOut(const IPC::Message* msg) { // Any Chrome-specific messages that must be allowed to be sent from swapped // out renderers. diff --git a/chrome/common/chrome_content_client.h b/chrome/common/chrome_content_client.h index 5d82037..6c252e1 100644 --- a/chrome/common/chrome_content_client.h +++ b/chrome/common/chrome_content_client.h @@ -21,6 +21,8 @@ class ChromeContentClient : 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; diff --git a/chrome/common/default_plugin.cc b/chrome/common/default_plugin.cc deleted file mode 100644 index b9b8fab..0000000 --- a/chrome/common/default_plugin.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/utf_string_conversions.h" -#include "chrome/common/default_plugin.h" -#include "chrome/default_plugin/plugin_main.h" -#include "webkit/plugins/npapi/plugin_list.h" - -namespace chrome { - -void RegisterInternalDefaultPlugin() { -#if defined(OS_WIN) && !defined(USE_AURA) - // TODO(bauerb): On Windows the default plug-in can download and install - // missing plug-ins, which we don't support in the browser yet, so keep - // using the default plug-in on Windows until we do. - // Aura isn't going to support NPAPI plugins. - const webkit::npapi::PluginEntryPoints entry_points = { -#if !defined(OS_POSIX) || defined(OS_MACOSX) - default_plugin::NP_GetEntryPoints, -#endif - default_plugin::NP_Initialize, - default_plugin::NP_Shutdown - }; - - webkit::WebPluginInfo info; - info.path = FilePath(webkit::npapi::kDefaultPluginLibraryName); - info.name = ASCIIToUTF16("Default Plug-in"); - info.version = ASCIIToUTF16("1"); - info.desc = ASCIIToUTF16("Provides functionality for installing third-party " - "plug-ins"); - - webkit::WebPluginMimeType mimeType; - mimeType.mime_type = "*"; - info.mime_types.push_back(mimeType); - - webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( - info, - entry_points, - false); -#endif -} - -} // namespace chrome diff --git a/chrome/common/default_plugin.h b/chrome/common/default_plugin.h deleted file mode 100644 index 6cc8348..0000000 --- a/chrome/common/default_plugin.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_DEFAULT_PLUGIN_H_ -#define CHROME_COMMON_DEFAULT_PLUGIN_H_ -#pragma once - -namespace chrome { - -// Register the default plugin as an internal plugin in the PluginList. -void RegisterInternalDefaultPlugin(); - -} // namespace chrome - -#endif // CHROME_COMMON_DEFAULT_PLUGIN_H_ diff --git a/chrome/plugin/chrome_content_plugin_client.cc b/chrome/plugin/chrome_content_plugin_client.cc index b26f523..0a8e42b 100644 --- a/chrome/plugin/chrome_content_plugin_client.cc +++ b/chrome/plugin/chrome_content_plugin_client.cc @@ -4,8 +4,6 @@ #include "chrome/plugin/chrome_content_plugin_client.h" -#include "chrome/common/default_plugin.h" - #if defined(OS_MACOSX) #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" @@ -29,8 +27,6 @@ void ChromeContentPluginClient::PluginProcessStarted( cf_plugin_name.get(), app_name.get())); base::mac::SetProcessName(process_name); #endif - - chrome::RegisterInternalDefaultPlugin(); } } // namespace chrome diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc index 7d2c811..82c689c 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( + GetPluginList()->set_will_load_plugins_callback( base::Bind(&WillLoadPluginsCallback)); RegisterPepperPlugins(); + content::GetContentClient()->AddNPAPIPlugins(GetPluginList()); + // 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); + AddExtraPluginPath(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); + GetPluginList()->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); + GetPluginList()->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); + GetPluginList()->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 (GetPluginList()->GetPluginsIfNoRefreshNeeded(&cached_plugins)) { // Can't assume the caller is reentrant. target_loop->PostTask(FROM_HERE, base::Bind(&RunGetPluginsCallback, callback, cached_plugins)); @@ -530,7 +525,7 @@ void PluginService::GetPluginsInternal( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); std::vector<webkit::WebPluginInfo> plugins; - webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); + GetPluginList()->GetPlugins(&plugins); target_loop->PostTask(FROM_HERE, base::Bind(&RunGetPluginsCallback, callback, plugins)); @@ -545,7 +540,7 @@ void PluginService::OnWaitableEventSignaled( hklm_key_.StartWatching(); } - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); + GetPluginList()->RefreshPlugins(); PurgePluginListCache(NULL, false); #else // This event should only get signaled on a Windows machine. @@ -581,8 +576,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()); } } @@ -623,3 +617,31 @@ void PluginService::RegisterFilePathWatcher( DCHECK(result); } #endif + +void PluginService::RefreshPlugins() { + GetPluginList()->RefreshPlugins(); +} + +void PluginService::AddExtraPluginPath(const FilePath& path) { + GetPluginList()->AddExtraPluginPath(path); +} + +void PluginService::RemoveExtraPluginPath(const FilePath& path) { + GetPluginList()->RemoveExtraPluginPath(path); +} + +void PluginService::UnregisterInternalPlugin(const FilePath& path) { + GetPluginList()->UnregisterInternalPlugin(path); +} + +webkit::npapi::PluginList* PluginService::GetPluginList() { + return webkit::npapi::PluginList::Singleton(); +} + +void PluginService::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { + GetPluginList()->RegisterInternalPlugin(info); +} + +string16 PluginService::GetPluginGroupName(const std::string& plugin_name) { + return GetPluginList()->GetPluginGroupName(plugin_name); +} diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h index 2b2c69f..e7a894b 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* GetPluginList(); + 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; |