OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_te
st_utils.h" |
| 6 |
| 7 namespace { |
| 8 // Test values to replace the values specified in preprocessor defines. |
| 9 static const char kDefaultDevOrigin[] = "https://dev.net:443/"; |
| 10 static const char kDefaultOrigin[] = "https://origin.net:443/"; |
| 11 static const char kDefaultFallbackOrigin[] = "http://fallback.net:80/"; |
| 12 static const char kDefaultSSLOrigin[] = "http://ssl.net:1080/"; |
| 13 static const char kDefaultAltOrigin[] = "https://alt.net:443/"; |
| 14 static const char kDefaultAltFallbackOrigin[] = "http://altfallback.net:80/"; |
| 15 static const char kDefaultProbeURL[] = "http://probe.net/"; |
| 16 |
| 17 static const char kFlagOrigin[] = "https://origin.org:443/"; |
| 18 static const char kFlagFallbackOrigin[] = "http://fallback.org:80/"; |
| 19 static const char kFlagSSLOrigin[] = "http://ssl.org:1080/"; |
| 20 static const char kFlagAltOrigin[] = "https://alt.org:443/"; |
| 21 static const char kFlagAltFallbackOrigin[] = "http://altfallback.org:80/"; |
| 22 static const char kFlagProbeURL[] = "http://probe.org/"; |
| 23 } |
| 24 |
| 25 namespace data_reduction_proxy { |
| 26 TestDataReductionProxyParams::TestDataReductionProxyParams( |
| 27 int flags, unsigned int has_definitions) |
| 28 : DataReductionProxyParams(flags, false), |
| 29 has_definitions_(has_definitions) { |
| 30 init_result_ = Init(flags & DataReductionProxyParams::kAllowed, |
| 31 flags & DataReductionProxyParams::kFallbackAllowed, |
| 32 flags & DataReductionProxyParams::kAlternativeAllowed); |
| 33 } |
| 34 |
| 35 bool TestDataReductionProxyParams::init_result() const { |
| 36 return init_result_; |
| 37 } |
| 38 |
| 39 // Test values to replace the values specified in preprocessor defines. |
| 40 std::string TestDataReductionProxyParams::DefaultDevOrigin() { |
| 41 return kDefaultDevOrigin; |
| 42 } |
| 43 |
| 44 std::string TestDataReductionProxyParams::DefaultOrigin() { |
| 45 return kDefaultOrigin; |
| 46 } |
| 47 |
| 48 std::string TestDataReductionProxyParams::DefaultFallbackOrigin() { |
| 49 return kDefaultFallbackOrigin; |
| 50 } |
| 51 |
| 52 std::string TestDataReductionProxyParams::DefaultSSLOrigin() { |
| 53 return kDefaultSSLOrigin; |
| 54 } |
| 55 |
| 56 std::string TestDataReductionProxyParams::DefaultAltOrigin() { |
| 57 return kDefaultAltOrigin; |
| 58 } |
| 59 |
| 60 std::string TestDataReductionProxyParams::DefaultAltFallbackOrigin() { |
| 61 return kDefaultAltFallbackOrigin; |
| 62 } |
| 63 |
| 64 std::string TestDataReductionProxyParams::DefaultProbeURL() { |
| 65 return kDefaultProbeURL; |
| 66 } |
| 67 |
| 68 std::string TestDataReductionProxyParams::FlagOrigin() { |
| 69 return kFlagOrigin; |
| 70 } |
| 71 |
| 72 std::string TestDataReductionProxyParams::FlagFallbackOrigin() { |
| 73 return kFlagFallbackOrigin; |
| 74 } |
| 75 |
| 76 std::string TestDataReductionProxyParams::FlagSSLOrigin() { |
| 77 return kFlagSSLOrigin; |
| 78 } |
| 79 |
| 80 std::string TestDataReductionProxyParams::FlagAltOrigin() { |
| 81 return kFlagAltOrigin; |
| 82 } |
| 83 |
| 84 std::string TestDataReductionProxyParams::FlagAltFallbackOrigin() { |
| 85 return kFlagAltFallbackOrigin; |
| 86 } |
| 87 |
| 88 std::string TestDataReductionProxyParams::FlagProbeURL() { |
| 89 return kFlagProbeURL; |
| 90 } |
| 91 |
| 92 std::string TestDataReductionProxyParams::GetDefaultDevOrigin() const { |
| 93 return GetDefinition( |
| 94 TestDataReductionProxyParams::HAS_DEV_ORIGIN, kDefaultDevOrigin); |
| 95 } |
| 96 |
| 97 std::string TestDataReductionProxyParams::GetDefaultOrigin() const { |
| 98 return GetDefinition( |
| 99 TestDataReductionProxyParams::HAS_ORIGIN, kDefaultOrigin); |
| 100 } |
| 101 |
| 102 std::string TestDataReductionProxyParams::GetDefaultFallbackOrigin() const { |
| 103 return GetDefinition( |
| 104 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, |
| 105 kDefaultFallbackOrigin); |
| 106 } |
| 107 |
| 108 std::string TestDataReductionProxyParams::GetDefaultSSLOrigin() const { |
| 109 return GetDefinition( |
| 110 TestDataReductionProxyParams::HAS_SSL_ORIGIN, kDefaultSSLOrigin); |
| 111 } |
| 112 |
| 113 std::string TestDataReductionProxyParams::GetDefaultAltOrigin() const { |
| 114 return GetDefinition( |
| 115 TestDataReductionProxyParams::HAS_ALT_ORIGIN, kDefaultAltOrigin); |
| 116 } |
| 117 |
| 118 std::string TestDataReductionProxyParams::GetDefaultAltFallbackOrigin() const { |
| 119 return GetDefinition( |
| 120 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
| 121 kDefaultAltFallbackOrigin); |
| 122 } |
| 123 |
| 124 std::string TestDataReductionProxyParams::GetDefaultProbeURL() const { |
| 125 return GetDefinition( |
| 126 TestDataReductionProxyParams::HAS_PROBE_URL, kDefaultProbeURL); |
| 127 } |
| 128 |
| 129 std::string TestDataReductionProxyParams::GetDefinition( |
| 130 unsigned int has_def, |
| 131 const std::string& definition) const { |
| 132 return ((has_definitions_ & has_def) ? definition : std::string()); |
| 133 } |
| 134 } // namespace data_reduction_proxy |
OLD | NEW |