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

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

Issue 7647002: [Mac] Implement the avatar menu bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test Created 9 years, 4 months 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/browser/avatar_button.mm
diff --git a/chrome/browser/ui/cocoa/browser/avatar_button.mm b/chrome/browser/ui/cocoa/browser/avatar_button.mm
index d3e7c598c23b2f39ea4b727bf5e67dc667aee5ec..d052fe36649f777724970a5d8875b928fa60fb00 100644
--- a/chrome/browser/ui/cocoa/browser/avatar_button.mm
+++ b/chrome/browser/ui/cocoa/browser/avatar_button.mm
@@ -10,6 +10,7 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
+#import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/image_utils.h"
#import "chrome/browser/ui/cocoa/menu_controller.h"
@@ -25,7 +26,6 @@
@interface AvatarButton (Private)
- (IBAction)buttonClicked:(id)sender;
- (NSImage*)compositeImageWithShadow:(NSImage*)image;
-- (void)updateMenu;
- (void)updateAvatar;
@end
@@ -45,7 +45,6 @@ class Observer : public NotificationObserver {
switch (type) {
case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED:
[button_ updateAvatar];
- [button_ updateMenu];
break;
default:
NOTREACHED();
@@ -61,6 +60,12 @@ class Observer : public NotificationObserver {
} // namespace AvatarButtonInternal
+namespace {
+
+const CGFloat kMenuYOffsetAdjust = 5.0;
+
+} // namespace
+
////////////////////////////////////////////////////////////////////////////////
@implementation AvatarButton
@@ -68,7 +73,6 @@ class Observer : public NotificationObserver {
- (id)initWithBrowser:(Browser*)browser {
if ((self = [super init])) {
browser_ = browser;
- [self updateMenu];
// This view's single child view is a button with the same size and width as
// the parent. Set it to automatically resize to the size of this view and
@@ -112,9 +116,17 @@ class Observer : public NotificationObserver {
- (IBAction)buttonClicked:(id)sender {
DCHECK_EQ(button_.get(), sender);
- [NSMenu popUpContextMenu:[menuController_ menu]
- withEvent:[NSApp currentEvent]
- forView:self];
+
+ NSPoint point = NSMakePoint(NSMidX([self bounds]),
+ NSMinY([self bounds]) + kMenuYOffsetAdjust);
+ point = [self convertPoint:point toView:nil];
+ point = [[self window] convertBaseToScreen:point];
+
+ // |menu| will automatically release itself on close.
+ AvatarMenuBubbleController* menu =
+ [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
+ anchoredAt:point];
+ [menu showWindow:self];
}
// This will take in an original image and redraw it with a shadow.
@@ -147,13 +159,6 @@ class Observer : public NotificationObserver {
return [destination.release() autorelease];
}
-// Rebuilds the menu and menu controller.
-- (void)updateMenu {
- model_.reset(new ProfileMenuModel(browser_));
- menuController_.reset([[MenuController alloc] initWithModel:model_.get()
- useWithPopUpButtonCell:NO]);
-}
-
// Updates the avatar information from the profile cache.
- (void)updateAvatar {
ProfileInfoCache& cache =
« no previous file with comments | « chrome/browser/ui/cocoa/browser/avatar_button.h ('k') | chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698