Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // The TokenService will supply authentication tokens for any service that | 5 // The TokenService will supply authentication tokens for any service that |
| 6 // needs it, such as sync. Whenever the user logs in, a controller watching | 6 // needs it, such as sync. Whenever the user logs in, a controller watching |
| 7 // the token service is expected either to call ClientLogin to derive a new | 7 // the token service is expected either to call ClientLogin to derive a new |
| 8 // SID and LSID, or to use GAIA OAuth requests to derive an OAuth1 access | 8 // SID and LSID, or to use GAIA OAuth requests to derive an OAuth1 access |
| 9 // token for the OAuthLogin scope. Whenever such credentials are available, | 9 // token for the OAuthLogin scope. Whenever such credentials are available, |
| 10 // the TokenService should be updated with new credentials. The controller | 10 // the TokenService should be updated with new credentials. The controller |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 // For services with their own auth routines, they can read the OAuth token | 141 // For services with their own auth routines, they can read the OAuth token |
| 142 // and secret directly. Deprecated (in the sense of discouraged). | 142 // and secret directly. Deprecated (in the sense of discouraged). |
| 143 bool HasOAuthCredentials() const; | 143 bool HasOAuthCredentials() const; |
| 144 const std::string& GetOAuthToken() const; | 144 const std::string& GetOAuthToken() const; |
| 145 const std::string& GetOAuthSecret() const; | 145 const std::string& GetOAuthSecret() const; |
| 146 | 146 |
| 147 // Tokens will be fetched for all services(sync, talk) in the background. | 147 // Tokens will be fetched for all services(sync, talk) in the background. |
| 148 // Results come back via event channel. Services can also poll before events | 148 // Results come back via event channel. Services can also poll before events |
| 149 // are issued. | 149 // are issued. |
| 150 void StartFetchingTokens(); | 150 void StartFetchingTokens(); |
| 151 // Fetch tokens for only those services for which we are missing tokens. | |
| 152 // This can happen when new services are added in new Chrome versions and the | |
| 153 // user is already logged in. | |
| 154 void StartFetchingMissingTokens(); | |
| 155 void StartFetchingOAuthTokens(); | 151 void StartFetchingOAuthTokens(); |
| 156 virtual bool HasTokenForService(const char* service) const; | 152 virtual bool HasTokenForService(const char* service) const; |
| 157 const std::string& GetTokenForService(const char* const service) const; | 153 const std::string& GetTokenForService(const char* const service) const; |
| 158 | 154 |
| 159 // OAuth login token is an all-powerful token that allows creating OAuth2 | 155 // OAuth login token is an all-powerful token that allows creating OAuth2 |
| 160 // tokens for any other scope (i.e. down-scoping). | 156 // tokens for any other scope (i.e. down-scoping). |
| 161 // Typical use is to create an OAuth2 token for appropriate scope and then | 157 // Typical use is to create an OAuth2 token for appropriate scope and then |
| 162 // use that token to call a Google API. | 158 // use that token to call a Google API. |
| 163 virtual bool HasOAuthLoginToken() const; | 159 virtual bool HasOAuthLoginToken() const; |
| 164 const std::string& GetOAuth2LoginRefreshToken() const; | 160 const std::string& GetOAuth2LoginRefreshToken() const; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 // Credentials from Gaia OAuth (uber/login token) | 238 // Credentials from Gaia OAuth (uber/login token) |
| 243 std::string oauth_token_; | 239 std::string oauth_token_; |
| 244 std::string oauth_secret_; | 240 std::string oauth_secret_; |
| 245 | 241 |
| 246 // Size of array of services capable of ClientLogin-based authentication. | 242 // Size of array of services capable of ClientLogin-based authentication. |
| 247 // This value must be defined here. | 243 // This value must be defined here. |
| 248 // NOTE: The use of --enable-sync-oauth does not affect this count. The | 244 // NOTE: The use of --enable-sync-oauth does not affect this count. The |
| 249 // TokenService can continue to do some degree of ClientLogin token | 245 // TokenService can continue to do some degree of ClientLogin token |
| 250 // management, mostly related to persistence while Sync and possibly other | 246 // management, mostly related to persistence while Sync and possibly other |
| 251 // services are using OAuth-based authentication. | 247 // services are using OAuth-based authentication. |
| 252 static const int kNumServices = 7; | 248 static const int kNumServices = 6; |
|
zel
2011/12/05 22:04:16
GaiaConstants::kPicasaService got removed as well
Munjal (Google)
2011/12/05 22:12:24
Yep, I have that in mind. In fact, I was wondering
| |
| 253 // List of services that are capable of ClientLogin-based authentication. | 249 // List of services that are capable of ClientLogin-based authentication. |
| 254 static const char* kServices[kNumServices]; | 250 static const char* kServices[kNumServices]; |
| 255 // A bunch of fetchers suitable for ClientLogin token issuing. We don't care | 251 // A bunch of fetchers suitable for ClientLogin token issuing. We don't care |
| 256 // about the ordering, nor do we care which is for which service. | 252 // about the ordering, nor do we care which is for which service. |
| 257 scoped_ptr<GaiaAuthFetcher> fetchers_[kNumServices]; | 253 scoped_ptr<GaiaAuthFetcher> fetchers_[kNumServices]; |
| 258 | 254 |
| 259 // Size of array of services capable of OAuth-based authentication. This | 255 // Size of array of services capable of OAuth-based authentication. This |
| 260 // value must be defined here. | 256 // value must be defined here. |
| 261 // NOTE: The use of --enable-sync-oauth does not affect this count. The | 257 // NOTE: The use of --enable-sync-oauth does not affect this count. The |
| 262 // TokenService can continue to do some degree of OAuth token | 258 // TokenService can continue to do some degree of OAuth token |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 276 | 272 |
| 277 friend class TokenServiceTest; | 273 friend class TokenServiceTest; |
| 278 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic); | 274 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic); |
| 279 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced); | 275 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced); |
| 280 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded); | 276 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded); |
| 281 | 277 |
| 282 DISALLOW_COPY_AND_ASSIGN(TokenService); | 278 DISALLOW_COPY_AND_ASSIGN(TokenService); |
| 283 }; | 279 }; |
| 284 | 280 |
| 285 #endif // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ | 281 #endif // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ |
| OLD | NEW |