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

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

Issue 2552423002: [Mac] Fix for avatar button active state (Closed)
Patch Set: Removed the Fast Chooser Profile Menu code in cocoa Created 4 years 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/profiles/avatar_base_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 NSPoint point = NSMakePoint(anchorX, 165 NSPoint point = NSMakePoint(anchorX,
166 NSMaxY([anchor bounds]) + kMenuYOffsetAdjust); 166 NSMaxY([anchor bounds]) + kMenuYOffsetAdjust);
167 point = [anchor convertPoint:point toView:nil]; 167 point = [anchor convertPoint:point toView:nil];
168 point = ui::ConvertPointFromWindowToScreen([anchor window], point); 168 point = ui::ConvertPointFromWindowToScreen([anchor window], point);
169 169
170 // |menuController_| will automatically release itself on close. 170 // |menuController_| will automatically release itself on close.
171 profiles::BubbleViewMode viewMode; 171 profiles::BubbleViewMode viewMode;
172 profiles::TutorialMode tutorialMode; 172 profiles::TutorialMode tutorialMode;
173 profiles::BubbleViewModeFromAvatarBubbleMode( 173 profiles::BubbleViewModeFromAvatarBubbleMode(
174 mode, &viewMode, &tutorialMode); 174 mode, &viewMode, &tutorialMode);
175 // Don't start creating the view if it would be an empty fast user switcher.
176 // It has to happen here to prevent the view system from creating an empty
177 // container.
178 if (viewMode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER &&
179 !profiles::HasProfileSwitchTargets(browser_->profile())) {
180 return;
181 }
182 175
183 menuController_ = 176 menuController_ =
184 [[ProfileChooserController alloc] initWithBrowser:browser_ 177 [[ProfileChooserController alloc] initWithBrowser:browser_
185 anchoredAt:point 178 anchoredAt:point
186 viewMode:viewMode 179 viewMode:viewMode
187 tutorialMode:tutorialMode 180 tutorialMode:tutorialMode
188 serviceType:serviceType 181 serviceType:serviceType
189 accessPoint:accessPoint]; 182 accessPoint:accessPoint];
190 183
191 [[NSNotificationCenter defaultCenter] 184 [[NSNotificationCenter defaultCenter]
192 addObserver:self 185 addObserver:self
193 selector:@selector(bubbleWillClose:) 186 selector:@selector(bubbleWillClose:)
194 name:NSWindowWillCloseNotification 187 name:NSWindowWillCloseNotification
195 object:[menuController_ window]]; 188 object:[menuController_ window]];
196 [menuController_ showWindow:self]; 189 [menuController_ showWindow:self];
197 190
198 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); 191 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE);
199 } 192 }
200 193
201 - (BOOL)isCtrlPressed {
202 return [NSEvent modifierFlags] & NSControlKeyMask ? YES : NO;
203 }
204
205 - (IBAction)buttonClicked:(id)sender { 194 - (IBAction)buttonClicked:(id)sender {
206 BrowserWindow::AvatarBubbleMode mode =
207 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT;
208 if ([self isCtrlPressed])
209 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH;
210
211 [self showAvatarBubbleAnchoredAt:button_ 195 [self showAvatarBubbleAnchoredAt:button_
212 withMode:mode 196 withMode:BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT
213 withServiceType:signin::GAIA_SERVICE_TYPE_NONE 197 withServiceType:signin::GAIA_SERVICE_TYPE_NONE
214 fromAccessPoint:signin_metrics::AccessPoint:: 198 fromAccessPoint:signin_metrics::AccessPoint::
215 ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN]; 199 ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN];
216 }
217
218 - (IBAction)buttonRightClicked:(id)sender {
219 BrowserWindow::AvatarBubbleMode mode =
220 BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH;
221
222 [self showAvatarBubbleAnchoredAt:button_
223 withMode:mode
224 withServiceType:signin::GAIA_SERVICE_TYPE_NONE
225 fromAccessPoint:signin_metrics::AccessPoint::
226 ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN];
227 } 200 }
228 201
229 - (void)bubbleWillClose:(NSNotification*)notif { 202 - (void)bubbleWillClose:(NSNotification*)notif {
230 NSWindowController* wc = 203 NSWindowController* wc =
231 [browser_->window()->GetNativeWindow() windowController]; 204 [browser_->window()->GetNativeWindow() windowController];
232 if ([wc isKindOfClass:[BrowserWindowController class]]) { 205 if ([wc isKindOfClass:[BrowserWindowController class]]) {
233 [static_cast<BrowserWindowController*>(wc) 206 [static_cast<BrowserWindowController*>(wc)
234 releaseToolbarVisibilityForOwner:self 207 releaseToolbarVisibilityForOwner:self
235 withAnimation:YES]; 208 withAnimation:YES];
236 } 209 }
237 menuController_ = nil; 210 menuController_ = nil;
238 } 211 }
239 212
240 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent { 213 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {
241 NOTREACHED(); 214 NOTREACHED();
242 } 215 }
243 216
244 - (void)setErrorStatus:(BOOL)hasError { 217 - (void)setErrorStatus:(BOOL)hasError {
245 } 218 }
246 219
247 - (BaseBubbleController*)menuController { 220 - (BaseBubbleController*)menuController {
248 return menuController_; 221 return menuController_;
249 } 222 }
250 223
251 @end 224 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698