| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/signin/token_service.h" | 5 #include "chrome/browser/signin/token_service.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // when ChromeOS is in forced OAuth2 use mode. OAuth2 token should only | 115 // when ChromeOS is in forced OAuth2 use mode. OAuth2 token should only |
| 116 // arrive into token service exclusively through UpdateCredentialsWithOAuth2. | 116 // arrive into token service exclusively through UpdateCredentialsWithOAuth2. |
| 117 #if !defined(OS_CHROMEOS) | 117 #if !defined(OS_CHROMEOS) |
| 118 // If we got ClientLogin token for "lso" service, and we don't already have | 118 // If we got ClientLogin token for "lso" service, and we don't already have |
| 119 // OAuth2 tokens, start fetching OAuth2 login scoped token pair. | 119 // OAuth2 tokens, start fetching OAuth2 login scoped token pair. |
| 120 if (service == GaiaConstants::kLSOService && !HasOAuthLoginToken()) { | 120 if (service == GaiaConstants::kLSOService && !HasOAuthLoginToken()) { |
| 121 int index = GetServiceIndex(service); | 121 int index = GetServiceIndex(service); |
| 122 CHECK_GE(index, 0); | 122 CHECK_GE(index, 0); |
| 123 // iOS fetches the service tokens outside of the TokenService. | 123 // iOS fetches the service tokens outside of the TokenService. |
| 124 if (!fetchers_[index].get()) { | 124 if (!fetchers_[index].get()) { |
| 125 fetchers_[index].reset(new GaiaAuthFetcher(this, source_, getter_)); | 125 fetchers_[index].reset(new GaiaAuthFetcher(this, source_, getter_.get())); |
| 126 } | 126 } |
| 127 fetchers_[index]->StartLsoForOAuthLoginTokenExchange(auth_token); | 127 fetchers_[index]->StartLsoForOAuthLoginTokenExchange(auth_token); |
| 128 } | 128 } |
| 129 #endif | 129 #endif |
| 130 } | 130 } |
| 131 | 131 |
| 132 | 132 |
| 133 void TokenService::ResetCredentialsInMemory() { | 133 void TokenService::ResetCredentialsInMemory() { |
| 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 135 | 135 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool TokenService::AreCredentialsValid() const { | 222 bool TokenService::AreCredentialsValid() const { |
| 223 return !credentials_.lsid.empty() && !credentials_.sid.empty(); | 223 return !credentials_.lsid.empty() && !credentials_.sid.empty(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void TokenService::StartFetchingTokens() { | 226 void TokenService::StartFetchingTokens() { |
| 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 228 DCHECK(AreCredentialsValid()); | 228 DCHECK(AreCredentialsValid()); |
| 229 for (size_t i = 0; i < arraysize(kServices); i++) { | 229 for (size_t i = 0; i < arraysize(kServices); i++) { |
| 230 fetchers_[i].reset(new GaiaAuthFetcher(this, source_, getter_)); | 230 fetchers_[i].reset(new GaiaAuthFetcher(this, source_, getter_.get())); |
| 231 fetchers_[i]->StartIssueAuthToken(credentials_.sid, | 231 fetchers_[i]->StartIssueAuthToken( |
| 232 credentials_.lsid, | 232 credentials_.sid, credentials_.lsid, kServices[i]); |
| 233 kServices[i]); | |
| 234 } | 233 } |
| 235 } | 234 } |
| 236 | 235 |
| 237 // Services dependent on a token will check if a token is available. | 236 // Services dependent on a token will check if a token is available. |
| 238 // If it isn't, they'll go to sleep until they get a token event. | 237 // If it isn't, they'll go to sleep until they get a token event. |
| 239 bool TokenService::HasTokenForService(const char* service) const { | 238 bool TokenService::HasTokenForService(const char* service) const { |
| 240 return token_map_.count(service) > 0; | 239 return token_map_.count(service) > 0; |
| 241 } | 240 } |
| 242 | 241 |
| 243 const std::string& TokenService::GetTokenForService( | 242 const std::string& TokenService::GetTokenForService( |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 456 |
| 458 void TokenService::AddSigninDiagnosticsObserver( | 457 void TokenService::AddSigninDiagnosticsObserver( |
| 459 SigninDiagnosticsObserver* observer) { | 458 SigninDiagnosticsObserver* observer) { |
| 460 signin_diagnostics_observers_.AddObserver(observer); | 459 signin_diagnostics_observers_.AddObserver(observer); |
| 461 } | 460 } |
| 462 | 461 |
| 463 void TokenService::RemoveSigninDiagnosticsObserver( | 462 void TokenService::RemoveSigninDiagnosticsObserver( |
| 464 SigninDiagnosticsObserver* observer) { | 463 SigninDiagnosticsObserver* observer) { |
| 465 signin_diagnostics_observers_.RemoveObserver(observer); | 464 signin_diagnostics_observers_.RemoveObserver(observer); |
| 466 } | 465 } |
| OLD | NEW |