diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 21:00:49 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 21:00:49 +0000 |
commit | 51ffaf742c78f2fdd9833167c5534d8009873751 (patch) | |
tree | acad7cf4038f246d01dd5852050cac7bd67b5aaf | |
parent | aaaab841d2e79745eb9e24ad873237509557fb53 (diff) | |
download | chromium_src-51ffaf742c78f2fdd9833167c5534d8009873751.zip chromium_src-51ffaf742c78f2fdd9833167c5534d8009873751.tar.gz chromium_src-51ffaf742c78f2fdd9833167c5534d8009873751.tar.bz2 |
Load only blocked plug-ins when allowing plug-ins from infobars.
BUG=126418
TEST=see bug for manual test
Review URL: https://chromiumcodereview.appspot.com/10384038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136123 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 3 | ||||
-rw-r--r-- | chrome/browser/plugin_infobar_delegates.cc | 17 | ||||
-rw-r--r-- | chrome/browser/plugin_infobar_delegates.h | 11 | ||||
-rw-r--r-- | chrome/browser/plugin_observer.cc | 6 | ||||
-rw-r--r-- | chrome/browser/plugin_observer.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/content_settings/content_setting_bubble_model.cc | 4 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 10 | ||||
-rw-r--r-- | chrome/renderer/chrome_content_renderer_client.cc | 22 | ||||
-rw-r--r-- | chrome/renderer/content_settings_observer.cc | 35 | ||||
-rw-r--r-- | chrome/renderer/content_settings_observer.h | 11 | ||||
-rw-r--r-- | chrome/renderer/content_settings_observer_browsertest.cc | 27 | ||||
-rw-r--r-- | chrome/renderer/plugins/plugin_placeholder.cc | 7 | ||||
-rw-r--r-- | chrome/renderer/plugins/plugin_placeholder.h | 4 |
13 files changed, 107 insertions, 53 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index ea91a5e..320d431 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -7132,7 +7132,8 @@ void TestingAutomationProvider::LoadBlockedPlugins(int tab_handle, if (!contents) return; RenderViewHost* host = contents->GetRenderViewHost(); - host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID())); + host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID(), + std::string())); *success = true; } } diff --git a/chrome/browser/plugin_infobar_delegates.cc b/chrome/browser/plugin_infobar_delegates.cc index 084e4f9..e8a94ba 100644 --- a/chrome/browser/plugin_infobar_delegates.cc +++ b/chrome/browser/plugin_infobar_delegates.cc @@ -31,9 +31,11 @@ using content::Referrer; using content::UserMetricsAction; PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, - const string16& name) + const string16& name, + const std::string& identifier) : ConfirmInfoBarDelegate(infobar_helper), - name_(name) { + name_(name), + identifier_(identifier) { } PluginInfoBarDelegate::~PluginInfoBarDelegate() { @@ -50,7 +52,8 @@ bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { } void PluginInfoBarDelegate::LoadBlockedPlugins() { - owner()->Send(new ChromeViewMsg_LoadBlockedPlugins(owner()->routing_id())); + owner()->Send( + new ChromeViewMsg_LoadBlockedPlugins(owner()->routing_id(), identifier_)); } gfx::Image* PluginInfoBarDelegate::GetIcon() const { @@ -67,8 +70,9 @@ string16 PluginInfoBarDelegate::GetLinkText() const { UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate( InfoBarTabHelper* infobar_helper, HostContentSettingsMap* content_settings, - const string16& utf16_name) - : PluginInfoBarDelegate(infobar_helper, utf16_name), + const string16& utf16_name, + const std::string& identifier) + : PluginInfoBarDelegate(infobar_helper, utf16_name, identifier), content_settings_(content_settings) { content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); std::string name = UTF16ToUTF8(utf16_name); @@ -165,7 +169,8 @@ OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( const string16& message) : PluginInfoBarDelegate( observer->tab_contents_wrapper()->infobar_tab_helper(), - installer->name()), + installer->name(), + installer->identifier()), WeakPluginInstallerObserver(installer), observer_(observer), message_(message) { diff --git a/chrome/browser/plugin_infobar_delegates.h b/chrome/browser/plugin_infobar_delegates.h index 355dc1f..cb0a4b8 100644 --- a/chrome/browser/plugin_infobar_delegates.h +++ b/chrome/browser/plugin_infobar_delegates.h @@ -20,7 +20,9 @@ class PluginObserver; // Base class for blocked plug-in infobars. class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { public: - PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, const string16& name); + PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, + const string16& name, + const std::string& identifier); protected: virtual ~PluginInfoBarDelegate(); @@ -39,6 +41,8 @@ class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { virtual gfx::Image* GetIcon() const OVERRIDE; virtual string16 GetLinkText() const OVERRIDE; + std::string identifier_; + DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); }; @@ -46,8 +50,9 @@ class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate { public: UnauthorizedPluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, - HostContentSettingsMap* content_settings, - const string16& name); + HostContentSettingsMap* content_settings, + const string16& name, + const std::string& identifier); private: virtual ~UnauthorizedPluginInfoBarDelegate(); diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index 34a708d..1b3e333 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -209,13 +209,15 @@ bool PluginObserver::OnMessageReceived(const IPC::Message& message) { return true; } -void PluginObserver::OnBlockedUnauthorizedPlugin(const string16& name) { +void PluginObserver::OnBlockedUnauthorizedPlugin( + const string16& name, + const std::string& identifier) { InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); infobar_helper->AddInfoBar( new UnauthorizedPluginInfoBarDelegate( infobar_helper, tab_contents_->profile()->GetHostContentSettingsMap(), - name)); + name, identifier)); } void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, diff --git a/chrome/browser/plugin_observer.h b/chrome/browser/plugin_observer.h index 0cde5e4..39287f2 100644 --- a/chrome/browser/plugin_observer.h +++ b/chrome/browser/plugin_observer.h @@ -41,7 +41,8 @@ class PluginObserver : public content::WebContentsObserver { private: class PluginPlaceholderHost; - void OnBlockedUnauthorizedPlugin(const string16& name); + void OnBlockedUnauthorizedPlugin(const string16& name, + const std::string& identifier); void OnBlockedOutdatedPlugin(int placeholder_id, const std::string& identifier); #if defined(ENABLE_PLUGIN_INSTALLATION) 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 4978542..49a0ca3 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -385,7 +385,9 @@ class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { DCHECK(tab_contents()); content::RenderViewHost* host = tab_contents()->web_contents()->GetRenderViewHost(); - host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID())); + // TODO(bauerb): We should send the identifiers of blocked plug-ins here. + host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID(), + std::string())); set_custom_link_enabled(false); tab_contents()->content_settings()->set_load_plugins_link_enabled(false); } diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 944c9ae..dec2997 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -229,8 +229,9 @@ IPC_MESSAGE_CONTROL0(ChromeViewMsg_VisitedLink_Reset) IPC_MESSAGE_CONTROL1(ChromeViewMsg_SetContentSettingRules, RendererContentSettingRules /* rules */) -// Tells the render view to load all blocked plugins. -IPC_MESSAGE_ROUTED0(ChromeViewMsg_LoadBlockedPlugins) +// Tells the render view to load all blocked plugins with the given identifier. +IPC_MESSAGE_ROUTED1(ChromeViewMsg_LoadBlockedPlugins, + std::string /* identifier */) // Asks the renderer to send back stats on the WebCore cache broken down by // resource types. @@ -530,8 +531,9 @@ IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_BlockedOutdatedPlugin, // Notifies when a plugin couldn't be loaded because it requires // user authorization. -IPC_MESSAGE_ROUTED1(ChromeViewHostMsg_BlockedUnauthorizedPlugin, - string16 /* name */) +IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_BlockedUnauthorizedPlugin, + string16 /* name */, + std::string /* plug-in group identifier */) // Provide the browser process with information about the WebCore resource // cache and current renderer framerate. diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 7c086c6..a3faee7 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -387,7 +387,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay || status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && - observer->plugins_temporarily_allowed()) { + observer->IsPluginTemporarilyAllowed(group->identifier())) { status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; } @@ -442,7 +442,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( "Chrome Web Store can load NaCl modules without enabling " "Native Client in about:flags.")); placeholder = PluginPlaceholder::CreateBlockedPlugin( - render_view, frame, params, plugin, name, + render_view, frame, params, plugin, group->identifier(), name, IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED); break; } @@ -454,7 +454,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( // reduce the chance of future regressions. if (prerender::PrerenderHelper::IsPrerendering(render_view)) { placeholder = PluginPlaceholder::CreateBlockedPlugin( - render_view, frame, params, plugin, name, + render_view, frame, params, plugin, group->identifier(), name, IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD); placeholder->set_blocked_for_prerendering(true); placeholder->set_allow_loading(true); @@ -465,14 +465,14 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( } case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { placeholder = PluginPlaceholder::CreateBlockedPlugin( - render_view, frame, params, plugin, name, + render_view, frame, params, plugin, group->identifier(), name, IDR_DISABLED_PLUGIN_HTML, IDS_PLUGIN_DISABLED); break; } case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { #if defined(ENABLE_PLUGIN_INSTALLATION) placeholder = PluginPlaceholder::CreateBlockedPlugin( - render_view, frame, params, plugin, name, + render_view, frame, params, plugin, group->identifier(), name, IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); placeholder->set_allow_loading(true); render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( @@ -485,22 +485,24 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( } case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { placeholder = PluginPlaceholder::CreateBlockedPlugin( - render_view, frame, params, plugin, name, + render_view, frame, params, plugin, group->identifier(), name, IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); break; } case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { placeholder = PluginPlaceholder::CreateBlockedPlugin( - render_view, frame, params, plugin, name, + render_view, frame, params, plugin, group->identifier(), name, IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_NOT_AUTHORIZED); placeholder->set_allow_loading(true); render_view->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( - render_view->GetRoutingID(), group->GetGroupName())); + render_view->GetRoutingID(), + group->GetGroupName(), + group->identifier())); break; } case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: { placeholder = PluginPlaceholder::CreateBlockedPlugin( - render_view, frame, params, plugin, name, + render_view, frame, params, plugin, group->identifier(), name, IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD); placeholder->set_allow_loading(true); RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay"); @@ -509,7 +511,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( } case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { placeholder = PluginPlaceholder::CreateBlockedPlugin( - render_view, frame, params, plugin, name, + render_view, frame, params, plugin, group->identifier(), name, IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED); placeholder->set_allow_loading(true); RenderThread::Get()->RecordUserMetrics("Plugin_Blocked"); diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc index b311751..fea2747 100644 --- a/chrome/renderer/content_settings_observer.cc +++ b/chrome/renderer/content_settings_observer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -68,7 +68,6 @@ ContentSettingsObserver::ContentSettingsObserver( : content::RenderViewObserver(render_view), content::RenderViewObserverTracker<ContentSettingsObserver>(render_view), content_setting_rules_(NULL), - plugins_temporarily_allowed_(false), is_interstitial_page_(false) { ClearBlockedContentSettings(); } @@ -81,6 +80,16 @@ void ContentSettingsObserver::SetContentSettingRules( content_setting_rules_ = content_setting_rules; } +bool ContentSettingsObserver::IsPluginTemporarilyAllowed( + const std::string& identifier) { + // If the empty string is in here, it means all plug-ins are allowed. + // TODO(bauerb): Remove this once we only pass in explicit identifiers. + return (temporarily_allowed_plugins_.find(identifier) != + temporarily_allowed_plugins_.end()) || + (temporarily_allowed_plugins_.find(std::string()) != + temporarily_allowed_plugins_.end()); +} + void ContentSettingsObserver::DidBlockContentType( ContentSettingsType settings_type, const std::string& resource_identifier) { @@ -98,14 +107,19 @@ void ContentSettingsObserver::DidBlockContentType( bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) - // Don't swallow LoadBlockedPlugins messages, as they're sent to every - // blocked plugin. - IPC_MESSAGE_HANDLER_GENERIC(ChromeViewMsg_LoadBlockedPlugins, - OnLoadBlockedPlugins(); handled = false) IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() - return handled; + if (handled) + return true; + + // Don't swallow LoadBlockedPlugins messages, as they're sent to every + // blocked plugin. + IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message) + IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) + IPC_END_MESSAGE_MAP() + + return false; } void ContentSettingsObserver::DidCommitProvisionalLoad( @@ -123,7 +137,7 @@ void ContentSettingsObserver::DidCommitProvisionalLoad( // correctly detect that a piece of content flipped from "not blocked" to // "blocked". ClearBlockedContentSettings(); - plugins_temporarily_allowed_ = false; + temporarily_allowed_plugins_.clear(); } GURL url = frame->document().url(); @@ -281,8 +295,9 @@ void ContentSettingsObserver::DidNotAllowScript(WebFrame* frame) { DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); } -void ContentSettingsObserver::OnLoadBlockedPlugins() { - plugins_temporarily_allowed_ = true; +void ContentSettingsObserver::OnLoadBlockedPlugins( + const std::string& identifier) { + temporarily_allowed_plugins_.insert(identifier); } void ContentSettingsObserver::OnSetAsInterstitial() { diff --git a/chrome/renderer/content_settings_observer.h b/chrome/renderer/content_settings_observer.h index 62b52a9..4e9a8f8 100644 --- a/chrome/renderer/content_settings_observer.h +++ b/chrome/renderer/content_settings_observer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,6 +7,7 @@ #pragma once #include <map> +#include <set> #include "chrome/common/content_settings.h" #include "content/public/renderer/render_view_observer.h" @@ -34,9 +35,7 @@ class ContentSettingsObserver void SetContentSettingRules( const RendererContentSettingRules* content_setting_rules); - bool plugins_temporarily_allowed() { - return plugins_temporarily_allowed_; - } + bool IsPluginTemporarilyAllowed(const std::string& identifier); // Sends an IPC notification that the specified content type was blocked. // If the content type requires it, |resource_identifier| names the specific @@ -76,7 +75,7 @@ class ContentSettingsObserver bool is_new_navigation) OVERRIDE; // Message handlers. - void OnLoadBlockedPlugins(); + void OnLoadBlockedPlugins(const std::string& identifier); void OnSetAsInterstitial(); // Resets the |content_blocked_| array. @@ -105,7 +104,7 @@ class ContentSettingsObserver // Caches the result of |AllowScript|. std::map<WebKit::WebFrame*, bool> cached_script_permissions_; - bool plugins_temporarily_allowed_; + std::set<std::string> temporarily_allowed_plugins_; bool is_interstitial_page_; DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); diff --git a/chrome/renderer/content_settings_observer_browsertest.cc b/chrome/renderer/content_settings_observer_browsertest.cc index cd9c016..2e7f564 100644 --- a/chrome/renderer/content_settings_observer_browsertest.cc +++ b/chrome/renderer/content_settings_observer_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -150,20 +150,33 @@ TEST_F(ChromeRenderViewTest, PluginsTemporarilyAllowed) { // Load some HTML. LoadHTML("<html>Foo</html>"); + std::string foo_plugin = "foo"; + std::string bar_plugin = "bar"; + ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); - EXPECT_FALSE(observer->plugins_temporarily_allowed()); + EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin)); - // Temporarily allow plugins. - OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE)); - EXPECT_TRUE(observer->plugins_temporarily_allowed()); + // Temporarily allow the "foo" plugin. + OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE, + foo_plugin)); + EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin)); + EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); // Simulate a navigation within the page. DidNavigateWithinPage(GetMainFrame(), true); - EXPECT_TRUE(observer->plugins_temporarily_allowed()); + EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin)); + EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); // Navigate to a different page. LoadHTML("<html>Bar</html>"); - EXPECT_FALSE(observer->plugins_temporarily_allowed()); + EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin)); + EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); + + // Temporarily allow all plugins. + OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE, + std::string())); + EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin)); + EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(bar_plugin)); } TEST_F(ChromeRenderViewTest, ImagesBlockedByDefault) { diff --git a/chrome/renderer/plugins/plugin_placeholder.cc b/chrome/renderer/plugins/plugin_placeholder.cc index 842dc28..e87bbea 100644 --- a/chrome/renderer/plugins/plugin_placeholder.cc +++ b/chrome/renderer/plugins/plugin_placeholder.cc @@ -150,6 +150,7 @@ PluginPlaceholder* PluginPlaceholder::CreateBlockedPlugin( WebFrame* frame, const WebPluginParams& params, const WebPluginInfo& plugin, + const std::string& identifier, const string16& name, int template_id, int message_id) { @@ -172,6 +173,7 @@ PluginPlaceholder* PluginPlaceholder::CreateBlockedPlugin( PluginPlaceholder* blocked_plugin = new PluginPlaceholder( render_view, frame, params, html_data, name); blocked_plugin->plugin_info_ = plugin; + blocked_plugin->identifier_ = identifier; return blocked_plugin; } @@ -523,7 +525,10 @@ void PluginPlaceholder::ShowContextMenu(const WebMouseEvent& event) { g_last_active_menu = this; } -void PluginPlaceholder::OnLoadBlockedPlugins() { +void PluginPlaceholder::OnLoadBlockedPlugins(const std::string& identifier) { + if (!identifier.empty() && identifier != identifier_) + return; + RenderThread::Get()->RecordUserMetrics("Plugin_Load_UI"); LoadPlugin(); } diff --git a/chrome/renderer/plugins/plugin_placeholder.h b/chrome/renderer/plugins/plugin_placeholder.h index 561cd16..b2bea5e 100644 --- a/chrome/renderer/plugins/plugin_placeholder.h +++ b/chrome/renderer/plugins/plugin_placeholder.h @@ -44,6 +44,7 @@ class PluginPlaceholder : public content::RenderViewObserver, WebKit::WebFrame* frame, const WebKit::WebPluginParams& params, const webkit::WebPluginInfo& info, + const std::string& identifier, const string16& name, int resource_id, int message_id); @@ -131,7 +132,7 @@ class PluginPlaceholder : public content::RenderViewObserver, void DidFinishLoadingCallback(const webkit_glue::CppArgumentList& args, webkit_glue::CppVariant* result); - void OnLoadBlockedPlugins(); + void OnLoadBlockedPlugins(const std::string& identifier); void OnSetIsPrerendering(bool is_prerendering); void OnDidNotFindMissingPlugin(); #if defined(ENABLE_PLUGIN_INSTALLATION) @@ -181,6 +182,7 @@ class PluginPlaceholder : public content::RenderViewObserver, bool has_host_; bool finished_loading_; string16 plugin_name_; + std::string identifier_; DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder); }; |