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 COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 94 |
95 // Returns true if the data reduction proxy key is set on the command line. | 95 // Returns true if the data reduction proxy key is set on the command line. |
96 static bool IsProxyKeySetOnCommandLine(); | 96 static bool IsProxyKeySetOnCommandLine(); |
97 | 97 |
98 // Returns true if this application instance is part of the data reduction | 98 // Returns true if this application instance is part of the data reduction |
99 // proxy field trial, or if it a proxy origin is set in flags. This is a | 99 // proxy field trial, or if it a proxy origin is set in flags. This is a |
100 // convenience method for platforms like Chrome on Android and iOS, to | 100 // convenience method for platforms like Chrome on Android and iOS, to |
101 // determine if the data reduction proxy is allowed. | 101 // determine if the data reduction proxy is allowed. |
102 static bool IsIncludedInFieldTrialOrFlags(); | 102 static bool IsIncludedInFieldTrialOrFlags(); |
103 | 103 |
104 static void SetKey(const std::string& key); | |
105 static void SetAllowed(bool allowed); | 104 static void SetAllowed(bool allowed); |
106 static void SetPromoAllowed(bool promo_allowed); | 105 static void SetPromoAllowed(bool promo_allowed); |
107 | 106 |
108 DataReductionProxySettings(); | 107 DataReductionProxySettings(); |
109 virtual ~DataReductionProxySettings(); | 108 virtual ~DataReductionProxySettings(); |
110 | 109 |
110 // Set and get the key to be used for data reduction proxy authentication. | |
111 void set_key(const std::string& key) { | |
112 key_ = key; | |
113 } | |
114 const std::string& key() const { | |
marq (ping after 24h)
2014/05/09 17:00:06
newline between methods.
bengr
2014/05/09 17:12:20
Done.
| |
115 return key_; | |
116 } | |
117 | |
111 // Initializes the data reduction proxy with profile and local state prefs, | 118 // Initializes the data reduction proxy with profile and local state prefs, |
112 // and a |UrlRequestContextGetter| for canary probes. The caller must ensure | 119 // and a |UrlRequestContextGetter| for canary probes. The caller must ensure |
113 // that all parameters remain alive for the lifetime of the | 120 // that all parameters remain alive for the lifetime of the |
114 // |DataReductionProxySettings| instance. | 121 // |DataReductionProxySettings| instance. |
115 void InitDataReductionProxySettings( | 122 void InitDataReductionProxySettings( |
116 PrefService* prefs, | 123 PrefService* prefs, |
117 PrefService* local_state_prefs, | 124 PrefService* local_state_prefs, |
118 net::URLRequestContextGetter* url_request_context_getter); | 125 net::URLRequestContextGetter* url_request_context_getter); |
119 | 126 |
120 // Initializes the data reduction proxy with profile and local state prefs, | 127 // Initializes the data reduction proxy with profile and local state prefs, |
121 // a |UrlRequestContextGetter| for canary probes, and a proxy configurator. | 128 // a |UrlRequestContextGetter| for canary probes, and a proxy configurator. |
122 // The caller must ensure that all parameters remain alive for the lifetime of | 129 // The caller must ensure that all parameters remain alive for the lifetime of |
123 // the |DataReductionProxySettings| instance. | 130 // the |DataReductionProxySettings| instance. |
124 // TODO(marq): Remove when iOS supports the new interface above. | 131 // TODO(marq): Remove when iOS supports the new interface above. |
125 void InitDataReductionProxySettings( | 132 void InitDataReductionProxySettings( |
126 PrefService* prefs, | 133 PrefService* prefs, |
127 PrefService* local_state_prefs, | 134 PrefService* local_state_prefs, |
128 net::URLRequestContextGetter* url_request_context_getter, | 135 net::URLRequestContextGetter* url_request_context_getter, |
129 scoped_ptr<DataReductionProxyConfigurator> config); | 136 scoped_ptr<DataReductionProxyConfigurator> config); |
130 | 137 |
131 // Sets the logic the embedder uses to set the networking configuration that | 138 // Sets the logic the embedder uses to set the networking configuration that |
132 // causes traffic to be proxied. | 139 // causes traffic to be proxied. |
133 void SetProxyConfigurator( | 140 void SetProxyConfigurator( |
134 scoped_ptr<DataReductionProxyConfigurator> configurator); | 141 scoped_ptr<DataReductionProxyConfigurator> configurator); |
135 | 142 |
136 // If proxy authentication is compiled in, pre-cache authentication | 143 // If proxy authentication is compiled in, pre-cache an authentication |
137 // keys for all configured proxies in |session|. | 144 // |key| for all configured proxies in |session|. |
138 static void InitDataReductionProxySession(net::HttpNetworkSession* session); | 145 static void InitDataReductionProxySession(net::HttpNetworkSession* session, |
146 const std::string& key); | |
139 | 147 |
140 // Returns true if the data reduction proxy is allowed to be used. This could | 148 // Returns true if the data reduction proxy is allowed to be used. This could |
141 // return false, for example, if this instance is not part of the field trial, | 149 // return false, for example, if this instance is not part of the field trial, |
142 // or if the proxy name is not configured via gyp. | 150 // or if the proxy name is not configured via gyp. |
143 static bool IsDataReductionProxyAllowed(); | 151 static bool IsDataReductionProxyAllowed(); |
144 | 152 |
145 // Returns true if a screen promoting the data reduction proxy is allowed to | 153 // Returns true if a screen promoting the data reduction proxy is allowed to |
146 // be shown. Logic that decides when to show the promo should check its | 154 // be shown. Logic that decides when to show the promo should check its |
147 // availability. This would return false if not part of a separate field | 155 // availability. This would return false if not part of a separate field |
148 // trial that governs the use of the promotion. | 156 // trial that governs the use of the promotion. |
(...skipping 12 matching lines...) Expand all Loading... | |
161 // Returns a vector of GURLs for all configured proxies. | 169 // Returns a vector of GURLs for all configured proxies. |
162 static DataReductionProxyList GetDataReductionProxies(); | 170 static DataReductionProxyList GetDataReductionProxies(); |
163 | 171 |
164 // Returns true if |auth_info| represents an authentication challenge from | 172 // Returns true if |auth_info| represents an authentication challenge from |
165 // a compatible, configured proxy. | 173 // a compatible, configured proxy. |
166 static bool IsAcceptableAuthChallenge(net::AuthChallengeInfo* auth_info); | 174 static bool IsAcceptableAuthChallenge(net::AuthChallengeInfo* auth_info); |
167 | 175 |
168 // Returns a UTF16 string suitable for use as an authentication token in | 176 // Returns a UTF16 string suitable for use as an authentication token in |
169 // response to the challenge represented by |auth_info|. If the token can't | 177 // response to the challenge represented by |auth_info|. If the token can't |
170 // be correctly generated for |auth_info|, returns an empty UTF16 string. | 178 // be correctly generated for |auth_info|, returns an empty UTF16 string. |
171 static base::string16 GetTokenForAuthChallenge( | 179 base::string16 GetTokenForAuthChallenge( |
marq (ping after 24h)
2014/05/09 17:00:06
Fits on one line now.
bengr
2014/05/09 17:12:20
Done.
| |
172 net::AuthChallengeInfo* auth_info); | 180 net::AuthChallengeInfo* auth_info); |
173 | 181 |
174 // Returns true if the proxy is enabled. | 182 // Returns true if the proxy is enabled. |
175 bool IsDataReductionProxyEnabled(); | 183 bool IsDataReductionProxyEnabled(); |
176 | 184 |
177 // Returns true if the proxy is managed by an adminstrator's policy. | 185 // Returns true if the proxy is managed by an adminstrator's policy. |
178 bool IsDataReductionProxyManaged(); | 186 bool IsDataReductionProxyManaged(); |
179 | 187 |
180 // Enables or disables the data reduction proxy. If a probe URL is available, | 188 // Enables or disables the data reduction proxy. If a probe URL is available, |
181 // and a probe request fails at some point, the proxy won't be used until a | 189 // and a probe request fails at some point, the proxy won't be used until a |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 287 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
280 TestBypassList); | 288 TestBypassList); |
281 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 289 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
282 CheckInitMetricsWhenNotAllowed); | 290 CheckInitMetricsWhenNotAllowed); |
283 | 291 |
284 // NetworkChangeNotifier::IPAddressObserver: | 292 // NetworkChangeNotifier::IPAddressObserver: |
285 virtual void OnIPAddressChanged() OVERRIDE; | 293 virtual void OnIPAddressChanged() OVERRIDE; |
286 | 294 |
287 // Underlying implementation of InitDataReductionProxySession(), factored | 295 // Underlying implementation of InitDataReductionProxySession(), factored |
288 // out to be testable without creating a full HttpNetworkSession. | 296 // out to be testable without creating a full HttpNetworkSession. |
289 static void InitDataReductionAuthentication(net::HttpAuthCache* auth_cache); | 297 static void InitDataReductionAuthentication(net::HttpAuthCache* auth_cache, |
298 const std::string& key); | |
290 | 299 |
291 void OnProxyEnabledPrefChange(); | 300 void OnProxyEnabledPrefChange(); |
292 | 301 |
293 void ResetDataReductionStatistics(); | 302 void ResetDataReductionStatistics(); |
294 | 303 |
295 void MaybeActivateDataReductionProxy(bool at_startup); | 304 void MaybeActivateDataReductionProxy(bool at_startup); |
296 | 305 |
297 // Requests the proxy probe URL, if one is set. If unable to do so, disables | 306 // Requests the proxy probe URL, if one is set. If unable to do so, disables |
298 // the proxy, if enabled. Otherwise enables the proxy if disabled by a probe | 307 // the proxy, if enabled. Otherwise enables the proxy if disabled by a probe |
299 // failure. | 308 // failure. |
300 void ProbeWhetherDataReductionProxyIsAvailable(); | 309 void ProbeWhetherDataReductionProxyIsAvailable(); |
301 std::string GetProxyCheckURL(); | 310 std::string GetProxyCheckURL(); |
302 | 311 |
303 // Returns a UTF16 string that's the hash of the configured authentication | 312 // Returns a UTF16 string that's the hash of the configured authentication |
304 // key and |salt|. Returns an empty UTF16 string if no key is configured or | 313 // |key| and |salt|. Returns an empty UTF16 string if no key is configured or |
305 // the data reduction proxy feature isn't available. | 314 // the data reduction proxy feature isn't available. |
306 static base::string16 AuthHashForSalt(int64 salt); | 315 static base::string16 AuthHashForSalt(int64 salt, |
316 const std::string& key); | |
marq (ping after 24h)
2014/05/09 17:00:06
Fits on one line?
bengr
2014/05/09 17:12:20
Done.
| |
307 | 317 |
308 static std::string key_; | |
309 static bool allowed_; | 318 static bool allowed_; |
310 static bool promo_allowed_; | 319 static bool promo_allowed_; |
311 | 320 |
321 std::string key_; | |
312 bool restricted_by_carrier_; | 322 bool restricted_by_carrier_; |
313 bool enabled_by_user_; | 323 bool enabled_by_user_; |
314 | 324 |
315 scoped_ptr<net::URLFetcher> fetcher_; | 325 scoped_ptr<net::URLFetcher> fetcher_; |
316 BooleanPrefMember spdy_proxy_auth_enabled_; | 326 BooleanPrefMember spdy_proxy_auth_enabled_; |
317 | 327 |
318 PrefService* prefs_; | 328 PrefService* prefs_; |
319 PrefService* local_state_prefs_; | 329 PrefService* local_state_prefs_; |
320 | 330 |
321 net::URLRequestContextGetter* url_request_context_getter_; | 331 net::URLRequestContextGetter* url_request_context_getter_; |
322 | 332 |
323 scoped_ptr<DataReductionProxyConfigurator> config_; | 333 scoped_ptr<DataReductionProxyConfigurator> config_; |
324 | 334 |
325 base::ThreadChecker thread_checker_; | 335 base::ThreadChecker thread_checker_; |
326 | 336 |
327 bool fallback_allowed_; | 337 bool fallback_allowed_; |
328 | 338 |
329 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); | 339 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); |
330 }; | 340 }; |
331 | 341 |
332 } // namespace data_reduction_proxy | 342 } // namespace data_reduction_proxy |
333 | 343 |
334 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS _H_ | 344 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS _H_ |
OLD | NEW |