Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profile_menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/profile_menu_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/avatar_menu.h" | 10 #include "chrome/browser/profiles/avatar_menu.h" |
| 11 #include "chrome/browser/profiles/avatar_menu_observer.h" | 11 #include "chrome/browser/profiles/avatar_menu_observer.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_info_cache.h" | 13 #include "chrome/browser/profiles/profile_info_cache.h" |
| 14 #include "chrome/browser/profiles/profile_info_interface.h" | 14 #include "chrome/browser/profiles/profile_info_interface.h" |
| 15 #include "chrome/browser/profiles/profile_info_util.h" | |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/profiles/profile_metrics.h" | 17 #include "chrome/browser/profiles/profile_metrics.h" |
| 17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
| 19 #include "chrome/browser/ui/browser_list_observer.h" | 20 #include "chrome/browser/ui/browser_list_observer.h" |
| 20 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 21 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 22 #include "ui/base/l10n/l10n_util_mac.h" | 23 #include "ui/base/l10n/l10n_util_mac.h" |
| 23 #include "ui/gfx/image/image.h" | 24 #include "ui/gfx/image/image.h" |
| 24 | 25 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 const AvatarMenu::Item& itemData = menu_->GetItemAt(i); | 123 const AvatarMenu::Item& itemData = menu_->GetItemAt(i); |
| 123 NSString* name = base::SysUTF16ToNSString(itemData.name); | 124 NSString* name = base::SysUTF16ToNSString(itemData.name); |
| 124 SEL action = dock ? @selector(switchToProfileFromDock:) | 125 SEL action = dock ? @selector(switchToProfileFromDock:) |
| 125 : @selector(switchToProfileFromMenu:); | 126 : @selector(switchToProfileFromMenu:); |
| 126 NSMenuItem* item = [self createItemWithTitle:name | 127 NSMenuItem* item = [self createItemWithTitle:name |
| 127 action:action]; | 128 action:action]; |
| 128 [item setTag:itemData.menu_index]; | 129 [item setTag:itemData.menu_index]; |
| 129 if (dock) { | 130 if (dock) { |
| 130 [item setIndentationLevel:1]; | 131 [item setIndentationLevel:1]; |
| 131 } else { | 132 } else { |
| 132 [item setImage:itemData.icon.ToNSImage()]; | 133 gfx::Image itemIcon = itemData.icon; |
| 134 // The image might be too large and need to be resized (i.e. if this is | |
| 135 // a signed-in user using the GAIA profile photo. | |
|
Alexei Svitkine (slow)
2014/01/29 20:23:56
Nit: Close your parenthesis!
noms (inactive)
2014/01/29 20:31:29
GAH. Done.
On 2014/01/29 20:23:56, Alexei Svitkine
| |
| 136 if (profiles::AvatarIconNeedsResizing(itemIcon)) | |
| 137 itemIcon = profiles::GetAvatarIconForWebUI(itemIcon, true); | |
| 138 | |
| 139 [item setImage:itemIcon.ToNSImage()]; | |
| 133 [item setState:itemData.active ? NSOnState : NSOffState]; | 140 [item setState:itemData.active ? NSOnState : NSOffState]; |
| 134 } | 141 } |
| 135 [menu insertItem:item atIndex:i + offset]; | 142 [menu insertItem:item atIndex:i + offset]; |
| 136 } | 143 } |
| 137 | 144 |
| 138 return YES; | 145 return YES; |
| 139 } | 146 } |
| 140 | 147 |
| 141 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { | 148 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { |
| 142 // In guest mode, chrome://settings isn't available, so disallow creating | 149 // In guest mode, chrome://settings isn't available, so disallow creating |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 } | 246 } |
| 240 | 247 |
| 241 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { | 248 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { |
| 242 base::scoped_nsobject<NSMenuItem> item( | 249 base::scoped_nsobject<NSMenuItem> item( |
| 243 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); | 250 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); |
| 244 [item setTarget:self]; | 251 [item setTarget:self]; |
| 245 return [item.release() autorelease]; | 252 return [item.release() autorelease]; |
| 246 } | 253 } |
| 247 | 254 |
| 248 @end | 255 @end |
| OLD | NEW |