 Chromium Code Reviews
 Chromium Code Reviews Issue 149513007:
  [Mac] The GAIA profile photo should be resized in the Users controller menu  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 149513007:
  [Mac] The GAIA profile photo should be resized in the Users controller menu  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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). | |
| 136 if (itemIcon.Width() > profiles::kAvatarIconWidth || | |
| 137 itemIcon.Height() > profiles::kAvatarIconHeight) | |
| 
Alexei Svitkine (slow)
2014/01/29 21:08:25
Nit: add {}
 
noms (inactive)
2014/01/29 22:14:19
Done.
 | |
| 138 itemIcon = profiles::GetAvatarIconForWebUI(itemIcon, true); | |
| 
Alexei Svitkine (slow)
2014/01/29 21:08:25
Maybe add DCHECKs that the new size meets the crit
 
noms (inactive)
2014/01/29 22:14:19
Done.
 | |
| 139 | |
| 140 [item setImage:itemIcon.ToNSImage()]; | |
| 133 [item setState:itemData.active ? NSOnState : NSOffState]; | 141 [item setState:itemData.active ? NSOnState : NSOffState]; | 
| 134 } | 142 } | 
| 135 [menu insertItem:item atIndex:i + offset]; | 143 [menu insertItem:item atIndex:i + offset]; | 
| 136 } | 144 } | 
| 137 | 145 | 
| 138 return YES; | 146 return YES; | 
| 139 } | 147 } | 
| 140 | 148 | 
| 141 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { | 149 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { | 
| 142 // In guest mode, chrome://settings isn't available, so disallow creating | 150 // 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 } | 247 } | 
| 240 | 248 | 
| 241 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { | 249 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { | 
| 242 base::scoped_nsobject<NSMenuItem> item( | 250 base::scoped_nsobject<NSMenuItem> item( | 
| 243 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); | 251 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); | 
| 244 [item setTarget:self]; | 252 [item setTarget:self]; | 
| 245 return [item.release() autorelease]; | 253 return [item.release() autorelease]; | 
| 246 } | 254 } | 
| 247 | 255 | 
| 248 @end | 256 @end | 
| OLD | NEW |