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 // 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 13 matching lines...) Expand all Loading... |
24 // SetMyToken(token_service.GetTokenForService(servicename)); | 24 // SetMyToken(token_service.GetTokenForService(servicename)); |
25 // } | 25 // } |
26 // RegisterSomeObserver(token_service); | 26 // RegisterSomeObserver(token_service); |
27 // | 27 // |
28 // Whenever a token update occurs: | 28 // Whenever a token update occurs: |
29 // OnTokenAvailable(...) { | 29 // OnTokenAvailable(...) { |
30 // if (IsServiceICareAbout(notification.service())) { | 30 // if (IsServiceICareAbout(notification.service())) { |
31 // SetMyToken(notification.token()) | 31 // SetMyToken(notification.token()) |
32 // } | 32 // } |
33 // } | 33 // } |
| 34 // |
| 35 // There is currently no easy way to create a fake TokenService. Tests that want |
| 36 // to use TokenService to issue tokens without the use of fake GaiaAuthFetchers |
| 37 // or persisting the tokens to disk via WebDataService can do this by |
| 38 // creating a TokenService (skipping the Initialize() step to avoid interacting |
| 39 // with WebDataService) and calling IssueAuthTokenForTest() to issue new tokens. |
| 40 // This will result in the TokenService sending out the appropriate |
| 41 // TOKEN_AVAILABLE notification and returning the correct response to future |
| 42 // calls to Has/GetTokenForService(). |
34 | 43 |
35 #ifndef CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ | 44 #ifndef CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ |
36 #define CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ | 45 #define CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ |
37 | 46 |
38 #include <map> | 47 #include <map> |
39 #include <string> | 48 #include <string> |
40 #include <vector> | 49 #include <vector> |
41 | 50 |
42 #include "base/gtest_prod_util.h" | 51 #include "base/gtest_prod_util.h" |
43 #include "base/memory/scoped_ptr.h" | 52 #include "base/memory/scoped_ptr.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 257 |
249 friend class TokenServiceTest; | 258 friend class TokenServiceTest; |
250 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic); | 259 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic); |
251 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced); | 260 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced); |
252 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded); | 261 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded); |
253 | 262 |
254 DISALLOW_COPY_AND_ASSIGN(TokenService); | 263 DISALLOW_COPY_AND_ASSIGN(TokenService); |
255 }; | 264 }; |
256 | 265 |
257 #endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ | 266 #endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ |
OLD | NEW |