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 6072f394d84cdde35069fc3a7e2f44eeb5ce490a..b106ec09f1202dbf8173dc4ce646fb47d77088ec 100644 |
--- a/components/cronet/url_request_context_config.cc |
+++ b/components/cronet/url_request_context_config.cc |
@@ -31,6 +31,15 @@ bool GetMockCertVerifierFromString( |
return success; |
} |
+bool GetDateFromDouble(const base::Value* json_value, base::Time* time) { |
pauljensen
2015/11/17 19:01:23
GetTimeFromDouble
kapishnikov
2015/11/18 00:10:31
Done.
|
+ 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; |
@@ -56,6 +65,21 @@ void URLRequestContextConfig::QuicHint::RegisterJSONConverter( |
&URLRequestContextConfig::QuicHint::alternate_port); |
} |
+// static |
+void URLRequestContextConfig::Hpkp::RegisterJSONConverter( |
+ base::JSONValueConverter<URLRequestContextConfig::Hpkp>* converter) { |
+ converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_HPKP_HOST, |
+ &URLRequestContextConfig::Hpkp::host); |
+ converter->RegisterRepeatedString(REQUEST_CONTEXT_CONFIG_HPKP_PIN_HASHES, |
+ &URLRequestContextConfig::Hpkp::pin_hashes); |
+ converter->RegisterBoolField( |
+ REQUEST_CONTEXT_CONFIG_HPKP_INCLUDE_SUBDOMAINS, |
+ &URLRequestContextConfig::Hpkp::include_subdomains); |
+ converter->RegisterCustomValueField<base::Time>( |
+ REQUEST_CONTEXT_CONFIG_HPKP_EXPIRATION_DATE, |
+ &URLRequestContextConfig::Hpkp::expiration_date, &GetDateFromDouble); |
+} |
+ |
URLRequestContextConfig::URLRequestContextConfig() {} |
URLRequestContextConfig::~URLRequestContextConfig() {} |
@@ -139,6 +163,8 @@ void URLRequestContextConfig::RegisterJSONConverter( |
converter->RegisterStringField( |
REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PROXY_KEY, |
&URLRequestContextConfig::data_reduction_proxy_key); |
+ converter->RegisterRepeatedMessage(REQUEST_CONTEXT_CONFIG_HPKP_LIST, |
+ &URLRequestContextConfig::hpkp_list); |
// For Testing. |
converter->RegisterCustomField<scoped_ptr<net::CertVerifier>>( |