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

Side by Side Diff: chrome/browser/ui/cocoa/browser/avatar_base_controller.mm

Issue 216523005: show avatar bubble in edit mode on mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits fixed Created 6 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/browser/avatar_base_controller.h" 5 #import "chrome/browser/ui/cocoa/browser/avatar_base_controller.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_info_cache_observer.h" 9 #include "chrome/browser/profiles/profile_info_cache_observer.h"
10 #include "chrome/browser/profiles/profile_info_util.h" 10 #include "chrome/browser/profiles/profile_info_util.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 name:NSWindowWillCloseNotification 90 name:NSWindowWillCloseNotification
91 object:[menuController_ window]]; 91 object:[menuController_ window]];
92 [super dealloc]; 92 [super dealloc];
93 } 93 }
94 94
95 - (NSButton*)buttonView { 95 - (NSButton*)buttonView {
96 CHECK(button_.get()); // Subclasses must set this. 96 CHECK(button_.get()); // Subclasses must set this.
97 return button_.get(); 97 return button_.get();
98 } 98 }
99 99
100 - (void)showAvatarBubble:(NSView*)anchor { 100 - (void)showAvatarBubble:(NSView*)anchor
101 withMode:(BrowserWindow::AvatarBubbleMode)mode {
101 if (menuController_) 102 if (menuController_)
102 return; 103 return;
103 104
104 DCHECK(chrome::IsCommandEnabled(browser_, IDC_SHOW_AVATAR_MENU)); 105 DCHECK(chrome::IsCommandEnabled(browser_, IDC_SHOW_AVATAR_MENU));
105 106
106 NSWindowController* wc = 107 NSWindowController* wc =
107 [browser_->window()->GetNativeWindow() windowController]; 108 [browser_->window()->GetNativeWindow() windowController];
108 if ([wc isKindOfClass:[BrowserWindowController class]]) { 109 if ([wc isKindOfClass:[BrowserWindowController class]]) {
109 [static_cast<BrowserWindowController*>(wc) 110 [static_cast<BrowserWindowController*>(wc)
110 lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; 111 lockBarVisibilityForOwner:self withAnimation:NO delay:NO];
111 } 112 }
112 113
113 NSPoint point = NSMakePoint(NSMidX([anchor bounds]), 114 NSPoint point = NSMakePoint(NSMidX([anchor bounds]),
114 NSMaxY([anchor bounds]) - kMenuYOffsetAdjust); 115 NSMaxY([anchor bounds]) - kMenuYOffsetAdjust);
115 point = [anchor convertPoint:point toView:nil]; 116 point = [anchor convertPoint:point toView:nil];
116 point = [[anchor window] convertBaseToScreen:point]; 117 point = [[anchor window] convertBaseToScreen:point];
117 118
118 // |menuController_| will automatically release itself on close. 119 // |menuController_| will automatically release itself on close.
119 if (switches::IsNewProfileManagement()) { 120 if (switches::IsNewProfileManagement()) {
121 BubbleViewMode viewMode =
122 mode == BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT ?
123 PROFILE_CHOOSER_VIEW :
124 ACCOUNT_MANAGEMENT_VIEW;
120 menuController_ = 125 menuController_ =
121 [[ProfileChooserController alloc] initWithBrowser:browser_ 126 [[ProfileChooserController alloc] initWithBrowser:browser_
122 anchoredAt:point]; 127 anchoredAt:point
128 withMode:viewMode];
123 } else { 129 } else {
124 menuController_ = 130 menuController_ =
125 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ 131 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
126 anchoredAt:point]; 132 anchoredAt:point];
127 } 133 }
128 134
129 [[NSNotificationCenter defaultCenter] 135 [[NSNotificationCenter defaultCenter]
130 addObserver:self 136 addObserver:self
131 selector:@selector(bubbleWillClose:) 137 selector:@selector(bubbleWillClose:)
132 name:NSWindowWillCloseNotification 138 name:NSWindowWillCloseNotification
133 object:[menuController_ window]]; 139 object:[menuController_ window]];
134 [menuController_ showWindow:self]; 140 [menuController_ showWindow:self];
135 141
136 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); 142 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE);
137 } 143 }
138 144
139 - (IBAction)buttonClicked:(id)sender { 145 - (IBAction)buttonClicked:(id)sender {
140 DCHECK_EQ(sender, button_.get()); 146 DCHECK_EQ(sender, button_.get());
141 [self showAvatarBubble:button_]; 147 [self showAvatarBubble:button_
148 withMode:BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT];
142 } 149 }
143 150
144 - (void)bubbleWillClose:(NSNotification*)notif { 151 - (void)bubbleWillClose:(NSNotification*)notif {
145 NSWindowController* wc = 152 NSWindowController* wc =
146 [browser_->window()->GetNativeWindow() windowController]; 153 [browser_->window()->GetNativeWindow() windowController];
147 if ([wc isKindOfClass:[BrowserWindowController class]]) { 154 if ([wc isKindOfClass:[BrowserWindowController class]]) {
148 [static_cast<BrowserWindowController*>(wc) 155 [static_cast<BrowserWindowController*>(wc)
149 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; 156 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO];
150 } 157 }
151 menuController_ = nil; 158 menuController_ = nil;
152 } 159 }
153 160
154 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent { 161 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {
155 NOTREACHED(); 162 NOTREACHED();
156 } 163 }
157 164
158 - (BaseBubbleController*)menuController { 165 - (BaseBubbleController*)menuController {
159 return menuController_; 166 return menuController_;
160 } 167 }
161 168
162 @end 169 @end
163 170
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser/avatar_base_controller.h ('k') | chrome/browser/ui/cocoa/browser/profile_chooser_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698