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

Side by Side Diff: chrome/browser/chromeos/login/profile_image_downloader.cc

Issue 8541002: [cros] Initial user image loading and repeated profile image loading fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Whitespace 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/login/profile_image_downloader.h" 5 #include "chrome/browser/chromeos/login/profile_image_downloader.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 ProfileImageDownloader::ProfileImageDownloader(Delegate* delegate) 162 ProfileImageDownloader::ProfileImageDownloader(Delegate* delegate)
163 : delegate_(delegate) { 163 : delegate_(delegate) {
164 } 164 }
165 165
166 void ProfileImageDownloader::Start() { 166 void ProfileImageDownloader::Start() {
167 VLOG(1) << "Starting profile image downloader..."; 167 VLOG(1) << "Starting profile image downloader...";
168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
169 169
170 // TODO(ivankr): ignore further Start() calls.
171
172 TokenService* service = 170 TokenService* service =
173 ProfileManager::GetDefaultProfile()->GetTokenService(); 171 ProfileManager::GetDefaultProfile()->GetTokenService();
174 if (!service) { 172 if (!service) {
175 // This can happen in some test paths. 173 // This can happen in some test paths.
176 LOG(WARNING) << "User has no token service"; 174 LOG(WARNING) << "User has no token service";
177 if (delegate_) 175 if (delegate_)
178 delegate_->OnDownloadFailure(); 176 delegate_->OnDownloadFailure();
179 return; 177 return;
180 } 178 }
181 if (service->HasTokenForService(GaiaConstants::kPicasaService)) { 179 if (service->HasTokenForService(GaiaConstants::kPicasaService)) {
182 auth_token_ = 180 auth_token_ =
183 service->GetTokenForService(GaiaConstants::kPicasaService); 181 service->GetTokenForService(GaiaConstants::kPicasaService);
184 StartFetchingImage(); 182 StartFetchingImage();
185 } else if (registrar_.IsEmpty()) { 183 } else {
186 registrar_.Add(this, 184 registrar_.Add(this,
187 chrome::NOTIFICATION_TOKEN_AVAILABLE, 185 chrome::NOTIFICATION_TOKEN_AVAILABLE,
188 content::Source<TokenService>(service)); 186 content::Source<TokenService>(service));
189 registrar_.Add(this, 187 registrar_.Add(this,
190 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, 188 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED,
191 content::Source<TokenService>(service)); 189 content::Source<TokenService>(service));
192 } 190 }
193 } 191 }
194 192
195 void ProfileImageDownloader::StartFetchingImage() { 193 void ProfileImageDownloader::StartFetchingImage() {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } else { 288 } else {
291 if (token_details->service() == GaiaConstants::kPicasaService) { 289 if (token_details->service() == GaiaConstants::kPicasaService) {
292 LOG(WARNING) << "ProfileImageDownloader: token request failed"; 290 LOG(WARNING) << "ProfileImageDownloader: token request failed";
293 if (delegate_) 291 if (delegate_)
294 delegate_->OnDownloadFailure(); 292 delegate_->OnDownloadFailure();
295 } 293 }
296 } 294 }
297 } 295 }
298 296
299 } // namespace chromeos 297 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/profile_image_downloader.h ('k') | chrome/browser/chromeos/login/user_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698