| 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_test_utils.h" | 5 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" |
| 6 | 6 |
| 7 namespace { | 7 namespace { |
| 8 // Test values to replace the values specified in preprocessor defines. | 8 // Test values to replace the values specified in preprocessor defines. |
| 9 static const char kDefaultOrigin[] = "origin.net:80"; | 9 static const char kDefaultOrigin[] = "origin.net:80"; |
| 10 static const char kDefaultFallbackOrigin[] = "fallback.net:80"; | 10 static const char kDefaultFallbackOrigin[] = "fallback.net:80"; |
| 11 static const char kDefaultSSLOrigin[] = "ssl.net:1080"; | |
| 12 static const char kDefaultSecureProxyCheckURL[] = "http://proxycheck.net/"; | 11 static const char kDefaultSecureProxyCheckURL[] = "http://proxycheck.net/"; |
| 13 | 12 |
| 14 static const char kFlagOrigin[] = "https://origin.org:443"; | 13 static const char kFlagOrigin[] = "https://origin.org:443"; |
| 15 static const char kFlagFallbackOrigin[] = "fallback.org:80"; | 14 static const char kFlagFallbackOrigin[] = "fallback.org:80"; |
| 16 static const char kFlagSSLOrigin[] = "ssl.org:1080"; | |
| 17 static const char kFlagSecureProxyCheckURL[] = "http://proxycheck.org/"; | 15 static const char kFlagSecureProxyCheckURL[] = "http://proxycheck.org/"; |
| 18 } | 16 } |
| 19 | 17 |
| 20 namespace data_reduction_proxy { | 18 namespace data_reduction_proxy { |
| 21 TestDataReductionProxyParams::TestDataReductionProxyParams( | 19 TestDataReductionProxyParams::TestDataReductionProxyParams( |
| 22 int flags, unsigned int has_definitions) | 20 int flags, unsigned int has_definitions) |
| 23 : DataReductionProxyParams(flags, false), | 21 : DataReductionProxyParams(flags, false), |
| 24 has_definitions_(has_definitions) { | 22 has_definitions_(has_definitions) { |
| 25 init_result_ = Init(flags & DataReductionProxyParams::kAllowed, | 23 init_result_ = Init(flags & DataReductionProxyParams::kAllowed, |
| 26 flags & DataReductionProxyParams::kFallbackAllowed); | 24 flags & DataReductionProxyParams::kFallbackAllowed); |
| 27 } | 25 } |
| 28 | 26 |
| 29 bool TestDataReductionProxyParams::init_result() const { | 27 bool TestDataReductionProxyParams::init_result() const { |
| 30 return init_result_; | 28 return init_result_; |
| 31 } | 29 } |
| 32 | 30 |
| 33 void TestDataReductionProxyParams::SetProxiesForHttp( | 31 void TestDataReductionProxyParams::SetProxiesForHttp( |
| 34 const std::vector<net::ProxyServer>& proxies) { | 32 const std::vector<net::ProxyServer>& proxies) { |
| 35 proxies_for_http_ = proxies; | 33 proxies_for_http_ = proxies; |
| 36 } | 34 } |
| 37 // Test values to replace the values specified in preprocessor defines. | 35 // Test values to replace the values specified in preprocessor defines. |
| 38 std::string TestDataReductionProxyParams::DefaultOrigin() { | 36 std::string TestDataReductionProxyParams::DefaultOrigin() { |
| 39 return kDefaultOrigin; | 37 return kDefaultOrigin; |
| 40 } | 38 } |
| 41 | 39 |
| 42 std::string TestDataReductionProxyParams::DefaultFallbackOrigin() { | 40 std::string TestDataReductionProxyParams::DefaultFallbackOrigin() { |
| 43 return kDefaultFallbackOrigin; | 41 return kDefaultFallbackOrigin; |
| 44 } | 42 } |
| 45 | 43 |
| 46 std::string TestDataReductionProxyParams::DefaultSSLOrigin() { | |
| 47 return kDefaultSSLOrigin; | |
| 48 } | |
| 49 | |
| 50 std::string TestDataReductionProxyParams::DefaultSecureProxyCheckURL() { | 44 std::string TestDataReductionProxyParams::DefaultSecureProxyCheckURL() { |
| 51 return kDefaultSecureProxyCheckURL; | 45 return kDefaultSecureProxyCheckURL; |
| 52 } | 46 } |
| 53 | 47 |
| 54 std::string TestDataReductionProxyParams::FlagOrigin() { | 48 std::string TestDataReductionProxyParams::FlagOrigin() { |
| 55 return kFlagOrigin; | 49 return kFlagOrigin; |
| 56 } | 50 } |
| 57 | 51 |
| 58 std::string TestDataReductionProxyParams::FlagFallbackOrigin() { | 52 std::string TestDataReductionProxyParams::FlagFallbackOrigin() { |
| 59 return kFlagFallbackOrigin; | 53 return kFlagFallbackOrigin; |
| 60 } | 54 } |
| 61 | 55 |
| 62 std::string TestDataReductionProxyParams::FlagSSLOrigin() { | |
| 63 return kFlagSSLOrigin; | |
| 64 } | |
| 65 | |
| 66 std::string TestDataReductionProxyParams::FlagSecureProxyCheckURL() { | 56 std::string TestDataReductionProxyParams::FlagSecureProxyCheckURL() { |
| 67 return kFlagSecureProxyCheckURL; | 57 return kFlagSecureProxyCheckURL; |
| 68 } | 58 } |
| 69 | 59 |
| 70 std::string TestDataReductionProxyParams::GetDefaultOrigin() const { | 60 std::string TestDataReductionProxyParams::GetDefaultOrigin() const { |
| 71 return GetDefinition( | 61 return GetDefinition( |
| 72 TestDataReductionProxyParams::HAS_ORIGIN, kDefaultOrigin); | 62 TestDataReductionProxyParams::HAS_ORIGIN, kDefaultOrigin); |
| 73 } | 63 } |
| 74 | 64 |
| 75 std::string TestDataReductionProxyParams::GetDefaultFallbackOrigin() const { | 65 std::string TestDataReductionProxyParams::GetDefaultFallbackOrigin() const { |
| 76 return GetDefinition( | 66 return GetDefinition( |
| 77 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, | 67 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, |
| 78 kDefaultFallbackOrigin); | 68 kDefaultFallbackOrigin); |
| 79 } | 69 } |
| 80 | 70 |
| 81 std::string TestDataReductionProxyParams::GetDefaultSSLOrigin() const { | |
| 82 return GetDefinition( | |
| 83 TestDataReductionProxyParams::HAS_SSL_ORIGIN, kDefaultSSLOrigin); | |
| 84 } | |
| 85 | |
| 86 std::string TestDataReductionProxyParams::GetDefaultSecureProxyCheckURL() | 71 std::string TestDataReductionProxyParams::GetDefaultSecureProxyCheckURL() |
| 87 const { | 72 const { |
| 88 return GetDefinition( | 73 return GetDefinition( |
| 89 TestDataReductionProxyParams::HAS_SECURE_PROXY_CHECK_URL, | 74 TestDataReductionProxyParams::HAS_SECURE_PROXY_CHECK_URL, |
| 90 kDefaultSecureProxyCheckURL); | 75 kDefaultSecureProxyCheckURL); |
| 91 } | 76 } |
| 92 | 77 |
| 93 std::string TestDataReductionProxyParams::GetDefinition( | 78 std::string TestDataReductionProxyParams::GetDefinition( |
| 94 unsigned int has_def, | 79 unsigned int has_def, |
| 95 const std::string& definition) const { | 80 const std::string& definition) const { |
| 96 return ((has_definitions_ & has_def) ? definition : std::string()); | 81 return ((has_definitions_ & has_def) ? definition : std::string()); |
| 97 } | 82 } |
| 98 } // namespace data_reduction_proxy | 83 } // namespace data_reduction_proxy |
| OLD | NEW |