| Index: components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc
|
| diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc
|
| index cc575c94c3f6ef5e5cabd93855ed99cb89d94dd7..8ae8763df75d6469a810894928a6a242c5462e75 100644
|
| --- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc
|
| +++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc
|
| @@ -8,6 +8,7 @@
|
| #include "base/command_line.h"
|
| #include "base/metrics/field_trial.h"
|
| #include "base/metrics/histogram.h"
|
| +#include "base/metrics/user_metrics.h"
|
| #include "base/prefs/pref_member.h"
|
| #include "base/prefs/pref_service.h"
|
| #include "base/prefs/scoped_user_pref_update.h"
|
| @@ -24,6 +25,7 @@
|
| #include "net/base/host_port_pair.h"
|
| #include "net/base/load_flags.h"
|
| #include "net/base/net_errors.h"
|
| +#include "net/base/net_util.h"
|
| #include "net/http/http_network_session.h"
|
| #include "net/http/http_response_headers.h"
|
| #include "net/url_request/url_fetcher.h"
|
| @@ -70,9 +72,11 @@ DataReductionProxySettings::DataReductionProxySettings(
|
| DataReductionProxyParams* params)
|
| : restricted_by_carrier_(false),
|
| enabled_by_user_(false),
|
| + disabled_on_vpn_(false),
|
| prefs_(NULL),
|
| local_state_prefs_(NULL),
|
| - url_request_context_getter_(NULL) {
|
| + url_request_context_getter_(NULL),
|
| + usage_stats_(NULL) {
|
| DCHECK(params);
|
| params_.reset(params);
|
| }
|
| @@ -311,6 +315,10 @@ void DataReductionProxySettings::OnIPAddressChanged() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| if (enabled_by_user_) {
|
| DCHECK(params_->allowed());
|
| + base::RecordAction(
|
| + base::UserMetricsAction("DataReductionProxy_IPAddressChanged"));
|
| + if (DisableIfVPN())
|
| + return;
|
| ProbeWhetherDataReductionProxyIsAvailable();
|
| WarmProxyConnection();
|
| }
|
| @@ -359,13 +367,13 @@ void DataReductionProxySettings::MaybeActivateDataReductionProxy(
|
|
|
| // Configure use of the data reduction proxy if it is enabled.
|
| enabled_by_user_= IsDataReductionProxyEnabled();
|
| - SetProxyConfigs(enabled_by_user_,
|
| + SetProxyConfigs(enabled_by_user_ && !disabled_on_vpn_,
|
| IsDataReductionProxyAlternativeEnabled(),
|
| restricted_by_carrier_,
|
| at_startup);
|
|
|
| // Check if the proxy has been restricted explicitly by the carrier.
|
| - if (enabled_by_user_) {
|
| + if (enabled_by_user_ && !disabled_on_vpn_) {
|
| ProbeWhetherDataReductionProxyIsAvailable();
|
| WarmProxyConnection();
|
| }
|
| @@ -425,6 +433,13 @@ void DataReductionProxySettings::RecordStartupState(ProxyStartupState state) {
|
| PROXY_STARTUP_STATE_COUNT);
|
| }
|
|
|
| +void DataReductionProxySettings::GetNetworkList(
|
| + net::NetworkInterfaceList* interfaces,
|
| + int policy) {
|
| + net::GetNetworkList(interfaces, policy);
|
| +
|
| +}
|
| +
|
| void DataReductionProxySettings::ResetParamsForTest(
|
| DataReductionProxyParams* params) {
|
| params_.reset(params);
|
| @@ -485,18 +500,6 @@ void DataReductionProxySettings::GetContentLengths(
|
| local_state->GetInt64(prefs::kDailyHttpContentLengthLastUpdateDate);
|
| }
|
|
|
| -// static
|
| -base::string16 DataReductionProxySettings::AuthHashForSalt(
|
| - int64 salt,
|
| - const std::string& key) {
|
| - std::string salted_key =
|
| - base::StringPrintf("%lld%s%lld",
|
| - static_cast<long long>(salt),
|
| - key.c_str(),
|
| - static_cast<long long>(salt));
|
| - return base::UTF8ToUTF16(base::MD5String(salted_key));
|
| -}
|
| -
|
| net::URLFetcher* DataReductionProxySettings::GetBaseURLFetcher(
|
| const GURL& gurl,
|
| int load_flags) {
|
| @@ -542,4 +545,28 @@ void DataReductionProxySettings::WarmProxyConnection() {
|
| warmup_fetcher_->Start();
|
| }
|
|
|
| +bool DataReductionProxySettings::DisableIfVPN() {
|
| + net::NetworkInterfaceList network_interfaces;
|
| + GetNetworkList(&network_interfaces, 0);
|
| + const std::string vpn_interface_name_prefix = "tun";
|
| + for (size_t i = 0; i < network_interfaces.size(); ++i) {
|
| + std::string interface_name = network_interfaces[i].name;
|
| + if (LowerCaseEqualsASCII(
|
| + interface_name.begin(),
|
| + interface_name.begin() + vpn_interface_name_prefix.size(),
|
| + vpn_interface_name_prefix.c_str())) {
|
| + SetProxyConfigs(false,
|
| + IsDataReductionProxyAlternativeEnabled(),
|
| + false,
|
| + false);
|
| + disabled_on_vpn_ = true;
|
| + base::RecordAction(
|
| + base::UserMetricsAction("DataReductionProxy_DisabledOnVPN"));
|
| + return true;
|
| + }
|
| + }
|
| + disabled_on_vpn_ = false;
|
| + return false;
|
| +}
|
| +
|
| } // namespace data_reduction_proxy
|
|
|