OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ |
6 #define CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 class PermissionRequestCreatorApiary : public PermissionRequestCreator, | 29 class PermissionRequestCreatorApiary : public PermissionRequestCreator, |
30 public OAuth2TokenService::Consumer, | 30 public OAuth2TokenService::Consumer, |
31 public net::URLFetcherDelegate { | 31 public net::URLFetcherDelegate { |
32 public: | 32 public: |
33 PermissionRequestCreatorApiary( | 33 PermissionRequestCreatorApiary( |
34 OAuth2TokenService* oauth2_token_service, | 34 OAuth2TokenService* oauth2_token_service, |
35 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, | 35 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, |
36 net::URLRequestContextGetter* context, | 36 net::URLRequestContextGetter* context, |
37 const GURL& apiary_url); | 37 const GURL& apiary_url); |
38 virtual ~PermissionRequestCreatorApiary(); | 38 ~PermissionRequestCreatorApiary() override; |
39 | 39 |
40 static scoped_ptr<PermissionRequestCreator> CreateWithProfile( | 40 static scoped_ptr<PermissionRequestCreator> CreateWithProfile( |
41 Profile* profile, const GURL& apiary_url); | 41 Profile* profile, const GURL& apiary_url); |
42 | 42 |
43 // PermissionRequestCreator implementation: | 43 // PermissionRequestCreator implementation: |
44 virtual bool IsEnabled() const override; | 44 bool IsEnabled() const override; |
45 virtual void CreatePermissionRequest( | 45 void CreatePermissionRequest(const GURL& url_requested, |
46 const GURL& url_requested, | 46 const SuccessCallback& callback) override; |
47 const SuccessCallback& callback) override; | |
48 | 47 |
49 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; } | 48 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; } |
50 | 49 |
51 private: | 50 private: |
52 struct Request; | 51 struct Request; |
53 typedef ScopedVector<Request>::iterator RequestIterator; | 52 typedef ScopedVector<Request>::iterator RequestIterator; |
54 | 53 |
55 // OAuth2TokenService::Consumer implementation: | 54 // OAuth2TokenService::Consumer implementation: |
56 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 55 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
57 const std::string& access_token, | 56 const std::string& access_token, |
58 const base::Time& expiration_time) override; | 57 const base::Time& expiration_time) override; |
59 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 58 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
60 const GoogleServiceAuthError& error) override; | 59 const GoogleServiceAuthError& error) override; |
61 | 60 |
62 // net::URLFetcherDelegate implementation. | 61 // net::URLFetcherDelegate implementation. |
63 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 62 void OnURLFetchComplete(const net::URLFetcher* source) override; |
64 | 63 |
65 std::string GetApiScopeToUse() const; | 64 std::string GetApiScopeToUse() const; |
66 | 65 |
67 // Requests an access token, which is the first thing we need. This is where | 66 // Requests an access token, which is the first thing we need. This is where |
68 // we restart when the returned access token has expired. | 67 // we restart when the returned access token has expired. |
69 void StartFetching(Request* request); | 68 void StartFetching(Request* request); |
70 | 69 |
71 void DispatchNetworkError(RequestIterator it, int error_code); | 70 void DispatchNetworkError(RequestIterator it, int error_code); |
72 void DispatchGoogleServiceAuthError(RequestIterator it, | 71 void DispatchGoogleServiceAuthError(RequestIterator it, |
73 const GoogleServiceAuthError& error); | 72 const GoogleServiceAuthError& error); |
74 | 73 |
75 OAuth2TokenService* oauth2_token_service_; | 74 OAuth2TokenService* oauth2_token_service_; |
76 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; | 75 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; |
77 net::URLRequestContextGetter* context_; | 76 net::URLRequestContextGetter* context_; |
78 GURL apiary_url_; | 77 GURL apiary_url_; |
79 int url_fetcher_id_; | 78 int url_fetcher_id_; |
80 | 79 |
81 ScopedVector<Request> requests_; | 80 ScopedVector<Request> requests_; |
82 }; | 81 }; |
83 | 82 |
84 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ | 83 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ |
OLD | NEW |