Skip to content

Commit

Permalink
Modify code in chrome to call wrapper functions on PluginService
Browse files Browse the repository at this point in the history
rather than calling into webkit::npapi::PluginList directly.

This change is necessary to ensure we only have one list when we switch
content to the component build.

R=jam@chromium.org
TBR=cpu@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/8440058

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108744 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dpranke@chromium.org committed Nov 4, 2011
1 parent deea482 commit 8dc30c4
Show file tree
Hide file tree
Showing 26 changed files with 149 additions and 131 deletions.
10 changes: 2 additions & 8 deletions chrome/browser/browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -792,24 +790,20 @@ 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)
// Also find plugins in a user-specific plugins dir,
// 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

Expand Down
9 changes: 4 additions & 5 deletions chrome/browser/chromeos/gview_request_interceptor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
16 changes: 7 additions & 9 deletions chrome/browser/extensions/extension_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/metrics/metrics_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/plugin_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/plugin_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -245,7 +245,7 @@ - (void)initializeBlockedPluginsList {
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];
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/gtk/content_setting_bubble_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/content_setting_bubble_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
34 changes: 34 additions & 0 deletions chrome/common/chrome_content_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions chrome/common/chrome_content_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 8dc30c4

Please sign in to comment.