Chromium Code Reviews| Index: chrome/browser/ui/cocoa/profile_menu_button.mm |
| diff --git a/chrome/browser/ui/cocoa/profile_menu_button.mm b/chrome/browser/ui/cocoa/profile_menu_button.mm |
| index aeb1bd9f556e724305b5a8342ab34ebfe2b2949b..c5a8de177e03a4f9ac8c16c77b38c9ad6b029c44 100644 |
| --- a/chrome/browser/ui/cocoa/profile_menu_button.mm |
| +++ b/chrome/browser/ui/cocoa/profile_menu_button.mm |
| @@ -54,14 +54,15 @@ NSColor* GetBlackWithAlpha(CGFloat alpha) { |
| [textFieldCell_ setFont:[NSFont systemFontOfSize: |
| [NSFont smallSystemFontSize]]]; |
| + [self setOpenMenuOnClick:YES]; |
| + |
| profile_menu_model_.reset(new ProfileMenuModel); |
| menu_.reset([[MenuController alloc] initWithModel:profile_menu_model_.get() |
| useWithPopUpButtonCell:NO]); |
| } |
| -- (id)initWithFrame:(NSRect)frame |
| - pullsDown:(BOOL)flag { |
| - if ((self = [super initWithFrame:frame pullsDown:flag])) |
| +- (id)initWithFrame:(NSRect)frame { |
| + if ((self = [super initWithFrame:frame])) |
| [self commonInit]; |
| return self; |
| } |
| @@ -331,58 +332,6 @@ NSColor* GetBlackWithAlpha(CGFloat alpha) { |
| } |
| } |
| -- (NSMenu *)menu { |
| - return [menu_.get() menu]; |
| -} |
| - |
| -- (NSPoint)popUpMenuPosition { |
| - NSPoint menuPos = [self tabRect].origin; |
| - // By default popUpContextMenu: causes the menu to show up a few pixels above |
| - // the point you give it. We need to shift it down a bit so that it lines up |
| - // with the bottom of the tab. |
| - menuPos.y -= 6; |
| - return [self convertPoint:menuPos toView:nil]; |
| -} |
| - |
| -- (void) mouseDown:(NSEvent*)event |
| - withShowMenuTarget:(id)target { |
| - if (![self menu]) { |
| - [super mouseDown:event]; |
| - return; |
| - } |
| - |
| - NSPoint point = [[self superview] |
| - convertPointFromBase:[event locationInWindow]]; |
| - if (![[self hitTest:point] isEqual:self]) |
| - return; |
| - |
| - // Draw the control as depressed. |
| - [self highlight:YES]; |
| - |
| - NSEvent* fakeEvent = [NSEvent |
| - mouseEventWithType:[event type] |
| - location:[self popUpMenuPosition] |
| - modifierFlags:[event modifierFlags] |
| - timestamp:[event timestamp] |
| - windowNumber:[event windowNumber] |
| - context:[event context] |
| - eventNumber:[event eventNumber] |
| - clickCount:[event clickCount] |
| - pressure:[event pressure]]; |
| - DCHECK([target respondsToSelector: |
| - @selector(popUpContextMenu:withEvent:forView:)]); |
| - [target popUpContextMenu:[self menu] |
| - withEvent:fakeEvent |
| - forView:self]; |
| - |
| - [self highlight:NO]; |
| -} |
| - |
| -- (void)mouseDown:(NSEvent*)event { |
| - [self mouseDown:event |
| - withShowMenuTarget:[NSMenu class]]; |
| -} |
| - |
| - (NSSize)desiredControlSize { |
| NSSize size = [self tabRect].size; |
| @@ -401,4 +350,14 @@ NSColor* GetBlackWithAlpha(CGFloat alpha) { |
| return [self tabRect].size; |
| } |
| +// Overridden from MenuButton. |
| +- (NSMenu *)attachedMenu { |
|
viettrungluu
2011/05/23 16:52:19
Nit: no space before the *.
|
| + return [menu_.get() menu]; |
| +} |
| + |
| +// Overridden from MenuButton. |
| +- (NSRect)menuRect { |
| + return [self tabRect]; |
| +} |
| + |
| @end |