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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 net::URLRequestContextGetter* url_request_context_getter) { | 120 net::URLRequestContextGetter* url_request_context_getter) { |
121 DCHECK(thread_checker_.CalledOnValidThread()); | 121 DCHECK(thread_checker_.CalledOnValidThread()); |
122 DCHECK(prefs); | 122 DCHECK(prefs); |
123 DCHECK(local_state_prefs); | 123 DCHECK(local_state_prefs); |
124 DCHECK(url_request_context_getter); | 124 DCHECK(url_request_context_getter); |
125 prefs_ = prefs; | 125 prefs_ = prefs; |
126 local_state_prefs_ = local_state_prefs; | 126 local_state_prefs_ = local_state_prefs; |
127 url_request_context_getter_ = url_request_context_getter; | 127 url_request_context_getter_ = url_request_context_getter; |
128 InitPrefMembers(); | 128 InitPrefMembers(); |
129 RecordDataReductionInit(); | 129 RecordDataReductionInit(); |
130 | |
131 // Disable the proxy if it is not allowed to be used. | 130 // Disable the proxy if it is not allowed to be used. |
132 if (!params_->allowed()) | 131 if (!params_->allowed()) |
133 return; | 132 return; |
134 | 133 |
135 AddDefaultProxyBypassRules(); | 134 AddDefaultProxyBypassRules(); |
136 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 135 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
137 | 136 |
138 // We set or reset the proxy pref at startup. | 137 // We set or reset the proxy pref at startup. |
139 MaybeActivateDataReductionProxy(true); | 138 MaybeActivateDataReductionProxy(true); |
140 } | 139 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 bool at_startup) { | 368 bool at_startup) { |
370 DCHECK(thread_checker_.CalledOnValidThread()); | 369 DCHECK(thread_checker_.CalledOnValidThread()); |
371 PrefService* prefs = GetOriginalProfilePrefs(); | 370 PrefService* prefs = GetOriginalProfilePrefs(); |
372 // TODO(marq): Consider moving this so stats are wiped the first time the | 371 // TODO(marq): Consider moving this so stats are wiped the first time the |
373 // proxy settings are actually (not maybe) turned on. | 372 // proxy settings are actually (not maybe) turned on. |
374 if (spdy_proxy_auth_enabled_.GetValue() && | 373 if (spdy_proxy_auth_enabled_.GetValue() && |
375 !prefs->GetBoolean(prefs::kDataReductionProxyWasEnabledBefore)) { | 374 !prefs->GetBoolean(prefs::kDataReductionProxyWasEnabledBefore)) { |
376 prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true); | 375 prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true); |
377 ResetDataReductionStatistics(); | 376 ResetDataReductionStatistics(); |
378 } | 377 } |
379 | |
380 // Configure use of the data reduction proxy if it is enabled. | 378 // Configure use of the data reduction proxy if it is enabled. |
381 enabled_by_user_= IsDataReductionProxyEnabled(); | 379 enabled_by_user_= IsDataReductionProxyEnabled(); |
382 SetProxyConfigs(enabled_by_user_ && !disabled_on_vpn_, | 380 SetProxyConfigs(enabled_by_user_ && !disabled_on_vpn_, |
383 IsDataReductionProxyAlternativeEnabled(), | 381 IsDataReductionProxyAlternativeEnabled(), |
384 restricted_by_carrier_, | 382 restricted_by_carrier_, |
385 at_startup); | 383 at_startup); |
386 | 384 |
387 // Check if the proxy has been restricted explicitly by the carrier. | 385 // Check if the proxy has been restricted explicitly by the carrier. |
388 if (enabled_by_user_ && !disabled_on_vpn_) { | 386 if (enabled_by_user_ && !disabled_on_vpn_) { |
389 ProbeWhetherDataReductionProxyIsAvailable(); | 387 ProbeWhetherDataReductionProxyIsAvailable(); |
390 WarmProxyConnection(); | 388 WarmProxyConnection(); |
391 } | 389 } |
392 } | 390 } |
393 | 391 |
394 void DataReductionProxySettings::SetProxyConfigs(bool enabled, | 392 void DataReductionProxySettings::SetProxyConfigs(bool enabled, |
395 bool alternative_enabled, | 393 bool alternative_enabled, |
396 bool restricted, | 394 bool restricted, |
397 bool at_startup) { | 395 bool at_startup) { |
398 DCHECK(thread_checker_.CalledOnValidThread()); | 396 DCHECK(thread_checker_.CalledOnValidThread()); |
399 LogProxyState(enabled, restricted, at_startup); | 397 LogProxyState(enabled, restricted, at_startup); |
400 // The alternative is only configured if the standard configuration is | 398 // The alternative is only configured if the standard configuration is |
401 // is enabled. | 399 // is enabled. |
402 if (enabled) { | 400 if (enabled & !params_->holdback()) { |
403 if (alternative_enabled) { | 401 if (alternative_enabled) { |
404 configurator_->Enable(restricted, | 402 configurator_->Enable(restricted, |
405 !params_->fallback_allowed(), | 403 !params_->fallback_allowed(), |
406 params_->alt_origin().spec(), | 404 params_->alt_origin().spec(), |
407 params_->alt_fallback_origin().spec(), | 405 params_->alt_fallback_origin().spec(), |
408 params_->ssl_origin().spec()); | 406 params_->ssl_origin().spec()); |
409 } else { | 407 } else { |
410 configurator_->Enable(restricted, | 408 configurator_->Enable(restricted, |
411 !params_->fallback_allowed(), | 409 !params_->fallback_allowed(), |
412 params_->origin().spec(), | 410 params_->origin().spec(), |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 SetProxyConfigs(enabled_by_user_, | 580 SetProxyConfigs(enabled_by_user_, |
583 IsDataReductionProxyAlternativeEnabled(), | 581 IsDataReductionProxyAlternativeEnabled(), |
584 restricted_by_carrier_, | 582 restricted_by_carrier_, |
585 false); | 583 false); |
586 } | 584 } |
587 disabled_on_vpn_ = false; | 585 disabled_on_vpn_ = false; |
588 return false; | 586 return false; |
589 } | 587 } |
590 | 588 |
591 } // namespace data_reduction_proxy | 589 } // namespace data_reduction_proxy |
OLD | NEW |