Chromium Code Reviews| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 prefs::kDataReductionProxyAltEnabled, | 114 prefs::kDataReductionProxyAltEnabled, |
| 115 GetOriginalProfilePrefs(), | 115 GetOriginalProfilePrefs(), |
| 116 base::Bind( | 116 base::Bind( |
| 117 &DataReductionProxySettings::OnProxyAlternativeEnabledPrefChange, | 117 &DataReductionProxySettings::OnProxyAlternativeEnabledPrefChange, |
| 118 base::Unretained(this))); | 118 base::Unretained(this))); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void DataReductionProxySettings::InitDataReductionProxySettings( | 121 void DataReductionProxySettings::InitDataReductionProxySettings( |
| 122 PrefService* prefs, | 122 PrefService* prefs, |
| 123 PrefService* local_state_prefs, | 123 PrefService* local_state_prefs, |
| 124 net::URLRequestContextGetter* url_request_context_getter) { | 124 net::URLRequestContextGetter* url_request_context_getter, |
| 125 const base::Callback<void(bool)>& on_data_reduction_proxy_enabled) { | |
|
bengr
2014/07/30 19:08:22
This is fine, but eventually we should move to add
| |
| 125 DCHECK(thread_checker_.CalledOnValidThread()); | 126 DCHECK(thread_checker_.CalledOnValidThread()); |
| 126 DCHECK(prefs); | 127 DCHECK(prefs); |
| 127 DCHECK(local_state_prefs); | 128 DCHECK(local_state_prefs); |
| 128 DCHECK(url_request_context_getter); | 129 DCHECK(url_request_context_getter); |
| 129 prefs_ = prefs; | 130 prefs_ = prefs; |
| 130 local_state_prefs_ = local_state_prefs; | 131 local_state_prefs_ = local_state_prefs; |
| 131 url_request_context_getter_ = url_request_context_getter; | 132 url_request_context_getter_ = url_request_context_getter; |
| 133 on_data_reduction_proxy_enabled_ = on_data_reduction_proxy_enabled; | |
| 132 InitPrefMembers(); | 134 InitPrefMembers(); |
| 133 RecordDataReductionInit(); | 135 RecordDataReductionInit(); |
| 136 | |
| 137 on_data_reduction_proxy_enabled_.Run(IsDataReductionProxyEnabled()); | |
| 138 | |
| 134 // Disable the proxy if it is not allowed to be used. | 139 // Disable the proxy if it is not allowed to be used. |
| 135 if (!params_->allowed()) | 140 if (!params_->allowed()) |
| 136 return; | 141 return; |
| 137 | 142 |
| 138 AddDefaultProxyBypassRules(); | 143 AddDefaultProxyBypassRules(); |
| 139 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 144 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 140 | 145 |
| 141 // We set or reset the proxy pref at startup. | 146 // We set or reset the proxy pref at startup. |
| 142 MaybeActivateDataReductionProxy(true); | 147 MaybeActivateDataReductionProxy(true); |
| 143 } | 148 } |
| 144 | 149 |
| 145 void DataReductionProxySettings::InitDataReductionProxySettings( | 150 void DataReductionProxySettings::InitDataReductionProxySettings( |
| 146 PrefService* prefs, | 151 PrefService* prefs, |
| 147 PrefService* local_state_prefs, | 152 PrefService* local_state_prefs, |
| 148 net::URLRequestContextGetter* url_request_context_getter, | 153 net::URLRequestContextGetter* url_request_context_getter, |
| 149 scoped_ptr<DataReductionProxyConfigurator> configurator) { | 154 scoped_ptr<DataReductionProxyConfigurator> configurator, |
| 155 const base::Callback<void(bool)>& on_data_reduction_proxy_enabled) { | |
| 150 InitDataReductionProxySettings(prefs, | 156 InitDataReductionProxySettings(prefs, |
| 151 local_state_prefs, | 157 local_state_prefs, |
| 152 url_request_context_getter); | 158 url_request_context_getter, |
| 159 on_data_reduction_proxy_enabled); | |
| 153 SetProxyConfigurator(configurator.Pass()); | 160 SetProxyConfigurator(configurator.Pass()); |
| 154 } | 161 } |
| 155 | 162 |
| 156 void DataReductionProxySettings::SetProxyConfigurator( | 163 void DataReductionProxySettings::SetProxyConfigurator( |
| 157 scoped_ptr<DataReductionProxyConfigurator> configurator) { | 164 scoped_ptr<DataReductionProxyConfigurator> configurator) { |
| 158 DCHECK(configurator); | 165 DCHECK(configurator); |
| 159 configurator_ = configurator.Pass(); | 166 configurator_ = configurator.Pass(); |
| 160 } | 167 } |
| 161 | 168 |
| 162 bool DataReductionProxySettings::IsDataReductionProxyEnabled() { | 169 bool DataReductionProxySettings::IsDataReductionProxyEnabled() { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 173 } | 180 } |
| 174 | 181 |
| 175 void DataReductionProxySettings::SetDataReductionProxyEnabled(bool enabled) { | 182 void DataReductionProxySettings::SetDataReductionProxyEnabled(bool enabled) { |
| 176 DCHECK(thread_checker_.CalledOnValidThread()); | 183 DCHECK(thread_checker_.CalledOnValidThread()); |
| 177 // Prevent configuring the proxy when it is not allowed to be used. | 184 // Prevent configuring the proxy when it is not allowed to be used. |
| 178 if (!params_->allowed()) | 185 if (!params_->allowed()) |
| 179 return; | 186 return; |
| 180 | 187 |
| 181 if (spdy_proxy_auth_enabled_.GetValue() != enabled) { | 188 if (spdy_proxy_auth_enabled_.GetValue() != enabled) { |
| 182 spdy_proxy_auth_enabled_.SetValue(enabled); | 189 spdy_proxy_auth_enabled_.SetValue(enabled); |
| 190 on_data_reduction_proxy_enabled_.Run(IsDataReductionProxyEnabled()); | |
|
bengr
2014/07/30 19:08:22
I think this should be done in OnProxyEnabledPrefC
megjablon
2014/07/30 21:27:07
Done.
| |
| 183 OnProxyEnabledPrefChange(); | 191 OnProxyEnabledPrefChange(); |
| 184 } | 192 } |
| 185 } | 193 } |
| 186 | 194 |
| 187 void DataReductionProxySettings::SetDataReductionProxyAlternativeEnabled( | 195 void DataReductionProxySettings::SetDataReductionProxyAlternativeEnabled( |
| 188 bool enabled) { | 196 bool enabled) { |
| 189 DCHECK(thread_checker_.CalledOnValidThread()); | 197 DCHECK(thread_checker_.CalledOnValidThread()); |
| 190 // Prevent configuring the proxy when it is not allowed to be used. | 198 // Prevent configuring the proxy when it is not allowed to be used. |
| 191 if (!params_->alternative_allowed()) | 199 if (!params_->alternative_allowed()) |
| 192 return; | 200 return; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 SetProxyConfigs(enabled_by_user_, | 611 SetProxyConfigs(enabled_by_user_, |
| 604 IsDataReductionProxyAlternativeEnabled(), | 612 IsDataReductionProxyAlternativeEnabled(), |
| 605 restricted_by_carrier_, | 613 restricted_by_carrier_, |
| 606 false); | 614 false); |
| 607 } | 615 } |
| 608 disabled_on_vpn_ = false; | 616 disabled_on_vpn_ = false; |
| 609 return false; | 617 return false; |
| 610 } | 618 } |
| 611 | 619 |
| 612 } // namespace data_reduction_proxy | 620 } // namespace data_reduction_proxy |
| OLD | NEW |