Index: chrome/browser/dom_ui/net_internals_ui.cc |
diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc |
index 6fe735f1abd444040e13d68c632301323efcae29..c741fb5214ef1f97fbb93a9109f3159fa80a9379 100644 |
--- a/chrome/browser/dom_ui/net_internals_ui.cc |
+++ b/chrome/browser/dom_ui/net_internals_ui.cc |
@@ -255,6 +255,9 @@ class NetInternalsMessageHandler::IOThreadImpl |
void OnClearHostResolverCache(const ListValue* list); |
void OnEnableIPv6(const ListValue* list); |
void OnStartConnectionTests(const ListValue* list); |
+ void OnHSTSQuery(const ListValue* list); |
+ void OnHSTSAdd(const ListValue* list); |
+ void OnHSTSDelete(const ListValue* list); |
void OnGetHttpCacheInfo(const ListValue* list); |
void OnGetSocketPoolInfo(const ListValue* list); |
void OnGetSpdySessionInfo(const ListValue* list); |
@@ -507,6 +510,15 @@ void NetInternalsMessageHandler::RegisterMessages() { |
"startConnectionTests", |
proxy_->CreateCallback(&IOThreadImpl::OnStartConnectionTests)); |
dom_ui_->RegisterMessageCallback( |
+ "hstsQuery", |
+ proxy_->CreateCallback(&IOThreadImpl::OnHSTSQuery)); |
+ dom_ui_->RegisterMessageCallback( |
+ "hstsAdd", |
+ proxy_->CreateCallback(&IOThreadImpl::OnHSTSAdd)); |
+ dom_ui_->RegisterMessageCallback( |
+ "hstsDelete", |
+ proxy_->CreateCallback(&IOThreadImpl::OnHSTSDelete)); |
+ dom_ui_->RegisterMessageCallback( |
"getHttpCacheInfo", |
proxy_->CreateCallback(&IOThreadImpl::OnGetHttpCacheInfo)); |
dom_ui_->RegisterMessageCallback( |
@@ -954,6 +966,65 @@ void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( |
connection_tester_->RunAllTests(url); |
} |
+void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( |
+ const ListValue* list) { |
+ // |value| should be: [<domain to query>]. |
mmenke
2011/02/16 15:15:34
nit: I think you mean |list|.
agl
2011/02/16 22:46:22
Done (several times).
|
+ std::string domain; |
+ CHECK(list->GetString(0, &domain)); |
+ net::TransportSecurityState* transport_security_state = |
+ context_getter_->GetURLRequestContext()->transport_security_state(); |
+ if (!transport_security_state) |
+ return; |
+ |
+ net::TransportSecurityState::DomainState state; |
+ const bool r = transport_security_state->IsEnabledForHost(&state, domain); |
+ |
+ DictionaryValue* result = new(DictionaryValue); |
+ result->SetBoolean("result", r); |
+ if (r) { |
+ result->SetInteger("mode", static_cast<int>(state.mode)); |
+ result->SetDouble("created", static_cast<double>(state.created.ToTimeT())); |
+ result->SetDouble("expiry", static_cast<double>(state.expiry.ToTimeT())); |
+ result->SetBoolean("subdomains", state.include_subdomains); |
+ result->SetBoolean("preloaded", state.preloaded); |
+ result->SetString("domain", state.domain); |
+ } |
+ CallJavascriptFunction(L"g_browser.receivedHSTSResult", result); |
+} |
+ |
+void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( |
+ const ListValue* list) { |
+ // |value| should be: [<domain to query>, <include subdomains>]. |
+ std::string domain; |
+ CHECK(list->GetString(0, &domain)); |
+ bool include_subdomains; |
+ CHECK(list->GetBoolean(1, &include_subdomains)); |
+ |
+ net::TransportSecurityState* transport_security_state = |
+ context_getter_->GetURLRequestContext()->transport_security_state(); |
+ if (!transport_security_state) |
+ return; |
+ |
+ net::TransportSecurityState::DomainState state; |
+ state.expiry = state.created + base::TimeDelta::FromDays(1000); |
+ state.include_subdomains = include_subdomains; |
+ |
+ transport_security_state->EnableHost(domain, state); |
+} |
+ |
+void NetInternalsMessageHandler::IOThreadImpl::OnHSTSDelete( |
+ const ListValue* list) { |
+ // |value| should be: [<domain to query>]. |
+ std::string domain; |
+ CHECK(list->GetString(0, &domain)); |
+ net::TransportSecurityState* transport_security_state = |
+ context_getter_->GetURLRequestContext()->transport_security_state(); |
+ if (!transport_security_state) |
+ return; |
+ |
+ transport_security_state->DeleteHost(domain); |
+} |
+ |
void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( |
const ListValue* list) { |
DictionaryValue* info_dict = new DictionaryValue(); |