OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/profiles/gaia_info_update_service.h" | 5 #include "chrome/browser/profiles/gaia_info_update_service.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 if (profile_index == std::string::npos) | 125 if (profile_index == std::string::npos) |
126 return; | 126 return; |
127 if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { | 127 if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { |
128 profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, | 128 profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, |
129 picture_url); | 129 picture_url); |
130 gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap); | 130 gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap); |
131 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); | 131 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); |
132 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { | 132 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { |
133 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); | 133 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); |
134 } | 134 } |
135 | |
136 // Order matters here for shortcut management, like in | |
137 // ProfileShortcutManagerWin::OnProfileAdded, as the picture update does not | |
138 // allow us to change the target, so we have to apply any renaming first. We | |
139 // also need to re-fetch the index, as changing the profile name may alter it. | |
140 profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); | |
141 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); | |
142 } | 135 } |
143 | 136 |
144 void GAIAInfoUpdateService::OnProfileDownloadFailure( | 137 void GAIAInfoUpdateService::OnProfileDownloadFailure( |
145 ProfileDownloader* downloader, | 138 ProfileDownloader* downloader, |
146 ProfileDownloaderDelegate::FailureReason reason) { | 139 ProfileDownloaderDelegate::FailureReason reason) { |
147 profile_image_downloader_.reset(); | 140 profile_image_downloader_.reset(); |
148 | 141 |
149 // Save the last updated time. | 142 // Save the last updated time. |
150 last_updated_ = base::Time::Now(); | 143 last_updated_ = base::Time::Now(); |
151 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime, | 144 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 201 |
209 void GAIAInfoUpdateService::GoogleSigninSucceeded( | 202 void GAIAInfoUpdateService::GoogleSigninSucceeded( |
210 const std::string& username, | 203 const std::string& username, |
211 const std::string& password) { | 204 const std::string& password) { |
212 OnUsernameChanged(username); | 205 OnUsernameChanged(username); |
213 } | 206 } |
214 | 207 |
215 void GAIAInfoUpdateService::GoogleSignedOut(const std::string& username) { | 208 void GAIAInfoUpdateService::GoogleSignedOut(const std::string& username) { |
216 OnUsernameChanged(std::string()); | 209 OnUsernameChanged(std::string()); |
217 } | 210 } |
OLD | NEW |