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_params.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " | 9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " |
| 10 #include "net/proxy/proxy_info.h" | 10 #include "net/proxy/proxy_info.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 DCHECK(request); | 234 DCHECK(request); |
| 235 return IsDataReductionProxy(request->proxy_server(), proxy_servers); | 235 return IsDataReductionProxy(request->proxy_server(), proxy_servers); |
| 236 } | 236 } |
| 237 | 237 |
| 238 bool DataReductionProxyParams::IsDataReductionProxy( | 238 bool DataReductionProxyParams::IsDataReductionProxy( |
| 239 const net::HostPortPair& host_port_pair, | 239 const net::HostPortPair& host_port_pair, |
| 240 std::pair<GURL, GURL>* proxy_servers) const { | 240 std::pair<GURL, GURL>* proxy_servers) const { |
| 241 if (net::HostPortPair::FromURL(origin()).Equals(host_port_pair)) { | 241 if (net::HostPortPair::FromURL(origin()).Equals(host_port_pair)) { |
| 242 if (proxy_servers) { | 242 if (proxy_servers) { |
| 243 (*proxy_servers).first = origin(); | 243 (*proxy_servers).first = origin(); |
| 244 if (fallback_allowed()) | 244 if (fallback_allowed()) { |
|
bengr
2014/07/17 00:11:08
no need for these curlies.
Not at Google. Contact bengr
2014/07/17 18:10:21
Done.
| |
| 245 (*proxy_servers).second = fallback_origin(); | 245 (*proxy_servers).second = fallback_origin(); |
| 246 } | |
| 246 } | 247 } |
| 247 return true; | 248 return true; |
| 248 } | 249 } |
| 249 | 250 |
| 250 // TODO(bolian): revert this once the proxy PAC fix is ready. | 251 // TODO(bolian): revert this once the proxy PAC fix is ready. |
| 251 // | 252 // |
| 252 // If dev host is configured as the primary proxy, we treat the default | 253 // If dev host is configured as the primary proxy, we treat the default |
| 253 // origin as a valid data reduction proxy to workaround PAC script. | 254 // origin as a valid data reduction proxy to workaround PAC script. |
| 254 if (GURL(GetDefaultDevOrigin()) == origin()) { | 255 if (GURL(GetDefaultDevOrigin()) == origin()) { |
| 255 const GURL& default_origin = GURL(GetDefaultOrigin()); | 256 const GURL& default_origin = GURL(GetDefaultOrigin()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 request->context()->proxy_service()->config().proxy_rules().Apply( | 310 request->context()->proxy_service()->config().proxy_rules().Apply( |
| 310 request->url(), &result); | 311 request->url(), &result); |
| 311 if (!result.proxy_server().is_valid()) | 312 if (!result.proxy_server().is_valid()) |
| 312 return false; | 313 return false; |
| 313 if (result.proxy_server().is_direct()) | 314 if (result.proxy_server().is_direct()) |
| 314 return false; | 315 return false; |
| 315 return IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); | 316 return IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); |
| 316 } | 317 } |
| 317 | 318 |
| 318 std::string DataReductionProxyParams::GetDefaultDevOrigin() const { | 319 std::string DataReductionProxyParams::GetDefaultDevOrigin() const { |
| 319 #if defined(DATA_REDUCTION_DEV_HOST) | |
| 320 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 320 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 321 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) | 321 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) |
| 322 return std::string(); | 322 return std::string(); |
| 323 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || | 323 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || |
| 324 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == | 324 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == |
| 325 kEnabled)) { | 325 kEnabled)) { |
| 326 return DATA_REDUCTION_DEV_HOST; | 326 return "http://proxy-dev.googlezip.net:80/"; |
| 327 } | 327 } |
| 328 #endif | |
| 329 return std::string(); | 328 return std::string(); |
| 330 } | 329 } |
| 331 | 330 // TODO(kundaji): Remove tests for macro definitions. |
| 332 std::string DataReductionProxyParams::GetDefaultOrigin() const { | 331 std::string DataReductionProxyParams::GetDefaultOrigin() const { |
| 333 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 332 return "https://proxy.googlezip.net:443/"; |
| 334 return SPDY_PROXY_AUTH_ORIGIN; | |
| 335 #endif | |
| 336 return std::string(); | |
| 337 } | 333 } |
| 338 | 334 |
| 339 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { | 335 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { |
| 340 #if defined(DATA_REDUCTION_FALLBACK_HOST) | 336 return "http://compress.googlezip.net:80/"; |
| 341 return DATA_REDUCTION_FALLBACK_HOST; | |
| 342 #endif | |
| 343 return std::string(); | |
| 344 } | 337 } |
| 345 | 338 |
| 346 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { | 339 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { |
| 347 #if defined(DATA_REDUCTION_PROXY_SSL_ORIGIN) | 340 return "http://ssl.googlezip.net:1043/"; |
| 348 return DATA_REDUCTION_PROXY_SSL_ORIGIN; | |
| 349 #endif | |
| 350 return std::string(); | |
| 351 } | 341 } |
| 352 | 342 |
| 353 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { | 343 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { |
| 354 #if defined(DATA_REDUCTION_PROXY_ALT_ORIGIN) | 344 return "https://proxy.googlezip.net:443/"; |
| 355 return DATA_REDUCTION_PROXY_ALT_ORIGIN; | |
| 356 #endif | |
| 357 return std::string(); | |
| 358 } | 345 } |
| 359 | 346 |
| 360 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { | 347 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { |
| 361 #if defined(DATA_REDUCTION_PROXY_ALT_FALLBACK_ORIGIN) | 348 return "http://compress.googlezip.net:80/"; |
| 362 return DATA_REDUCTION_PROXY_ALT_FALLBACK_ORIGIN; | |
| 363 #endif | |
| 364 return std::string(); | |
| 365 } | 349 } |
| 366 | 350 |
| 367 std::string DataReductionProxyParams::GetDefaultProbeURL() const { | 351 std::string DataReductionProxyParams::GetDefaultProbeURL() const { |
| 368 #if defined(DATA_REDUCTION_PROXY_PROBE_URL) | 352 return "http://check.googlezip.net/connect"; |
| 369 return DATA_REDUCTION_PROXY_PROBE_URL; | |
| 370 #endif | |
| 371 return std::string(); | |
| 372 } | 353 } |
| 373 | 354 |
| 374 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { | 355 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { |
| 375 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) | 356 return "http://www.gstatic.com/generate_204"; |
| 376 return DATA_REDUCTION_PROXY_WARMUP_URL; | |
| 377 #endif | |
| 378 return std::string(); | |
| 379 } | 357 } |
| 380 | 358 |
| 381 } // namespace data_reduction_proxy | 359 } // namespace data_reduction_proxy |
| OLD | NEW |