Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: extensions/browser/webstore_oauth2_token_provider.h

Issue 434493002: OAuth2 support for Webstore downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef EXTENSIONS_BROWSER_WEBSTORE_OAUTH2_TOKEN_PROVIDER_H_
6 #define EXTENSIONS_BROWSER_WEBSTORE_OAUTH2_TOKEN_PROVIDER_H_
7
8 #include <queue>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "google_apis/gaia/oauth2_token_service.h"
13
14 class IdentityProvider;
15
16 namespace extensions {
17
18 // Provides access tokens for resources
19 class WebstoreOAuth2TokenProvider : public OAuth2TokenService::Consumer {
20 public:
21 typedef base::Callback<void(bool success, const std::string& token)>
22 FetchCallback;
23
24 explicit WebstoreOAuth2TokenProvider(IdentityProvider* identity_provider);
25 virtual ~WebstoreOAuth2TokenProvider();
26
27 void FetchToken(const FetchCallback& callback);
28
29 private:
30 // OAuth2TokenService::Consumer implementation.
31 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
32 const std::string& access_token,
33 const base::Time& expiration_time) OVERRIDE;
34 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
35 const GoogleServiceAuthError& error) OVERRIDE;
36
37 // Exposes an OAuth2TokenService and information about the active account ID.
38 // Not owned and must outlive this WebstoreOAuth2TokenProvider.
39 IdentityProvider* identity_provider_;
40
41 // A cached access token from the last successful token fetch.
42 std::string access_token_;
43
44 // Callbacks pending the receipt of a new token.
45 typedef std::queue<FetchCallback> CallbackQueue;
46 CallbackQueue pending_callbacks_;
47
48 scoped_ptr<OAuth2TokenService::Request> access_token_request_;
49
50 DISALLOW_COPY_AND_ASSIGN(WebstoreOAuth2TokenProvider);
51 };
52
53 } // namespace extensions
54
55 #endif // EXTENSIONS_BROWSER_WEBSTORE_OAUTH2_TOKEN_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698