diff options
author | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-01 07:49:30 +0000 |
---|---|---|
committer | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-01 07:49:30 +0000 |
commit | 8b75315a99bb43615b5efbf56734811bf06cd86b (patch) | |
tree | bb978996cecc4481307b776d60f4687b374a60ee /chrome | |
parent | e57cc4844f188b59ceafb76110c612a9420b2693 (diff) | |
download | chromium_src-8b75315a99bb43615b5efbf56734811bf06cd86b.zip chromium_src-8b75315a99bb43615b5efbf56734811bf06cd86b.tar.gz chromium_src-8b75315a99bb43615b5efbf56734811bf06cd86b.tar.bz2 |
Broke ContentSettingBubbleModelTest.Plugins on Android.
Revert 180103 - Only permit plug-in loads in the browser if the plug-in isn't blocked or the
user has authorized it with a browser-mediated interaction.
BUG=172573
Review URL: https://codereview.chromium.org/12086077
TBR=cevans@chromium.org
Review URL: https://chromiumcodereview.appspot.com/12114045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
9 files changed, 29 insertions, 180 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); |