| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/prefs/pref_member.h" | 14 #include "base/prefs/pref_member.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" | 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" |
| 17 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 17 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 18 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
| 19 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
| 20 | 20 |
| 21 class PrefService; | 21 class PrefService; |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 class AuthChallengeInfo; | |
| 25 class HostPortPair; | 24 class HostPortPair; |
| 26 class HttpAuthCache; | |
| 27 class HttpNetworkSession; | 25 class HttpNetworkSession; |
| 28 class HttpResponseHeaders; | 26 class HttpResponseHeaders; |
| 29 class URLFetcher; | 27 class URLFetcher; |
| 30 class URLRequestContextGetter; | 28 class URLRequestContextGetter; |
| 31 } | 29 } |
| 32 | 30 |
| 33 namespace data_reduction_proxy { | 31 namespace data_reduction_proxy { |
| 34 | 32 |
| 35 // The number of days of bandwidth usage statistics that are tracked. | 33 // The number of days of bandwidth usage statistics that are tracked. |
| 36 const unsigned int kNumDaysInHistory = 60; | 34 const unsigned int kNumDaysInHistory = 60; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 PrefService* prefs, | 113 PrefService* prefs, |
| 116 PrefService* local_state_prefs, | 114 PrefService* local_state_prefs, |
| 117 net::URLRequestContextGetter* url_request_context_getter, | 115 net::URLRequestContextGetter* url_request_context_getter, |
| 118 scoped_ptr<DataReductionProxyConfigurator> configurator); | 116 scoped_ptr<DataReductionProxyConfigurator> configurator); |
| 119 | 117 |
| 120 // Sets the logic the embedder uses to set the networking configuration that | 118 // Sets the logic the embedder uses to set the networking configuration that |
| 121 // causes traffic to be proxied. | 119 // causes traffic to be proxied. |
| 122 void SetProxyConfigurator( | 120 void SetProxyConfigurator( |
| 123 scoped_ptr<DataReductionProxyConfigurator> configurator); | 121 scoped_ptr<DataReductionProxyConfigurator> configurator); |
| 124 | 122 |
| 125 // If proxy authentication is compiled in, pre-cache authentication | |
| 126 // keys for all configured proxies in |session|. | |
| 127 static void InitDataReductionProxySession( | |
| 128 net::HttpNetworkSession* session, | |
| 129 const DataReductionProxyParams* params); | |
| 130 | |
| 131 // Returns true if |auth_info| represents an authentication challenge from | |
| 132 // a compatible, configured proxy. | |
| 133 bool IsAcceptableAuthChallenge(net::AuthChallengeInfo* auth_info); | |
| 134 | |
| 135 // Returns a UTF16 string suitable for use as an authentication token in | |
| 136 // response to the challenge represented by |auth_info|. If the token can't | |
| 137 // be correctly generated for |auth_info|, returns an empty UTF16 string. | |
| 138 base::string16 GetTokenForAuthChallenge(net::AuthChallengeInfo* auth_info); | |
| 139 | |
| 140 // Returns true if the proxy is enabled. | 123 // Returns true if the proxy is enabled. |
| 141 bool IsDataReductionProxyEnabled(); | 124 bool IsDataReductionProxyEnabled(); |
| 142 | 125 |
| 143 // Returns true if the alternative proxy is enabled. | 126 // Returns true if the alternative proxy is enabled. |
| 144 bool IsDataReductionProxyAlternativeEnabled() const; | 127 bool IsDataReductionProxyAlternativeEnabled() const; |
| 145 | 128 |
| 146 // Returns true if the proxy is managed by an adminstrator's policy. | 129 // Returns true if the proxy is managed by an adminstrator's policy. |
| 147 bool IsDataReductionProxyManaged(); | 130 bool IsDataReductionProxyManaged(); |
| 148 | 131 |
| 149 // Enables or disables the data reduction proxy. If a probe URL is available, | 132 // Enables or disables the data reduction proxy. If a probe URL is available, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 237 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
| 255 TestBypassList); | 238 TestBypassList); |
| 256 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 239 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
| 257 CheckInitMetricsWhenNotAllowed); | 240 CheckInitMetricsWhenNotAllowed); |
| 258 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 241 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
| 259 TestSetProxyConfigs); | 242 TestSetProxyConfigs); |
| 260 | 243 |
| 261 // NetworkChangeNotifier::IPAddressObserver: | 244 // NetworkChangeNotifier::IPAddressObserver: |
| 262 virtual void OnIPAddressChanged() OVERRIDE; | 245 virtual void OnIPAddressChanged() OVERRIDE; |
| 263 | 246 |
| 264 // Underlying implementation of InitDataReductionProxySession(), factored | |
| 265 // out to be testable without creating a full HttpNetworkSession. | |
| 266 static void InitDataReductionAuthentication( | |
| 267 net::HttpAuthCache* auth_cache, | |
| 268 const DataReductionProxyParams* params); | |
| 269 | |
| 270 void OnProxyEnabledPrefChange(); | 247 void OnProxyEnabledPrefChange(); |
| 271 void OnProxyAlternativeEnabledPrefChange(); | 248 void OnProxyAlternativeEnabledPrefChange(); |
| 272 | 249 |
| 273 void ResetDataReductionStatistics(); | 250 void ResetDataReductionStatistics(); |
| 274 | 251 |
| 275 void MaybeActivateDataReductionProxy(bool at_startup); | 252 void MaybeActivateDataReductionProxy(bool at_startup); |
| 276 | 253 |
| 277 // Requests the proxy probe URL, if one is set. If unable to do so, disables | 254 // Requests the proxy probe URL, if one is set. If unable to do so, disables |
| 278 // the proxy, if enabled. Otherwise enables the proxy if disabled by a probe | 255 // the proxy, if enabled. Otherwise enables the proxy if disabled by a probe |
| 279 // failure. | 256 // failure. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 base::ThreadChecker thread_checker_; | 288 base::ThreadChecker thread_checker_; |
| 312 | 289 |
| 313 scoped_ptr<DataReductionProxyParams> params_; | 290 scoped_ptr<DataReductionProxyParams> params_; |
| 314 | 291 |
| 315 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); | 292 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); |
| 316 }; | 293 }; |
| 317 | 294 |
| 318 } // namespace data_reduction_proxy | 295 } // namespace data_reduction_proxy |
| 319 | 296 |
| 320 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS
_H_ | 297 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS
_H_ |
| OLD | NEW |