| 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_CHILD_ACCOUNTS_PERMISSION_REQUEST_CREATOR
_APIARY_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_PERMISSION_REQUEST_CREATOR
_APIARY_H_ |
| 6 #define CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_PERMISSION_REQUEST_CREATOR
_APIARY_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_PERMISSION_REQUEST_CREATOR
_APIARY_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" | |
| 13 #include "chrome/browser/supervised_user/permission_request_creator.h" | 13 #include "chrome/browser/supervised_user/permission_request_creator.h" |
| 14 #include "google_apis/gaia/oauth2_token_service.h" | 14 #include "google_apis/gaia/oauth2_token_service.h" |
| 15 #include "net/url_request/url_fetcher_delegate.h" | 15 #include "net/url_request/url_fetcher_delegate.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 class Profile; | 18 class Profile; |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class Time; | 21 class Time; |
| 22 } | 22 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 45 const SuccessCallback& callback) override; | 45 const SuccessCallback& callback) override; |
| 46 void CreateExtensionInstallRequest(const std::string& id, | 46 void CreateExtensionInstallRequest(const std::string& id, |
| 47 const SuccessCallback& callback) override; | 47 const SuccessCallback& callback) override; |
| 48 void CreateExtensionUpdateRequest(const std::string& id, | 48 void CreateExtensionUpdateRequest(const std::string& id, |
| 49 const SuccessCallback& callback) override; | 49 const SuccessCallback& callback) override; |
| 50 | 50 |
| 51 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; } | 51 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 struct Request; | 54 struct Request; |
| 55 using RequestIterator = ScopedVector<Request>::iterator; | 55 using RequestIterator = std::vector<std::unique_ptr<Request>>::iterator; |
| 56 | 56 |
| 57 // OAuth2TokenService::Consumer implementation: | 57 // OAuth2TokenService::Consumer implementation: |
| 58 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 58 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 59 const std::string& access_token, | 59 const std::string& access_token, |
| 60 const base::Time& expiration_time) override; | 60 const base::Time& expiration_time) override; |
| 61 void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 61 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 62 const GoogleServiceAuthError& error) override; | 62 const GoogleServiceAuthError& error) override; |
| 63 | 63 |
| 64 // net::URLFetcherDelegate implementation. | 64 // net::URLFetcherDelegate implementation. |
| 65 void OnURLFetchComplete(const net::URLFetcher* source) override; | 65 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 66 | 66 |
| 67 GURL GetApiUrl() const; | 67 GURL GetApiUrl() const; |
| 68 std::string GetApiScope() const; | 68 std::string GetApiScope() const; |
| 69 | 69 |
| 70 void CreateRequest(const std::string& request_type, | 70 void CreateRequest(const std::string& request_type, |
| 71 const std::string& object_ref, | 71 const std::string& object_ref, |
| 72 const SuccessCallback& callback); | 72 const SuccessCallback& callback); |
| 73 | 73 |
| 74 // Requests an access token, which is the first thing we need. This is where | 74 // Requests an access token, which is the first thing we need. This is where |
| 75 // we restart when the returned access token has expired. | 75 // we restart when the returned access token has expired. |
| 76 void StartFetching(Request* request); | 76 void StartFetching(Request* request); |
| 77 | 77 |
| 78 void DispatchResult(RequestIterator it, bool success); | 78 void DispatchResult(RequestIterator it, bool success); |
| 79 | 79 |
| 80 OAuth2TokenService* oauth2_token_service_; | 80 OAuth2TokenService* oauth2_token_service_; |
| 81 std::string account_id_; | 81 std::string account_id_; |
| 82 net::URLRequestContextGetter* context_; | 82 net::URLRequestContextGetter* context_; |
| 83 int url_fetcher_id_; | 83 int url_fetcher_id_; |
| 84 | 84 |
| 85 ScopedVector<Request> requests_; | 85 std::vector<std::unique_ptr<Request>> requests_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(PermissionRequestCreatorApiary); | 87 DISALLOW_COPY_AND_ASSIGN(PermissionRequestCreatorApiary); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 #endif // CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_PERMISSION_REQUEST_CREA
TOR_APIARY_H_ | 90 #endif // CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_PERMISSION_REQUEST_CREA
TOR_APIARY_H_ |
| OLD | NEW |