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

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

Issue 222313005: [Profiles] Download high-res avatars using the --new-profile-management flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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.h » ('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 0ae3f29f783da30227a3efb7acd85c90164b3178..13241943d9bc1dd0700c4d7a01b7c4addf65529e 100644
--- a/chrome/browser/profiles/profile_avatar_icon_util.cc
+++ b/chrome/browser/profiles/profile_avatar_icon_util.cc
@@ -4,10 +4,13 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
+#include "base/file_util.h"
#include "base/format_macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
+#include "chrome/common/chrome_paths.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkPaint.h"
@@ -17,6 +20,7 @@
#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"
#include "ui/gfx/image/image_skia_operations.h"
// Helper methods for transforming and drawing avatar icons.
@@ -25,7 +29,6 @@ namespace {
// Determine what the scaled height of the avatar icon should be for a
// specified width, to preserve the aspect ratio.
int GetScaledAvatarHeightForWidth(int width, const gfx::ImageSkia& avatar) {
-
// Multiply the width by the inverted aspect ratio (height over
// width), and then add 0.5 to ensure the int truncation rounds nicely.
int scaled_height = width *
@@ -220,7 +223,8 @@ gfx::Image GetSizedAvatarIcon(const gfx::Image& image,
size,
std::min(width, height),
AvatarImageSource::POSITION_CENTER,
- AvatarImageSource::BORDER_NONE));
+ is_rectangle ? AvatarImageSource::BORDER_NORMAL :
+ AvatarImageSource::BORDER_NONE));
return gfx::Image(gfx::ImageSkia(source.release(), size));
}
@@ -327,6 +331,14 @@ const char* GetNoHighResAvatarFileName() {
return kNoHighResAvatar;
}
+base::FilePath GetPathOfHighResAvatarAtIndex(size_t index) {
+ std::string file_name = GetDefaultAvatarIconResourceInfo(index)->filename;
+ base::FilePath user_data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
+ return user_data_dir.AppendASCII(
+ kHighResAvatarFolderName).AppendASCII(file_name);
+}
+
std::string GetDefaultAvatarIconUrl(size_t index) {
DCHECK(IsDefaultAvatarIconIndex(index));
return base::StringPrintf("%s%" PRIuS, kDefaultUrlPrefix, index);
@@ -336,8 +348,7 @@ bool IsDefaultAvatarIconIndex(size_t index) {
return index < kDefaultAvatarIconsCount;
}
-bool IsDefaultAvatarIconUrl(const std::string& url,
- size_t* icon_index) {
+bool IsDefaultAvatarIconUrl(const std::string& url, size_t* icon_index) {
DCHECK(icon_index);
if (url.find(kDefaultUrlPrefix) != 0)
return false;
« no previous file with comments | « chrome/browser/profiles/profile_avatar_icon_util.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698