OLD | NEW |
---|---|
(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> Create( | |
38 OAuth2TokenService* oauth2_token_service, | |
39 scoped_ptr<ManagedUserSigninManagerWrapper>, | |
40 net::URLRequestContextGetter* context); | |
41 | |
42 static scoped_ptr<PermissionRequestCreator> CreateWithProfile( | |
43 Profile* profile); | |
44 | |
45 // PermissionRequestCreator implementation: | |
46 virtual void CreatePermissionRequest( | |
47 const std::string& url_requested, | |
48 const PermissionRequestCallback& callback) OVERRIDE; | |
49 | |
50 protected: | |
51 // OAuth2TokenService::Consumer implementation: | |
52 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | |
Bernhard Bauer
2014/05/19 17:11:26
Why is this protected?
Adrian Kuegel
2014/05/20 08:38:06
Copy/paste from ManagedUserRefreshTokenFetcher, an
| |
53 const std::string& access_token, | |
54 const base::Time& expiration_time) OVERRIDE; | |
55 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | |
56 const GoogleServiceAuthError& error) OVERRIDE; | |
57 | |
58 // net::URLFetcherDelegate implementation. | |
59 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
60 | |
61 private: | |
62 // Requests an access token, which is the first thing we need. This is where | |
63 // we restart when the returned access token has expired. | |
64 void StartFetching(); | |
65 | |
66 void DispatchNetworkError(int error_code); | |
67 void DispatchGoogleServiceAuthError(const GoogleServiceAuthError& error); | |
68 | |
69 OAuth2TokenService* oauth2_token_service_; | |
70 scoped_ptr<ManagedUserSigninManagerWrapper> signin_wrapper_; | |
71 PermissionRequestCallback callback_; | |
72 net::URLRequestContextGetter* context_; | |
73 std::string url_requested_; | |
74 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | |
75 std::string access_token_; | |
76 bool access_token_expired_; | |
77 scoped_ptr<net::URLFetcher> url_fetcher_; | |
78 }; | |
79 | |
80 #endif // CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_APIARY_H_ | |
OLD | NEW |