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

Side by Side Diff: chrome/browser/profiles/avatar_menu_desktop.cc

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
« no previous file with comments | « chrome/browser/profiles/avatar_menu.h ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/profiles/avatar_menu.h" 5 #include "chrome/browser/profiles/avatar_menu.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_attributes_entry.h" 11 #include "chrome/browser/profiles/profile_attributes_entry.h"
12 #include "chrome/browser/profiles/profile_attributes_storage.h" 12 #include "chrome/browser/profiles/profile_attributes_storage.h"
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 13 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 16
17 // static 17 // static
18 void AvatarMenu::GetImageForMenuButton(const base::FilePath& profile_path, 18 void AvatarMenu::GetImageForMenuButton(const base::FilePath& profile_path,
19 gfx::Image* image, 19 gfx::Image* image) {
20 bool* is_rectangle) {
21 ProfileAttributesEntry* entry; 20 ProfileAttributesEntry* entry;
22 if (!g_browser_process->profile_manager()->GetProfileAttributesStorage(). 21 if (!g_browser_process->profile_manager()->GetProfileAttributesStorage().
23 GetProfileAttributesWithPath(profile_path, &entry)) { 22 GetProfileAttributesWithPath(profile_path, &entry)) {
24 NOTREACHED(); 23 // This can happen if the user deletes the current profile.
25 return; 24 return;
26 } 25 }
27 26
28 // If there is a Gaia image available, try to use that. 27 // If there is a Gaia image available, try to use that.
29 if (entry->IsUsingGAIAPicture()) { 28 if (entry->IsUsingGAIAPicture()) {
30 const gfx::Image* gaia_image = entry->GetGAIAPicture(); 29 const gfx::Image* gaia_image = entry->GetGAIAPicture();
31 if (gaia_image) { 30 if (gaia_image) {
32 *image = *gaia_image; 31 *image = *gaia_image;
33 *is_rectangle = true;
34 return; 32 return;
35 } 33 }
36 } 34 }
37 35
38 // Otherwise, use the default resource, not the downloaded high-res one. 36 // Otherwise, use the default resource, not the downloaded high-res one.
39 const size_t icon_index = entry->GetAvatarIconIndex(); 37 const size_t icon_index = entry->GetAvatarIconIndex();
40 const int resource_id = 38 const int resource_id =
41 profiles::GetDefaultAvatarIconResourceIDAtIndex(icon_index); 39 profiles::GetDefaultAvatarIconResourceIDAtIndex(icon_index);
42 *image = ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); 40 *image = ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
43 *is_rectangle = false;
44 } 41 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/avatar_menu.h ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698