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

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

Issue 8742009: Cache GAIA profile picture URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 9 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
« no previous file with comments | « chrome/browser/profiles/profile_downloader.h ('k') | chrome/browser/profiles/profile_downloader_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_downloader.cc
diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc
index 428df3a3fb733363b62061f713d0455b5a41e559..1b24d3dbdf6c6d17a81247a134cdfa0519ed2448 100644
--- a/chrome/browser/profiles/profile_downloader.cc
+++ b/chrome/browser/profiles/profile_downloader.cc
@@ -184,7 +184,8 @@ bool ProfileDownloader::IsDefaultProfileImageURL(const std::string& url) const {
}
ProfileDownloader::ProfileDownloader(ProfileDownloaderDelegate* delegate)
- : delegate_(delegate) {
+ : delegate_(delegate),
+ picture_status_(PICTURE_FAILED) {
DCHECK(delegate_);
}
@@ -226,6 +227,15 @@ SkBitmap ProfileDownloader::GetProfilePicture() const {
return profile_picture_;
}
+ProfileDownloader::PictureStatus ProfileDownloader::GetProfilePictureStatus()
+ const {
+ return picture_status_;
+}
+
+std::string ProfileDownloader::GetProfilePictureURL() const {
+ return picture_url_;
+}
+
void ProfileDownloader::StartFetchingImage() {
VLOG(1) << "Fetching user entry with token: " << auth_token_;
user_entry_fetcher_.reset(content::URLFetcher::Create(
@@ -280,10 +290,19 @@ void ProfileDownloader::OnURLFetchComplete(const content::URLFetcher* source) {
return;
}
if (IsDefaultProfileImageURL(image_url)) {
+ VLOG(1) << "User has default profile picture";
+ picture_status_ = PICTURE_DEFAULT;
+ delegate_->OnDownloadComplete(this, true);
+ return;
+ }
+ if (!image_url.empty() && image_url == delegate_->GetCachedPictureURL()) {
+ VLOG(1) << "Picture URL matches cached picture URL";
+ picture_status_ = PICTURE_CACHED;
delegate_->OnDownloadComplete(this, true);
return;
}
VLOG(1) << "Fetching profile image from " << image_url;
+ picture_url_ = image_url;
profile_image_fetcher_.reset(content::URLFetcher::Create(
GURL(image_url), content::URLFetcher::GET, this));
profile_image_fetcher_->SetRequestContext(
@@ -310,6 +329,7 @@ void ProfileDownloader::OnImageDecoded(const ImageDecoder* decoder,
skia::ImageOperations::RESIZE_BEST,
image_size,
image_size);
+ picture_status_ = PICTURE_SUCCESS;
delegate_->OnDownloadComplete(this, true);
}
« no previous file with comments | « chrome/browser/profiles/profile_downloader.h ('k') | chrome/browser/profiles/profile_downloader_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698