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

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

Issue 1487283005: Implement the new Sync Confirmation dialog on Linux and Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted a few sign changes missed in last patchset Created 4 years, 11 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_downloader.cc
diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc
index 8f0b2469e4a65a1e8e68bb801fa232fdcbfa15c6..01e192953768c36a1f792ea563804addb1a4c04b 100644
--- a/chrome/browser/profiles/profile_downloader.cc
+++ b/chrome/browser/profiles/profile_downloader.cc
@@ -18,6 +18,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_downloader_delegate.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/account_fetcher_service_factory.h"
@@ -47,11 +48,6 @@ namespace {
const char kAuthorizationHeader[] =
"Authorization: Bearer %s";
-// Path format for specifying thumbnail's size.
-const char kThumbnailSizeFormat[] = "s%d-c";
-// Default thumbnail size.
-const int kDefaultThumbnailSize = 64;
-
// Separator of URL path components.
const char kURLPathSeparator = '/';
@@ -70,55 +66,6 @@ const int kPhotoIdPathComponentIndex = 2;
// Index of path component with photo version.
const int kPhotoVersionPathComponentIndex = 3;
-// Given an image URL this function builds a new URL set to |size|.
-// For example, if |size| was set to 256 and |old_url| was either:
-// https://example.com/--Abc/AAAAAAAAAAI/AAAAAAAAACQ/Efg/photo.jpg
-// or
-// https://example.com/--Abc/AAAAAAAAAAI/AAAAAAAAACQ/Efg/s64-c/photo.jpg
-// then return value in |new_url| would be:
-// https://example.com/--Abc/AAAAAAAAAAI/AAAAAAAAACQ/Efg/s256-c/photo.jpg
-bool GetImageURLWithSize(const GURL& old_url, int size, GURL* new_url) {
- DCHECK(new_url);
- std::vector<std::string> components = base::SplitString(
- old_url.path(), std::string(1, kURLPathSeparator),
- base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
- if (components.size() == 0)
- return false;
-
- const std::string& old_spec = old_url.spec();
- std::string default_size_component(
- base::StringPrintf(kThumbnailSizeFormat, kDefaultThumbnailSize));
- std::string new_size_component(
- base::StringPrintf(kThumbnailSizeFormat, size));
-
- size_t pos = old_spec.find(default_size_component);
- size_t end = std::string::npos;
- if (pos != std::string::npos) {
- // The default size is already specified in the URL so it needs to be
- // replaced with the new size.
- end = pos + default_size_component.size();
- } else {
- // The default size is not in the URL so try to insert it before the last
- // component.
- const std::string& file_name = old_url.ExtractFileName();
- if (!file_name.empty()) {
- pos = old_spec.find(file_name);
- end = pos - 1;
- }
- }
-
- if (pos != std::string::npos) {
- std::string new_spec = old_spec.substr(0, pos) + new_size_component +
- old_spec.substr(end);
- *new_url = GURL(new_spec);
- return new_url->is_valid();
- }
-
- // We can't set the image size, just use the default size.
- *new_url = old_url;
- return true;
-}
-
} // namespace
// static
@@ -214,9 +161,10 @@ ProfileDownloader::PictureStatus ProfileDownloader::GetProfilePictureStatus()
std::string ProfileDownloader::GetProfilePictureURL() const {
GURL url;
- if (GetImageURLWithSize(GURL(account_info_.picture_url),
- delegate_->GetDesiredImageSideLength(),
- &url)) {
+ if (profiles::GetImageURLWithThumbnailSize(
+ GURL(account_info_.picture_url),
+ delegate_->GetDesiredImageSideLength(),
+ &url)) {
return url.spec();
}
return account_info_.picture_url;

Powered by Google App Engine
This is Rietveld 408576698