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