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

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

Issue 660813002: [Win] Add a fast profile switcher to the Windows taskbar item. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile Created 6 years, 1 month 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_avatar_icon_util.cc
diff --git a/chrome/browser/profiles/profile_avatar_icon_util.cc b/chrome/browser/profiles/profile_avatar_icon_util.cc
index b074d11f11ca28df535c0d1f871a72ee732fadd6..6c9ea0b39ad187707b17fcabd8c02d6dd26baeb6 100644
--- a/chrome/browser/profiles/profile_avatar_icon_util.cc
+++ b/chrome/browser/profiles/profile_avatar_icon_util.cc
@@ -10,6 +10,9 @@
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile_info_cache.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_paths.h"
#include "grit/theme_resources.h"
#include "skia/ext/image_operations.h"
@@ -17,6 +20,7 @@
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "third_party/skia/include/core/SkXfermode.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image.h"
@@ -287,6 +291,35 @@ SkBitmap GetAvatarIconAsSquare(const SkBitmap& source_bitmap,
return square_bitmap;
}
+void GetTransparentBackgroundProfileAvatar(const base::FilePath& profile_path,
tapted 2014/11/03 23:57:06 nit: move to end of file? (to be consistent with d
noms (inactive) 2014/11/04 20:03:09 Turns out everything was in a whack order, so I re
+ gfx::Image* image,
+ bool* is_rectangle) {
+ const ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ size_t index = cache.GetIndexOfProfileWithPath(profile_path);
+ if (index == std::string::npos) {
+ NOTREACHED();
+ return;
+ }
+
+ // If there is a Gaia image available, try to use that.
+ if (cache.IsUsingGAIAPictureOfProfileAtIndex(index)) {
+ const gfx::Image* gaia_image = cache.GetGAIAPictureOfProfileAtIndex(index);
+ if (gaia_image) {
+ *image = *gaia_image;
+ *is_rectangle = true;
+ return;
+ }
+ }
+
+ // Otherwise, use the default resource, not the downloaded high-res one.
+ const size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index);
+ const int resource_id =
+ profiles::GetDefaultAvatarIconResourceIDAtIndex(icon_index);
+ *image = ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
+ *is_rectangle = false;
+}
+
// Helper methods for accessing, transforming and drawing avatar icons.
size_t GetDefaultAvatarIconCount() {
return kDefaultAvatarIconsCount;

Powered by Google App Engine
This is Rietveld 408576698