| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/profile_downloader.h" | 5 #include "chrome/browser/profiles/profile_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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 void ProfileDownloader::StartFetchingImage() { | 223 void ProfileDownloader::StartFetchingImage() { |
| 224 VLOG(1) << "Fetching user entry with token: " << auth_token_; | 224 VLOG(1) << "Fetching user entry with token: " << auth_token_; |
| 225 account_info_ = account_tracker_service_->GetAccountInfo(account_id_); | 225 account_info_ = account_tracker_service_->GetAccountInfo(account_id_); |
| 226 | 226 |
| 227 if (delegate_->IsPreSignin()) { | 227 if (delegate_->IsPreSignin()) { |
| 228 AccountFetcherServiceFactory::GetForProfile(delegate_->GetBrowserProfile()) | 228 AccountFetcherServiceFactory::GetForProfile(delegate_->GetBrowserProfile()) |
| 229 ->FetchUserInfoBeforeSignin(account_id_); | 229 ->FetchUserInfoBeforeSignin(account_id_); |
| 230 } | 230 } |
| 231 | 231 |
| 232 if (account_info_.IsValid()) | 232 if (account_info_.IsValid()) { |
| 233 // FetchImageData might call the delegate's OnProfileDownloadSuccess |
| 234 // synchronously, causing |this| to be deleted so there should not be more |
| 235 // code after it. |
| 233 FetchImageData(); | 236 FetchImageData(); |
| 234 else | 237 } else { |
| 235 waiting_for_account_info_ = true; | 238 waiting_for_account_info_ = true; |
| 239 } |
| 236 } | 240 } |
| 237 | 241 |
| 238 void ProfileDownloader::StartFetchingOAuth2AccessToken() { | 242 void ProfileDownloader::StartFetchingOAuth2AccessToken() { |
| 239 Profile* profile = delegate_->GetBrowserProfile(); | 243 Profile* profile = delegate_->GetBrowserProfile(); |
| 240 OAuth2TokenService::ScopeSet scopes; | 244 OAuth2TokenService::ScopeSet scopes; |
| 241 scopes.insert(GaiaConstants::kGoogleUserInfoProfile); | 245 scopes.insert(GaiaConstants::kGoogleUserInfoProfile); |
| 242 // Increase scope to get hd attribute to determine if lock should be enabled. | 246 // Increase scope to get hd attribute to determine if lock should be enabled. |
| 243 if (switches::IsNewProfileManagement()) | 247 if (switches::IsNewProfileManagement()) |
| 244 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); | 248 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); |
| 245 ProfileOAuth2TokenService* token_service = | 249 ProfileOAuth2TokenService* token_service = |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 this, ProfileDownloaderDelegate::TOKEN_ERROR); | 382 this, ProfileDownloaderDelegate::TOKEN_ERROR); |
| 379 } | 383 } |
| 380 | 384 |
| 381 void ProfileDownloader::OnAccountUpdated(const AccountInfo& info) { | 385 void ProfileDownloader::OnAccountUpdated(const AccountInfo& info) { |
| 382 if (info.account_id == account_id_ && info.IsValid()) { | 386 if (info.account_id == account_id_ && info.IsValid()) { |
| 383 account_info_ = info; | 387 account_info_ = info; |
| 384 | 388 |
| 385 // If the StartFetchingImage was called before we had valid info, the | 389 // If the StartFetchingImage was called before we had valid info, the |
| 386 // downloader has been waiting so we need to fetch the image data now. | 390 // downloader has been waiting so we need to fetch the image data now. |
| 387 if (waiting_for_account_info_) { | 391 if (waiting_for_account_info_) { |
| 392 waiting_for_account_info_ = false; |
| 393 // FetchImageData might call the delegate's OnProfileDownloadSuccess |
| 394 // synchronously, causing |this| to be deleted so there should not be more |
| 395 // code after it. |
| 388 FetchImageData(); | 396 FetchImageData(); |
| 389 waiting_for_account_info_ = false; | |
| 390 } | 397 } |
| 391 } | 398 } |
| 392 } | 399 } |
| OLD | NEW |