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

Side by Side Diff: chrome/browser/dom_ui/net_internals_ui.cc

Issue 6500010: HSTS: add net-internals UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/dom_ui/net_internals_ui.h" 5 #include "chrome/browser/dom_ui/net_internals_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 void OnRendererReady(const ListValue* list); 248 void OnRendererReady(const ListValue* list);
249 249
250 void OnGetProxySettings(const ListValue* list); 250 void OnGetProxySettings(const ListValue* list);
251 void OnReloadProxySettings(const ListValue* list); 251 void OnReloadProxySettings(const ListValue* list);
252 void OnGetBadProxies(const ListValue* list); 252 void OnGetBadProxies(const ListValue* list);
253 void OnClearBadProxies(const ListValue* list); 253 void OnClearBadProxies(const ListValue* list);
254 void OnGetHostResolverInfo(const ListValue* list); 254 void OnGetHostResolverInfo(const ListValue* list);
255 void OnClearHostResolverCache(const ListValue* list); 255 void OnClearHostResolverCache(const ListValue* list);
256 void OnEnableIPv6(const ListValue* list); 256 void OnEnableIPv6(const ListValue* list);
257 void OnStartConnectionTests(const ListValue* list); 257 void OnStartConnectionTests(const ListValue* list);
258 void OnHSTSQuery(const ListValue* list);
259 void OnHSTSAdd(const ListValue* list);
260 void OnHSTSDelete(const ListValue* list);
258 void OnGetHttpCacheInfo(const ListValue* list); 261 void OnGetHttpCacheInfo(const ListValue* list);
259 void OnGetSocketPoolInfo(const ListValue* list); 262 void OnGetSocketPoolInfo(const ListValue* list);
260 void OnGetSpdySessionInfo(const ListValue* list); 263 void OnGetSpdySessionInfo(const ListValue* list);
261 void OnGetSpdyStatus(const ListValue* list); 264 void OnGetSpdyStatus(const ListValue* list);
262 void OnGetSpdyAlternateProtocolMappings(const ListValue* list); 265 void OnGetSpdyAlternateProtocolMappings(const ListValue* list);
263 #ifdef OS_WIN 266 #ifdef OS_WIN
264 void OnGetServiceProviders(const ListValue* list); 267 void OnGetServiceProviders(const ListValue* list);
265 #endif 268 #endif
266 269
267 void OnSetLogLevel(const ListValue* list); 270 void OnSetLogLevel(const ListValue* list);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 dom_ui_->RegisterMessageCallback( 503 dom_ui_->RegisterMessageCallback(
501 "clearHostResolverCache", 504 "clearHostResolverCache",
502 proxy_->CreateCallback(&IOThreadImpl::OnClearHostResolverCache)); 505 proxy_->CreateCallback(&IOThreadImpl::OnClearHostResolverCache));
503 dom_ui_->RegisterMessageCallback( 506 dom_ui_->RegisterMessageCallback(
504 "enableIPv6", 507 "enableIPv6",
505 proxy_->CreateCallback(&IOThreadImpl::OnEnableIPv6)); 508 proxy_->CreateCallback(&IOThreadImpl::OnEnableIPv6));
506 dom_ui_->RegisterMessageCallback( 509 dom_ui_->RegisterMessageCallback(
507 "startConnectionTests", 510 "startConnectionTests",
508 proxy_->CreateCallback(&IOThreadImpl::OnStartConnectionTests)); 511 proxy_->CreateCallback(&IOThreadImpl::OnStartConnectionTests));
509 dom_ui_->RegisterMessageCallback( 512 dom_ui_->RegisterMessageCallback(
513 "hstsQuery",
514 proxy_->CreateCallback(&IOThreadImpl::OnHSTSQuery));
515 dom_ui_->RegisterMessageCallback(
516 "hstsAdd",
517 proxy_->CreateCallback(&IOThreadImpl::OnHSTSAdd));
518 dom_ui_->RegisterMessageCallback(
519 "hstsDelete",
520 proxy_->CreateCallback(&IOThreadImpl::OnHSTSDelete));
521 dom_ui_->RegisterMessageCallback(
510 "getHttpCacheInfo", 522 "getHttpCacheInfo",
511 proxy_->CreateCallback(&IOThreadImpl::OnGetHttpCacheInfo)); 523 proxy_->CreateCallback(&IOThreadImpl::OnGetHttpCacheInfo));
512 dom_ui_->RegisterMessageCallback( 524 dom_ui_->RegisterMessageCallback(
513 "getSocketPoolInfo", 525 "getSocketPoolInfo",
514 proxy_->CreateCallback(&IOThreadImpl::OnGetSocketPoolInfo)); 526 proxy_->CreateCallback(&IOThreadImpl::OnGetSocketPoolInfo));
515 dom_ui_->RegisterMessageCallback( 527 dom_ui_->RegisterMessageCallback(
516 "getSpdySessionInfo", 528 "getSpdySessionInfo",
517 proxy_->CreateCallback(&IOThreadImpl::OnGetSpdySessionInfo)); 529 proxy_->CreateCallback(&IOThreadImpl::OnGetSpdySessionInfo));
518 dom_ui_->RegisterMessageCallback( 530 dom_ui_->RegisterMessageCallback(
519 "getSpdyStatus", 531 "getSpdyStatus",
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 959
948 // Try to fix-up the user provided URL into something valid. 960 // Try to fix-up the user provided URL into something valid.
949 // For example, turn "www.google.com" into "http://www.google.com". 961 // For example, turn "www.google.com" into "http://www.google.com".
950 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(url_str), std::string())); 962 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(url_str), std::string()));
951 963
952 connection_tester_.reset(new ConnectionTester( 964 connection_tester_.reset(new ConnectionTester(
953 this, io_thread_->globals()->proxy_script_fetcher_context.get())); 965 this, io_thread_->globals()->proxy_script_fetcher_context.get()));
954 connection_tester_->RunAllTests(url); 966 connection_tester_->RunAllTests(url);
955 } 967 }
956 968
969 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery(
970 const ListValue* list) {
971 // |list| should be: [<domain to query>].
972 std::string domain;
973 CHECK(list->GetString(0, &domain));
eroman 2011/02/16 20:12:45 Note that GetString() is going to give you a UTF-8
agl 2011/02/16 22:46:22 Restricted to ASCII.
974 net::TransportSecurityState* transport_security_state =
975 context_getter_->GetURLRequestContext()->transport_security_state();
eroman 2011/02/16 20:12:45 nit: indent by 4.
agl 2011/02/16 22:46:22 Done.
976 if (!transport_security_state)
977 return;
eroman 2011/02/16 20:12:45 I think it would be better to call g_browser.recen
agl 2011/02/16 22:46:22 Now replies with error.
978
979 net::TransportSecurityState::DomainState state;
980 const bool r = transport_security_state->IsEnabledForHost(&state, domain);
eroman 2011/02/16 20:12:45 can you use a more descriptive variable name than
agl 2011/02/16 22:46:22 Done.
981
982 DictionaryValue* result = new(DictionaryValue);
983 result->SetBoolean("result", r);
984 if (r) {
985 result->SetInteger("mode", static_cast<int>(state.mode));
986 result->SetDouble("created", static_cast<double>(state.created.ToTimeT()));
eroman 2011/02/16 20:12:45 Are you sure this works? Isn't Chrome representin
agl 2011/02/16 22:46:22 I didn't end up exposing the timestamps anyway so
987 result->SetDouble("expiry", static_cast<double>(state.expiry.ToTimeT()));
988 result->SetBoolean("subdomains", state.include_subdomains);
989 result->SetBoolean("preloaded", state.preloaded);
990 result->SetString("domain", state.domain);
991 }
992 CallJavascriptFunction(L"g_browser.receivedHSTSResult", result);
993 }
994
995 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd(
996 const ListValue* list) {
997 // |list| should be: [<domain to query>, <include subdomains>].
998 std::string domain;
999 CHECK(list->GetString(0, &domain));
1000 bool include_subdomains;
1001 CHECK(list->GetBoolean(1, &include_subdomains));
1002
1003 net::TransportSecurityState* transport_security_state =
1004 context_getter_->GetURLRequestContext()->transport_security_state();
eroman 2011/02/16 20:12:45 indent continued lines by 4.
agl 2011/02/16 22:46:22 Done.
1005 if (!transport_security_state)
1006 return;
1007
1008 net::TransportSecurityState::DomainState state;
1009 state.expiry = state.created + base::TimeDelta::FromDays(1000);
eroman 2011/02/16 20:12:45 What is the significance of 1000 days?
agl 2011/02/16 22:46:22 It's long enough to be useful basically. This is i
1010 state.include_subdomains = include_subdomains;
1011
1012 transport_security_state->EnableHost(domain, state);
1013 }
1014
1015 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSDelete(
1016 const ListValue* list) {
1017 // |list| should be: [<domain to query>].
1018 std::string domain;
1019 CHECK(list->GetString(0, &domain));
1020 net::TransportSecurityState* transport_security_state =
1021 context_getter_->GetURLRequestContext()->transport_security_state();
eroman 2011/02/16 20:12:45 indent by 4
agl 2011/02/16 22:46:22 Done.
1022 if (!transport_security_state)
1023 return;
1024
1025 transport_security_state->DeleteHost(domain);
1026 }
1027
957 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( 1028 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo(
958 const ListValue* list) { 1029 const ListValue* list) {
959 DictionaryValue* info_dict = new DictionaryValue(); 1030 DictionaryValue* info_dict = new DictionaryValue();
960 DictionaryValue* stats_dict = new DictionaryValue(); 1031 DictionaryValue* stats_dict = new DictionaryValue();
961 1032
962 disk_cache::Backend* disk_cache = GetDiskCacheBackend( 1033 disk_cache::Backend* disk_cache = GetDiskCacheBackend(
963 context_getter_->GetURLRequestContext()); 1034 context_getter_->GetURLRequestContext());
964 1035
965 if (disk_cache) { 1036 if (disk_cache) {
966 // Extract the statistics key/value pairs from the backend. 1037 // Extract the statistics key/value pairs from the backend.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 //////////////////////////////////////////////////////////////////////////////// 1290 ////////////////////////////////////////////////////////////////////////////////
1220 1291
1221 NetInternalsUI::NetInternalsUI(TabContents* contents) : WebUI(contents) { 1292 NetInternalsUI::NetInternalsUI(TabContents* contents) : WebUI(contents) {
1222 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); 1293 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this));
1223 1294
1224 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); 1295 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource();
1225 1296
1226 // Set up the chrome://net-internals/ source. 1297 // Set up the chrome://net-internals/ source.
1227 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); 1298 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
1228 } 1299 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/net_internals/hstsview.js » ('j') | chrome/browser/resources/net_internals/hstsview.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698