Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.cc |
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.cc |
| index 5ba7a4f574b9a5b6c5c66804be7739d2d23c3f96..01a9de7d4d9b975754b7e5d1cd60d67646b00ec4 100644 |
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.cc |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.cc |
| @@ -4,7 +4,13 @@ |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.h" |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/command_line.h" |
| +#include "base/strings/string_split.h" |
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" |
| +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" |
| namespace data_reduction_proxy { |
| @@ -25,7 +31,22 @@ DataReductionProxyMutableConfigValues::DataReductionProxyMutableConfigValues() |
| : promo_allowed_(false), |
| holdback_(false), |
| allowed_(false), |
| - fallback_allowed_(false) { |
| + fallback_allowed_(false), |
| + use_override_proxies_for_http_(false) { |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kDataReductionProxyConfigHttpProxiesOverride)) { |
| + use_override_proxies_for_http_ = true; |
| + std::string proxy_overrides = |
| + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + switches::kDataReductionProxyConfigHttpProxiesOverride); |
| + std::vector<std::string> proxy_override_values = base::SplitString( |
| + proxy_overrides, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| + for (const std::string& proxy_override : proxy_override_values) { |
| + override_proxies_for_http_.push_back(net::ProxyServer::FromURI( |
|
bengr
2015/09/17 17:27:33
What happens if the string is not a valid proxy UR
sclittle
2015/09/22 19:01:59
Then an empty invalid net::ProxyServer() will be r
|
| + proxy_override, net::ProxyServer::SCHEME_HTTP)); |
| + } |
| + } |
| + |
| // Constructed on the UI thread, but should be checked on the IO thread. |
| thread_checker_.DetachFromThread(); |
| } |
| @@ -58,6 +79,13 @@ bool DataReductionProxyMutableConfigValues::UsingHTTPTunnel( |
| const std::vector<net::ProxyServer>& |
| DataReductionProxyMutableConfigValues::proxies_for_http() const { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| + if (use_override_proxies_for_http_ && !proxies_for_http_.empty()) { |
|
bengr
2015/09/17 17:27:34
Do you need this separate use_override_proxies_for
sclittle
2015/09/22 19:01:59
The main reason to have the bool is to allow for s
|
| + // Only override the proxies if a non-empty list of proxies would have been |
| + // returned otherwise. This is to prevent use of the proxies when the config |
| + // has been invalidated, since attempting to use a Data Reduction Proxy |
| + // without valid credentials could cause a proxy bypass. |
| + return override_proxies_for_http_; |
| + } |
| return proxies_for_http_; |
| } |