OLD | NEW |
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 "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 10 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // Space between the avatar icon and the avatar menu bubble. | 27 // Space between the avatar icon and the avatar menu bubble. |
28 const CGFloat kMenuYOffsetAdjust = 1.0; | 28 const CGFloat kMenuYOffsetAdjust = 1.0; |
29 // Offset needed to align the edge of the avatar bubble with the edge of the | 29 // Offset needed to align the edge of the avatar bubble with the edge of the |
30 // avatar button. | 30 // avatar button. |
31 const CGFloat kMenuXOffsetAdjust = 2.0; | 31 const CGFloat kMenuXOffsetAdjust = 2.0; |
32 | 32 |
33 @interface AvatarBaseController (Private) | 33 @interface AvatarBaseController (Private) |
34 // Shows the avatar bubble. | 34 // Shows the avatar bubble. |
35 - (IBAction)buttonClicked:(id)sender; | 35 - (IBAction)buttonClicked:(id)sender; |
| 36 - (IBAction)buttonRightClicked:(id)sender; |
36 | 37 |
37 - (void)bubbleWillClose:(NSNotification*)notif; | 38 - (void)bubbleWillClose:(NSNotification*)notif; |
38 | 39 |
39 // Updates the profile name displayed by the avatar button. If |layoutParent| is | 40 // Updates the profile name displayed by the avatar button. If |layoutParent| is |
40 // yes, then the BrowserWindowController is notified to relayout the subviews, | 41 // yes, then the BrowserWindowController is notified to relayout the subviews, |
41 // as the button needs to be repositioned. | 42 // as the button needs to be repositioned. |
42 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent; | 43 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent; |
43 | 44 |
44 // Displays an error icon if any accounts associated with this profile have an | 45 // Displays an error icon if any accounts associated with this profile have an |
45 // auth error. | 46 // auth error. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 object:[menuController_ window]]; | 207 object:[menuController_ window]]; |
207 [menuController_ showWindow:self]; | 208 [menuController_ showWindow:self]; |
208 | 209 |
209 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); | 210 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); |
210 } | 211 } |
211 | 212 |
212 - (IBAction)buttonClicked:(id)sender { | 213 - (IBAction)buttonClicked:(id)sender { |
213 BrowserWindow::AvatarBubbleMode mode = | 214 BrowserWindow::AvatarBubbleMode mode = |
214 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; | 215 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; |
215 | 216 |
216 if ([NSEvent modifierFlags] & NSCommandKeyMask) | 217 [self showAvatarBubbleAnchoredAt:button_ |
217 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH; | 218 withMode:mode |
| 219 withServiceType:signin::GAIA_SERVICE_TYPE_NONE]; |
| 220 } |
| 221 |
| 222 - (IBAction)buttonRightClicked:(id)sender { |
| 223 BrowserWindow::AvatarBubbleMode mode = |
| 224 BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH; |
218 | 225 |
219 [self showAvatarBubbleAnchoredAt:button_ | 226 [self showAvatarBubbleAnchoredAt:button_ |
220 withMode:mode | 227 withMode:mode |
221 withServiceType:signin::GAIA_SERVICE_TYPE_NONE]; | 228 withServiceType:signin::GAIA_SERVICE_TYPE_NONE]; |
222 } | 229 } |
223 | 230 |
224 - (void)bubbleWillClose:(NSNotification*)notif { | 231 - (void)bubbleWillClose:(NSNotification*)notif { |
225 NSWindowController* wc = | 232 NSWindowController* wc = |
226 [browser_->window()->GetNativeWindow() windowController]; | 233 [browser_->window()->GetNativeWindow() windowController]; |
227 if ([wc isKindOfClass:[BrowserWindowController class]]) { | 234 if ([wc isKindOfClass:[BrowserWindowController class]]) { |
228 [static_cast<BrowserWindowController*>(wc) | 235 [static_cast<BrowserWindowController*>(wc) |
229 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; | 236 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; |
230 } | 237 } |
231 menuController_ = nil; | 238 menuController_ = nil; |
232 } | 239 } |
233 | 240 |
234 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent { | 241 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent { |
235 NOTREACHED(); | 242 NOTREACHED(); |
236 } | 243 } |
237 | 244 |
238 - (void)updateErrorStatus:(BOOL)hasError { | 245 - (void)updateErrorStatus:(BOOL)hasError { |
239 } | 246 } |
240 | 247 |
241 - (BaseBubbleController*)menuController { | 248 - (BaseBubbleController*)menuController { |
242 return menuController_; | 249 return menuController_; |
243 } | 250 } |
244 | 251 |
245 @end | 252 @end |
OLD | NEW |