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

Side by Side Diff: chrome/browser/managed_mode/permission_request_creator_apiary.h

Issue 288913003: Add permission request creator class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use base::Closure, and simplify things. Created 6 years, 7 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 CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_APIARY_H_
6 #define CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_APIARY_H_
7
8 #include "chrome/browser/managed_mode/permission_request_creator.h"
9
10 #include "base/memory/scoped_ptr.h"
11 #include "google_apis/gaia/oauth2_token_service.h"
12 #include "net/url_request/url_fetcher_delegate.h"
13
14 class ManagedUserSigninManagerWrapper;
15 class Profile;
16
17 namespace base {
18 class Time;
19 }
20
21 namespace net {
22 class URLFetcher;
23 class URLRequestContextGetter;
24 }
25
26 class PermissionRequestCreatorApiary
27 : public PermissionRequestCreator,
28 public OAuth2TokenService::Consumer,
29 public net::URLFetcherDelegate {
30 public:
31 PermissionRequestCreatorApiary(
32 OAuth2TokenService* oauth2_token_service,
33 scoped_ptr<ManagedUserSigninManagerWrapper> signin_wrapper,
34 net::URLRequestContextGetter* context);
35 virtual ~PermissionRequestCreatorApiary();
36
37 static scoped_ptr<PermissionRequestCreator> CreateWithProfile(
38 Profile* profile);
39
40 // PermissionRequestCreator implementation:
41 virtual void CreatePermissionRequest(
42 const std::string& url_requested,
43 const base::Closure& callback) OVERRIDE;
44
45 private:
46 // OAuth2TokenService::Consumer implementation:
47 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
48 const std::string& access_token,
49 const base::Time& expiration_time) OVERRIDE;
50 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
51 const GoogleServiceAuthError& error) OVERRIDE;
52
53 // net::URLFetcherDelegate implementation.
54 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
55
56 // Requests an access token, which is the first thing we need. This is where
57 // we restart when the returned access token has expired.
58 void StartFetching();
59
60 void DispatchNetworkError(int error_code);
61 void DispatchGoogleServiceAuthError(const GoogleServiceAuthError& error);
62
63 OAuth2TokenService* oauth2_token_service_;
64 scoped_ptr<ManagedUserSigninManagerWrapper> signin_wrapper_;
65 base::Closure callback_;
66 net::URLRequestContextGetter* context_;
67 std::string url_requested_;
68 scoped_ptr<OAuth2TokenService::Request> access_token_request_;
69 std::string access_token_;
70 bool access_token_expired_;
71 scoped_ptr<net::URLFetcher> url_fetcher_;
72 };
73
74 #endif // CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_APIARY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698