Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui.cc

Issue 270183002: Move IsStringUTF8/ASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more minor nit Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 connection_tester_->RunAllTests(url); 1194 connection_tester_->RunAllTests(url);
1195 } 1195 }
1196 1196
1197 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( 1197 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery(
1198 const base::ListValue* list) { 1198 const base::ListValue* list) {
1199 // |list| should be: [<domain to query>]. 1199 // |list| should be: [<domain to query>].
1200 std::string domain; 1200 std::string domain;
1201 CHECK(list->GetString(0, &domain)); 1201 CHECK(list->GetString(0, &domain));
1202 base::DictionaryValue* result = new base::DictionaryValue(); 1202 base::DictionaryValue* result = new base::DictionaryValue();
1203 1203
1204 if (!IsStringASCII(domain)) { 1204 if (!base::IsStringASCII(domain)) {
1205 result->SetString("error", "non-ASCII domain name"); 1205 result->SetString("error", "non-ASCII domain name");
1206 } else { 1206 } else {
1207 net::TransportSecurityState* transport_security_state = 1207 net::TransportSecurityState* transport_security_state =
1208 GetMainContext()->transport_security_state(); 1208 GetMainContext()->transport_security_state();
1209 if (!transport_security_state) { 1209 if (!transport_security_state) {
1210 result->SetString("error", "no TransportSecurityState active"); 1210 result->SetString("error", "no TransportSecurityState active");
1211 } else { 1211 } else {
1212 net::TransportSecurityState::DomainState state; 1212 net::TransportSecurityState::DomainState state;
1213 const bool found = transport_security_state->GetDomainState( 1213 const bool found = transport_security_state->GetDomainState(
1214 domain, true, &state); 1214 domain, true, &state);
(...skipping 20 matching lines...) Expand all
1235 1235
1236 SendJavascriptCommand("receivedHSTSResult", result); 1236 SendJavascriptCommand("receivedHSTSResult", result);
1237 } 1237 }
1238 1238
1239 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( 1239 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd(
1240 const base::ListValue* list) { 1240 const base::ListValue* list) {
1241 // |list| should be: [<domain to query>, <STS include subdomains>, <PKP 1241 // |list| should be: [<domain to query>, <STS include subdomains>, <PKP
1242 // include subdomains>, <key pins>]. 1242 // include subdomains>, <key pins>].
1243 std::string domain; 1243 std::string domain;
1244 CHECK(list->GetString(0, &domain)); 1244 CHECK(list->GetString(0, &domain));
1245 if (!IsStringASCII(domain)) { 1245 if (!base::IsStringASCII(domain)) {
1246 // Silently fail. The user will get a helpful error if they query for the 1246 // Silently fail. The user will get a helpful error if they query for the
1247 // name. 1247 // name.
1248 return; 1248 return;
1249 } 1249 }
1250 bool sts_include_subdomains; 1250 bool sts_include_subdomains;
1251 CHECK(list->GetBoolean(1, &sts_include_subdomains)); 1251 CHECK(list->GetBoolean(1, &sts_include_subdomains));
1252 bool pkp_include_subdomains; 1252 bool pkp_include_subdomains;
1253 CHECK(list->GetBoolean(2, &pkp_include_subdomains)); 1253 CHECK(list->GetBoolean(2, &pkp_include_subdomains));
1254 std::string hashes_str; 1254 std::string hashes_str;
1255 CHECK(list->GetString(3, &hashes_str)); 1255 CHECK(list->GetString(3, &hashes_str));
(...skipping 13 matching lines...) Expand all
1269 transport_security_state->AddHSTS(domain, expiry, sts_include_subdomains); 1269 transport_security_state->AddHSTS(domain, expiry, sts_include_subdomains);
1270 transport_security_state->AddHPKP(domain, expiry, pkp_include_subdomains, 1270 transport_security_state->AddHPKP(domain, expiry, pkp_include_subdomains,
1271 hashes); 1271 hashes);
1272 } 1272 }
1273 1273
1274 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSDelete( 1274 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSDelete(
1275 const base::ListValue* list) { 1275 const base::ListValue* list) {
1276 // |list| should be: [<domain to query>]. 1276 // |list| should be: [<domain to query>].
1277 std::string domain; 1277 std::string domain;
1278 CHECK(list->GetString(0, &domain)); 1278 CHECK(list->GetString(0, &domain));
1279 if (!IsStringASCII(domain)) { 1279 if (!base::IsStringASCII(domain)) {
1280 // There cannot be a unicode entry in the HSTS set. 1280 // There cannot be a unicode entry in the HSTS set.
1281 return; 1281 return;
1282 } 1282 }
1283 net::TransportSecurityState* transport_security_state = 1283 net::TransportSecurityState* transport_security_state =
1284 GetMainContext()->transport_security_state(); 1284 GetMainContext()->transport_security_state();
1285 if (!transport_security_state) 1285 if (!transport_security_state)
1286 return; 1286 return;
1287 1287
1288 transport_security_state->DeleteDynamicDataForHost(domain); 1288 transport_security_state->DeleteDynamicDataForHost(domain);
1289 } 1289 }
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 } 1850 }
1851 1851
1852 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) 1852 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui)
1853 : WebUIController(web_ui) { 1853 : WebUIController(web_ui) {
1854 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); 1854 web_ui->AddMessageHandler(new NetInternalsMessageHandler());
1855 1855
1856 // Set up the chrome://net-internals/ source. 1856 // Set up the chrome://net-internals/ source.
1857 Profile* profile = Profile::FromWebUI(web_ui); 1857 Profile* profile = Profile::FromWebUI(web_ui);
1858 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); 1858 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource());
1859 } 1859 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698