| 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 13 matching lines...) Expand all Loading... |
| 24 namespace net { | 24 namespace net { |
| 25 class URLFetcher; | 25 class URLFetcher; |
| 26 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
| 27 } | 27 } |
| 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 const GURL& api_url, |
| 34 OAuth2TokenService* oauth2_token_service, | 35 OAuth2TokenService* oauth2_token_service, |
| 35 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, | 36 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, |
| 36 net::URLRequestContextGetter* context); | 37 net::URLRequestContextGetter* context); |
| 37 virtual ~PermissionRequestCreatorApiary(); | 38 virtual ~PermissionRequestCreatorApiary(); |
| 38 | 39 |
| 39 static scoped_ptr<PermissionRequestCreator> CreateWithProfile( | 40 static scoped_ptr<PermissionRequestCreator> CreateWithProfile( |
| 40 Profile* profile); | 41 const GURL& api_url, Profile* profile); |
| 41 | 42 |
| 42 // PermissionRequestCreator implementation: | 43 // PermissionRequestCreator implementation: |
| 43 virtual void CreatePermissionRequest(const GURL& url_requested, | 44 virtual void CreatePermissionRequest(const GURL& url_requested, |
| 44 const base::Closure& callback) OVERRIDE; | 45 const base::Closure& callback) OVERRIDE; |
| 45 | 46 |
| 47 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; } |
| 48 |
| 46 private: | 49 private: |
| 47 struct Request; | 50 struct Request; |
| 48 typedef ScopedVector<Request>::iterator RequestIterator; | 51 typedef ScopedVector<Request>::iterator RequestIterator; |
| 49 | 52 |
| 50 // OAuth2TokenService::Consumer implementation: | 53 // OAuth2TokenService::Consumer implementation: |
| 51 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 54 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 52 const std::string& access_token, | 55 const std::string& access_token, |
| 53 const base::Time& expiration_time) OVERRIDE; | 56 const base::Time& expiration_time) OVERRIDE; |
| 54 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 57 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 55 const GoogleServiceAuthError& error) OVERRIDE; | 58 const GoogleServiceAuthError& error) OVERRIDE; |
| 56 | 59 |
| 57 // net::URLFetcherDelegate implementation. | 60 // net::URLFetcherDelegate implementation. |
| 58 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 61 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 59 | 62 |
| 60 std::string GetApiScopeToUse() const; | 63 std::string GetApiScopeToUse() const; |
| 61 | 64 |
| 62 // Requests an access token, which is the first thing we need. This is where | 65 // Requests an access token, which is the first thing we need. This is where |
| 63 // we restart when the returned access token has expired. | 66 // we restart when the returned access token has expired. |
| 64 void StartFetching(Request* request); | 67 void StartFetching(Request* request); |
| 65 | 68 |
| 66 void DispatchNetworkError(RequestIterator it, int error_code); | 69 void DispatchNetworkError(RequestIterator it, int error_code); |
| 67 void DispatchGoogleServiceAuthError(RequestIterator it, | 70 void DispatchGoogleServiceAuthError(RequestIterator it, |
| 68 const GoogleServiceAuthError& error); | 71 const GoogleServiceAuthError& error); |
| 69 | 72 |
| 73 GURL url_; |
| 70 OAuth2TokenService* oauth2_token_service_; | 74 OAuth2TokenService* oauth2_token_service_; |
| 71 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; | 75 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; |
| 72 net::URLRequestContextGetter* context_; | 76 net::URLRequestContextGetter* context_; |
| 77 int url_fetcher_id_; |
| 73 | 78 |
| 74 ScopedVector<Request> requests_; | 79 ScopedVector<Request> requests_; |
| 75 }; | 80 }; |
| 76 | 81 |
| 77 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ | 82 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ |
| OLD | NEW |