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 28 matching lines...) Expand all Loading... |
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 virtual bool IsEnabled() const OVERRIDE; |
45 virtual void CreatePermissionRequest( | 45 virtual void CreatePermissionRequest( |
46 const GURL& url_requested, | 46 const GURL& url_requested, |
47 const SuccessCallback& callback) OVERRIDE; | 47 const SuccessCallback& callback) OVERRIDE; |
48 | 48 |
| 49 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; } |
| 50 |
49 private: | 51 private: |
50 struct Request; | 52 struct Request; |
51 typedef ScopedVector<Request>::iterator RequestIterator; | 53 typedef ScopedVector<Request>::iterator RequestIterator; |
52 | 54 |
53 // OAuth2TokenService::Consumer implementation: | 55 // OAuth2TokenService::Consumer implementation: |
54 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 56 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
55 const std::string& access_token, | 57 const std::string& access_token, |
56 const base::Time& expiration_time) OVERRIDE; | 58 const base::Time& expiration_time) OVERRIDE; |
57 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 59 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
58 const GoogleServiceAuthError& error) OVERRIDE; | 60 const GoogleServiceAuthError& error) OVERRIDE; |
59 | 61 |
60 // net::URLFetcherDelegate implementation. | 62 // net::URLFetcherDelegate implementation. |
61 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 63 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
62 | 64 |
63 std::string GetApiScopeToUse() const; | 65 std::string GetApiScopeToUse() const; |
64 | 66 |
65 // Requests an access token, which is the first thing we need. This is where | 67 // Requests an access token, which is the first thing we need. This is where |
66 // we restart when the returned access token has expired. | 68 // we restart when the returned access token has expired. |
67 void StartFetching(Request* request); | 69 void StartFetching(Request* request); |
68 | 70 |
69 void DispatchNetworkError(RequestIterator it, int error_code); | 71 void DispatchNetworkError(RequestIterator it, int error_code); |
70 void DispatchGoogleServiceAuthError(RequestIterator it, | 72 void DispatchGoogleServiceAuthError(RequestIterator it, |
71 const GoogleServiceAuthError& error); | 73 const GoogleServiceAuthError& error); |
72 | 74 |
73 OAuth2TokenService* oauth2_token_service_; | 75 OAuth2TokenService* oauth2_token_service_; |
74 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; | 76 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; |
75 net::URLRequestContextGetter* context_; | 77 net::URLRequestContextGetter* context_; |
76 GURL apiary_url_; | 78 GURL apiary_url_; |
| 79 int url_fetcher_id_; |
77 | 80 |
78 ScopedVector<Request> requests_; | 81 ScopedVector<Request> requests_; |
79 }; | 82 }; |
80 | 83 |
81 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ | 84 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ |
OLD | NEW |