summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 08:22:21 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 08:22:21 +0000
commit97c5c596e4b649651fbef56875e125c06acb0f90 (patch)
tree3acba85143369eacd72006d383e5e198a59f9c7a /chrome/browser/cocoa
parent7a13e7926699ad5d03f2d6e121b7bdb68ca05680 (diff)
downloadchromium_src-97c5c596e4b649651fbef56875e125c06acb0f90.zip
chromium_src-97c5c596e4b649651fbef56875e125c06acb0f90.tar.gz
chromium_src-97c5c596e4b649651fbef56875e125c06acb0f90.tar.bz2
Add "Load all plugins on this page" button to blocked plugins bubble if click-to-play is enabled.
Screenshot: http://imgur.com/ZKsQB.png XIB changes: Add a rounded rect button hooked up to |loadAllPlugins:| in the File's Owner and referenced by its |loadAllPluginsButton_| outlet, wrapped in a GTMWidthBasedTweaker. BUG=49677 TEST=ContentSettingBubbleModelTest.* Review URL: http://codereview.chromium.org/3015036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/content_blocked_bubble_controller.h4
-rw-r--r--chrome/browser/cocoa/content_blocked_bubble_controller.mm54
2 files changed, 52 insertions, 6 deletions
diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.h b/chrome/browser/cocoa/content_blocked_bubble_controller.h
index 74b23ce..56f2313 100644
--- a/chrome/browser/cocoa/content_blocked_bubble_controller.h
+++ b/chrome/browser/cocoa/content_blocked_bubble_controller.h
@@ -29,6 +29,7 @@ typedef std::map<NSButton*, int> PopupLinks;
IBOutlet NSButton* manageButton_;
IBOutlet NSButton* doneButton_;
+ IBOutlet NSButton* loadAllPluginsButton_;
// The container for the bubble contents of the geolocation bubble.
IBOutlet NSView* contentsContainer_;
@@ -59,4 +60,7 @@ typedef std::map<NSButton*, int> PopupLinks;
// Callback for "info" link.
- (IBAction)showMoreInfo:(id)sender;
+// Callback for "load all plugins" button.
+- (IBAction)loadAllPlugins:(id)sender;
+
@end
diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.mm b/chrome/browser/cocoa/content_blocked_bubble_controller.mm
index 8f3d613..494a3c9 100644
--- a/chrome/browser/cocoa/content_blocked_bubble_controller.mm
+++ b/chrome/browser/cocoa/content_blocked_bubble_controller.mm
@@ -46,6 +46,10 @@ const int kGeoLabelHeight = 14;
// Height of the "Clear" button in the geolocation bubble.
const int kGeoClearButtonHeight = 17;
+// Padding between radio buttons and "Load all plugins" button
+// in the plugin bubble.
+const int kLoadAllPluginsButtonVerticalPadding = 8;
+
// General padding between elements in the geolocation bubble.
const int kGeoPadding = 8;
@@ -87,6 +91,7 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
- (void)initializeRadioGroup;
- (void)initializePopupList;
- (void)initializeGeoLists;
+- (void)sizeToFitLoadPluginsButton;
- (void)sizeToFitManageDoneButtons;
- (void)removeInfoButton;
- (void)popupLinkClicked:(id)sender;
@@ -345,6 +350,36 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
[contentsContainer_ setFrame:containerFrame];
}
+- (void)sizeToFitLoadPluginsButton {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableClickToPlay)) {
+ const ContentSettingBubbleModel::BubbleContent& content =
+ contentSettingBubbleModel_->bubble_content();
+ [loadAllPluginsButton_ setEnabled:content.load_plugins_link_enabled];
+
+ // Resize horizontally to fit button if necessary.
+ NSRect windowFrame = [[self window] frame];
+ int widthNeeded = NSWidth([loadAllPluginsButton_ frame]) +
+ 2 * NSMinX([loadAllPluginsButton_ frame]);
+ if (NSWidth(windowFrame) < widthNeeded) {
+ windowFrame.size.width = widthNeeded;
+ [[self window] setFrame:windowFrame display:NO];
+ }
+ } else {
+ // Remove button and resize vertically.
+ int deltaY = kLoadAllPluginsButtonVerticalPadding +
+ NSHeight([loadAllPluginsButton_ frame]);
+ [loadAllPluginsButton_ removeFromSuperview];
+ NSRect frame = [[self window] frame];
+ frame.size.height -= deltaY;
+ [[self window] setFrame:frame display:NO];
+ NSPoint radioOrigin = [allowBlockRadioGroup_ frame].origin;
+ radioOrigin.y -= deltaY;
+ [allowBlockRadioGroup_ setFrameOrigin:radioOrigin];
+ [allowBlockRadioGroup_ setNeedsDisplay];
+ }
+}
+
- (void)sizeToFitManageDoneButtons {
CGFloat actualWidth = NSWidth([[[self window] contentView] frame]);
CGFloat requiredWidth = NSMaxX([manageButton_ frame]) + kManageDonePadding +
@@ -381,16 +416,18 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
[self sizeToFitManageDoneButtons];
[self initializeTitle];
- if (contentSettingBubbleModel_->content_type() ==
- CONTENT_SETTINGS_TYPE_COOKIES)
+
+ ContentSettingsType type = contentSettingBubbleModel_->content_type();
+ if (type == CONTENT_SETTINGS_TYPE_PLUGINS)
+ [self sizeToFitLoadPluginsButton];
+ if (type == CONTENT_SETTINGS_TYPE_COOKIES)
[self removeInfoButton];
if (allowBlockRadioGroup_) // not bound in cookie bubble xib
[self initializeRadioGroup];
- if (contentSettingBubbleModel_->content_type() ==
- CONTENT_SETTINGS_TYPE_POPUPS)
+
+ if (type == CONTENT_SETTINGS_TYPE_POPUPS)
[self initializePopupList];
- if (contentSettingBubbleModel_->content_type() ==
- CONTENT_SETTINGS_TYPE_GEOLOCATION)
+ if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
[self initializeGeoLists];
}
@@ -416,6 +453,11 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
[self close];
}
+- (IBAction)loadAllPlugins:(id)sender {
+ contentSettingBubbleModel_->OnLoadPluginsLinkClicked();
+ [self close];
+}
+
- (void)popupLinkClicked:(id)sender {
content_blocked_bubble::PopupLinks::iterator i(popupLinks_.find(sender));
DCHECK(i != popupLinks_.end());