| 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/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.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/string_split.h" | 13 #include "base/string_split.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/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/signin/about_signin_internals.h" |
| 20 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 19 #include "chrome/browser/signin/token_service.h" | 21 #include "chrome/browser/signin/token_service.h" |
| 20 #include "chrome/browser/signin/token_service_factory.h" | 22 #include "chrome/browser/signin/token_service_factory.h" |
| 21 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 22 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
| 24 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
| 25 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
| 26 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 27 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
| 28 #include "google_apis/gaia/gaia_constants.h" | 30 #include "google_apis/gaia/gaia_constants.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 delegate_->OnProfileDownloadFailure( | 385 delegate_->OnProfileDownloadFailure( |
| 384 this, ProfileDownloaderDelegate::TOKEN_ERROR); | 386 this, ProfileDownloaderDelegate::TOKEN_ERROR); |
| 385 } | 387 } |
| 386 } | 388 } |
| 387 } | 389 } |
| 388 | 390 |
| 389 // Callback for OAuth2AccessTokenFetcher on success. |access_token| is the token | 391 // Callback for OAuth2AccessTokenFetcher on success. |access_token| is the token |
| 390 // used to start fetching user data. | 392 // used to start fetching user data. |
| 391 void ProfileDownloader::OnGetTokenSuccess(const std::string& access_token, | 393 void ProfileDownloader::OnGetTokenSuccess(const std::string& access_token, |
| 392 const base::Time& expiration_time) { | 394 const base::Time& expiration_time) { |
| 395 // TODO(vishwath): This can be removed when refactoring this class to use |
| 396 // OAuth2TokenService instead. |
| 397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 398 Profile* profile = delegate_->GetBrowserProfile(); |
| 399 DCHECK(profile); |
| 400 AboutSigninInternalsFactory::GetForProfile(profile)-> |
| 401 NotifyTokenReceivedSuccess(signin_internals_util::kProfileDownloaderToken, |
| 402 access_token, |
| 403 true); |
| 404 |
| 393 auth_token_ = access_token; | 405 auth_token_ = access_token; |
| 394 StartFetchingImage(); | 406 StartFetchingImage(); |
| 395 } | 407 } |
| 396 | 408 |
| 397 // Callback for OAuth2AccessTokenFetcher on failure. | 409 // Callback for OAuth2AccessTokenFetcher on failure. |
| 398 void ProfileDownloader::OnGetTokenFailure(const GoogleServiceAuthError& error) { | 410 void ProfileDownloader::OnGetTokenFailure(const GoogleServiceAuthError& error) { |
| 399 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed"; | 411 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed"; |
| 412 |
| 413 // TODO(vishwath): This can be removed when refactoring this class to use |
| 414 // OAuth2TokenService instead. |
| 415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 416 Profile* profile = delegate_->GetBrowserProfile(); |
| 417 DCHECK(profile); |
| 418 AboutSigninInternalsFactory::GetForProfile(profile)-> |
| 419 NotifyTokenReceivedFailure(signin_internals_util::kProfileDownloaderToken, |
| 420 error.ToString()); |
| 400 delegate_->OnProfileDownloadFailure( | 421 delegate_->OnProfileDownloadFailure( |
| 401 this, ProfileDownloaderDelegate::TOKEN_ERROR); | 422 this, ProfileDownloaderDelegate::TOKEN_ERROR); |
| 402 } | 423 } |
| OLD | NEW |