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

Unified Diff: chrome/browser/profiles/profile_shortcut_manager_win.cc

Issue 462713002: [Win] Profile desktop shortcuts should use the Gaia avatar if it's in use. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: alexei comments and revert them scoped_ptrs Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profiles/profile_info_cache_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0854b93bd5f92e159261c8ab308de71fd819d254 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,17 +589,22 @@ base::string16 SanitizeShortcutProfileNameString(
return sanitized;
}
+// Returns a copied SkBitmap for the given image that can be safely passed to
+// another thread.
+SkBitmap GetSkBitmapCopy(const gfx::Image& image) {
+ 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);
DCHECK(!image.IsEmpty());
Alexei Svitkine (slow) 2014/08/12 14:54:07 Nit: Move this check to GetSkBitmapCopy() since th
noms (inactive) 2014/08/12 18:52:53 Done.
-
- const SkBitmap* image_bitmap = image.ToSkBitmap();
- SkBitmap bitmap_copy;
- image_bitmap->deepCopyTo(&bitmap_copy);
- return bitmap_copy;
+ return GetSkBitmapCopy(image);
}
} // namespace
@@ -808,15 +813,24 @@ 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.
+ if (cache->IsUsingGAIAPictureOfProfileAtIndex(profile_index)) {
+ const gfx::Image* image =
+ cache->GetGAIAPictureOfProfileAtIndex(profile_index);
Alexei Svitkine (slow) 2014/08/12 14:54:07 According to the docs for that method: // Retur
noms (inactive) 2014/08/12 18:52:53 Done.
+ params.avatar_image_1x = GetSkBitmapCopy(*image);
+ params.avatar_image_2x = params.avatar_image_1x;
gab 2014/08/11 20:49:34 Maybe add a comment about explaining why it's okay
noms (inactive) 2014/08/12 18:52:53 Done.
+ } else {
+ 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,
« no previous file with comments | « chrome/browser/profiles/profile_info_cache_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698