| 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 <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 } |
| OLD | NEW |