Chromium Code Reviews| 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..ecbb1e65cb8160c1a324c3f142196e36d1b0ecd8 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,68 @@ void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( |
| connection_tester_->RunAllTests(url); |
| } |
| +void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( |
| + const ListValue* list) { |
| + // |value| should be: [<domain to query>]. |
| + string16 domain16; |
| + CHECK(list->GetString(0, &domain16)); |
| + const std::string domain(UTF16ToUTF8(domain16)); |
|
mmenke
2011/02/11 22:06:32
No need for this conversion. GetString is overloa
|
| + net::TransportSecurityState* t = |
|
mmenke
2011/02/11 22:06:32
Might want to use more verbose variable names here
|
| + context_getter_->GetURLRequestContext()->transport_security_state(); |
| + if (!t) |
| + return; |
| + |
| + net::TransportSecurityState::DomainState state; |
| + const bool r = t->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>]. |
| + string16 domain16; |
| + CHECK(list->GetString(0, &domain16)); |
| + bool include_subdomains; |
| + CHECK(list->GetBoolean(1, &include_subdomains)); |
| + |
| + const std::string domain(UTF16ToUTF8(domain16)); |
| + net::TransportSecurityState* t = |
| + context_getter_->GetURLRequestContext()->transport_security_state(); |
| + if (!t) |
| + return; |
| + |
| + net::TransportSecurityState::DomainState state; |
| + state.expiry = state.created + base::TimeDelta::FromDays(1000); |
| + state.include_subdomains = include_subdomains; |
| + |
| + t->EnableHost(domain, state); |
| +} |
| + |
| +void NetInternalsMessageHandler::IOThreadImpl::OnHSTSDelete( |
| + const ListValue* list) { |
| + // |value| should be: [<domain to query>]. |
| + string16 domain16; |
| + CHECK(list->GetString(0, &domain16)); |
| + const std::string domain(UTF16ToUTF8(domain16)); |
| + net::TransportSecurityState* t = |
| + context_getter_->GetURLRequestContext()->transport_security_state(); |
| + if (!t) |
| + return; |
| + |
| + t->DeleteHost(domain); |
| +} |
| + |
| void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( |
| const ListValue* list) { |
| DictionaryValue* info_dict = new DictionaryValue(); |