summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 16:14:22 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 16:14:22 +0000
commit6b3db4350e3cb5b7d5ef9ff5995f5dcfe9bac6e9 (patch)
treebde9dde95d828715441bb818cf78397846ef32c7 /chrome/browser/cocoa
parent3c5ce41e6cb80f816e7d398594d77e2c6b03a22a (diff)
downloadchromium_src-6b3db4350e3cb5b7d5ef9ff5995f5dcfe9bac6e9.zip
chromium_src-6b3db4350e3cb5b7d5ef9ff5995f5dcfe9bac6e9.tar.gz
chromium_src-6b3db4350e3cb5b7d5ef9ff5995f5dcfe9bac6e9.tar.bz2
Revert 55888: Allow per-plugin content settings.
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=manual Review URL: http://codereview.chromium.org/2873104 TBR: bauerb@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55891 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/content_setting_bubble_cocoa.h2
-rw-r--r--chrome/browser/cocoa/content_setting_bubble_cocoa.mm59
2 files changed, 9 insertions, 52 deletions
diff --git a/chrome/browser/cocoa/content_setting_bubble_cocoa.h b/chrome/browser/cocoa/content_setting_bubble_cocoa.h
index ae6f422..ecdaaf9 100644
--- a/chrome/browser/cocoa/content_setting_bubble_cocoa.h
+++ b/chrome/browser/cocoa/content_setting_bubble_cocoa.h
@@ -37,8 +37,6 @@ typedef std::map<NSButton*, int> PopupLinks;
// The info button of the cookies bubble.
IBOutlet NSButton* infoButton_;
- IBOutlet NSTextField* blockedResourcesField_;
-
scoped_ptr<ContentSettingBubbleModel> contentSettingBubbleModel_;
content_setting_bubble::PopupLinks popupLinks_;
}
diff --git a/chrome/browser/cocoa/content_setting_bubble_cocoa.mm b/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
index 9d34f16..de4f73a 100644
--- a/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
+++ b/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
@@ -20,7 +20,6 @@
#include "grit/generated_resources.h"
#include "skia/ext/skia_utils_mac.h"
#import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
-#include "webkit/glue/plugins/plugin_list.h"
namespace {
@@ -89,7 +88,6 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
title:(NSString*)title
icon:(NSImage*)icon
referenceFrame:(NSRect)referenceFrame;
-- (void)initializeBlockedPluginsList;
- (void)initializeTitle;
- (void)initializeRadioGroup;
- (void)initializePopupList;
@@ -149,10 +147,6 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
if (!titleLabel_)
return;
- NSString* label = base::SysUTF8ToNSString(
- contentSettingBubbleModel_->bubble_content().title);
- [titleLabel_ setStringValue:label];
-
// Layout title post-localization.
CGFloat deltaY = [GTMUILocalizerAndLayoutTweaker
sizeToFitFixedWidthTextField:titleLabel_];
@@ -167,22 +161,20 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
- (void)initializeRadioGroup {
// Configure the radio group. For now, only deal with the
// strictly needed case of group containing 2 radio buttons.
- const ContentSettingBubbleModel::RadioGroup& radio_group =
+ // TODO(joth): Implement the generic case, getting localized strings from the
+ // bubble model instead of the xib, or remove it if it's never needed.
+ // http://crbug.com/38432
+ const ContentSettingBubbleModel::RadioGroup& radioGroup =
contentSettingBubbleModel_->bubble_content().radio_group;
// Select appropriate radio button.
[allowBlockRadioGroup_ selectCellWithTag:
- radio_group.default_item == 0 ? kAllowTag : kBlockTag];
+ radioGroup.default_item == 0 ? kAllowTag : kBlockTag];
- const ContentSettingBubbleModel::RadioItems& radio_items =
- radio_group.radio_items;
- DCHECK_EQ(2u, radio_items.size()) << "Only 2 radio items per group supported";
- // Set radio group labels from model.
+ // Copy |host_| into radio group label.
NSCell* radioCell = [allowBlockRadioGroup_ cellWithTag:kAllowTag];
- [radioCell setTitle:base::SysUTF8ToNSString(radio_items[0])];
-
- radioCell = [allowBlockRadioGroup_ cellWithTag:kBlockTag];
- [radioCell setTitle:base::SysUTF8ToNSString(radio_items[1])];
+ [radioCell setTitle:cocoa_l10n_util::ReplaceNSStringPlaceholders(
+ [radioCell title], UTF8ToUTF16(radioGroup.url.host()), NULL)];
// Layout radio group labels post-localization.
[GTMUILocalizerAndLayoutTweaker
@@ -227,37 +219,6 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
return button;
}
-- (void)initializeBlockedPluginsList {
- NSMutableArray* pluginArray = [NSMutableArray array];
- const std::set<std::string>& plugins =
- contentSettingBubbleModel_->bubble_content().resource_identifiers;
- if (plugins.empty()) {
- int delta = NSMinY([titleLabel_ frame]) -
- NSMinY([blockedResourcesField_ frame]);
- [blockedResourcesField_ removeFromSuperview];
- NSRect frame = [[self window] frame];
- frame.size.height -= delta;
- [[self window] setFrame:frame display:NO];
- } else {
- for (std::set<std::string>::iterator it = plugins.begin();
- it != plugins.end(); ++it) {
- WebPluginInfo plugin;
- NSString* name;
- if (NPAPI::PluginList::Singleton()->
- GetPluginInfoByPath(FilePath(*it), &plugin)) {
- name = base::SysUTF16ToNSString(plugin.name);
- } else {
- name = base::SysUTF8ToNSString(*it);
- }
- [pluginArray addObject:name];
- }
- [blockedResourcesField_
- setStringValue:[pluginArray componentsJoinedByString:@"\n"]];
- [GTMUILocalizerAndLayoutTweaker
- sizeToFitFixedWidthTextField:blockedResourcesField_];
- }
-}
-
- (void)initializePopupList {
// I didn't put the buttons into a NSMatrix because then they are only one
// entity in the key view loop. This way, one can tab through all of them.
@@ -458,10 +419,8 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
[self initializeTitle];
ContentSettingsType type = contentSettingBubbleModel_->content_type();
- if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
+ if (type == CONTENT_SETTINGS_TYPE_PLUGINS)
[self sizeToFitLoadPluginsButton];
- [self initializeBlockedPluginsList];
- }
if (type == CONTENT_SETTINGS_TYPE_COOKIES)
[self removeInfoButton];
if (allowBlockRadioGroup_) // not bound in cookie bubble xib