| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 // |value| should be: [<domain to query>]. |
| 972 string16 domain16; |
| 973 CHECK(list->GetString(0, &domain16)); |
| 974 const std::string domain(UTF16ToUTF8(domain16)); |
| 975 net::TransportSecurityState* t = |
| 976 context_getter_->GetURLRequestContext()->transport_security_state(); |
| 977 if (!t) |
| 978 return; |
| 979 |
| 980 net::TransportSecurityState::DomainState state; |
| 981 const bool r = t->IsEnabledForHost(&state, domain); |
| 982 |
| 983 DictionaryValue* result = new(DictionaryValue); |
| 984 result->SetBoolean("result", r); |
| 985 if (r) { |
| 986 result->SetInteger("mode", static_cast<int>(state.mode)); |
| 987 result->SetDouble("created", static_cast<double>(state.created.ToTimeT())); |
| 988 result->SetDouble("expiry", static_cast<double>(state.expiry.ToTimeT())); |
| 989 result->SetBoolean("subdomains", state.include_subdomains); |
| 990 result->SetBoolean("preloaded", state.preloaded); |
| 991 result->SetString("domain", state.domain); |
| 992 } |
| 993 CallJavascriptFunction(L"g_browser.receivedHSTSResult", result); |
| 994 } |
| 995 |
| 996 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( |
| 997 const ListValue* list) { |
| 998 // |value| should be: [<domain to query>, <include subdomains>]. |
| 999 string16 domain16; |
| 1000 CHECK(list->GetString(0, &domain16)); |
| 1001 bool include_subdomains; |
| 1002 CHECK(list->GetBoolean(1, &include_subdomains)); |
| 1003 |
| 1004 const std::string domain(UTF16ToUTF8(domain16)); |
| 1005 net::TransportSecurityState* t = |
| 1006 context_getter_->GetURLRequestContext()->transport_security_state(); |
| 1007 if (!t) |
| 1008 return; |
| 1009 |
| 1010 net::TransportSecurityState::DomainState state; |
| 1011 state.expiry = state.created + base::TimeDelta::FromDays(1000); |
| 1012 state.include_subdomains = include_subdomains; |
| 1013 |
| 1014 t->EnableHost(domain, state); |
| 1015 } |
| 1016 |
| 1017 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSDelete( |
| 1018 const ListValue* list) { |
| 1019 // |value| should be: [<domain to query>]. |
| 1020 string16 domain16; |
| 1021 CHECK(list->GetString(0, &domain16)); |
| 1022 const std::string domain(UTF16ToUTF8(domain16)); |
| 1023 net::TransportSecurityState* t = |
| 1024 context_getter_->GetURLRequestContext()->transport_security_state(); |
| 1025 if (!t) |
| 1026 return; |
| 1027 |
| 1028 t->DeleteHost(domain); |
| 1029 } |
| 1030 |
| 957 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( | 1031 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( |
| 958 const ListValue* list) { | 1032 const ListValue* list) { |
| 959 DictionaryValue* info_dict = new DictionaryValue(); | 1033 DictionaryValue* info_dict = new DictionaryValue(); |
| 960 DictionaryValue* stats_dict = new DictionaryValue(); | 1034 DictionaryValue* stats_dict = new DictionaryValue(); |
| 961 | 1035 |
| 962 disk_cache::Backend* disk_cache = GetDiskCacheBackend( | 1036 disk_cache::Backend* disk_cache = GetDiskCacheBackend( |
| 963 context_getter_->GetURLRequestContext()); | 1037 context_getter_->GetURLRequestContext()); |
| 964 | 1038 |
| 965 if (disk_cache) { | 1039 if (disk_cache) { |
| 966 // Extract the statistics key/value pairs from the backend. | 1040 // Extract the statistics key/value pairs from the backend. |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 //////////////////////////////////////////////////////////////////////////////// | 1293 //////////////////////////////////////////////////////////////////////////////// |
| 1220 | 1294 |
| 1221 NetInternalsUI::NetInternalsUI(TabContents* contents) : WebUI(contents) { | 1295 NetInternalsUI::NetInternalsUI(TabContents* contents) : WebUI(contents) { |
| 1222 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); | 1296 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); |
| 1223 | 1297 |
| 1224 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); | 1298 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); |
| 1225 | 1299 |
| 1226 // Set up the chrome://net-internals/ source. | 1300 // Set up the chrome://net-internals/ source. |
| 1227 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 1301 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
| 1228 } | 1302 } |
| OLD | NEW |