| Index: chrome/browser/net/gaia/token_service.h
|
| diff --git a/chrome/browser/net/gaia/token_service.h b/chrome/browser/net/gaia/token_service.h
|
| index c8b777820b17c8e1c66d7c44e462a879d5d5d25d..d04dcd13f01d485fc77c7afb1b5939a651208994 100644
|
| --- a/chrome/browser/net/gaia/token_service.h
|
| +++ b/chrome/browser/net/gaia/token_service.h
|
| @@ -3,29 +3,94 @@
|
| // found in the LICENSE file.
|
| //
|
| // The TokenService will supply authentication tokens for any service that
|
| -// needs it. One such service is Sync.
|
| -// For the time being, the Token Service just supplies the LSID from the
|
| -// ChromiumOS login. In the future, it'll have a bit more logic and supply
|
| -// only AuthTokens from Gaia, and not LSIDs.
|
| +// needs it, such as sync.
|
|
|
| #ifndef CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
|
| #define CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
|
|
|
| +#include <map>
|
| +#include <string>
|
| +#include "base/scoped_ptr.h"
|
| #include "chrome/common/net/gaia/gaia_auth_consumer.h"
|
| +#include "chrome/common/net/gaia/gaia_authenticator2.h"
|
| +#include "chrome/test/testing_profile.h"
|
|
|
| -class TokenService {
|
| +class URLRequestContextGetter;
|
| +
|
| +// The TokenService is a Profile member, so all calls are expected
|
| +// from the UI thread.
|
| +class TokenService : public GaiaAuthConsumer {
|
| public:
|
| - void SetClientLoginResult(
|
| - const GaiaAuthConsumer::ClientLoginResult& credentials);
|
| + TokenService() {}
|
| +
|
| + // Notification classes
|
| + class TokenAvailableDetails {
|
| + public:
|
| + TokenAvailableDetails() {}
|
| + TokenAvailableDetails(const std::string& service,
|
| + const std::string& token)
|
| + : service_(service), token_(token) {}
|
| + const std::string& service() const { return service_; }
|
| + const std::string& token() const { return token_; }
|
| + private:
|
| + std::string service_;
|
| + std::string token_;
|
| + };
|
| +
|
| + class TokenRequestFailedDetails {
|
| + public:
|
| + TokenRequestFailedDetails() {}
|
| + TokenRequestFailedDetails(const std::string& service,
|
| + const GaiaAuthError& error)
|
| + : service_(service), error_(error) {}
|
| + const std::string& service() const { return service_; }
|
| + const GaiaAuthError& error() const { return error_; }
|
| + private:
|
| + std::string service_;
|
| + GaiaAuthError error_;
|
| + };
|
| +
|
| + // Initialize this token service with a request source
|
| + // (usually from a GaiaAuthConsumer constant), a getter and
|
| + // results from ClientLogin.
|
| + void Initialize(
|
| + const char* const source,
|
| + URLRequestContextGetter* getter,
|
| + const GaiaAuthConsumer::ClientLoginResult& credentials);
|
|
|
| - bool HasLsid();
|
| - const std::string& GetLsid();
|
| + // For legacy services with their own auth routines, they can just read
|
| + // the LSID out directly. Deprecated.
|
| + const bool HasLsid() const;
|
| + const std::string& GetLsid() const;
|
|
|
| - // TODO(chron): Token broadcast will require removing a lot of auth code
|
| - // from sync. For the time being we'll start with LSID passing.
|
| + // On login, StartFetchingTokens() should be called to kick off token
|
| + // fetching.
|
| + // Tokens will be fetched for all services(sync, talk) in the background.
|
| + // Results come back via event channel. Services can also poll.
|
| + void StartFetchingTokens();
|
| + const bool HasTokenForService(const char* const service) const;
|
| + const std::string& GetTokenForService(const char* const service) const;
|
| +
|
| + // Callbacks from the fetchers.
|
| + void OnIssueAuthTokenSuccess(const std::string& service,
|
| + const std::string& auth_token);
|
| + void OnIssueAuthTokenFailure(const std::string& service,
|
| + const GaiaAuthError& error);
|
|
|
| private:
|
| + // Did we get a proper LSID?
|
| + const bool AreCredentialsValid() const;
|
| +
|
| + // Gaia request source for Gaia accounting.
|
| + std::string source_;
|
| + // Credentials from ClientLogin for Issuing auth tokens.
|
| GaiaAuthConsumer::ClientLoginResult credentials_;
|
| + scoped_ptr<GaiaAuthenticator2> sync_token_fetcher_;
|
| + scoped_ptr<GaiaAuthenticator2> talk_token_fetcher_;
|
| + // Map from service to token.
|
| + std::map<std::string, std::string> token_map_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TokenService);
|
| };
|
|
|
| #endif // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
|
|
|