diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 14:53:28 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 14:53:28 +0000 |
commit | 55126134af52fe0f6a426f0f7ccfeeb8cf2c9f28 (patch) | |
tree | 9c283aee59bc21de2843c49eb0bbf03a428cfcfc /chrome/renderer | |
parent | 904f191f2f7edc9b331e2590c77eb4e8dd845549 (diff) | |
download | chromium_src-55126134af52fe0f6a426f0f7ccfeeb8cf2c9f28.zip chromium_src-55126134af52fe0f6a426f0f7ccfeeb8cf2c9f28.tar.gz chromium_src-55126134af52fe0f6a426f0f7ccfeeb8cf2c9f28.tar.bz2 |
Reland 55888: Allow per-plugin content settings.
Now with Fixed Unit Tests!
Run with --enable-resource-content-settings and --enable-click-to-play to enable.
TabSpecificContentSettings now keeps track of which resources were blocked. The content setting bubble displays those resource, and selecting the "allow radio buttons adds exceptions for these resources.
The infobar for non-sandboxed plug-ins now also shows a button to always allow the blocked plug-in on that site.
Screenshot of the plugin bubble: http://imgur.com/6npqv.png
Because we need to change the title and radio button labels depending on whether we track specific plug-ins, we copy them from the ContentSettingBubbleModel.
XIB changes: Add a text field for the blocked plug-ins to ContentBlockedPlugins.xib, hooked up to the |blockedResourcesField_| outlet.
BUG=39252,38432
TEST=HostContentSettingsMapTest.*,manual
Review URL: http://codereview.chromium.org/2873104
Review URL: http://codereview.chromium.org/3124018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/blocked_plugin.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 41 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 6 |
3 files changed, 34 insertions, 15 deletions
diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc index 4cba462..57d342b 100644 --- a/chrome/renderer/blocked_plugin.cc +++ b/chrome/renderer/blocked_plugin.cc @@ -57,7 +57,7 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view, values.SetString("updatePlugin", l10n_util::GetStringUTF16(IDS_PLUGIN_UPDATE)); values.SetString("message", - l10n_util::GetStringUTF16(IDS_BLOCKED_PLUGINS_TITLE)); + l10n_util::GetStringUTF16(IDS_BLOCKED_PLUGINS_MESSAGE)); if (group) values.Set("pluginGroup", group->GetDataForUI()); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 22aef07..cf52039 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -21,6 +21,7 @@ #include "base/string_piece.h" #include "base/string_util.h" #include "base/time.h" +#include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "build/build_config.h" #include "chrome/common/appcache/appcache_dispatcher.h" @@ -561,10 +562,11 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, const WebPluginParams& params) { WebPluginInfo info; bool found; + ContentSetting setting; std::string mime_type; Send(new ViewHostMsg_GetPluginInfo( params.url, frame->top()->url(), params.mimeType.utf8(), &found, - &info, &mime_type)); + &info, &setting, &mime_type)); if (!found || !info.enabled) return NULL; scoped_refptr<pepper::PluginModule> pepper_module = @@ -2258,6 +2260,8 @@ void RenderView::runModal() { WebPlugin* RenderView::createPlugin(WebFrame* frame, const WebPluginParams& params) { bool found = false; + ContentSetting setting = CONTENT_SETTING_DEFAULT; + CommandLine* cmd = CommandLine::ForCurrentProcess(); WebPluginInfo info; GURL url(params.url); std::string actual_mime_type; @@ -2266,6 +2270,7 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, params.mimeType.utf8(), &found, &info, + &setting, &actual_mime_type)); if (!found) @@ -2275,8 +2280,7 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, group->AddPlugin(info, 0); if (!info.enabled) { - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableOutdatedPlugins) && + if (cmd->HasSwitch(switches::kDisableOutdatedPlugins) && group->IsVulnerable()) { Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_, group->GetGroupName(), @@ -2287,10 +2291,17 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, } if (info.path.value() != kDefaultPluginLibraryName) { - if (!AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS)) { - DCHECK(CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableClickToPlay)); - didNotAllowPlugins(frame); + std::string resource; + if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) { +#if defined(OS_POSIX) + resource = info.path.value(); +#elif defined(OS_WIN) + resource = base::SysWideToUTF8(info.path.value()); +#endif + } + if (setting == CONTENT_SETTING_BLOCK) { + DCHECK(cmd->HasSwitch(switches::kEnableClickToPlay)); + DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); return CreatePluginPlaceholder(frame, params, NULL); } scoped_refptr<pepper::PluginModule> pepper_module = @@ -2298,8 +2309,10 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, if (pepper_module) return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kBlockNonSandboxedPlugins)) { + switches::kBlockNonSandboxedPlugins) && + setting != CONTENT_SETTING_ALLOW) { Send(new ViewHostMsg_NonSandboxedPluginBlocked(routing_id_, + resource, group->GetGroupName())); return CreatePluginPlaceholder(frame, params, NULL); } @@ -2449,7 +2462,7 @@ bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) { if (IsWhitelistedForContentSettings(frame)) return true; - DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES); + DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string()); return false; // Other protocols fall through here. } @@ -3245,11 +3258,11 @@ bool RenderView::allowDatabase( return result; } void RenderView::didNotAllowScript(WebKit::WebFrame* frame) { - DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT); + DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); } void RenderView::didNotAllowPlugins(WebKit::WebFrame* frame) { - DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS); + DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); } void RenderView::didExhaustMemoryAvailableForScript(WebFrame* frame) { @@ -3796,10 +3809,12 @@ bool RenderView::AllowContentType(ContentSettingsType settings_type) { CONTENT_SETTING_BLOCK; } -void RenderView::DidBlockContentType(ContentSettingsType settings_type) { +void RenderView::DidBlockContentType(ContentSettingsType settings_type, + const std::string& resource_identifier) { if (!content_blocked_[settings_type]) { content_blocked_[settings_type] = true; - Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type)); + Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type, + resource_identifier)); } } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 5f9aa2d..0cf6c12 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -877,7 +877,11 @@ class RenderView : public RenderWidget, PluginGroup* group); // Sends an IPC notification that the specified content type was blocked. - void DidBlockContentType(ContentSettingsType settings_type); + // If the content type requires it, |resource_identifier| names the specific + // resource that was blocked (the plugin path in the case of plugins), + // otherwise it's the empty string. + void DidBlockContentType(ContentSettingsType settings_type, + const std::string& resource_identifier); // This callback is triggered when DownloadImage completes, either // succesfully or with a failure. See DownloadImage for more details. |