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/cronet/url_request_context_config.h" | 5 #include "components/cronet/url_request_context_config.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_QUIC_HINT_HOST, | 49 converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_QUIC_HINT_HOST, |
50 &URLRequestContextConfig::QuicHint::host); | 50 &URLRequestContextConfig::QuicHint::host); |
51 converter->RegisterIntField( | 51 converter->RegisterIntField( |
52 REQUEST_CONTEXT_CONFIG_QUIC_HINT_PORT, | 52 REQUEST_CONTEXT_CONFIG_QUIC_HINT_PORT, |
53 &URLRequestContextConfig::QuicHint::port); | 53 &URLRequestContextConfig::QuicHint::port); |
54 converter->RegisterIntField( | 54 converter->RegisterIntField( |
55 REQUEST_CONTEXT_CONFIG_QUIC_HINT_ALT_PORT, | 55 REQUEST_CONTEXT_CONFIG_QUIC_HINT_ALT_PORT, |
56 &URLRequestContextConfig::QuicHint::alternate_port); | 56 &URLRequestContextConfig::QuicHint::alternate_port); |
57 } | 57 } |
58 | 58 |
| 59 // static |
| 60 void URLRequestContextConfig::Hpkp::RegisterJSONConverter( |
| 61 base::JSONValueConverter<URLRequestContextConfig::Hpkp>* converter) { |
| 62 converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_HPKP_HOST, |
| 63 &URLRequestContextConfig::Hpkp::host); |
| 64 converter->RegisterRepeatedString(REQUEST_CONTEXT_CONFIG_HPKP_PIN_HASHES, |
| 65 &URLRequestContextConfig::Hpkp::pin_hashes); |
| 66 converter->RegisterBoolField( |
| 67 REQUEST_CONTEXT_CONFIG_HPKP_INCLUDE_SUBDOMAINS, |
| 68 &URLRequestContextConfig::Hpkp::include_subdomains); |
| 69 } |
| 70 |
59 URLRequestContextConfig::URLRequestContextConfig() {} | 71 URLRequestContextConfig::URLRequestContextConfig() {} |
60 | 72 |
61 URLRequestContextConfig::~URLRequestContextConfig() {} | 73 URLRequestContextConfig::~URLRequestContextConfig() {} |
62 | 74 |
63 bool URLRequestContextConfig::LoadFromJSON(const std::string& config_string) { | 75 bool URLRequestContextConfig::LoadFromJSON(const std::string& config_string) { |
64 scoped_ptr<base::Value> config_value = base::JSONReader::Read(config_string); | 76 scoped_ptr<base::Value> config_value = base::JSONReader::Read(config_string); |
65 if (!config_value || !config_value->IsType(base::Value::TYPE_DICTIONARY)) { | 77 if (!config_value || !config_value->IsType(base::Value::TYPE_DICTIONARY)) { |
66 DLOG(ERROR) << "Bad JSON: " << config_string; | 78 DLOG(ERROR) << "Bad JSON: " << config_string; |
67 return false; | 79 return false; |
68 } | 80 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 &URLRequestContextConfig::data_reduction_primary_proxy); | 144 &URLRequestContextConfig::data_reduction_primary_proxy); |
133 converter->RegisterStringField( | 145 converter->RegisterStringField( |
134 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_FALLBACK_PROXY, | 146 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_FALLBACK_PROXY, |
135 &URLRequestContextConfig::data_reduction_fallback_proxy); | 147 &URLRequestContextConfig::data_reduction_fallback_proxy); |
136 converter->RegisterStringField( | 148 converter->RegisterStringField( |
137 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_SECURE_PROXY_CHECK_URL, | 149 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_SECURE_PROXY_CHECK_URL, |
138 &URLRequestContextConfig::data_reduction_secure_proxy_check_url); | 150 &URLRequestContextConfig::data_reduction_secure_proxy_check_url); |
139 converter->RegisterStringField( | 151 converter->RegisterStringField( |
140 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PROXY_KEY, | 152 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PROXY_KEY, |
141 &URLRequestContextConfig::data_reduction_proxy_key); | 153 &URLRequestContextConfig::data_reduction_proxy_key); |
| 154 converter->RegisterRepeatedMessage(REQUEST_CONTEXT_CONFIG_HPKP_LIST, |
| 155 &URLRequestContextConfig::hpkp_list); |
142 | 156 |
143 // For Testing. | 157 // For Testing. |
144 converter->RegisterCustomField<scoped_ptr<net::CertVerifier>>( | 158 converter->RegisterCustomField<scoped_ptr<net::CertVerifier>>( |
145 REQUEST_CONTEXT_CONFIG_MOCK_CERT_VERIFIER, | 159 REQUEST_CONTEXT_CONFIG_MOCK_CERT_VERIFIER, |
146 &URLRequestContextConfig::mock_cert_verifier, | 160 &URLRequestContextConfig::mock_cert_verifier, |
147 &GetMockCertVerifierFromString); | 161 &GetMockCertVerifierFromString); |
148 } | 162 } |
149 | 163 |
150 } // namespace cronet | 164 } // namespace cronet |
OLD | NEW |