Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8037)

Unified Diff: chrome/browser/ui/cocoa/content_setting_bubble_cocoa.mm

Issue 5564007: Update Content Settings Bubbles (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: x Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/content_setting_bubble_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/content_setting_bubble_cocoa.mm b/chrome/browser/ui/cocoa/content_setting_bubble_cocoa.mm
index 4ac68c0173549eeb89849ff7cf615e57a9dcdeec..33952eb9dc94419925b476d0396a10d110fc2f93 100644
--- a/chrome/browser/ui/cocoa/content_setting_bubble_cocoa.mm
+++ b/chrome/browser/ui/cocoa/content_setting_bubble_cocoa.mm
@@ -315,35 +315,44 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
NSRect containerFrame = [contentsContainer_ frame];
NSRect frame = NSMakeRect(0, 0, NSWidth(containerFrame), kGeoLabelHeight);
- // "Clear" button.
- if (!content.clear_link.empty()) {
- NSRect buttonFrame = NSMakeRect(0, 0,
- NSWidth(containerFrame),
- kGeoClearButtonHeight);
- scoped_nsobject<NSButton> button([[NSButton alloc]
- initWithFrame:buttonFrame]);
- [button setTitle:base::SysUTF8ToNSString(content.clear_link)];
- [button setTarget:self];
- [button setAction:@selector(clearGeolocationForCurrentHost:)];
- [button setBezelStyle:NSRoundRectBezelStyle];
- SetControlSize(button, NSSmallControlSize);
- [button sizeToFit];
-
- // If the button is wider than the container, widen the window.
- CGFloat buttonWidth = NSWidth([button frame]);
- if (buttonWidth > NSWidth(containerFrame)) {
+ // "Clear" button / text field.
+ if (!content.custom_link.empty()) {
+ NSControl* control = nil;
+ if(content.custom_link_enabled) {
+ NSRect buttonFrame = NSMakeRect(0, 0,
+ NSWidth(containerFrame),
+ kGeoClearButtonHeight);
+ scoped_nsobject<NSButton> button([[NSButton alloc]
+ initWithFrame:buttonFrame]);
+ [button setTitle:base::SysUTF8ToNSString(content.custom_link)];
+ [button setTarget:self];
+ [button setAction:@selector(clearGeolocationForCurrentHost:)];
+ [button setBezelStyle:NSRoundRectBezelStyle];
+ SetControlSize(button, NSSmallControlSize);
+ [button sizeToFit];
+ control = button.release();
Nico 2010/12/09 06:41:46 This is wrong – please read http://developer.apple
+ } else {
+ // Add the notification that settings will be cleared on next reload.
+ scoped_nsobject<NSTextField> custom_text(
+ LabelWithFrame(base::SysUTF8ToNSString(content.custom_link), frame));
Nico 2010/12/09 06:41:46 LabelWithFrame() returns an autoreleased object.
+ SetControlSize(custom_text, NSSmallControlSize);
+ control = custom_text.release();
+ }
+
+ // If the new control is wider than the container, widen the window.
+ CGFloat controlWidth = NSWidth([control frame]);
+ if (controlWidth > NSWidth(containerFrame)) {
NSRect windowFrame = [[self window] frame];
- windowFrame.size.width += buttonWidth - NSWidth(containerFrame);
+ windowFrame.size.width += controlWidth - NSWidth(containerFrame);
[[self window] setFrame:windowFrame display:NO];
// Fetch the updated sizes.
containerFrame = [contentsContainer_ frame];
frame = NSMakeRect(0, 0, NSWidth(containerFrame), kGeoLabelHeight);
}
- // Add the button.
- [contentsContainer_ addSubview:button];
-
- frame.origin.y = NSMaxY([button frame]) + kGeoPadding;
+ DCHECK(control);
+ [contentsContainer_ addSubview:control];
+ frame.origin.y = NSMaxY([control frame]) + kGeoPadding;
}
typedef
@@ -390,7 +399,7 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
- (void)sizeToFitLoadPluginsButton {
const ContentSettingBubbleModel::BubbleContent& content =
contentSettingBubbleModel_->bubble_content();
- [loadAllPluginsButton_ setEnabled:content.load_plugins_link_enabled];
+ [loadAllPluginsButton_ setEnabled:content.custom_link_enabled];
// Resize horizontally to fit button if necessary.
NSRect windowFrame = [[self window] frame];
@@ -451,32 +460,32 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
[selectedCell tag] == kAllowTag ? 0 : 1);
}
-- (IBAction)closeBubble:(id)sender {
- [self close];
+- (void)popupLinkClicked:(id)sender {
+ content_setting_bubble::PopupLinks::iterator i(popupLinks_.find(sender));
+ DCHECK(i != popupLinks_.end());
+ contentSettingBubbleModel_->OnPopupClicked(i->second);
}
-- (IBAction)manageBlocking:(id)sender {
- contentSettingBubbleModel_->OnManageLinkClicked();
+- (void)clearGeolocationForCurrentHost:(id)sender {
+ contentSettingBubbleModel_->OnCustomLinkClicked();
+ [self close];
}
- (IBAction)showMoreInfo:(id)sender {
- contentSettingBubbleModel_->OnInfoLinkClicked();
+ contentSettingBubbleModel_->OnCustomLinkClicked();
[self close];
}
- (IBAction)loadAllPlugins:(id)sender {
- contentSettingBubbleModel_->OnLoadPluginsLinkClicked();
+ contentSettingBubbleModel_->OnCustomLinkClicked();
[self close];
}
-- (void)popupLinkClicked:(id)sender {
- content_setting_bubble::PopupLinks::iterator i(popupLinks_.find(sender));
- DCHECK(i != popupLinks_.end());
- contentSettingBubbleModel_->OnPopupClicked(i->second);
+- (IBAction)manageBlocking:(id)sender {
+ contentSettingBubbleModel_->OnManageLinkClicked();
}
-- (void)clearGeolocationForCurrentHost:(id)sender {
- contentSettingBubbleModel_->OnClearLinkClicked();
+- (IBAction)closeBubble:(id)sender {
[self close];
}

Powered by Google App Engine
This is Rietveld 408576698