| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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. | 6 // needs it, such as sync. | 
| 7 | 7 | 
| 8 #ifndef CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ | 
| 9 #define CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ | 9 #define CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ | 
| 10 #pragma once | 10 #pragma once | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 54   // Initialize this token service with a request source | 54   // Initialize this token service with a request source | 
| 55   // (usually from a GaiaAuthConsumer constant), a getter and | 55   // (usually from a GaiaAuthConsumer constant), a getter and | 
| 56   // results from ClientLogin. | 56   // results from ClientLogin. | 
| 57   void Initialize( | 57   void Initialize( | 
| 58       const char* const source, | 58       const char* const source, | 
| 59       URLRequestContextGetter* getter, | 59       URLRequestContextGetter* getter, | 
| 60       const GaiaAuthConsumer::ClientLoginResult& credentials); | 60       const GaiaAuthConsumer::ClientLoginResult& credentials); | 
| 61 | 61 | 
| 62   // For legacy services with their own auth routines, they can just read | 62   // For legacy services with their own auth routines, they can just read | 
| 63   // the LSID out directly. Deprecated. | 63   // the LSID out directly. Deprecated. | 
| 64   const bool HasLsid() const; | 64   bool HasLsid() const; | 
| 65   const std::string& GetLsid() const; | 65   const std::string& GetLsid() const; | 
| 66 | 66 | 
| 67   // On login, StartFetchingTokens() should be called to kick off token | 67   // On login, StartFetchingTokens() should be called to kick off token | 
| 68   // fetching. | 68   // fetching. | 
| 69   // Tokens will be fetched for all services(sync, talk) in the background. | 69   // Tokens will be fetched for all services(sync, talk) in the background. | 
| 70   // Results come back via event channel. Services can also poll. | 70   // Results come back via event channel. Services can also poll. | 
| 71   void StartFetchingTokens(); | 71   void StartFetchingTokens(); | 
| 72   const bool HasTokenForService(const char* const service) const; | 72   bool HasTokenForService(const char* const service) const; | 
| 73   const std::string& GetTokenForService(const char* const service) const; | 73   const std::string& GetTokenForService(const char* const service) const; | 
| 74 | 74 | 
| 75   // Callbacks from the fetchers. | 75   // Callbacks from the fetchers. | 
| 76   void OnIssueAuthTokenSuccess(const std::string& service, | 76   void OnIssueAuthTokenSuccess(const std::string& service, | 
| 77                                const std::string& auth_token); | 77                                const std::string& auth_token); | 
| 78   void OnIssueAuthTokenFailure(const std::string& service, | 78   void OnIssueAuthTokenFailure(const std::string& service, | 
| 79                                const GaiaAuthError& error); | 79                                const GaiaAuthError& error); | 
| 80 | 80 | 
| 81  private: | 81  private: | 
| 82   // Did we get a proper LSID? | 82   // Did we get a proper LSID? | 
| 83   const bool AreCredentialsValid() const; | 83   bool AreCredentialsValid() const; | 
| 84 | 84 | 
| 85   // Gaia request source for Gaia accounting. | 85   // Gaia request source for Gaia accounting. | 
| 86   std::string source_; | 86   std::string source_; | 
| 87   // Credentials from ClientLogin for Issuing auth tokens. | 87   // Credentials from ClientLogin for Issuing auth tokens. | 
| 88   GaiaAuthConsumer::ClientLoginResult credentials_; | 88   GaiaAuthConsumer::ClientLoginResult credentials_; | 
| 89   scoped_ptr<GaiaAuthenticator2> sync_token_fetcher_; | 89   scoped_ptr<GaiaAuthenticator2> sync_token_fetcher_; | 
| 90   scoped_ptr<GaiaAuthenticator2> talk_token_fetcher_; | 90   scoped_ptr<GaiaAuthenticator2> talk_token_fetcher_; | 
| 91   // Map from service to token. | 91   // Map from service to token. | 
| 92   std::map<std::string, std::string> token_map_; | 92   std::map<std::string, std::string> token_map_; | 
| 93 | 93 | 
| 94   DISALLOW_COPY_AND_ASSIGN(TokenService); | 94   DISALLOW_COPY_AND_ASSIGN(TokenService); | 
| 95 }; | 95 }; | 
| 96 | 96 | 
| 97 #endif  // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ | 97 #endif  // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ | 
| OLD | NEW | 
|---|