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

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

Issue 212603011: Newly created profiles should have the grey silhouette as avatar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Post-Rebase merge. Created 6 years, 8 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_avatar_icon_util.h ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 30c0661c8eb32883ca27a1e4ce5c0b060651a606..d7df02f68f4f1caca1ad08d85dc9ab0fa0c2a1cc 100644
--- a/chrome/browser/profiles/profile_avatar_icon_util.cc
+++ b/chrome/browser/profiles/profile_avatar_icon_util.cc
@@ -177,7 +177,7 @@ void AvatarImageSource::Draw(gfx::Canvas* canvas) {
namespace profiles {
const int kAvatarIconWidth = 38;
-const int kAvatarIconHeight = 31;
+const int kAvatarIconHeight = 38;
const int kAvatarIconPadding = 2;
const SkColor kAvatarTutorialBackgroundColor = SkColorSetRGB(0x42, 0x85, 0xf4);
const SkColor kAvatarTutorialContentTextColor = SkColorSetRGB(0xc6, 0xda, 0xfc);
@@ -213,8 +213,12 @@ const int kDefaultAvatarIconResources[] = {
IDR_PROFILE_AVATAR_23,
IDR_PROFILE_AVATAR_24,
IDR_PROFILE_AVATAR_25,
+ IDR_PROFILE_AVATAR_26,
};
+// This avatar does not exist on the server, the high res copy is in the build.
+const char* kNoHighResAvatar = "NothingToDownload";
viettrungluu 2014/04/11 18:08:20 const char kNoHighResAvatar[]
Mike Lerman 2014/04/14 18:51:29 Done.
+
// File names for the high-res avatar icon resources. In the same order as
// the avatars in kDefaultAvatarIconResources.
const char* kDefaultAvatarIconResourceFileNames[] = {
viettrungluu 2014/04/11 18:08:20 const char* const
Mike Lerman 2014/04/14 18:51:29 Done.
@@ -244,6 +248,7 @@ const char* kDefaultAvatarIconResourceFileNames[] = {
"avatar_margarita.png",
"avatar_note.png",
"avatar_sun_cloud.png",
+ kNoHighResAvatar,
};
const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources);
@@ -251,35 +256,42 @@ const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources);
// The first 8 icons are generic.
const size_t kGenericAvatarIconsCount = 8;
+// The avatar used as a placeholder (grey silhouette).
+const int kPlaceholderAvatarIcon = 26;
+
gfx::Image GetSizedAvatarIconWithBorder(const gfx::Image& image,
- bool is_rectangle,
+ bool is_gaia_image,
int width, int height) {
- if (!is_rectangle)
+ // The image requires no border or resizing.
+ if (!is_gaia_image && image.Height() <= height)
return image;
gfx::Size size(width, height);
- // Source for a centered, sized icon with a border.
+ // Source for a centered, sized icon.
+ // GAIA images get a border.
scoped_ptr<gfx::ImageSkiaSource> source(
new AvatarImageSource(
*image.ToImageSkia(),
size,
std::min(width, height),
AvatarImageSource::POSITION_CENTER,
- AvatarImageSource::BORDER_NORMAL));
+ is_gaia_image ? AvatarImageSource::BORDER_NORMAL :
+ AvatarImageSource::BORDER_NONE));
return gfx::Image(gfx::ImageSkia(source.release(), size));
}
gfx::Image GetAvatarIconForMenu(const gfx::Image& image,
- bool is_rectangle) {
+ bool is_gaia_image) {
return GetSizedAvatarIconWithBorder(
- image, is_rectangle, kAvatarIconWidth, kAvatarIconHeight);
+ image, is_gaia_image, kAvatarIconWidth, kAvatarIconHeight);
}
gfx::Image GetAvatarIconForWebUI(const gfx::Image& image,
- bool is_rectangle) {
- if (!is_rectangle)
+ bool is_gaia_image) {
+ // The image requires no border or resizing.
+ if (!is_gaia_image && image.Height() <= kAvatarIconHeight)
return image;
gfx::Size size(kAvatarIconWidth, kAvatarIconHeight);
@@ -297,10 +309,11 @@ gfx::Image GetAvatarIconForWebUI(const gfx::Image& image,
}
gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image,
- bool is_rectangle,
+ bool is_gaia_image,
int dst_width,
int dst_height) {
- if (!is_rectangle)
+ // The image requires no border or resizing.
+ if (!is_gaia_image && image.Height() <= kAvatarIconHeight)
return image;
int size = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight),
@@ -308,14 +321,15 @@ gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image,
gfx::Size dst_size(dst_width, dst_height);
// Source for a sized icon drawn at the bottom center of the canvas,
- // with an etched border.
+ // with an etched border (for GAIA images).
scoped_ptr<gfx::ImageSkiaSource> source(
new AvatarImageSource(
*image.ToImageSkia(),
dst_size,
size,
AvatarImageSource::POSITION_BOTTOM_CENTER,
- AvatarImageSource::BORDER_ETCHED));
+ is_gaia_image ? AvatarImageSource::BORDER_ETCHED :
+ AvatarImageSource::BORDER_NONE));
return gfx::Image(gfx::ImageSkia(source.release(), dst_size));
}
@@ -329,6 +343,14 @@ size_t GetGenericAvatarIconCount() {
return kGenericAvatarIconsCount;
}
+int GetPlaceholderAvatarIndex() {
+ return kPlaceholderAvatarIcon;
+}
+
+int GetPlaceholderAvatarIconResourceID() {
+ return IDR_PROFILE_AVATAR_26;
+}
+
int GetDefaultAvatarIconResourceIDAtIndex(size_t index) {
DCHECK(IsDefaultAvatarIconIndex(index));
return kDefaultAvatarIconResources[index];
@@ -338,6 +360,10 @@ const char* GetDefaultAvatarIconFileNameAtIndex(size_t index) {
return kDefaultAvatarIconResourceFileNames[index];
}
+const char* GetNoHighResAvatarFileName() {
+ return kNoHighResAvatar;
+}
+
std::string GetDefaultAvatarIconUrl(size_t index) {
DCHECK(IsDefaultAvatarIconIndex(index));
return base::StringPrintf("%s%" PRIuS, kDefaultUrlPrefix, index);
« no previous file with comments | « chrome/browser/profiles/profile_avatar_icon_util.h ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698