Chromium Code Reviews| 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::FingerprintVector& hashes, | 1087 void SPKIHashesToString(const net::HashValueVector& hashes, |
| 1088 std::string* string) { | 1088 std::string* string) { |
| 1089 for (net::FingerprintVector::const_iterator | 1089 for (net::HashValueVector::const_iterator |
| 1090 i = hashes.begin(); i != hashes.end(); ++i) { | 1090 i = hashes.begin(); i != hashes.end(); ++i) { |
| 1091 base::StringPiece hash_str(reinterpret_cast<const char*>(i->data), | 1091 std::string label; |
| 1092 arraysize(i->data)); | 1092 switch (i->tag) { |
| 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 } | |
|
Ryan Sleevi
2012/08/11 01:39:55
Duplicate code with transport_security_persister -
palmer
2012/08/14 19:40:42
Yep, I added a HashValue.label method in x509_cert
| |
| 1104 | |
| 1105 base::StringPiece hash_str(reinterpret_cast<const char*>(i->data()), | |
| 1106 i->size()); | |
| 1093 std::string encoded; | 1107 std::string encoded; |
| 1094 base::Base64Encode(hash_str, &encoded); | 1108 base::Base64Encode(hash_str, &encoded); |
| 1095 | 1109 |
| 1096 if (i != hashes.begin()) | 1110 if (i != hashes.begin()) |
| 1097 *string += ","; | 1111 *string += ","; |
| 1098 *string += "sha1/" + encoded; | 1112 *string += label + encoded; |
| 1099 } | 1113 } |
| 1100 } | 1114 } |
| 1101 | 1115 |
| 1102 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( | 1116 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( |
| 1103 const ListValue* list) { | 1117 const ListValue* list) { |
| 1104 // |list| should be: [<domain to query>]. | 1118 // |list| should be: [<domain to query>]. |
| 1105 std::string domain; | 1119 std::string domain; |
| 1106 CHECK(list->GetString(0, &domain)); | 1120 CHECK(list->GetString(0, &domain)); |
| 1107 DictionaryValue* result = new DictionaryValue(); | 1121 DictionaryValue* result = new DictionaryValue(); |
| 1108 | 1122 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1164 net::TransportSecurityState::DomainState state; | 1178 net::TransportSecurityState::DomainState state; |
| 1165 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); | 1179 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); |
| 1166 state.include_subdomains = include_subdomains; | 1180 state.include_subdomains = include_subdomains; |
| 1167 if (!hashes_str.empty()) { | 1181 if (!hashes_str.empty()) { |
| 1168 std::vector<std::string> type_and_b64s; | 1182 std::vector<std::string> type_and_b64s; |
| 1169 base::SplitString(hashes_str, ',', &type_and_b64s); | 1183 base::SplitString(hashes_str, ',', &type_and_b64s); |
| 1170 for (std::vector<std::string>::const_iterator | 1184 for (std::vector<std::string>::const_iterator |
| 1171 i = type_and_b64s.begin(); i != type_and_b64s.end(); ++i) { | 1185 i = type_and_b64s.begin(); i != type_and_b64s.end(); ++i) { |
| 1172 std::string type_and_b64; | 1186 std::string type_and_b64; |
| 1173 RemoveChars(*i, " \t\r\n", &type_and_b64); | 1187 RemoveChars(*i, " \t\r\n", &type_and_b64); |
| 1174 net::SHA1Fingerprint hash; | 1188 net::HashValue hash; |
| 1175 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) | 1189 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) |
| 1176 continue; | 1190 continue; |
| 1177 | 1191 |
| 1178 state.dynamic_spki_hashes.push_back(hash); | 1192 state.dynamic_spki_hashes.push_back(hash); |
| 1179 } | 1193 } |
| 1180 } | 1194 } |
| 1181 | 1195 |
| 1182 transport_security_state->EnableHost(domain, state); | 1196 transport_security_state->EnableHost(domain, state); |
| 1183 } | 1197 } |
| 1184 | 1198 |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1743 } | 1757 } |
| 1744 | 1758 |
| 1745 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1759 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 1746 : WebUIController(web_ui) { | 1760 : WebUIController(web_ui) { |
| 1747 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1761 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 1748 | 1762 |
| 1749 // Set up the chrome://net-internals/ source. | 1763 // Set up the chrome://net-internals/ source. |
| 1750 Profile* profile = Profile::FromWebUI(web_ui); | 1764 Profile* profile = Profile::FromWebUI(web_ui); |
| 1751 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); | 1765 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); |
| 1752 } | 1766 } |
| OLD | NEW |