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 <list> | 7 #include <list> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 // For example, turn "www.google.com" into "http://www.google.com". | 1077 // For example, turn "www.google.com" into "http://www.google.com". |
1078 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(url_str), std::string())); | 1078 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(url_str), std::string())); |
1079 | 1079 |
1080 connection_tester_.reset(new ConnectionTester( | 1080 connection_tester_.reset(new ConnectionTester( |
1081 this, | 1081 this, |
1082 io_thread_->globals()->proxy_script_fetcher_context.get(), | 1082 io_thread_->globals()->proxy_script_fetcher_context.get(), |
1083 net_log())); | 1083 net_log())); |
1084 connection_tester_->RunAllTests(url); | 1084 connection_tester_->RunAllTests(url); |
1085 } | 1085 } |
1086 | 1086 |
1087 void SPKIHashesToString(const net::HashValueVector& hashes, | 1087 void SPKIHashesToString(const net::FingerprintVector& hashes, |
1088 std::string* string) { | 1088 std::string* string) { |
1089 for (net::HashValueVector::const_iterator | 1089 for (net::FingerprintVector::const_iterator |
1090 i = hashes.begin(); i != hashes.end(); ++i) { | 1090 i = hashes.begin(); i != hashes.end(); ++i) { |
1091 std::string label; | 1091 base::StringPiece hash_str(reinterpret_cast<const char*>(i->data), |
1092 switch (i->tag) { | 1092 arraysize(i->data)); |
1093 case net::HASH_VALUE_SHA1: | |
1094 label = "sha1/"; | |
1095 break; | |
1096 case net::HASH_VALUE_SHA256: | |
1097 label = "sha256/"; | |
1098 break; | |
1099 default: | |
1100 NOTREACHED(); | |
1101 LOG(WARNING) << "Invalid fingerprint of unknown type " << i->tag; | |
1102 label = "unknown/"; | |
1103 } | |
1104 | |
1105 base::StringPiece hash_str(reinterpret_cast<const char*>(i->data()), | |
1106 i->size()); | |
1107 std::string encoded; | 1093 std::string encoded; |
1108 base::Base64Encode(hash_str, &encoded); | 1094 base::Base64Encode(hash_str, &encoded); |
1109 | 1095 |
1110 if (i != hashes.begin()) | 1096 if (i != hashes.begin()) |
1111 *string += ","; | 1097 *string += ","; |
1112 *string += label + encoded; | 1098 *string += "sha1/" + encoded; |
1113 } | 1099 } |
1114 } | 1100 } |
1115 | 1101 |
1116 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( | 1102 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( |
1117 const ListValue* list) { | 1103 const ListValue* list) { |
1118 // |list| should be: [<domain to query>]. | 1104 // |list| should be: [<domain to query>]. |
1119 std::string domain; | 1105 std::string domain; |
1120 CHECK(list->GetString(0, &domain)); | 1106 CHECK(list->GetString(0, &domain)); |
1121 DictionaryValue* result = new DictionaryValue(); | 1107 DictionaryValue* result = new DictionaryValue(); |
1122 | 1108 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 net::TransportSecurityState::DomainState state; | 1164 net::TransportSecurityState::DomainState state; |
1179 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); | 1165 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); |
1180 state.include_subdomains = include_subdomains; | 1166 state.include_subdomains = include_subdomains; |
1181 if (!hashes_str.empty()) { | 1167 if (!hashes_str.empty()) { |
1182 std::vector<std::string> type_and_b64s; | 1168 std::vector<std::string> type_and_b64s; |
1183 base::SplitString(hashes_str, ',', &type_and_b64s); | 1169 base::SplitString(hashes_str, ',', &type_and_b64s); |
1184 for (std::vector<std::string>::const_iterator | 1170 for (std::vector<std::string>::const_iterator |
1185 i = type_and_b64s.begin(); i != type_and_b64s.end(); ++i) { | 1171 i = type_and_b64s.begin(); i != type_and_b64s.end(); ++i) { |
1186 std::string type_and_b64; | 1172 std::string type_and_b64; |
1187 RemoveChars(*i, " \t\r\n", &type_and_b64); | 1173 RemoveChars(*i, " \t\r\n", &type_and_b64); |
1188 net::HashValue hash; | 1174 net::SHA1Fingerprint hash; |
1189 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) | 1175 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) |
1190 continue; | 1176 continue; |
1191 | 1177 |
1192 state.dynamic_spki_hashes.push_back(hash); | 1178 state.dynamic_spki_hashes.push_back(hash); |
1193 } | 1179 } |
1194 } | 1180 } |
1195 | 1181 |
1196 transport_security_state->EnableHost(domain, state); | 1182 transport_security_state->EnableHost(domain, state); |
1197 } | 1183 } |
1198 | 1184 |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 } | 1743 } |
1758 | 1744 |
1759 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1745 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1760 : WebUIController(web_ui) { | 1746 : WebUIController(web_ui) { |
1761 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1747 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1762 | 1748 |
1763 // Set up the chrome://net-internals/ source. | 1749 // Set up the chrome://net-internals/ source. |
1764 Profile* profile = Profile::FromWebUI(web_ui); | 1750 Profile* profile = Profile::FromWebUI(web_ui); |
1765 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); | 1751 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); |
1766 } | 1752 } |
OLD | NEW |