Index: chrome/browser/cocoa/extensions/browser_actions_controller.mm |
=================================================================== |
--- chrome/browser/cocoa/extensions/browser_actions_controller.mm (revision 39220) |
+++ chrome/browser/cocoa/extensions/browser_actions_controller.mm (working copy) |
@@ -22,6 +22,11 @@ |
// The padding between browser action buttons. |
extern const CGFloat kBrowserActionButtonPadding = 3; |
+namespace { |
+const CGFloat kContainerPadding = 2.0; |
+const CGFloat kGrippyXOffset = 8.0; |
+} // namespace |
+ |
NSString* const kBrowserActionsChangedNotification = @"BrowserActionsChanged"; |
@interface BrowserActionsController(Private) |
@@ -82,6 +87,8 @@ |
@implementation BrowserActionsController |
+@synthesize containerView = containerView_; |
+ |
- (id)initWithBrowser:(Browser*)browser |
containerView:(BrowserActionsContainerView*)container { |
DCHECK(browser && container); |
@@ -135,6 +142,15 @@ |
} |
} |
+- (CGFloat)idealContainerWidth { |
+ NSUInteger buttonCount = [self visibleButtonCount]; |
+ if (buttonCount == 0) |
+ return 0.0; |
+ |
+ return kGrippyXOffset + kContainerPadding + (buttonCount * |
+ (kBrowserActionWidth + kBrowserActionButtonPadding)); |
+} |
+ |
- (void)createActionButtonForExtension:(Extension*)extension |
withIndex:(int)index { |
if (!extension->browser_action()) |
@@ -192,7 +208,8 @@ |
- (void)repositionActionButtons { |
for (NSUInteger i = 0; i < [buttonOrder_ count]; ++i) { |
- CGFloat xOffset = i * (kBrowserActionWidth + kBrowserActionButtonPadding); |
+ CGFloat xOffset = kGrippyXOffset + |
+ (i * (kBrowserActionWidth + kBrowserActionButtonPadding)); |
BrowserActionButton* button = [buttonOrder_ objectAtIndex:i]; |
NSRect buttonFrame = [button frame]; |
buttonFrame.origin.x = xOffset; |
@@ -200,11 +217,11 @@ |
} |
} |
-- (int)buttonCount { |
+- (NSUInteger)buttonCount { |
return [buttons_ count]; |
} |
-- (int)visibleButtonCount { |
+- (NSUInteger)visibleButtonCount { |
int count = 0; |
for (BrowserActionButton* button in [buttons_ allValues]) { |
if (![button isHidden]) |