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 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 | 1033 |
1034 if (!IsStringASCII(domain)) { | 1034 if (!IsStringASCII(domain)) { |
1035 result->SetString("error", "non-ASCII domain name"); | 1035 result->SetString("error", "non-ASCII domain name"); |
1036 } else { | 1036 } else { |
1037 net::TransportSecurityState* transport_security_state = | 1037 net::TransportSecurityState* transport_security_state = |
1038 context_getter_->GetURLRequestContext()->transport_security_state(); | 1038 context_getter_->GetURLRequestContext()->transport_security_state(); |
1039 if (!transport_security_state) { | 1039 if (!transport_security_state) { |
1040 result->SetString("error", "no TransportSecurityState active"); | 1040 result->SetString("error", "no TransportSecurityState active"); |
1041 } else { | 1041 } else { |
1042 net::TransportSecurityState::DomainState state; | 1042 net::TransportSecurityState::DomainState state; |
1043 const bool found = transport_security_state->HasMetadata( | 1043 const bool found = transport_security_state->GetDomainState( |
1044 &state, domain, true); | 1044 domain, true, &state); |
1045 | 1045 |
1046 result->SetBoolean("result", found); | 1046 result->SetBoolean("result", found); |
1047 if (found) { | 1047 if (found) { |
1048 result->SetInteger("mode", static_cast<int>(state.mode)); | 1048 result->SetInteger("mode", static_cast<int>(state.upgrade_mode)); |
1049 result->SetBoolean("subdomains", state.include_subdomains); | 1049 result->SetBoolean("subdomains", state.include_subdomains); |
1050 result->SetBoolean("preloaded", state.preloaded); | |
1051 result->SetString("domain", state.domain); | 1050 result->SetString("domain", state.domain); |
1052 result->SetDouble("expiry", state.expiry.ToDoubleT()); | 1051 result->SetDouble("expiry", state.upgrade_expiry.ToDoubleT()); |
1053 result->SetDouble("dynamic_spki_hashes_expiry", | 1052 result->SetDouble("dynamic_spki_hashes_expiry", |
1054 state.dynamic_spki_hashes_expiry.ToDoubleT()); | 1053 state.dynamic_spki_hashes_expiry.ToDoubleT()); |
1055 | 1054 |
1056 std::string hashes; | 1055 std::string hashes; |
1057 SPKIHashesToString(state.preloaded_spki_hashes, &hashes); | 1056 SPKIHashesToString(state.static_spki_hashes, &hashes); |
1058 result->SetString("preloaded_spki_hashes", hashes); | 1057 result->SetString("static_spki_hashes", hashes); |
1059 | 1058 |
1060 hashes.clear(); | 1059 hashes.clear(); |
1061 SPKIHashesToString(state.dynamic_spki_hashes, &hashes); | 1060 SPKIHashesToString(state.dynamic_spki_hashes, &hashes); |
1062 result->SetString("dynamic_spki_hashes", hashes); | 1061 result->SetString("dynamic_spki_hashes", hashes); |
1063 } | 1062 } |
1064 } | 1063 } |
1065 } | 1064 } |
1066 | 1065 |
1067 SendJavascriptCommand("receivedHSTSResult", result); | 1066 SendJavascriptCommand("receivedHSTSResult", result); |
1068 } | 1067 } |
(...skipping 12 matching lines...) Expand all Loading... |
1081 CHECK(list->GetBoolean(1, &include_subdomains)); | 1080 CHECK(list->GetBoolean(1, &include_subdomains)); |
1082 std::string hashes_str; | 1081 std::string hashes_str; |
1083 CHECK(list->GetString(2, &hashes_str)); | 1082 CHECK(list->GetString(2, &hashes_str)); |
1084 | 1083 |
1085 net::TransportSecurityState* transport_security_state = | 1084 net::TransportSecurityState* transport_security_state = |
1086 context_getter_->GetURLRequestContext()->transport_security_state(); | 1085 context_getter_->GetURLRequestContext()->transport_security_state(); |
1087 if (!transport_security_state) | 1086 if (!transport_security_state) |
1088 return; | 1087 return; |
1089 | 1088 |
1090 net::TransportSecurityState::DomainState state; | 1089 net::TransportSecurityState::DomainState state; |
1091 state.expiry = state.created + base::TimeDelta::FromDays(1000); | 1090 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); |
1092 state.include_subdomains = include_subdomains; | 1091 state.include_subdomains = include_subdomains; |
1093 if (!hashes_str.empty()) { | 1092 if (!hashes_str.empty()) { |
1094 std::vector<std::string> type_and_b64s; | 1093 std::vector<std::string> type_and_b64s; |
1095 base::SplitString(hashes_str, ',', &type_and_b64s); | 1094 base::SplitString(hashes_str, ',', &type_and_b64s); |
1096 for (std::vector<std::string>::const_iterator | 1095 for (std::vector<std::string>::const_iterator |
1097 i = type_and_b64s.begin(); i != type_and_b64s.end(); i++) { | 1096 i = type_and_b64s.begin(); i != type_and_b64s.end(); i++) { |
1098 std::string type_and_b64; | 1097 std::string type_and_b64; |
1099 RemoveChars(*i, " \t\r\n", &type_and_b64); | 1098 RemoveChars(*i, " \t\r\n", &type_and_b64); |
1100 net::SHA1Fingerprint hash; | 1099 net::SHA1Fingerprint hash; |
1101 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) | 1100 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 } | 1673 } |
1675 | 1674 |
1676 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1675 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1677 : WebUIController(web_ui) { | 1676 : WebUIController(web_ui) { |
1678 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1677 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1679 | 1678 |
1680 // Set up the chrome://net-internals/ source. | 1679 // Set up the chrome://net-internals/ source. |
1681 Profile* profile = Profile::FromWebUI(web_ui); | 1680 Profile* profile = Profile::FromWebUI(web_ui); |
1682 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); | 1681 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); |
1683 } | 1682 } |
OLD | NEW |