OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "google_apis/gaia/gaia_auth_consumer.h" | 16 #include "google_apis/gaia/gaia_auth_consumer.h" |
17 #include "google_apis/gaia/oauth2_access_token_consumer.h" | 17 #include "google_apis/gaia/oauth2_access_token_consumer.h" |
18 | 18 |
19 class GaiaAuthFetcher; | 19 class GaiaAuthFetcher; |
20 class OAuth2AccessTokenFetcher; | 20 class OAuth2AccessTokenFetcher; |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
24 } | 24 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 // Passes |token| and |error| to the |callback_|. | 95 // Passes |token| and |error| to the |callback_|. |
96 void ForwardPolicyToken(const std::string& token, | 96 void ForwardPolicyToken(const std::string& token, |
97 const GoogleServiceAuthError& error); | 97 const GoogleServiceAuthError& error); |
98 | 98 |
99 // Auth code which is used to retreive a refresh token. | 99 // Auth code which is used to retreive a refresh token. |
100 std::string auth_code_; | 100 std::string auth_code_; |
101 | 101 |
102 scoped_refptr<net::URLRequestContextGetter> auth_context_getter_; | 102 scoped_refptr<net::URLRequestContextGetter> auth_context_getter_; |
103 scoped_refptr<net::URLRequestContextGetter> system_context_getter_; | 103 scoped_refptr<net::URLRequestContextGetter> system_context_getter_; |
104 scoped_ptr<GaiaAuthFetcher> refresh_token_fetcher_; | 104 std::unique_ptr<GaiaAuthFetcher> refresh_token_fetcher_; |
105 scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; | 105 std::unique_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; |
106 | 106 |
107 // OAuth2 refresh token. Could come either from the outside or through | 107 // OAuth2 refresh token. Could come either from the outside or through |
108 // refresh token fetching flow within this class. | 108 // refresh token fetching flow within this class. |
109 std::string oauth2_refresh_token_; | 109 std::string oauth2_refresh_token_; |
110 | 110 |
111 // OAuth2 access token. | 111 // OAuth2 access token. |
112 std::string oauth2_access_token_; | 112 std::string oauth2_access_token_; |
113 | 113 |
114 // The retry counter. Increment this only when failure happened. | 114 // The retry counter. Increment this only when failure happened. |
115 int retry_count_ = 0; | 115 int retry_count_ = 0; |
116 | 116 |
117 // True if we have already failed to fetch the policy. | 117 // True if we have already failed to fetch the policy. |
118 bool failed_ = false; | 118 bool failed_ = false; |
119 | 119 |
120 // The callback to invoke when done. | 120 // The callback to invoke when done. |
121 TokenCallback callback_; | 121 TokenCallback callback_; |
122 | 122 |
123 DISALLOW_COPY_AND_ASSIGN(PolicyOAuth2TokenFetcher); | 123 DISALLOW_COPY_AND_ASSIGN(PolicyOAuth2TokenFetcher); |
124 }; | 124 }; |
125 | 125 |
126 } // namespace policy | 126 } // namespace policy |
127 | 127 |
128 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ | 128 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ |
OLD | NEW |