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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/profiles/profile_downloader_delegate.h" | 18 #include "chrome/browser/profiles/profile_downloader_delegate.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 20 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 22 #include "chrome/browser/signin/signin_manager.h" |
| 23 #include "chrome/browser/signin/signin_manager_factory.h" |
22 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
23 #include "google_apis/gaia/gaia_constants.h" | 25 #include "google_apis/gaia/gaia_constants.h" |
24 #include "google_apis/gaia/gaia_urls.h" | 26 #include "google_apis/gaia/gaia_urls.h" |
25 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
26 #include "net/url_request/url_fetcher.h" | 28 #include "net/url_request/url_fetcher.h" |
27 #include "net/url_request/url_request_status.h" | 29 #include "net/url_request/url_request_status.h" |
28 #include "skia/ext/image_operations.h" | 30 #include "skia/ext/image_operations.h" |
29 #include "url/gurl.h" | 31 #include "url/gurl.h" |
30 | 32 |
31 using content::BrowserThread; | 33 using content::BrowserThread; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ProfileOAuth2TokenServiceFactory::GetForProfile( | 228 ProfileOAuth2TokenServiceFactory::GetForProfile( |
227 delegate_->GetBrowserProfile()); | 229 delegate_->GetBrowserProfile()); |
228 if (!service) { | 230 if (!service) { |
229 // This can happen in some test paths. | 231 // This can happen in some test paths. |
230 LOG(WARNING) << "User has no token service"; | 232 LOG(WARNING) << "User has no token service"; |
231 delegate_->OnProfileDownloadFailure( | 233 delegate_->OnProfileDownloadFailure( |
232 this, ProfileDownloaderDelegate::TOKEN_ERROR); | 234 this, ProfileDownloaderDelegate::TOKEN_ERROR); |
233 return; | 235 return; |
234 } | 236 } |
235 | 237 |
| 238 SigninManagerBase* signin_manager = |
| 239 SigninManagerFactory::GetForProfile(delegate_->GetBrowserProfile()); |
236 account_id_ = | 240 account_id_ = |
237 account_id.empty() ? service->GetPrimaryAccountId() : account_id; | 241 account_id.empty() ? |
| 242 signin_manager->GetAuthenticatedAccountId() : account_id; |
238 if (service->RefreshTokenIsAvailable(account_id_)) { | 243 if (service->RefreshTokenIsAvailable(account_id_)) { |
239 StartFetchingOAuth2AccessToken(); | 244 StartFetchingOAuth2AccessToken(); |
240 } else { | 245 } else { |
241 service->AddObserver(this); | 246 service->AddObserver(this); |
242 } | 247 } |
243 } | 248 } |
244 | 249 |
245 base::string16 ProfileDownloader::GetProfileFullName() const { | 250 base::string16 ProfileDownloader::GetProfileFullName() const { |
246 return profile_full_name_; | 251 return profile_full_name_; |
247 } | 252 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 void ProfileDownloader::OnGetTokenFailure( | 423 void ProfileDownloader::OnGetTokenFailure( |
419 const OAuth2TokenService::Request* request, | 424 const OAuth2TokenService::Request* request, |
420 const GoogleServiceAuthError& error) { | 425 const GoogleServiceAuthError& error) { |
421 DCHECK_EQ(request, oauth2_access_token_request_.get()); | 426 DCHECK_EQ(request, oauth2_access_token_request_.get()); |
422 oauth2_access_token_request_.reset(); | 427 oauth2_access_token_request_.reset(); |
423 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed:" | 428 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed:" |
424 << error.ToString(); | 429 << error.ToString(); |
425 delegate_->OnProfileDownloadFailure( | 430 delegate_->OnProfileDownloadFailure( |
426 this, ProfileDownloaderDelegate::TOKEN_ERROR); | 431 this, ProfileDownloaderDelegate::TOKEN_ERROR); |
427 } | 432 } |
OLD | NEW |