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