| 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" |
| 11 #include "base/memory/scoped_vector.h" |
| 11 #include "chrome/browser/supervised_user/permission_request_creator.h" | 12 #include "chrome/browser/supervised_user/permission_request_creator.h" |
| 12 #include "google_apis/gaia/oauth2_token_service.h" | 13 #include "google_apis/gaia/oauth2_token_service.h" |
| 13 #include "net/url_request/url_fetcher_delegate.h" | 14 #include "net/url_request/url_fetcher_delegate.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 class Profile; | 17 class Profile; |
| 17 class SupervisedUserSigninManagerWrapper; | 18 class SupervisedUserSigninManagerWrapper; |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 class Time; | 21 class Time; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 36 virtual ~PermissionRequestCreatorApiary(); | 37 virtual ~PermissionRequestCreatorApiary(); |
| 37 | 38 |
| 38 static scoped_ptr<PermissionRequestCreator> CreateWithProfile( | 39 static scoped_ptr<PermissionRequestCreator> CreateWithProfile( |
| 39 Profile* profile); | 40 Profile* profile); |
| 40 | 41 |
| 41 // PermissionRequestCreator implementation: | 42 // PermissionRequestCreator implementation: |
| 42 virtual void CreatePermissionRequest(const GURL& url_requested, | 43 virtual void CreatePermissionRequest(const GURL& url_requested, |
| 43 const base::Closure& callback) OVERRIDE; | 44 const base::Closure& callback) OVERRIDE; |
| 44 | 45 |
| 45 private: | 46 private: |
| 47 struct Request; |
| 48 typedef ScopedVector<Request>::iterator RequestIterator; |
| 49 |
| 46 // OAuth2TokenService::Consumer implementation: | 50 // OAuth2TokenService::Consumer implementation: |
| 47 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 51 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 48 const std::string& access_token, | 52 const std::string& access_token, |
| 49 const base::Time& expiration_time) OVERRIDE; | 53 const base::Time& expiration_time) OVERRIDE; |
| 50 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 54 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 51 const GoogleServiceAuthError& error) OVERRIDE; | 55 const GoogleServiceAuthError& error) OVERRIDE; |
| 52 | 56 |
| 53 // net::URLFetcherDelegate implementation. | 57 // net::URLFetcherDelegate implementation. |
| 54 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 58 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 55 | 59 |
| 56 std::string GetApiScopeToUse() const; | 60 std::string GetApiScopeToUse() const; |
| 57 | 61 |
| 58 // Requests an access token, which is the first thing we need. This is where | 62 // Requests an access token, which is the first thing we need. This is where |
| 59 // we restart when the returned access token has expired. | 63 // we restart when the returned access token has expired. |
| 60 void StartFetching(); | 64 void StartFetching(Request* request); |
| 61 | 65 |
| 62 void DispatchNetworkError(int error_code); | 66 void DispatchNetworkError(RequestIterator it, int error_code); |
| 63 void DispatchGoogleServiceAuthError(const GoogleServiceAuthError& error); | 67 void DispatchGoogleServiceAuthError(RequestIterator it, |
| 68 const GoogleServiceAuthError& error); |
| 64 | 69 |
| 65 OAuth2TokenService* oauth2_token_service_; | 70 OAuth2TokenService* oauth2_token_service_; |
| 66 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; | 71 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; |
| 67 base::Closure callback_; | |
| 68 net::URLRequestContextGetter* context_; | 72 net::URLRequestContextGetter* context_; |
| 69 GURL url_requested_; | 73 |
| 70 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | 74 ScopedVector<Request> requests_; |
| 71 std::string access_token_; | |
| 72 bool access_token_expired_; | |
| 73 scoped_ptr<net::URLFetcher> url_fetcher_; | |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ | 77 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ |
| OLD | NEW |