Index: components/cronet/url_request_context_config.cc |
diff --git a/components/cronet/url_request_context_config.cc b/components/cronet/url_request_context_config.cc |
index 5cd24b8664120160a03325b4288a9fd4b1c68752..0415a37bbf236552058b7aa8293e7ab7bc900710 100644 |
--- a/components/cronet/url_request_context_config.cc |
+++ b/components/cronet/url_request_context_config.cc |
@@ -70,6 +70,15 @@ void ParseAndSetExperimentalOptions( |
} |
} |
+bool GetTimeFromDouble(const base::Value* json_value, base::Time* time) { |
+ double time_double; |
+ bool success = json_value->GetAsDouble(&time_double); |
+ if (success) { |
+ *time = base::Time::FromDoubleT(time_double); |
+ } |
+ return success; |
+} |
+ |
} // namespace |
#define DEFINE_CONTEXT_CONFIG(x) const char REQUEST_CONTEXT_CONFIG_##x[] = #x; |
@@ -95,6 +104,21 @@ void URLRequestContextConfig::QuicHint::RegisterJSONConverter( |
&URLRequestContextConfig::QuicHint::alternate_port); |
} |
+// static |
+void URLRequestContextConfig::Pkp::RegisterJSONConverter( |
+ base::JSONValueConverter<URLRequestContextConfig::Pkp>* converter) { |
+ converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_PKP_HOST, |
+ &URLRequestContextConfig::Pkp::host); |
+ converter->RegisterRepeatedString(REQUEST_CONTEXT_CONFIG_PKP_PIN_HASHES, |
+ &URLRequestContextConfig::Pkp::pin_hashes); |
+ converter->RegisterBoolField( |
+ REQUEST_CONTEXT_CONFIG_PKP_INCLUDE_SUBDOMAINS, |
+ &URLRequestContextConfig::Pkp::include_subdomains); |
+ converter->RegisterCustomValueField<base::Time>( |
+ REQUEST_CONTEXT_CONFIG_PKP_EXPIRATION_DATE, |
+ &URLRequestContextConfig::Pkp::expiration_date, &GetTimeFromDouble); |
+} |
+ |
URLRequestContextConfig::URLRequestContextConfig() {} |
URLRequestContextConfig::~URLRequestContextConfig() {} |
@@ -179,6 +203,8 @@ void URLRequestContextConfig::RegisterJSONConverter( |
converter->RegisterStringField( |
REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PROXY_KEY, |
&URLRequestContextConfig::data_reduction_proxy_key); |
+ converter->RegisterRepeatedMessage(REQUEST_CONTEXT_CONFIG_PKP_LIST, |
+ &URLRequestContextConfig::pkp_list); |
// For Testing. |
converter->RegisterCustomField<scoped_ptr<net::CertVerifier>>( |