| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/signin/core/browser/signin_account_id_helper.h" | 5 #include "components/signin/core/browser/signin_account_id_helper.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/profiler/scoped_profile.h" | 8 #include "base/profiler/scoped_profile.h" |
| 9 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 9 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 10 #include "components/signin/core/browser/signin_client.h" | 10 #include "components/signin/core/browser/signin_client.h" |
| 11 #include "components/signin/core/common/signin_pref_names.h" | 11 #include "components/signin/core/common/signin_pref_names.h" |
| 12 #include "google_apis/gaia/gaia_oauth_client.h" | 12 #include "google_apis/gaia/gaia_oauth_client.h" |
| 13 | 13 |
| 14 // TODO(guohui): this class should be moved to a more generic place for reuse. | 14 // TODO(guohui): this class should be moved to a more generic place for reuse. |
| 15 class SigninAccountIdHelper::GaiaIdFetcher | 15 class SigninAccountIdHelper::GaiaIdFetcher |
| 16 : public OAuth2TokenService::Consumer, | 16 : public OAuth2TokenService::Consumer, |
| 17 public gaia::GaiaOAuthClient::Delegate { | 17 public gaia::GaiaOAuthClient::Delegate { |
| 18 public: | 18 public: |
| 19 GaiaIdFetcher(SigninClient* client, | 19 GaiaIdFetcher(SigninClient* client, |
| 20 ProfileOAuth2TokenService* token_service, | 20 ProfileOAuth2TokenService* token_service, |
| 21 SigninManagerBase* signin_manager, | 21 SigninManagerBase* signin_manager, |
| 22 SigninAccountIdHelper* signin_account_id_helper); | 22 SigninAccountIdHelper* signin_account_id_helper); |
| 23 virtual ~GaiaIdFetcher(); | 23 ~GaiaIdFetcher() override; |
| 24 | 24 |
| 25 // OAuth2TokenService::Consumer implementation. | 25 // OAuth2TokenService::Consumer implementation. |
| 26 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 26 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 27 const std::string& access_token, | 27 const std::string& access_token, |
| 28 const base::Time& expiration_time) override; | 28 const base::Time& expiration_time) override; |
| 29 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 29 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 30 const GoogleServiceAuthError& error) override; | 30 const GoogleServiceAuthError& error) override; |
| 31 | 31 |
| 32 // gaia::GaiaOAuthClient::Delegate implementation. | 32 // gaia::GaiaOAuthClient::Delegate implementation. |
| 33 virtual void OnGetUserIdResponse(const std::string& gaia_id) override; | 33 void OnGetUserIdResponse(const std::string& gaia_id) override; |
| 34 virtual void OnOAuthError() override; | 34 void OnOAuthError() override; |
| 35 virtual void OnNetworkError(int response_code) override; | 35 void OnNetworkError(int response_code) override; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 void Start(); | 38 void Start(); |
| 39 | 39 |
| 40 SigninClient* client_; | 40 SigninClient* client_; |
| 41 ProfileOAuth2TokenService* token_service_; | 41 ProfileOAuth2TokenService* token_service_; |
| 42 SigninManagerBase* signin_manager_; | 42 SigninManagerBase* signin_manager_; |
| 43 SigninAccountIdHelper* signin_account_id_helper_; | 43 SigninAccountIdHelper* signin_account_id_helper_; |
| 44 | 44 |
| 45 scoped_ptr<OAuth2TokenService::Request> login_token_request_; | 45 scoped_ptr<OAuth2TokenService::Request> login_token_request_; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 // static | 163 // static |
| 164 bool SigninAccountIdHelper::disable_for_test_ = false; | 164 bool SigninAccountIdHelper::disable_for_test_ = false; |
| 165 | 165 |
| 166 // static | 166 // static |
| 167 void SigninAccountIdHelper::SetDisableForTest(bool disable_for_test) { | 167 void SigninAccountIdHelper::SetDisableForTest(bool disable_for_test) { |
| 168 disable_for_test_ = disable_for_test; | 168 disable_for_test_ = disable_for_test; |
| 169 } | 169 } |
| OLD | NEW |