OLD | NEW |
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 "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 10 #include "chrome/browser/profiles/profile_attributes_storage.h" |
9 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
10 #include "chrome/browser/profiles/profile_info_cache.h" | |
11 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
13 | 14 |
14 // static | 15 // static |
15 void AvatarMenu::GetImageForMenuButton(const base::FilePath& profile_path, | 16 void AvatarMenu::GetImageForMenuButton(const base::FilePath& profile_path, |
16 gfx::Image* image, | 17 gfx::Image* image, |
17 bool* is_rectangle) { | 18 bool* is_rectangle) { |
18 ProfileInfoCache& cache = | 19 ProfileAttributesStorage& storage = |
19 g_browser_process->profile_manager()->GetProfileInfoCache(); | 20 g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
20 size_t index = cache.GetIndexOfProfileWithPath(profile_path); | 21 ProfileAttributesEntry* entry; |
21 if (index == std::string::npos) { | 22 if (!storage.GetProfileAttributesWithPath(profile_path, &entry)) { |
22 NOTREACHED(); | 23 NOTREACHED(); |
23 return; | 24 return; |
24 } | 25 } |
25 | 26 |
26 // If there is a Gaia image available, try to use that. | 27 // If there is a Gaia image available, try to use that. |
27 if (cache.IsUsingGAIAPictureOfProfileAtIndex(index)) { | 28 if (entry->IsUsingGAIAPicture()) { |
28 const gfx::Image* gaia_image = cache.GetGAIAPictureOfProfileAtIndex(index); | 29 const gfx::Image* gaia_image = entry->GetGAIAPicture(); |
29 if (gaia_image) { | 30 if (gaia_image) { |
30 *image = *gaia_image; | 31 *image = *gaia_image; |
31 *is_rectangle = true; | 32 *is_rectangle = true; |
32 return; | 33 return; |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
36 // Otherwise, use the default resource, not the downloaded high-res one. | 37 // Otherwise, use the default resource, not the downloaded high-res one. |
37 const size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index); | 38 const size_t icon_index = entry->GetAvatarIconIndex(); |
38 const int resource_id = | 39 const int resource_id = |
39 profiles::GetDefaultAvatarIconResourceIDAtIndex(icon_index); | 40 profiles::GetDefaultAvatarIconResourceIDAtIndex(icon_index); |
40 *image = ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); | 41 *image = ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); |
41 *is_rectangle = false; | 42 *is_rectangle = false; |
42 } | 43 } |
OLD | NEW |