OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/net_internals/net_internals_ui.h" | 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
992 | 992 |
993 if (!IsStringASCII(domain)) { | 993 if (!IsStringASCII(domain)) { |
994 result->SetString("error", "non-ASCII domain name"); | 994 result->SetString("error", "non-ASCII domain name"); |
995 } else { | 995 } else { |
996 net::TransportSecurityState* transport_security_state = | 996 net::TransportSecurityState* transport_security_state = |
997 context_getter_->GetURLRequestContext()->transport_security_state(); | 997 context_getter_->GetURLRequestContext()->transport_security_state(); |
998 if (!transport_security_state) { | 998 if (!transport_security_state) { |
999 result->SetString("error", "no TransportSecurityState active"); | 999 result->SetString("error", "no TransportSecurityState active"); |
1000 } else { | 1000 } else { |
1001 net::TransportSecurityState::DomainState state; | 1001 net::TransportSecurityState::DomainState state; |
1002 const bool found = transport_security_state->HasMetadata( | 1002 const bool found = transport_security_state->GetDomainState( |
1003 &state, domain, true); | 1003 domain, true, &state); |
1004 | 1004 |
1005 result->SetBoolean("result", found); | 1005 result->SetBoolean("result", found); |
1006 if (found) { | 1006 if (found) { |
1007 result->SetInteger("mode", static_cast<int>(state.mode)); | 1007 result->SetInteger("mode", static_cast<int>(state.upgrade_mode)); |
1008 result->SetBoolean("subdomains", state.include_subdomains); | 1008 result->SetBoolean("subdomains", state.include_subdomains); |
1009 result->SetBoolean("preloaded", state.preloaded); | |
1010 result->SetString("domain", state.domain); | 1009 result->SetString("domain", state.domain); |
1011 result->SetDouble("expiry", state.expiry.ToDoubleT()); | 1010 result->SetDouble("expiry", state.upgrade_expiry.ToDoubleT()); |
1012 result->SetDouble("dynamic_spki_hashes_expiry", | 1011 result->SetDouble("dynamic_spki_hashes_expiry", |
1013 state.dynamic_spki_hashes_expiry.ToDoubleT()); | 1012 state.dynamic_spki_hashes_expiry.ToDoubleT()); |
1014 | 1013 |
1015 std::string hashes; | 1014 std::string hashes; |
1016 SPKIHashesToString(state.preloaded_spki_hashes, &hashes); | 1015 SPKIHashesToString(state.static_spki_hashes, &hashes); |
1017 result->SetString("preloaded_spki_hashes", hashes); | 1016 result->SetString("static_spki_hashes", hashes); |
eroman
2012/03/23 22:59:24
You need to update the javascript too if you make
palmer
2012/04/10 23:25:51
Thank you. And, unfortunately, chrome/test/data/we
| |
1018 | 1017 |
1019 hashes.clear(); | 1018 hashes.clear(); |
1020 SPKIHashesToString(state.dynamic_spki_hashes, &hashes); | 1019 SPKIHashesToString(state.dynamic_spki_hashes, &hashes); |
1021 result->SetString("dynamic_spki_hashes", hashes); | 1020 result->SetString("dynamic_spki_hashes", hashes); |
1022 } | 1021 } |
1023 } | 1022 } |
1024 } | 1023 } |
1025 | 1024 |
1026 SendJavascriptCommand("receivedHSTSResult", result); | 1025 SendJavascriptCommand("receivedHSTSResult", result); |
1027 } | 1026 } |
(...skipping 12 matching lines...) Expand all Loading... | |
1040 CHECK(list->GetBoolean(1, &include_subdomains)); | 1039 CHECK(list->GetBoolean(1, &include_subdomains)); |
1041 std::string hashes_str; | 1040 std::string hashes_str; |
1042 CHECK(list->GetString(2, &hashes_str)); | 1041 CHECK(list->GetString(2, &hashes_str)); |
1043 | 1042 |
1044 net::TransportSecurityState* transport_security_state = | 1043 net::TransportSecurityState* transport_security_state = |
1045 context_getter_->GetURLRequestContext()->transport_security_state(); | 1044 context_getter_->GetURLRequestContext()->transport_security_state(); |
1046 if (!transport_security_state) | 1045 if (!transport_security_state) |
1047 return; | 1046 return; |
1048 | 1047 |
1049 net::TransportSecurityState::DomainState state; | 1048 net::TransportSecurityState::DomainState state; |
1050 state.expiry = state.created + base::TimeDelta::FromDays(1000); | 1049 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); |
1051 state.include_subdomains = include_subdomains; | 1050 state.include_subdomains = include_subdomains; |
1052 if (!hashes_str.empty()) { | 1051 if (!hashes_str.empty()) { |
1053 std::vector<std::string> type_and_b64s; | 1052 std::vector<std::string> type_and_b64s; |
1054 base::SplitString(hashes_str, ',', &type_and_b64s); | 1053 base::SplitString(hashes_str, ',', &type_and_b64s); |
1055 for (std::vector<std::string>::const_iterator | 1054 for (std::vector<std::string>::const_iterator |
1056 i = type_and_b64s.begin(); i != type_and_b64s.end(); i++) { | 1055 i = type_and_b64s.begin(); i != type_and_b64s.end(); i++) { |
1057 std::string type_and_b64; | 1056 std::string type_and_b64; |
1058 RemoveChars(*i, " \t\r\n", &type_and_b64); | 1057 RemoveChars(*i, " \t\r\n", &type_and_b64); |
1059 net::SHA1Fingerprint hash; | 1058 net::SHA1Fingerprint hash; |
1060 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) | 1059 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1582 | 1581 |
1583 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1582 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1584 : WebUIController(web_ui) { | 1583 : WebUIController(web_ui) { |
1585 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1584 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1586 | 1585 |
1587 // Set up the chrome://net-internals/ source. | 1586 // Set up the chrome://net-internals/ source. |
1588 Profile* profile = Profile::FromWebUI(web_ui); | 1587 Profile* profile = Profile::FromWebUI(web_ui); |
1589 profile->GetChromeURLDataManager()->AddDataSource( | 1588 profile->GetChromeURLDataManager()->AddDataSource( |
1590 CreateNetInternalsHTMLSource()); | 1589 CreateNetInternalsHTMLSource()); |
1591 } | 1590 } |
OLD | NEW |