| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 << " " << (at_startup ? kAtStartup : kByUser); | 332 << " " << (at_startup ? kAtStartup : kByUser); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void DataReductionProxySettings::OnIPAddressChanged() { | 335 void DataReductionProxySettings::OnIPAddressChanged() { |
| 336 DCHECK(thread_checker_.CalledOnValidThread()); | 336 DCHECK(thread_checker_.CalledOnValidThread()); |
| 337 if (enabled_by_user_) { | 337 if (enabled_by_user_) { |
| 338 DCHECK(params_->allowed()); | 338 DCHECK(params_->allowed()); |
| 339 RecordNetworkChangeEvent(IP_CHANGED); | 339 RecordNetworkChangeEvent(IP_CHANGED); |
| 340 if (DisableIfVPN()) | 340 if (DisableIfVPN()) |
| 341 return; | 341 return; |
| 342 if (IsDataReductionProxyAlternativeEnabled() && |
| 343 !params_->alternative_fallback_allowed()) { |
| 344 return; |
| 345 } |
| 342 ProbeWhetherDataReductionProxyIsAvailable(); | 346 ProbeWhetherDataReductionProxyIsAvailable(); |
| 343 } | 347 } |
| 344 } | 348 } |
| 345 | 349 |
| 346 void DataReductionProxySettings::OnProxyEnabledPrefChange() { | 350 void DataReductionProxySettings::OnProxyEnabledPrefChange() { |
| 347 DCHECK(thread_checker_.CalledOnValidThread()); | 351 DCHECK(thread_checker_.CalledOnValidThread()); |
| 348 if (!on_data_reduction_proxy_enabled_.is_null()) | 352 if (!on_data_reduction_proxy_enabled_.is_null()) |
| 349 on_data_reduction_proxy_enabled_.Run(IsDataReductionProxyEnabled()); | 353 on_data_reduction_proxy_enabled_.Run(IsDataReductionProxyEnabled()); |
| 350 if (!params_->allowed()) | 354 if (!params_->allowed()) |
| 351 return; | 355 return; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 ResetDataReductionStatistics(); | 390 ResetDataReductionStatistics(); |
| 387 } | 391 } |
| 388 // Configure use of the data reduction proxy if it is enabled. | 392 // Configure use of the data reduction proxy if it is enabled. |
| 389 enabled_by_user_= IsDataReductionProxyEnabled(); | 393 enabled_by_user_= IsDataReductionProxyEnabled(); |
| 390 SetProxyConfigs(enabled_by_user_ && !disabled_on_vpn_, | 394 SetProxyConfigs(enabled_by_user_ && !disabled_on_vpn_, |
| 391 IsDataReductionProxyAlternativeEnabled(), | 395 IsDataReductionProxyAlternativeEnabled(), |
| 392 restricted_by_carrier_, | 396 restricted_by_carrier_, |
| 393 at_startup); | 397 at_startup); |
| 394 | 398 |
| 395 // Check if the proxy has been restricted explicitly by the carrier. | 399 // Check if the proxy has been restricted explicitly by the carrier. |
| 396 if (enabled_by_user_ && !disabled_on_vpn_) { | 400 if (enabled_by_user_ && !disabled_on_vpn_ && |
| 401 !(IsDataReductionProxyAlternativeEnabled() && |
| 402 !params_->alternative_fallback_allowed())) { |
| 397 ProbeWhetherDataReductionProxyIsAvailable(); | 403 ProbeWhetherDataReductionProxyIsAvailable(); |
| 398 } | 404 } |
| 399 } | 405 } |
| 400 | 406 |
| 401 void DataReductionProxySettings::SetProxyConfigs(bool enabled, | 407 void DataReductionProxySettings::SetProxyConfigs(bool enabled, |
| 402 bool alternative_enabled, | 408 bool alternative_enabled, |
| 403 bool restricted, | 409 bool restricted, |
| 404 bool at_startup) { | 410 bool at_startup) { |
| 405 DCHECK(thread_checker_.CalledOnValidThread()); | 411 DCHECK(thread_checker_.CalledOnValidThread()); |
| 406 DCHECK(configurator_); | 412 DCHECK(configurator_); |
| 407 | 413 |
| 408 LogProxyState(enabled, restricted, at_startup); | 414 LogProxyState(enabled, restricted, at_startup); |
| 409 // The alternative is only configured if the standard configuration is | 415 // The alternative is only configured if the standard configuration is |
| 410 // is enabled. | 416 // is enabled. |
| 411 if (enabled & !params_->holdback()) { | 417 if (enabled & !params_->holdback()) { |
| 412 if (alternative_enabled) { | 418 if (alternative_enabled) { |
| 413 configurator_->Enable(restricted, | 419 configurator_->Enable(restricted, |
| 414 !params_->fallback_allowed(), | 420 !params_->alternative_fallback_allowed(), |
| 415 params_->alt_origin().spec(), | 421 params_->alt_origin().spec(), |
| 416 params_->alt_fallback_origin().spec(), | 422 std::string(), |
| 417 params_->ssl_origin().spec()); | 423 params_->ssl_origin().spec()); |
| 418 } else { | 424 } else { |
| 419 configurator_->Enable(restricted, | 425 configurator_->Enable(restricted, |
| 420 !params_->fallback_allowed(), | 426 !params_->fallback_allowed(), |
| 421 params_->origin().spec(), | 427 params_->origin().spec(), |
| 422 params_->fallback_origin().spec(), | 428 params_->fallback_origin().spec(), |
| 423 std::string()); | 429 std::string()); |
| 424 } | 430 } |
| 425 } else { | 431 } else { |
| 426 configurator_->Disable(); | 432 configurator_->Disable(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 SetProxyConfigs(enabled_by_user_, | 580 SetProxyConfigs(enabled_by_user_, |
| 575 IsDataReductionProxyAlternativeEnabled(), | 581 IsDataReductionProxyAlternativeEnabled(), |
| 576 restricted_by_carrier_, | 582 restricted_by_carrier_, |
| 577 false); | 583 false); |
| 578 } | 584 } |
| 579 disabled_on_vpn_ = false; | 585 disabled_on_vpn_ = false; |
| 580 return false; | 586 return false; |
| 581 } | 587 } |
| 582 | 588 |
| 583 } // namespace data_reduction_proxy | 589 } // namespace data_reduction_proxy |
| OLD | NEW |