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

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

Issue 8742009: Cache GAIA profile picture URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: chrome/browser/profiles/gaia_info_update_service.cc
diff --git a/chrome/browser/profiles/gaia_info_update_service.cc b/chrome/browser/profiles/gaia_info_update_service.cc
index 0f58dc0d4b557cc0018d9f40d7aefb49d96ea4e3..b1672e084c87f443394957900ab2a4022e512871 100644
--- a/chrome/browser/profiles/gaia_info_update_service.cc
+++ b/chrome/browser/profiles/gaia_info_update_service.cc
@@ -78,6 +78,8 @@ bool GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(Profile* profile) {
void GAIAInfoUpdateService::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterInt64Pref(
prefs::kProfileGAIAInfoUpdateTime, 0, PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterStringPref(
+ prefs::kProfileGAIAInfoPictureURL, "", PrefService::UNSYNCABLE_PREF);
}
int GAIAInfoUpdateService::GetDesiredImageSideLength() {
@@ -88,6 +90,10 @@ Profile* GAIAInfoUpdateService::GetBrowserProfile() {
return profile_;
}
+std::string GAIAInfoUpdateService::GetCachedPictureURL() {
+ return profile_->GetPrefs()->GetString(prefs::kProfileGAIAInfoPictureURL);
+}
+
void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
bool success) {
// Save the last updated time.
@@ -103,6 +109,9 @@ void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
string16 full_name = downloader->GetProfileFullName();
SkBitmap bitmap = downloader->GetProfilePicture();
+ ProfileDownloader::PictureResult picture_result =
+ downloader->GetProfilePictureResult();
+ std::string picture_url = downloader->GetProfilePictureURL();
profile_image_downloader_.reset();
ProfileInfoCache& cache =
@@ -112,8 +121,14 @@ void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
return;
cache.SetGAIANameOfProfileAtIndex(profile_index, full_name);
- gfx::Image gfx_image(new SkBitmap(bitmap));
- cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image);
+ if (picture_result == ProfileDownloader::PICTURE_SUCCESS) {
+ profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL,
+ picture_url);
+ gfx::Image gfx_image(new SkBitmap(bitmap));
+ cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image);
+ } else if (picture_result == ProfileDownloader::PICTURE_DEFAULT) {
+ cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL);
+ }
// If this profile hasn't switched to using GAIA information for the profile
// name and picture then switch it now. Once the profile has switched this

Powered by Google App Engine
This is Rietveld 408576698