| Index: extensions/browser/webstore_oauth2_token_provider.h
|
| diff --git a/extensions/browser/webstore_oauth2_token_provider.h b/extensions/browser/webstore_oauth2_token_provider.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d1baf8512eb7dbe0c812e2ea27d65213f0d46840
|
| --- /dev/null
|
| +++ b/extensions/browser/webstore_oauth2_token_provider.h
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2014 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 EXTENSIONS_BROWSER_WEBSTORE_OAUTH2_TOKEN_PROVIDER_H_
|
| +#define EXTENSIONS_BROWSER_WEBSTORE_OAUTH2_TOKEN_PROVIDER_H_
|
| +
|
| +#include <queue>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/macros.h"
|
| +#include "google_apis/gaia/oauth2_token_service.h"
|
| +
|
| +class IdentityProvider;
|
| +
|
| +namespace extensions {
|
| +
|
| +// Provides access tokens for resources
|
| +class WebstoreOAuth2TokenProvider : public OAuth2TokenService::Consumer {
|
| + public:
|
| + typedef base::Callback<void(bool success, const std::string& token)>
|
| + FetchCallback;
|
| +
|
| + explicit WebstoreOAuth2TokenProvider(IdentityProvider* identity_provider);
|
| + virtual ~WebstoreOAuth2TokenProvider();
|
| +
|
| + void FetchToken(const FetchCallback& callback);
|
| +
|
| + private:
|
| + // OAuth2TokenService::Consumer implementation.
|
| + virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
|
| + const std::string& access_token,
|
| + const base::Time& expiration_time) OVERRIDE;
|
| + virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
|
| + const GoogleServiceAuthError& error) OVERRIDE;
|
| +
|
| + // Exposes an OAuth2TokenService and information about the active account ID.
|
| + // Not owned and must outlive this WebstoreOAuth2TokenProvider.
|
| + IdentityProvider* identity_provider_;
|
| +
|
| + // A cached access token from the last successful token fetch.
|
| + std::string access_token_;
|
| +
|
| + // Callbacks pending the receipt of a new token.
|
| + typedef std::queue<FetchCallback> CallbackQueue;
|
| + CallbackQueue pending_callbacks_;
|
| +
|
| + scoped_ptr<OAuth2TokenService::Request> access_token_request_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebstoreOAuth2TokenProvider);
|
| +};
|
| +
|
| +} // namespace extensions
|
| +
|
| +#endif // EXTENSIONS_BROWSER_WEBSTORE_OAUTH2_TOKEN_PROVIDER_H_
|
|
|