Disable fallback support for alternative data reduction proxy
[chromium-blink-merge.git] / components / data_reduction_proxy / browser / data_reduction_proxy_params_test_utils.cc
blobe0bcab648588e8c0e51952badaf91789ad986697
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.
5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_test_utils.h"
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 kDefaultDevFallbackOrigin[] = "http://dev.net:80/";
11 static const char kDefaultOrigin[] = "https://origin.net:443/";
12 static const char kDefaultFallbackOrigin[] = "http://fallback.net:80/";
13 static const char kDefaultSSLOrigin[] = "http://ssl.net:1080/";
14 static const char kDefaultAltOrigin[] = "https://alt.net:443/";
15 static const char kDefaultAltFallbackOrigin[] = "http://altfallback.net:80/";
16 static const char kDefaultProbeURL[] = "http://probe.net/";
18 static const char kFlagOrigin[] = "https://origin.org:443/";
19 static const char kFlagFallbackOrigin[] = "http://fallback.org:80/";
20 static const char kFlagSSLOrigin[] = "http://ssl.org:1080/";
21 static const char kFlagAltOrigin[] = "https://alt.org:443/";
22 static const char kFlagAltFallbackOrigin[] = "http://altfallback.org:80/";
23 static const char kFlagProbeURL[] = "http://probe.org/";
26 namespace data_reduction_proxy {
27 TestDataReductionProxyParams::TestDataReductionProxyParams(
28 int flags, unsigned int has_definitions)
29 : DataReductionProxyParams(flags, false),
30 has_definitions_(has_definitions) {
31 init_result_ = Init(
32 flags & DataReductionProxyParams::kAllowed,
33 flags & DataReductionProxyParams::kFallbackAllowed,
34 flags & DataReductionProxyParams::kAlternativeAllowed,
35 flags & DataReductionProxyParams::kAlternativeFallbackAllowed);
38 bool TestDataReductionProxyParams::init_result() const {
39 return init_result_;
42 // Test values to replace the values specified in preprocessor defines.
43 std::string TestDataReductionProxyParams::DefaultDevOrigin() {
44 return kDefaultDevOrigin;
47 std::string TestDataReductionProxyParams::DefaultDevFallbackOrigin() {
48 return kDefaultDevFallbackOrigin;
51 std::string TestDataReductionProxyParams::DefaultOrigin() {
52 return kDefaultOrigin;
55 std::string TestDataReductionProxyParams::DefaultFallbackOrigin() {
56 return kDefaultFallbackOrigin;
59 std::string TestDataReductionProxyParams::DefaultSSLOrigin() {
60 return kDefaultSSLOrigin;
63 std::string TestDataReductionProxyParams::DefaultAltOrigin() {
64 return kDefaultAltOrigin;
67 std::string TestDataReductionProxyParams::DefaultAltFallbackOrigin() {
68 return kDefaultAltFallbackOrigin;
71 std::string TestDataReductionProxyParams::DefaultProbeURL() {
72 return kDefaultProbeURL;
75 std::string TestDataReductionProxyParams::FlagOrigin() {
76 return kFlagOrigin;
79 std::string TestDataReductionProxyParams::FlagFallbackOrigin() {
80 return kFlagFallbackOrigin;
83 std::string TestDataReductionProxyParams::FlagSSLOrigin() {
84 return kFlagSSLOrigin;
87 std::string TestDataReductionProxyParams::FlagAltOrigin() {
88 return kFlagAltOrigin;
91 std::string TestDataReductionProxyParams::FlagAltFallbackOrigin() {
92 return kFlagAltFallbackOrigin;
95 std::string TestDataReductionProxyParams::FlagProbeURL() {
96 return kFlagProbeURL;
99 std::string TestDataReductionProxyParams::GetDefaultDevOrigin() const {
100 return GetDefinition(
101 TestDataReductionProxyParams::HAS_DEV_ORIGIN, kDefaultDevOrigin);
104 std::string TestDataReductionProxyParams::GetDefaultDevFallbackOrigin() const {
105 return GetDefinition(
106 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN,
107 kDefaultDevFallbackOrigin);
110 std::string TestDataReductionProxyParams::GetDefaultOrigin() const {
111 return GetDefinition(
112 TestDataReductionProxyParams::HAS_ORIGIN, kDefaultOrigin);
115 std::string TestDataReductionProxyParams::GetDefaultFallbackOrigin() const {
116 return GetDefinition(
117 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
118 kDefaultFallbackOrigin);
121 std::string TestDataReductionProxyParams::GetDefaultSSLOrigin() const {
122 return GetDefinition(
123 TestDataReductionProxyParams::HAS_SSL_ORIGIN, kDefaultSSLOrigin);
126 std::string TestDataReductionProxyParams::GetDefaultAltOrigin() const {
127 return GetDefinition(
128 TestDataReductionProxyParams::HAS_ALT_ORIGIN, kDefaultAltOrigin);
131 std::string TestDataReductionProxyParams::GetDefaultAltFallbackOrigin() const {
132 return GetDefinition(
133 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
134 kDefaultAltFallbackOrigin);
137 std::string TestDataReductionProxyParams::GetDefaultProbeURL() const {
138 return GetDefinition(
139 TestDataReductionProxyParams::HAS_PROBE_URL, kDefaultProbeURL);
142 std::string TestDataReductionProxyParams::GetDefinition(
143 unsigned int has_def,
144 const std::string& definition) const {
145 return ((has_definitions_ & has_def) ? definition : std::string());
147 } // namespace data_reduction_proxy