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

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

Issue 882113003: [Mac] Always use the small, non-high res default avatars in the People menu bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const AvatarMenu::Item& itemData = avatarMenu_->GetItemAt(i); 126 const AvatarMenu::Item& itemData = avatarMenu_->GetItemAt(i);
127 NSString* name = base::SysUTF16ToNSString(itemData.name); 127 NSString* name = base::SysUTF16ToNSString(itemData.name);
128 SEL action = dock ? @selector(switchToProfileFromDock:) 128 SEL action = dock ? @selector(switchToProfileFromDock:)
129 : @selector(switchToProfileFromMenu:); 129 : @selector(switchToProfileFromMenu:);
130 NSMenuItem* item = [self createItemWithTitle:name 130 NSMenuItem* item = [self createItemWithTitle:name
131 action:action]; 131 action:action];
132 [item setTag:itemData.menu_index]; 132 [item setTag:itemData.menu_index];
133 if (dock) { 133 if (dock) {
134 [item setIndentationLevel:1]; 134 [item setIndentationLevel:1];
135 } else { 135 } else {
136 gfx::Image itemIcon = itemData.icon; 136 gfx::Image itemIcon;
137 bool isRectangle;
138 // Always use the low-res, small default avatars in the menu.
139 AvatarMenu::GetImageForMenuButton(itemData.profile_path,
140 &itemIcon,
141 &isRectangle);
142
137 // The image might be too large and need to be resized (i.e. if this is 143 // The image might be too large and need to be resized (i.e. if this is
138 // a signed-in user using the GAIA profile photo). 144 // a signed-in user using the GAIA profile photo).
139 if (itemIcon.Width() > profiles::kAvatarIconWidth || 145 if (itemIcon.Width() > profiles::kAvatarIconWidth ||
140 itemIcon.Height() > profiles::kAvatarIconHeight) { 146 itemIcon.Height() > profiles::kAvatarIconHeight) {
141 itemIcon = profiles::GetAvatarIconForWebUI(itemIcon, true); 147 itemIcon = profiles::GetAvatarIconForWebUI(itemIcon, true);
142 } 148 }
143 DCHECK(itemIcon.Width() <= profiles::kAvatarIconWidth); 149 DCHECK(itemIcon.Width() <= profiles::kAvatarIconWidth);
144 DCHECK(itemIcon.Height() <= profiles::kAvatarIconHeight); 150 DCHECK(itemIcon.Height() <= profiles::kAvatarIconHeight);
145 [item setImage:itemIcon.ToNSImage()]; 151 [item setImage:itemIcon.ToNSImage()];
146 [item setState:itemData.active ? NSOnState : NSOffState]; 152 [item setState:itemData.active ? NSOnState : NSOffState];
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 260 }
255 261
256 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { 262 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel {
257 base::scoped_nsobject<NSMenuItem> item( 263 base::scoped_nsobject<NSMenuItem> item(
258 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); 264 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]);
259 [item setTarget:self]; 265 [item setTarget:self];
260 return [item.release() autorelease]; 266 return [item.release() autorelease];
261 } 267 }
262 268
263 @end 269 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698