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

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: 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
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 aa8d8986121fcb6c9e3abecaa0aa076fba02f1e5..9b8998d02a8e629fc00df5f66d476b902e47cc70 100644
--- a/chrome/browser/profiles/gaia_info_update_service.cc
+++ b/chrome/browser/profiles/gaia_info_update_service.cc
@@ -78,9 +78,11 @@ 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() {
+int GAIAInfoUpdateService::GetDesiredImageSideLength() const {
return 256;
}
@@ -88,10 +90,14 @@ Profile* GAIAInfoUpdateService::GetBrowserProfile() {
return profile_;
}
-bool GAIAInfoUpdateService::ShouldUseOAuthRefreshToken() {
+bool GAIAInfoUpdateService::ShouldUseOAuthRefreshToken() const {
return true;
}
+std::string GAIAInfoUpdateService::GetCachedPictureURL() const {
+ return profile_->GetPrefs()->GetString(prefs::kProfileGAIAInfoPictureURL);
+}
+
void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
bool success) {
// Save the last updated time.
@@ -107,6 +113,9 @@ void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
string16 full_name = downloader->GetProfileFullName();
SkBitmap bitmap = downloader->GetProfilePicture();
+ ProfileDownloader::PictureStatus picture_status =
+ downloader->GetProfilePictureStatus();
+ std::string picture_url = downloader->GetProfilePictureURL();
profile_image_downloader_.reset();
ProfileInfoCache& cache =
@@ -116,8 +125,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_status == 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_status == 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
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service.h ('k') | chrome/browser/profiles/gaia_info_update_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698