Chromium Code Reviews| Index: google_apis/gaia/oauth2_token_service_delegate.h |
| diff --git a/google_apis/gaia/oauth2_token_service_delegate.h b/google_apis/gaia/oauth2_token_service_delegate.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6909f85247733af96381a15acce41f54b08fb1ac |
| --- /dev/null |
| +++ b/google_apis/gaia/oauth2_token_service_delegate.h |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ |
| +#define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ |
| + |
| +#include "base/observer_list.h" |
| +#include "google_apis/gaia/gaia_auth_util.h" |
| +#include "google_apis/gaia/oauth2_token_service.h" |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +} |
| + |
| +class SigninClient; |
| + |
| +// ProfileOAuth2TokenServiceDelegate provides an alternative to |
| +// ProfileOAuth2TokenService. It allows token to be fetched from other external |
|
Mattias Nissler (ping if slow)
2015/06/29 08:20:07
nit: Why is this talking about *Profile*OAuth2Toke
gogerald1
2015/07/01 17:58:41
Done.
|
| +// entity such as a OS level accounts database. |
| +class OAuth2TokenServiceDelegate { |
| + public: |
| + OAuth2TokenServiceDelegate(); |
| + virtual ~OAuth2TokenServiceDelegate(); |
| + |
| + virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
| + const std::string& account_id, |
| + net::URLRequestContextGetter* getter, |
| + OAuth2AccessTokenConsumer* consumer) = 0; |
| + |
| + virtual bool RefreshTokenIsAvailable(const std::string& account_id) const = 0; |
| + virtual void UpdateAuthError(const std::string& account_id, |
| + const GoogleServiceAuthError& error) = 0; |
| + |
| + virtual std::vector<std::string> GetAccounts() = 0; |
| + virtual void RevokeAllCredentials() = 0; |
| + |
| + virtual void InvalidateAccessToken(const std::string& account_id, |
| + const std::string& client_id, |
| + const std::set<std::string>& scopes, |
| + const std::string& access_token) {} |
| + |
| + virtual void Shutdown() {} |
| + virtual void LoadCredentials(const std::string& primary_account_id) {} |
| + virtual void UpdateCredentials(const std::string& account_id, |
| + const std::string& refresh_token) {} |
| + virtual void RevokeCredentials(const std::string& account_id) {} |
| + virtual net::URLRequestContextGetter* GetRequestContext() const; |
| + |
| + void ValidateAccountId(const std::string& account_id) const; |
| + |
| + // Add or remove observers of this token service. |
| + void AddObserver(OAuth2TokenService::Observer* observer); |
| + void RemoveObserver(OAuth2TokenService::Observer* observer); |
| + |
| + protected: |
| + // Called by subclasses to notify observers. |
| + virtual void FireRefreshTokenAvailable(const std::string& account_id); |
| + virtual void FireRefreshTokenRevoked(const std::string& account_id); |
| + virtual void FireRefreshTokensLoaded(); |
| + |
| + // Helper class to scope batch changes. |
| + class ScopedBatchChange { |
| + public: |
| + explicit ScopedBatchChange(OAuth2TokenServiceDelegate* delegate); |
| + ~ScopedBatchChange(); |
| + |
| + private: |
| + OAuth2TokenServiceDelegate* delegate_; // Weak. |
| + DISALLOW_COPY_AND_ASSIGN(ScopedBatchChange); |
| + }; |
| + |
| + private: |
| + // List of observers to notify when refresh token availability changes. |
| + // Makes sure list is empty on destruction. |
| + base::ObserverList<OAuth2TokenService::Observer, true> observer_list_; |
| + |
| + void StartBatchChanges(); |
| + void EndBatchChanges(); |
| + |
| + // The depth of batch changes. |
| + int batch_change_depth_; |
|
Mattias Nissler (ping if slow)
2015/06/29 08:20:07
nit: DISALLOW_COPY_AND_ASSIGN?
gogerald1
2015/07/01 17:58:41
Done.
|
| +}; |
| + |
| +#endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ |