| 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 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 namespace data_reduction_proxy { | 87 namespace data_reduction_proxy { |
| 88 | 88 |
| 89 DataReductionProxySettings::DataReductionProxySettings( | 89 DataReductionProxySettings::DataReductionProxySettings( |
| 90 DataReductionProxyParams* params) | 90 DataReductionProxyParams* params) |
| 91 : restricted_by_carrier_(false), | 91 : restricted_by_carrier_(false), |
| 92 enabled_by_user_(false), | 92 enabled_by_user_(false), |
| 93 disabled_on_vpn_(false), | 93 disabled_on_vpn_(false), |
| 94 unreachable_(false), | 94 unreachable_(false), |
| 95 prefs_(NULL), | 95 prefs_(NULL), |
| 96 local_state_prefs_(NULL), | 96 local_state_prefs_(NULL), |
| 97 url_request_context_getter_(NULL) { | 97 url_request_context_getter_(NULL), |
| 98 configurator_(NULL) { |
| 98 DCHECK(params); | 99 DCHECK(params); |
| 99 params_.reset(params); | 100 params_.reset(params); |
| 100 } | 101 } |
| 101 | 102 |
| 102 DataReductionProxySettings::~DataReductionProxySettings() { | 103 DataReductionProxySettings::~DataReductionProxySettings() { |
| 103 if (params_->allowed()) | 104 if (params_->allowed()) |
| 104 spdy_proxy_auth_enabled_.Destroy(); | 105 spdy_proxy_auth_enabled_.Destroy(); |
| 105 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 106 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| 106 } | 107 } |
| 107 | 108 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 143 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 143 | 144 |
| 144 // We set or reset the proxy pref at startup. | 145 // We set or reset the proxy pref at startup. |
| 145 MaybeActivateDataReductionProxy(true); | 146 MaybeActivateDataReductionProxy(true); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void DataReductionProxySettings::InitDataReductionProxySettings( | 149 void DataReductionProxySettings::InitDataReductionProxySettings( |
| 149 PrefService* prefs, | 150 PrefService* prefs, |
| 150 PrefService* local_state_prefs, | 151 PrefService* local_state_prefs, |
| 151 net::URLRequestContextGetter* url_request_context_getter, | 152 net::URLRequestContextGetter* url_request_context_getter, |
| 152 scoped_ptr<DataReductionProxyConfigurator> configurator) { | 153 DataReductionProxyConfigurator* configurator) { |
| 153 InitDataReductionProxySettings(prefs, | 154 InitDataReductionProxySettings(prefs, |
| 154 local_state_prefs, | 155 local_state_prefs, |
| 155 url_request_context_getter); | 156 url_request_context_getter); |
| 156 SetProxyConfigurator(configurator.Pass()); | 157 SetProxyConfigurator(configurator); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void DataReductionProxySettings::SetOnDataReductionEnabledCallback( | 160 void DataReductionProxySettings::SetOnDataReductionEnabledCallback( |
| 160 const base::Callback<void(bool)>& on_data_reduction_proxy_enabled) { | 161 const base::Callback<void(bool)>& on_data_reduction_proxy_enabled) { |
| 161 on_data_reduction_proxy_enabled_ = on_data_reduction_proxy_enabled; | 162 on_data_reduction_proxy_enabled_ = on_data_reduction_proxy_enabled; |
| 162 on_data_reduction_proxy_enabled_.Run(IsDataReductionProxyEnabled()); | 163 on_data_reduction_proxy_enabled_.Run(IsDataReductionProxyEnabled()); |
| 163 } | 164 } |
| 164 | 165 |
| 165 void DataReductionProxySettings::SetProxyConfigurator( | 166 void DataReductionProxySettings::SetProxyConfigurator( |
| 166 scoped_ptr<DataReductionProxyConfigurator> configurator) { | 167 DataReductionProxyConfigurator* configurator) { |
| 167 DCHECK(configurator); | 168 DCHECK(configurator); |
| 168 configurator_ = configurator.Pass(); | 169 configurator_ = configurator; |
| 169 } | 170 } |
| 170 | 171 |
| 171 bool DataReductionProxySettings::IsDataReductionProxyEnabled() { | 172 bool DataReductionProxySettings::IsDataReductionProxyEnabled() { |
| 172 return spdy_proxy_auth_enabled_.GetValue() || IsEnabledOnCommandLine(); | 173 return spdy_proxy_auth_enabled_.GetValue() || IsEnabledOnCommandLine(); |
| 173 } | 174 } |
| 174 | 175 |
| 175 bool | 176 bool |
| 176 DataReductionProxySettings::IsDataReductionProxyAlternativeEnabled() const { | 177 DataReductionProxySettings::IsDataReductionProxyAlternativeEnabled() const { |
| 177 return data_reduction_proxy_alternative_enabled_.GetValue(); | 178 return data_reduction_proxy_alternative_enabled_.GetValue(); |
| 178 } | 179 } |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 SetProxyConfigs(enabled_by_user_, | 604 SetProxyConfigs(enabled_by_user_, |
| 604 IsDataReductionProxyAlternativeEnabled(), | 605 IsDataReductionProxyAlternativeEnabled(), |
| 605 restricted_by_carrier_, | 606 restricted_by_carrier_, |
| 606 false); | 607 false); |
| 607 } | 608 } |
| 608 disabled_on_vpn_ = false; | 609 disabled_on_vpn_ = false; |
| 609 return false; | 610 return false; |
| 610 } | 611 } |
| 611 | 612 |
| 612 } // namespace data_reduction_proxy | 613 } // namespace data_reduction_proxy |
| OLD | NEW |