diff options
16 files changed, 52 insertions, 271 deletions
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc index d87dcb5..976364a 100644 --- a/chrome/browser/content_settings/content_settings_browsertest.cc +++ b/chrome/browser/content_settings/content_settings_browsertest.cc @@ -10,7 +10,6 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/net/url_request_mock_util.h" -#include "chrome/browser/plugins/chrome_plugin_service_filter.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" @@ -20,8 +19,6 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/plugin_service.h" -#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_switches.h" @@ -316,12 +313,6 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, Basic) { content::RenderViewHost* host = browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); - ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); - int process_id = host->GetProcess()->GetID(); - FilePath path(FILE_PATH_LITERAL("blah")); - EXPECT_FALSE(filter->CanLoadPlugin(process_id, path)); - filter->AuthorizeAllPlugins(process_id); - EXPECT_TRUE(filter->CanLoadPlugin(process_id, path)); host->Send(new ChromeViewMsg_LoadBlockedPlugins( host->GetRoutingID(), std::string())); @@ -382,8 +373,6 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, LoadAllBlockedPlugins) { content::RenderViewHost* host = browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - host->GetProcess()->GetID()); host->Send(new ChromeViewMsg_LoadBlockedPlugins( host->GetRoutingID(), std::string())); EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); @@ -417,8 +406,6 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, NoCallbackAtLoad) { content::RenderViewHost* host = browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - host->GetProcess()->GetID()); host->Send(new ChromeViewMsg_LoadBlockedPlugins( host->GetRoutingID(), std::string())); @@ -439,8 +426,6 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) { content::RenderViewHost* host = browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - host->GetProcess()->GetID()); host->Send(new ChromeViewMsg_LoadBlockedPlugins( host->GetRoutingID(), std::string())); diff --git a/chrome/browser/plugins/chrome_plugin_service_filter.cc b/chrome/browser/plugins/chrome_plugin_service_filter.cc index d96f5f2..c0bebdc 100644 --- a/chrome/browser/plugins/chrome_plugin_service_filter.cc +++ b/chrome/browser/plugins/chrome_plugin_service_filter.cc @@ -44,13 +44,13 @@ void ChromePluginServiceFilter::OverridePluginForTab( int render_view_id, const GURL& url, const webkit::WebPluginInfo& plugin) { - base::AutoLock auto_lock(lock_); - ProcessDetails* details = GetOrRegisterProcess(render_process_id); OverriddenPlugin overridden_plugin; + overridden_plugin.render_process_id = render_process_id; overridden_plugin.render_view_id = render_view_id; overridden_plugin.url = url; overridden_plugin.plugin = plugin; - details->overridden_plugins.push_back(overridden_plugin); + base::AutoLock auto_lock(lock_); + overridden_plugins_.push_back(overridden_plugin); } void ChromePluginServiceFilter::RestrictPluginToProfileAndOrigin( @@ -69,7 +69,7 @@ void ChromePluginServiceFilter::UnrestrictPlugin( restricted_plugins_.erase(plugin_path); } -bool ChromePluginServiceFilter::IsPluginEnabled( +bool ChromePluginServiceFilter::ShouldUsePlugin( int render_process_id, int render_view_id, const void* context, @@ -77,21 +77,17 @@ bool ChromePluginServiceFilter::IsPluginEnabled( const GURL& policy_url, webkit::WebPluginInfo* plugin) { base::AutoLock auto_lock(lock_); - const ProcessDetails* details = GetProcess(render_process_id); - // Check whether the plugin is overridden. - if (details) { - for (size_t i = 0; i < details->overridden_plugins.size(); ++i) { - if (details->overridden_plugins[i].render_view_id == render_view_id && - (details->overridden_plugins[i].url == url || - details->overridden_plugins[i].url.is_empty())) { - - bool use = details->overridden_plugins[i].plugin.path == plugin->path; - if (!use) - return false; - *plugin = details->overridden_plugins[i].plugin; - break; - } + for (size_t i = 0; i < overridden_plugins_.size(); ++i) { + if (overridden_plugins_[i].render_process_id == render_process_id && + overridden_plugins_[i].render_view_id == render_view_id && + (overridden_plugins_[i].url == url || + overridden_plugins_[i].url.is_empty())) { + + bool use = overridden_plugins_[i].plugin.path == plugin->path; + if (use) + *plugin = overridden_plugins_[i].plugin; + return use; } } @@ -123,39 +119,6 @@ bool ChromePluginServiceFilter::IsPluginEnabled( return true; } -bool ChromePluginServiceFilter::CanLoadPlugin(int render_process_id, - const FilePath& path) { - // The browser itself sometimes loads plug-ins to e.g. clear plug-in data. - // We always grant the browser permission. - if (!render_process_id) - return true; - - base::AutoLock auto_lock(lock_); - const ProcessDetails* details = GetProcess(render_process_id); - if (!details) - return false; - - if (details->authorized_plugins.find(path) == - details->authorized_plugins.end() && - details->authorized_plugins.find(FilePath()) == - details->authorized_plugins.end()) { - return false; - } - - return true; -} - -void ChromePluginServiceFilter::AuthorizePlugin(int render_process_id, - const FilePath& plugin_path) { - base::AutoLock auto_lock(lock_); - ProcessDetails* details = GetOrRegisterProcess(render_process_id); - details->authorized_plugins.insert(plugin_path); -} - -void ChromePluginServiceFilter::AuthorizeAllPlugins(int render_process_id) { - AuthorizePlugin(render_process_id, FilePath()); -} - ChromePluginServiceFilter::ChromePluginServiceFilter() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, @@ -178,7 +141,12 @@ void ChromePluginServiceFilter::Observe( content::Source<content::RenderProcessHost>(source).ptr()->GetID(); base::AutoLock auto_lock(lock_); - plugin_details_.erase(render_process_id); + for (size_t i = 0; i < overridden_plugins_.size(); ++i) { + if (overridden_plugins_[i].render_process_id == render_process_id) { + overridden_plugins_.erase(overridden_plugins_.begin() + i); + break; + } + } break; } case chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED: { @@ -195,33 +163,3 @@ void ChromePluginServiceFilter::Observe( } } } - -ChromePluginServiceFilter::ProcessDetails* -ChromePluginServiceFilter::GetOrRegisterProcess( - int render_process_id) { - return &plugin_details_[render_process_id]; -} - -const ChromePluginServiceFilter::ProcessDetails* -ChromePluginServiceFilter::GetProcess( - int render_process_id) const { - std::map<int, ProcessDetails>::const_iterator it = - plugin_details_.find(render_process_id); - if (it == plugin_details_.end()) - return NULL; - return &it->second; -} - -ChromePluginServiceFilter::OverriddenPlugin::OverriddenPlugin() - : render_view_id(MSG_ROUTING_NONE) { -} - -ChromePluginServiceFilter::OverriddenPlugin::~OverriddenPlugin() { -} - -ChromePluginServiceFilter::ProcessDetails::ProcessDetails() { -} - -ChromePluginServiceFilter::ProcessDetails::~ProcessDetails() { -} - diff --git a/chrome/browser/plugins/chrome_plugin_service_filter.h b/chrome/browser/plugins/chrome_plugin_service_filter.h index f9104dd..a1d5a72 100644 --- a/chrome/browser/plugins/chrome_plugin_service_filter.h +++ b/chrome/browser/plugins/chrome_plugin_service_filter.h @@ -6,7 +6,6 @@ #define CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ #include <map> -#include <set> #include <vector> #include "base/file_path.h" @@ -51,14 +50,8 @@ class ChromePluginServiceFilter : public content::PluginServiceFilter, // Lifts a restriction on a plug-in. void UnrestrictPlugin(const FilePath& plugin_path); - // Authorizes a given plug-in for a given process. - void AuthorizePlugin(int render_process_id, const FilePath& plugin_path); - - // Authorizes all plug-ins for a given process. - void AuthorizeAllPlugins(int render_process_id); - // PluginServiceFilter implementation: - virtual bool IsPluginEnabled( + virtual bool ShouldUsePlugin( int render_process_id, int render_view_id, const void* context, @@ -66,32 +59,16 @@ class ChromePluginServiceFilter : public content::PluginServiceFilter, const GURL& policy_url, webkit::WebPluginInfo* plugin) OVERRIDE; - // CanLoadPlugin always grants permission to the browser - // (render_process_id == 0) - virtual bool CanLoadPlugin( - int render_process_id, - const FilePath& path) OVERRIDE; - private: friend struct DefaultSingletonTraits<ChromePluginServiceFilter>; struct OverriddenPlugin { - OverriddenPlugin(); - ~OverriddenPlugin(); - + int render_process_id; int render_view_id; GURL url; // If empty, the override applies to all urls in render_view. webkit::WebPluginInfo plugin; }; - struct ProcessDetails { - ProcessDetails(); - ~ProcessDetails(); - - std::vector<OverriddenPlugin> overridden_plugins; - std::set<FilePath> authorized_plugins; - }; - ChromePluginServiceFilter(); virtual ~ChromePluginServiceFilter(); @@ -100,9 +77,6 @@ class ChromePluginServiceFilter : public content::PluginServiceFilter, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; - ProcessDetails* GetOrRegisterProcess(int render_process_id); - const ProcessDetails* GetProcess(int render_process_id) const; - content::NotificationRegistrar registrar_; base::Lock lock_; // Guards access to member variables. @@ -113,7 +87,7 @@ class ChromePluginServiceFilter : public content::PluginServiceFilter, typedef std::map<const void*, scoped_refptr<PluginPrefs> > ResourceContextMap; ResourceContextMap resource_context_map_; - std::map<int, ProcessDetails> plugin_details_; + std::vector<OverriddenPlugin> overridden_plugins_; }; #endif // CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ diff --git a/chrome/browser/plugins/plugin_info_message_filter.cc b/chrome/browser/plugins/plugin_info_message_filter.cc index bbfcdc5..42acad0 100644 --- a/chrome/browser/plugins/plugin_info_message_filter.cc +++ b/chrome/browser/plugins/plugin_info_message_filter.cc @@ -10,7 +10,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/content_settings/content_settings_utils.h" #include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/plugins/chrome_plugin_service_filter.h" #include "chrome/browser/plugins/plugin_finder.h" #include "chrome/browser/plugins/plugin_metadata.h" #include "chrome/browser/prefs/pref_service.h" @@ -133,8 +132,6 @@ void PluginInfoMessageFilter::PluginsLoaded( output.group_name = plugin_metadata->name(); } - context_.GrantAccess(output.status, output.plugin.path); - ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output); Send(reply_msg); } @@ -228,7 +225,7 @@ bool PluginInfoMessageFilter::Context::FindEnabledPlugin( PluginService::GetInstance()->GetFilter(); size_t i = 0; for (; i < matching_plugins.size(); ++i) { - if (!filter || filter->IsPluginEnabled(render_process_id_, + if (!filter || filter->ShouldUsePlugin(render_process_id_, render_view_id, resource_context_, url, @@ -292,14 +289,3 @@ void PluginInfoMessageFilter::Context::GetPluginContentSetting( info.primary_pattern == ContentSettingsPattern::Wildcard() && info.secondary_pattern == ContentSettingsPattern::Wildcard(); } - -void PluginInfoMessageFilter::Context::GrantAccess( - const ChromeViewHostMsg_GetPluginInfo_Status& status, - const FilePath& path) const { - if (status.value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed || - status.value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay) { - ChromePluginServiceFilter::GetInstance()->AuthorizePlugin( - render_process_id_, path); - } -} - diff --git a/chrome/browser/plugins/plugin_info_message_filter.h b/chrome/browser/plugins/plugin_info_message_filter.h index 51c3023..a07be39 100644 --- a/chrome/browser/plugins/plugin_info_message_filter.h +++ b/chrome/browser/plugins/plugin_info_message_filter.h @@ -63,8 +63,6 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter { const std::string& resource, ContentSetting* setting, bool* is_default) const; - void GrantAccess(const ChromeViewHostMsg_GetPluginInfo_Status& status, - const FilePath& path) const; private: int render_process_id_; diff --git a/chrome/browser/plugins/plugin_infobar_delegates.cc b/chrome/browser/plugins/plugin_infobar_delegates.cc index dfc1b59..1667a62 100644 --- a/chrome/browser/plugins/plugin_infobar_delegates.cc +++ b/chrome/browser/plugins/plugin_infobar_delegates.cc @@ -9,12 +9,10 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/lifetime/application_lifetime.h" -#include "chrome/browser/plugins/chrome_plugin_service_filter.h" #include "chrome/browser/plugins/plugin_metadata.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" -#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" @@ -64,11 +62,8 @@ bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { void PluginInfoBarDelegate::LoadBlockedPlugins() { content::WebContents* web_contents = owner()->GetWebContents(); if (web_contents) { - content::RenderViewHost* host = web_contents->GetRenderViewHost(); - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - host->GetProcess()->GetID()); - host->Send(new ChromeViewMsg_LoadBlockedPlugins( - host->GetRoutingID(), identifier_)); + web_contents->Send(new ChromeViewMsg_LoadBlockedPlugins( + web_contents->GetRoutingID(), identifier_)); } } diff --git a/chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc b/chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc index f33461a..48aae58 100644 --- a/chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc +++ b/chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc @@ -27,16 +27,13 @@ class FakePluginServiceFilter : public content::PluginServiceFilter { FakePluginServiceFilter() {} virtual ~FakePluginServiceFilter() {} - virtual bool IsPluginEnabled(int render_process_id, + virtual bool ShouldUsePlugin(int render_process_id, int render_view_id, const void* context, const GURL& url, const GURL& policy_url, webkit::WebPluginInfo* plugin) OVERRIDE; - virtual bool CanLoadPlugin(int render_process_id, - const FilePath& path) OVERRIDE; - void set_plugin_enabled(const FilePath& plugin_path, bool enabled) { plugin_state_[plugin_path] = enabled; } @@ -45,7 +42,7 @@ class FakePluginServiceFilter : public content::PluginServiceFilter { std::map<FilePath, bool> plugin_state_; }; -bool FakePluginServiceFilter::IsPluginEnabled(int render_process_id, +bool FakePluginServiceFilter::ShouldUsePlugin(int render_process_id, int render_view_id, const void* context, const GURL& url, @@ -59,11 +56,6 @@ bool FakePluginServiceFilter::IsPluginEnabled(int render_process_id, return it->second; } -bool FakePluginServiceFilter::CanLoadPlugin(int render_process_id, - const FilePath& path) { - return true; -} - } // namespace class PluginInfoMessageFilterTest : public ::testing::Test { diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 3908e2a..7f72b09 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -29,7 +29,6 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/plugins/chrome_plugin_service_filter.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/printing/print_preview_context_menu_observer.h" @@ -71,7 +70,6 @@ #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_service.h" -#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/user_metrics.h" @@ -1318,14 +1316,7 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; - const content::CustomContextMenuContext& context = params_.custom_context; -#if defined(ENABLE_PLUGINS) - if (context.request_id && !context.is_pepper_menu) { - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - rvh->GetProcess()->GetID()); - } -#endif - rvh->ExecuteCustomContextMenuCommand(action, context); + rvh->ExecuteCustomContextMenuCommand(action, params_.custom_context); return; } diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index b4e4a86..c38ceda 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -12,7 +12,6 @@ #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/favicon/favicon_tab_helper.h" -#include "chrome/browser/plugins/chrome_plugin_service_filter.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" @@ -24,7 +23,6 @@ #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" #include "content/public/browser/notification_service.h" -#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" @@ -398,8 +396,6 @@ void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() { delegate()->ShowCollectedCookiesDialog(web_contents()); } -#if defined(ENABLE_PLUGINS) - class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { public: ContentSettingPluginBubbleModel(Delegate* delegate, @@ -431,8 +427,6 @@ void ContentSettingPluginBubbleModel::OnCustomLinkClicked() { DCHECK(web_contents()); content::RenderViewHost* host = web_contents()->GetRenderViewHost(); // TODO(bauerb): We should send the identifiers of blocked plug-ins here. - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - host->GetProcess()->GetID()); host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID(), std::string())); set_custom_link_enabled(false); @@ -440,8 +434,6 @@ void ContentSettingPluginBubbleModel::OnCustomLinkClicked() { set_load_plugins_link_enabled(false); } -#endif // ENABLE_PLUGINS - class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { public: ContentSettingPopupBubbleModel(Delegate* delegate, @@ -898,12 +890,10 @@ ContentSettingBubbleModel* return new ContentSettingMediaStreamBubbleModel(delegate, web_contents, profile); } -#if defined(ENABLE_PLUGINS) if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { return new ContentSettingPluginBubbleModel(delegate, web_contents, profile, content_type); } -#endif if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { return new ContentSettingMixedScriptBubbleModel(delegate, web_contents, profile, content_type); diff --git a/content/browser/pepper_flash_settings_helper_impl.cc b/content/browser/pepper_flash_settings_helper_impl.cc index 557a2d5..bd6af82 100644 --- a/content/browser/pepper_flash_settings_helper_impl.cc +++ b/content/browser/pepper_flash_settings_helper_impl.cc @@ -38,7 +38,7 @@ void PepperFlashSettingsHelperImpl::OpenChannelToBroker( callback_ = callback; PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance(); - plugin_service->OpenChannelToPpapiBroker(0, path, this); + plugin_service->OpenChannelToPpapiBroker(path, this); } void PepperFlashSettingsHelperImpl::GetPpapiChannelInfo( diff --git a/content/browser/plugin_data_remover_impl.cc b/content/browser/plugin_data_remover_impl.cc index 7b8effc..6b9ca8a 100644 --- a/content/browser/plugin_data_remover_impl.cc +++ b/content/browser/plugin_data_remover_impl.cc @@ -109,7 +109,7 @@ class PluginDataRemoverImpl::Context if (pepper_info) { plugin_name_ = pepper_info->name; // Use the broker since we run this function outside the sandbox. - plugin_service->OpenChannelToPpapiBroker(0, plugin_path, this); + plugin_service->OpenChannelToPpapiBroker(plugin_path, this); } else { plugin_service->OpenChannelToNpapiPlugin( 0, 0, GURL(), GURL(), mime_type, this); diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index 47c3078..9b90fe0 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -259,13 +259,9 @@ PpapiPluginProcessHost* PluginServiceImpl::FindPpapiBrokerProcess( } PluginProcessHost* PluginServiceImpl::FindOrStartNpapiPluginProcess( - int render_process_id, const FilePath& plugin_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) - return NULL; - PluginProcessHost* plugin_host = FindNpapiPluginProcess(plugin_path); if (plugin_host) return plugin_host; @@ -285,15 +281,11 @@ PluginProcessHost* PluginServiceImpl::FindOrStartNpapiPluginProcess( } PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( - int render_process_id, const FilePath& plugin_path, const FilePath& profile_data_directory, PpapiPluginProcessHost::PluginClient* client) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) - return NULL; - PpapiPluginProcessHost* plugin_host = FindPpapiPluginProcess(plugin_path, profile_data_directory); if (plugin_host) @@ -311,13 +303,9 @@ PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( } PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( - int render_process_id, const FilePath& plugin_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path)) - return NULL; - PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); if (plugin_host) return plugin_host; @@ -358,12 +346,11 @@ void PluginServiceImpl::OpenChannelToNpapiPlugin( } void PluginServiceImpl::OpenChannelToPpapiPlugin( - int render_process_id, const FilePath& plugin_path, const FilePath& profile_data_directory, PpapiPluginProcessHost::PluginClient* client) { PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( - render_process_id, plugin_path, profile_data_directory, client); + plugin_path, profile_data_directory, client); if (plugin_host) { plugin_host->OpenChannelToPlugin(client); } else { @@ -373,11 +360,9 @@ void PluginServiceImpl::OpenChannelToPpapiPlugin( } void PluginServiceImpl::OpenChannelToPpapiBroker( - int render_process_id, const FilePath& path, PpapiPluginProcessHost::BrokerClient* client) { - PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess( - render_process_id, path); + PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path); if (plugin_host) { plugin_host->OpenChannelToPlugin(client); } else { @@ -426,14 +411,10 @@ void PluginServiceImpl::GetAllowedPluginForOpenChannelToPlugin( BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin, - base::Unretained(this), - render_process_id, - plugin_path, - client)); + base::Unretained(this), plugin_path, client)); } void PluginServiceImpl::FinishOpenChannelToPlugin( - int render_process_id, const FilePath& plugin_path, PluginProcessHost::Client* client) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -443,8 +424,7 @@ void PluginServiceImpl::FinishOpenChannelToPlugin( return; pending_plugin_clients_.erase(client); - PluginProcessHost* plugin_host = FindOrStartNpapiPluginProcess( - render_process_id, plugin_path); + PluginProcessHost* plugin_host = FindOrStartNpapiPluginProcess(plugin_path); if (plugin_host) { client->OnFoundPluginProcessHost(plugin_host); plugin_host->OpenChannelToPlugin(client); @@ -483,7 +463,7 @@ bool PluginServiceImpl::GetPluginInfo(int render_process_id, *is_stale = stale; for (size_t i = 0; i < plugins.size(); ++i) { - if (!filter_ || filter_->IsPluginEnabled(render_process_id, + if (!filter_ || filter_->ShouldUsePlugin(render_process_id, render_view_id, context, url, diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h index 5ad03ed..8808c4b 100644 --- a/content/browser/plugin_service_impl.h +++ b/content/browser/plugin_service_impl.h @@ -120,14 +120,13 @@ class CONTENT_EXPORT PluginServiceImpl // 'plugin_path' if needed. If the process fails to start, the return value // is NULL. Must be called on the IO thread. PluginProcessHost* FindOrStartNpapiPluginProcess( - int render_process_id, const FilePath& plugin_path); + const FilePath& plugin_path); PpapiPluginProcessHost* FindOrStartPpapiPluginProcess( - int render_process_id, const FilePath& plugin_path, const FilePath& profile_data_directory, PpapiPluginProcessHost::PluginClient* client); PpapiPluginProcessHost* FindOrStartPpapiBrokerProcess( - int render_process_id, const FilePath& plugin_path); + const FilePath& plugin_path); // Opens a channel to a plugin process for the given mime type, starting // a new plugin process if necessary. This must be called on the IO thread @@ -138,12 +137,10 @@ class CONTENT_EXPORT PluginServiceImpl const GURL& page_url, const std::string& mime_type, PluginProcessHost::Client* client); - void OpenChannelToPpapiPlugin(int render_process_id, - const FilePath& plugin_path, + void OpenChannelToPpapiPlugin(const FilePath& plugin_path, const FilePath& profile_data_directory, PpapiPluginProcessHost::PluginClient* client); - void OpenChannelToPpapiBroker(int render_process_id, - const FilePath& path, + void OpenChannelToPpapiBroker(const FilePath& path, PpapiPluginProcessHost::BrokerClient* client); // Cancels opening a channel to a NPAPI plugin. @@ -199,8 +196,7 @@ class CONTENT_EXPORT PluginServiceImpl // Helper so we can finish opening the channel after looking up the // plugin. - void FinishOpenChannelToPlugin(int render_process_id, - const FilePath& plugin_path, + void FinishOpenChannelToPlugin(const FilePath& plugin_path, PluginProcessHost::Client* client); #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID) diff --git a/content/browser/plugin_service_impl_browsertest.cc b/content/browser/plugin_service_impl_browsertest.cc index 0f25185..18780355 100644 --- a/content/browser/plugin_service_impl_browsertest.cc +++ b/content/browser/plugin_service_impl_browsertest.cc @@ -9,7 +9,6 @@ #include "base/command_line.h" #include "base/path_service.h" #include "content/public/browser/browser_context.h" -#include "content/public/browser/plugin_service_filter.h" #include "content/public/browser/resource_context.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_switches.h" @@ -37,11 +36,10 @@ void OpenChannel(PluginProcessHost::Client* client) { class MockPluginProcessHostClient : public PluginProcessHost::Client, public IPC::Listener { public: - MockPluginProcessHostClient(ResourceContext* context, bool expect_fail) + MockPluginProcessHostClient(ResourceContext* context) : context_(context), channel_(NULL), - set_plugin_info_called_(false), - expect_fail_(expect_fail) { + set_plugin_info_called_(false) { } virtual ~MockPluginProcessHostClient() { @@ -82,8 +80,6 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client, return false; } virtual void OnChannelConnected(int32 peer_pid) OVERRIDE { - if (expect_fail_) - FAIL(); QuitMessageLoop(); } virtual void OnChannelError() OVERRIDE { @@ -100,8 +96,7 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client, private: void Fail() { - if (!expect_fail_) - FAIL(); + FAIL(); QuitMessageLoop(); } @@ -113,27 +108,9 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client, ResourceContext* context_; IPC::Channel* channel_; bool set_plugin_info_called_; - bool expect_fail_; DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient); }; -class MockPluginServiceFilter : public content::PluginServiceFilter { - public: - MockPluginServiceFilter() {} - - virtual bool IsPluginEnabled( - int render_process_id, - int render_view_id, - const void* context, - const GURL& url, - const GURL& policy_url, - webkit::WebPluginInfo* plugin) OVERRIDE { return true; } - - virtual bool CanLoadPlugin( - int render_process_id, - const FilePath& path) OVERRIDE { return false; } -}; - class PluginServiceTest : public ContentBrowserTest { public: PluginServiceTest() {} @@ -163,19 +140,7 @@ class PluginServiceTest : public ContentBrowserTest { IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { if (!webkit::npapi::NPAPIPluginsSupported()) return; - MockPluginProcessHostClient mock_client(GetResourceContext(), false); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&OpenChannel, &mock_client)); - RunMessageLoop(); -} - -IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToDeniedPlugin) { - if (!webkit::npapi::NPAPIPluginsSupported()) - return; - MockPluginServiceFilter filter; - PluginServiceImpl::GetInstance()->SetFilter(&filter); - MockPluginProcessHostClient mock_client(GetResourceContext(), true); + MockPluginProcessHostClient mock_client(GetResourceContext()); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&OpenChannel, &mock_client)); diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 6f4ca95..aacc6e9 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -657,7 +657,7 @@ void RenderMessageFilter::GetPluginsCallback( for (size_t i = 0; i < all_plugins.size(); ++i) { // Copy because the filter can mutate. webkit::WebPluginInfo plugin(all_plugins[i]); - if (!filter || filter->IsPluginEnabled(child_process_id, + if (!filter || filter->ShouldUsePlugin(child_process_id, routing_id, resource_context_, GURL(), @@ -704,10 +704,8 @@ void RenderMessageFilter::OnOpenChannelToPepperPlugin( const FilePath& path, IPC::Message* reply_msg) { plugin_service_->OpenChannelToPpapiPlugin( - render_process_id_, - path, - profile_data_directory_, - new OpenChannelToPpapiPluginCallback(this, resource_context_, reply_msg)); + path, profile_data_directory_, new OpenChannelToPpapiPluginCallback( + this, resource_context_, reply_msg)); } void RenderMessageFilter::OnDidCreateOutOfProcessPepperInstance( @@ -757,9 +755,7 @@ void RenderMessageFilter::OnOpenChannelToPpapiBroker(int routing_id, int request_id, const FilePath& path) { plugin_service_->OpenChannelToPpapiBroker( - render_process_id_, - path, - new OpenChannelToPpapiBrokerCallback(this, routing_id, request_id)); + path, new OpenChannelToPpapiBrokerCallback(this, routing_id, request_id)); } void RenderMessageFilter::OnGenerateRoutingID(int* route_id) { diff --git a/content/public/browser/plugin_service_filter.h b/content/public/browser/plugin_service_filter.h index 6b64818..237f354 100644 --- a/content/public/browser/plugin_service_filter.h +++ b/content/public/browser/plugin_service_filter.h @@ -13,25 +13,20 @@ struct WebPluginInfo; namespace content { -// Callback class to let the client filter the list of all installed plug-ins -// and block them from being loaded. +// Callback class to let the client filter the list of all installed plug-ins. // This class is called on the FILE thread. class PluginServiceFilter { public: virtual ~PluginServiceFilter() {} - // Whether |plugin| is enabled. The client can return false to hide the + // Whether to use |plugin|. The client can return false to disallow the // plugin, or return true and optionally change the passed in plugin. - virtual bool IsPluginEnabled(int render_process_id, + virtual bool ShouldUsePlugin(int render_process_id, int render_view_id, const void* context, const GURL& url, const GURL& policy_url, webkit::WebPluginInfo* plugin) = 0; - - // Whether the renderer has permission to load enabled |plugin|. - virtual bool CanLoadPlugin(int render_process_id, - const FilePath& path) = 0; }; } // namespace content |