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..0698c718359a17103286e4c1879207d82748cb38 100644 |
--- a/chrome/browser/ui/cocoa/content_setting_bubble_cocoa.mm |
+++ b/chrome/browser/ui/cocoa/content_setting_bubble_cocoa.mm |
@@ -315,35 +315,43 @@ 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()) { |
+ scoped_nsobject<NSControl> control; |
+ if(content.custom_link_enabled) { |
+ NSRect buttonFrame = NSMakeRect(0, 0, |
+ NSWidth(containerFrame), |
+ kGeoClearButtonHeight); |
+ NSButton* button = [[NSButton alloc] initWithFrame:buttonFrame]; |
+ control.reset(static_cast<NSControl*>(button)); |
Nico
2010/12/10 00:41:42
NSButton is derived from NSControl, you shouldn't
msw
2010/12/10 03:32:05
Done.
|
+ [button setTitle:base::SysUTF8ToNSString(content.custom_link)]; |
+ [button setTarget:self]; |
+ [button setAction:@selector(clearGeolocationForCurrentHost:)]; |
+ [button setBezelStyle:NSRoundRectBezelStyle]; |
+ SetControlSize(button, NSSmallControlSize); |
+ [button sizeToFit]; |
+ } else { |
Nico
2010/12/10 00:41:42
Why is this branch required now but wasn't previou
msw
2010/12/10 03:32:05
Previously this text was delivered as an extra geo
|
+ // Add the notification that settings will be cleared on next reload. |
+ NSTextField* customText = |
+ LabelWithFrame(base::SysUTF8ToNSString(content.custom_link), frame); |
+ control.reset(static_cast<NSControl*>([customText retain])); |
Nico
2010/12/10 00:41:42
Same here. Since you don't call NSTextField-specif
msw
2010/12/10 03:32:05
Done.
|
+ SetControlSize(customText, NSSmallControlSize); |
+ } |
+ |
+ // 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 +398,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 +459,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]; |
} |