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

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

Issue 686353002: Fix transparent avatar icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix linux compile Created 6 years, 2 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
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 e0b6b86145a054966d1bced9289be201a4e88b6d..56e1def5de6ea2175ecf040c84675641af97561e 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -73,8 +73,8 @@ const int kProfileAvatarBadgeSize = kShortcutIconSize / 2;
const int kCurrentProfileIconVersion = 3;
-// 2x sized profile avatar icons. Mirrors |kDefaultAvatarIconResources| in
-// profile_info_cache.cc.
+// 2x sized profile avatar icons. Mirrors |GetDefaultAvatarIconResourceInfo()|
+// in profile_avatar_icon_util.cc
noms (inactive) 2014/10/30 17:39:08 nit: needs to end in a .
Roger Tawa OOO till Jul 10th 2014/10/31 19:44:39 Removed this code from CL.
const int kProfileAvatarIconResources2x[] = {
IDR_PROFILE_AVATAR_2X_0,
IDR_PROFILE_AVATAR_2X_1,
@@ -599,14 +599,6 @@ SkBitmap GetSkBitmapCopy(const gfx::Image& image) {
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 {
@@ -813,35 +805,12 @@ void ProfileShortcutManagerWin::CreateOrUpdateShortcutsForProfileAtPath(
if (!remove_badging) {
params.profile_name = cache->GetNameOfProfileAtIndex(profile_index);
- // 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);
- 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_GE(image->Width(), IconUtil::kLargeIconSize);
- 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);
- }
+ gfx::Image image_1x;
+ gfx::Image image_2x;
+ GetBadgingAvatarImages(profile_manager_, profile_path, &image_1x,
+ &image_2x);
+ params.avatar_image_1x = GetSkBitmapCopy(image_1x);
+ params.avatar_image_2x = GetSkBitmapCopy(image_2x);
}
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
@@ -872,3 +841,52 @@ void ProfileShortcutManagerWin::Observe(
break;
}
}
+
+// static
+void ProfileShortcutManagerWin::GetBadgingAvatarImages(
+ ProfileManager* profile_manager,
+ const base::FilePath& profile_path,
+ gfx::Image* image_1x,
+ gfx::Image* image_2x) {
+ const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
+ size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path);
+
+ // 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);
+ if (image) {
+ if (image_1x)
+ *image_1x = *image;
+ // Gaia images are 256px, which makes them big enough to use in the
+ // large icon case as well.
+ DCHECK_GE(image->Width(), IconUtil::kLargeIconSize);
+ if (image_2x)
+ *image_2x = *image;
+ 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];
+ if (image_1x) {
+ *image_1x =
+ ResourceBundle::GetSharedInstance().GetNativeImageNamed(
noms (inactive) 2014/10/30 17:39:08 Maybe you get pull the ResourceBundle instance out
Roger Tawa OOO till Jul 10th 2014/10/31 19:44:39 Removed this code from CL.
+ resource_id_1x);
+ }
+ if (image_2x) {
+ *image_2x =
+ ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ resource_id_2x);
+ }
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698