Chromium Code Reviews| Index: chrome/browser/profiles/profile_shortcut_manager_win.cc |
| diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc |
| index 72256196a964929786ec37c968159783a6a13dde..6566846f2c0ed9bdc41f536a0f7d08723f9ac1c2 100644 |
| --- a/chrome/browser/profiles/profile_shortcut_manager_win.cc |
| +++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc |
| @@ -71,7 +71,7 @@ const int kMaxProfileShortcutFileNameLength = 64; |
| const int kShortcutIconSize = 48; |
| const int kProfileAvatarBadgeSize = kShortcutIconSize / 2; |
| -const int kCurrentProfileIconVersion = 2; |
| +const int kCurrentProfileIconVersion = 3; |
| // 2x sized profile avatar icons. Mirrors |kDefaultAvatarIconResources| in |
| // profile_info_cache.cc. |
| @@ -589,19 +589,24 @@ base::string16 SanitizeShortcutProfileNameString( |
| return sanitized; |
| } |
| -// Returns a copied SkBitmap for the given resource id that can be safely passed |
| -// to another thread. |
| -SkBitmap GetImageResourceSkBitmapCopy(int resource_id) { |
| - const gfx::Image image = |
| - ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); |
| +// Returns a copied SkBitmap for the given image that can be safely passed to |
| +// another thread. |
| +SkBitmap GetSkBitmapCopy(const gfx::Image& image) { |
| DCHECK(!image.IsEmpty()); |
| - |
| const SkBitmap* image_bitmap = image.ToSkBitmap(); |
| SkBitmap bitmap_copy; |
| image_bitmap->deepCopyTo(&bitmap_copy); |
| return bitmap_copy; |
| } |
| +// Returns a copied SkBitmap for the given resource id that can be safely passed |
| +// to another thread. |
| +SkBitmap GetImageResourceSkBitmapCopy(int resource_id) { |
| + const gfx::Image image = |
| + ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); |
| + return GetSkBitmapCopy(image); |
| +} |
| + |
| } // namespace |
| namespace profiles { |
| @@ -808,15 +813,35 @@ void ProfileShortcutManagerWin::CreateOrUpdateShortcutsForProfileAtPath( |
| if (!remove_badging) { |
| params.profile_name = cache->GetNameOfProfileAtIndex(profile_index); |
| - const size_t icon_index = |
| - cache->GetAvatarIconIndexOfProfileAtIndex(profile_index); |
| - const int resource_id_1x = |
| - profiles::GetDefaultAvatarIconResourceIDAtIndex(icon_index); |
| - const int resource_id_2x = kProfileAvatarIconResources2x[icon_index]; |
| - // Make a copy of the SkBitmaps to ensure that we can safely use the image |
| - // data on the FILE thread. |
| - params.avatar_image_1x = GetImageResourceSkBitmapCopy(resource_id_1x); |
| - params.avatar_image_2x = GetImageResourceSkBitmapCopy(resource_id_2x); |
| + // The profile might be using the Gaia avatar, which is not in the |
| + // resources array. |
| + bool has_gaia_image = false; |
| + if (cache->IsUsingGAIAPictureOfProfileAtIndex(profile_index)) { |
| + const gfx::Image* image = |
| + cache->GetGAIAPictureOfProfileAtIndex(profile_index); |
|
gab
2014/08/12 18:56:17
When would IsUsingGAIAPictureOfProfileAtIndex() re
noms (inactive)
2014/08/12 19:09:58
When the file is saved, the ProfileInfoCache sends
|
| + if (image) { |
| + params.avatar_image_1x = GetSkBitmapCopy(*image); |
| + // Gaia images are 256px, which makes them big enough to use in the |
| + // large icon case as well. |
| + DCHECK(image->Width() >= IconUtil::kLargeIconSize); |
|
Alexei Svitkine (slow)
2014/08/12 18:57:56
Nit: Can this use DCHECK_GE?
noms (inactive)
2014/08/12 19:09:57
Done.
|
| + params.avatar_image_2x = params.avatar_image_1x; |
| + has_gaia_image = true; |
| + } |
| + } |
| + |
| + // If the profile isn't using a Gaia image, or if the Gaia image did not |
| + // exist, revert to the previously used avatar icon. |
| + if (!has_gaia_image) { |
| + const size_t icon_index = |
| + cache->GetAvatarIconIndexOfProfileAtIndex(profile_index); |
| + const int resource_id_1x = |
| + profiles::GetDefaultAvatarIconResourceIDAtIndex(icon_index); |
| + const int resource_id_2x = kProfileAvatarIconResources2x[icon_index]; |
| + // Make a copy of the SkBitmaps to ensure that we can safely use the image |
| + // data on the FILE thread. |
| + params.avatar_image_1x = GetImageResourceSkBitmapCopy(resource_id_1x); |
| + params.avatar_image_2x = GetImageResourceSkBitmapCopy(resource_id_2x); |
| + } |
| } |
| BrowserThread::PostTask( |
| BrowserThread::FILE, FROM_HERE, |