| 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/core/common/data_reduction_proxy_param
s.h" | 5 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const char kDefaultWarmupUrl[] = "http://www.gstatic.com/generate_204"; | 42 const char kDefaultWarmupUrl[] = "http://www.gstatic.com/generate_204"; |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 namespace data_reduction_proxy { | 46 namespace data_reduction_proxy { |
| 47 | 47 |
| 48 // static | 48 // static |
| 49 bool DataReductionProxyParams::IsIncludedInAlternativeFieldTrial() { | 49 bool DataReductionProxyParams::IsIncludedInAlternativeFieldTrial() { |
| 50 const std::string group_name = base::FieldTrialList::FindFullName( | 50 const std::string group_name = base::FieldTrialList::FindFullName( |
| 51 "DataCompressionProxyAlternativeConfiguration"); | 51 "DataCompressionProxyAlternativeConfiguration"); |
| 52 if (CommandLine::ForCurrentProcess()->HasSwitch( | 52 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 53 data_reduction_proxy::switches::kEnableDataReductionProxyAlt)) { | 53 data_reduction_proxy::switches::kEnableDataReductionProxyAlt)) { |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 return group_name == kEnabled; | 56 return group_name == kEnabled; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 bool DataReductionProxyParams::IsIncludedInPromoFieldTrial() { | 60 bool DataReductionProxyParams::IsIncludedInPromoFieldTrial() { |
| 61 return FieldTrialList::FindFullName( | 61 return FieldTrialList::FindFullName( |
| 62 "DataCompressionProxyPromoVisibility") == kEnabled; | 62 "DataCompressionProxyPromoVisibility") == kEnabled; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (promo_allowed_ && !allowed_) { | 234 if (promo_allowed_ && !allowed_) { |
| 235 DVLOG(1) << "The data reduction proxy promo cannot be allowed if the " | 235 DVLOG(1) << "The data reduction proxy promo cannot be allowed if the " |
| 236 << "data reduction proxy is not allowed"; | 236 << "data reduction proxy is not allowed"; |
| 237 return false; | 237 return false; |
| 238 } | 238 } |
| 239 return true; | 239 return true; |
| 240 | 240 |
| 241 } | 241 } |
| 242 | 242 |
| 243 void DataReductionProxyParams::InitWithoutChecks() { | 243 void DataReductionProxyParams::InitWithoutChecks() { |
| 244 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 244 const base::CommandLine& command_line = |
| 245 *base::CommandLine::ForCurrentProcess(); |
| 245 std::string origin; | 246 std::string origin; |
| 246 if (!command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) { | 247 if (!command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) { |
| 247 origin = command_line.GetSwitchValueASCII( | 248 origin = command_line.GetSwitchValueASCII( |
| 248 switches::kDataReductionProxyDev); | 249 switches::kDataReductionProxyDev); |
| 249 } | 250 } |
| 250 if (origin.empty()) | 251 if (origin.empty()) |
| 251 origin = command_line.GetSwitchValueASCII(switches::kDataReductionProxy); | 252 origin = command_line.GetSwitchValueASCII(switches::kDataReductionProxy); |
| 252 std::string fallback_origin = | 253 std::string fallback_origin = |
| 253 command_line.GetSwitchValueASCII(switches::kDataReductionProxyFallback); | 254 command_line.GetSwitchValueASCII(switches::kDataReductionProxyFallback); |
| 254 std::string ssl_origin = | 255 std::string ssl_origin = |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 data_reduction_proxy_config.proxy_rules().Apply( | 378 data_reduction_proxy_config.proxy_rules().Apply( |
| 378 request.url(), &result); | 379 request.url(), &result); |
| 379 if (!result.proxy_server().is_valid()) | 380 if (!result.proxy_server().is_valid()) |
| 380 return true; | 381 return true; |
| 381 if (result.proxy_server().is_direct()) | 382 if (result.proxy_server().is_direct()) |
| 382 return true; | 383 return true; |
| 383 return !IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); | 384 return !IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); |
| 384 } | 385 } |
| 385 | 386 |
| 386 std::string DataReductionProxyParams::GetDefaultDevOrigin() const { | 387 std::string DataReductionProxyParams::GetDefaultDevOrigin() const { |
| 387 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 388 const base::CommandLine& command_line = |
| 389 *base::CommandLine::ForCurrentProcess(); |
| 388 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) | 390 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) |
| 389 return std::string(); | 391 return std::string(); |
| 390 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || | 392 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || |
| 391 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == | 393 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == |
| 392 kEnabled)) { | 394 kEnabled)) { |
| 393 return kDevOrigin; | 395 return kDevOrigin; |
| 394 } | 396 } |
| 395 return std::string(); | 397 return std::string(); |
| 396 } | 398 } |
| 397 | 399 |
| 398 std::string DataReductionProxyParams::GetDefaultDevFallbackOrigin() const { | 400 std::string DataReductionProxyParams::GetDefaultDevFallbackOrigin() const { |
| 399 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 401 const base::CommandLine& command_line = |
| 402 *base::CommandLine::ForCurrentProcess(); |
| 400 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) | 403 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) |
| 401 return std::string(); | 404 return std::string(); |
| 402 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || | 405 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || |
| 403 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == | 406 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == |
| 404 kEnabled)) { | 407 kEnabled)) { |
| 405 return kDevFallbackOrigin; | 408 return kDevFallbackOrigin; |
| 406 } | 409 } |
| 407 return std::string(); | 410 return std::string(); |
| 408 } | 411 } |
| 409 | 412 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 | 517 |
| 515 std::string DataReductionProxyParams::GetDefaultProbeURL() const { | 518 std::string DataReductionProxyParams::GetDefaultProbeURL() const { |
| 516 return kDefaultProbeUrl; | 519 return kDefaultProbeUrl; |
| 517 } | 520 } |
| 518 | 521 |
| 519 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { | 522 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { |
| 520 return kDefaultWarmupUrl; | 523 return kDefaultWarmupUrl; |
| 521 } | 524 } |
| 522 | 525 |
| 523 } // namespace data_reduction_proxy | 526 } // namespace data_reduction_proxy |
| OLD | NEW |