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

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

Issue 1972033002: Simplify some old avatar menu button code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reinstate ash browser test fix Created 4 years, 7 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/profiles/profile_menu_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 NSString* name = base::SysUTF16ToNSString(itemData.name); 144 NSString* name = base::SysUTF16ToNSString(itemData.name);
145 SEL action = dock ? @selector(switchToProfileFromDock:) 145 SEL action = dock ? @selector(switchToProfileFromDock:)
146 : @selector(switchToProfileFromMenu:); 146 : @selector(switchToProfileFromMenu:);
147 NSMenuItem* item = [self createItemWithTitle:name 147 NSMenuItem* item = [self createItemWithTitle:name
148 action:action]; 148 action:action];
149 [item setTag:itemData.menu_index]; 149 [item setTag:itemData.menu_index];
150 if (dock) { 150 if (dock) {
151 [item setIndentationLevel:1]; 151 [item setIndentationLevel:1];
152 } else { 152 } else {
153 gfx::Image itemIcon; 153 gfx::Image itemIcon;
154 bool isRectangle;
155 // Always use the low-res, small default avatars in the menu. 154 // Always use the low-res, small default avatars in the menu.
156 AvatarMenu::GetImageForMenuButton(itemData.profile_path, 155 AvatarMenu::GetImageForMenuButton(itemData.profile_path, &itemIcon);
157 &itemIcon,
158 &isRectangle);
159 156
160 // The image might be too large and need to be resized (i.e. if this is 157 // The image might be too large and need to be resized (i.e. if this is
161 // a signed-in user using the GAIA profile photo). 158 // a signed-in user using the GAIA profile photo).
162 if (itemIcon.Width() > profiles::kAvatarIconWidth || 159 if (itemIcon.Width() > profiles::kAvatarIconWidth ||
163 itemIcon.Height() > profiles::kAvatarIconHeight) { 160 itemIcon.Height() > profiles::kAvatarIconHeight) {
164 itemIcon = profiles::GetAvatarIconForWebUI(itemIcon, true); 161 itemIcon = profiles::GetAvatarIconForWebUI(itemIcon, true);
165 } 162 }
166 DCHECK(itemIcon.Width() <= profiles::kAvatarIconWidth); 163 DCHECK(itemIcon.Width() <= profiles::kAvatarIconWidth);
167 DCHECK(itemIcon.Height() <= profiles::kAvatarIconHeight); 164 DCHECK(itemIcon.Height() <= profiles::kAvatarIconHeight);
168 [item setImage:itemIcon.ToNSImage()]; 165 [item setImage:itemIcon.ToNSImage()];
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 297 }
301 298
302 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { 299 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel {
303 base::scoped_nsobject<NSMenuItem> item( 300 base::scoped_nsobject<NSMenuItem> item(
304 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); 301 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]);
305 [item setTarget:self]; 302 [item setTarget:self];
306 return [item.release() autorelease]; 303 return [item.release() autorelease];
307 } 304 }
308 305
309 @end 306 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm ('k') | chrome/browser/ui/view_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698