| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mutable_profile_oauth2_token_service.h" | 5 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" |
| 6 | 6 |
| 7 #include "base/profiler/scoped_tracker.h" | 7 #include "base/profiler/scoped_tracker.h" |
| 8 #include "components/signin/core/browser/signin_client.h" | 8 #include "components/signin/core/browser/signin_client.h" |
| 9 #include "components/signin/core/browser/signin_metrics.h" | 9 #include "components/signin/core/browser/signin_metrics.h" |
| 10 #include "components/signin/core/browser/webdata/token_web_data.h" | 10 #include "components/signin/core/browser/webdata/token_web_data.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 last_auth_error_ = error; | 105 last_auth_error_ = error; |
| 106 signin_error_controller_->AuthStatusChanged(); | 106 signin_error_controller_->AuthStatusChanged(); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 std::string | 110 std::string |
| 111 MutableProfileOAuth2TokenService::AccountInfo::GetAccountId() const { | 111 MutableProfileOAuth2TokenService::AccountInfo::GetAccountId() const { |
| 112 return account_id_; | 112 return account_id_; |
| 113 } | 113 } |
| 114 | 114 |
| 115 std::string | |
| 116 MutableProfileOAuth2TokenService::AccountInfo::GetUsername() const { | |
| 117 // TODO(rogerta): when |account_id| becomes the obfuscated gaia id, this | |
| 118 // will need to be changed. | |
| 119 return account_id_; | |
| 120 } | |
| 121 | |
| 122 GoogleServiceAuthError | 115 GoogleServiceAuthError |
| 123 MutableProfileOAuth2TokenService::AccountInfo::GetAuthStatus() const { | 116 MutableProfileOAuth2TokenService::AccountInfo::GetAuthStatus() const { |
| 124 return last_auth_error_; | 117 return last_auth_error_; |
| 125 } | 118 } |
| 126 | 119 |
| 127 MutableProfileOAuth2TokenService::MutableProfileOAuth2TokenService() | 120 MutableProfileOAuth2TokenService::MutableProfileOAuth2TokenService() |
| 128 : web_data_service_request_(0), | 121 : web_data_service_request_(0), |
| 129 backoff_entry_(&backoff_policy_), | 122 backoff_entry_(&backoff_policy_), |
| 130 backoff_error_(GoogleServiceAuthError::NONE) { | 123 backoff_error_(GoogleServiceAuthError::NONE) { |
| 131 VLOG(1) << "MutablePO2TS::MutablePO2TS"; | 124 VLOG(1) << "MutablePO2TS::MutablePO2TS"; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 194 |
| 202 void MutableProfileOAuth2TokenService::LoadCredentials( | 195 void MutableProfileOAuth2TokenService::LoadCredentials( |
| 203 const std::string& primary_account_id) { | 196 const std::string& primary_account_id) { |
| 204 DCHECK(!primary_account_id.empty()); | 197 DCHECK(!primary_account_id.empty()); |
| 205 ValidateAccountId(primary_account_id); | 198 ValidateAccountId(primary_account_id); |
| 206 DCHECK(loading_primary_account_id_.empty()); | 199 DCHECK(loading_primary_account_id_.empty()); |
| 207 DCHECK_EQ(0, web_data_service_request_); | 200 DCHECK_EQ(0, web_data_service_request_); |
| 208 | 201 |
| 209 CancelAllRequests(); | 202 CancelAllRequests(); |
| 210 refresh_tokens().clear(); | 203 refresh_tokens().clear(); |
| 211 loading_primary_account_id_ = primary_account_id; | 204 |
| 205 // If the account_id is an email address, then canonicalize it. This |
| 206 // is to support legacy account_ids, and will not be needed after |
| 207 // switching to gaia-ids. |
| 208 if (primary_account_id.find('@') != std::string::npos) { |
| 209 loading_primary_account_id_ = gaia::CanonicalizeEmail(primary_account_id); |
| 210 } else { |
| 211 loading_primary_account_id_ = primary_account_id; |
| 212 } |
| 213 |
| 212 scoped_refptr<TokenWebData> token_web_data = client()->GetDatabase(); | 214 scoped_refptr<TokenWebData> token_web_data = client()->GetDatabase(); |
| 213 if (token_web_data.get()) | 215 if (token_web_data.get()) |
| 214 web_data_service_request_ = token_web_data->GetAllTokens(this); | 216 web_data_service_request_ = token_web_data->GetAllTokens(this); |
| 215 } | 217 } |
| 216 | 218 |
| 217 void MutableProfileOAuth2TokenService::OnWebDataServiceRequestDone( | 219 void MutableProfileOAuth2TokenService::OnWebDataServiceRequestDone( |
| 218 WebDataServiceBase::Handle handle, | 220 WebDataServiceBase::Handle handle, |
| 219 const WDTypedResult* result) { | 221 const WDTypedResult* result) { |
| 220 VLOG(1) << "MutablePO2TS::OnWebDataServiceRequestDone. Result type: " | 222 VLOG(1) << "MutablePO2TS::OnWebDataServiceRequestDone. Result type: " |
| 221 << (result == nullptr ? -1 : (int)result->GetType()); | 223 << (result == nullptr ? -1 : (int)result->GetType()); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 } | 461 } |
| 460 | 462 |
| 461 void MutableProfileOAuth2TokenService::CancelWebTokenFetch() { | 463 void MutableProfileOAuth2TokenService::CancelWebTokenFetch() { |
| 462 if (web_data_service_request_ != 0) { | 464 if (web_data_service_request_ != 0) { |
| 463 scoped_refptr<TokenWebData> token_web_data = client()->GetDatabase(); | 465 scoped_refptr<TokenWebData> token_web_data = client()->GetDatabase(); |
| 464 DCHECK(token_web_data.get()); | 466 DCHECK(token_web_data.get()); |
| 465 token_web_data->CancelRequest(web_data_service_request_); | 467 token_web_data->CancelRequest(web_data_service_request_); |
| 466 web_data_service_request_ = 0; | 468 web_data_service_request_ = 0; |
| 467 } | 469 } |
| 468 } | 470 } |
| OLD | NEW |