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