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 26 matching lines...) Expand all Loading... |
37 #include "chrome/common/net/url_request_context_getter.h" | 37 #include "chrome/common/net/url_request_context_getter.h" |
38 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
40 #include "grit/net_internals_resources.h" | 40 #include "grit/net_internals_resources.h" |
41 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
42 #include "net/base/host_resolver_impl.h" | 42 #include "net/base/host_resolver_impl.h" |
43 #include "net/base/net_errors.h" | 43 #include "net/base/net_errors.h" |
44 #include "net/base/net_util.h" | 44 #include "net/base/net_util.h" |
45 #include "net/base/sys_addrinfo.h" | 45 #include "net/base/sys_addrinfo.h" |
46 #include "net/disk_cache/disk_cache.h" | 46 #include "net/disk_cache/disk_cache.h" |
| 47 #include "net/http/http_alternate_protocols.h" |
47 #include "net/http/http_cache.h" | 48 #include "net/http/http_cache.h" |
| 49 #include "net/http/http_stream_factory.h" |
48 #include "net/http/http_network_layer.h" | 50 #include "net/http/http_network_layer.h" |
49 #include "net/http/http_network_session.h" | 51 #include "net/http/http_network_session.h" |
50 #include "net/proxy/proxy_service.h" | 52 #include "net/proxy/proxy_service.h" |
51 #include "net/url_request/url_request_context.h" | 53 #include "net/url_request/url_request_context.h" |
52 #include "ui/base/l10n/l10n_util.h" | 54 #include "ui/base/l10n/l10n_util.h" |
53 #include "ui/base/resource/resource_bundle.h" | 55 #include "ui/base/resource/resource_bundle.h" |
54 | 56 |
55 #ifdef OS_WIN | 57 #ifdef OS_WIN |
56 #include "chrome/browser/net/service_providers_win.h" | 58 #include "chrome/browser/net/service_providers_win.h" |
57 #endif | 59 #endif |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 void OnReloadProxySettings(const ListValue* list); | 251 void OnReloadProxySettings(const ListValue* list); |
250 void OnGetBadProxies(const ListValue* list); | 252 void OnGetBadProxies(const ListValue* list); |
251 void OnClearBadProxies(const ListValue* list); | 253 void OnClearBadProxies(const ListValue* list); |
252 void OnGetHostResolverInfo(const ListValue* list); | 254 void OnGetHostResolverInfo(const ListValue* list); |
253 void OnClearHostResolverCache(const ListValue* list); | 255 void OnClearHostResolverCache(const ListValue* list); |
254 void OnEnableIPv6(const ListValue* list); | 256 void OnEnableIPv6(const ListValue* list); |
255 void OnStartConnectionTests(const ListValue* list); | 257 void OnStartConnectionTests(const ListValue* list); |
256 void OnGetHttpCacheInfo(const ListValue* list); | 258 void OnGetHttpCacheInfo(const ListValue* list); |
257 void OnGetSocketPoolInfo(const ListValue* list); | 259 void OnGetSocketPoolInfo(const ListValue* list); |
258 void OnGetSpdySessionInfo(const ListValue* list); | 260 void OnGetSpdySessionInfo(const ListValue* list); |
| 261 void OnGetSpdyStatus(const ListValue* list); |
| 262 void OnGetSpdyAlternateProtocolMappings(const ListValue* list); |
259 #ifdef OS_WIN | 263 #ifdef OS_WIN |
260 void OnGetServiceProviders(const ListValue* list); | 264 void OnGetServiceProviders(const ListValue* list); |
261 #endif | 265 #endif |
262 | 266 |
263 void OnSetLogLevel(const ListValue* list); | 267 void OnSetLogLevel(const ListValue* list); |
264 | 268 |
265 // ChromeNetLog::ThreadSafeObserver implementation: | 269 // ChromeNetLog::ThreadSafeObserver implementation: |
266 virtual void OnAddEntry(net::NetLog::EventType type, | 270 virtual void OnAddEntry(net::NetLog::EventType type, |
267 const base::TimeTicks& time, | 271 const base::TimeTicks& time, |
268 const net::NetLog::Source& source, | 272 const net::NetLog::Source& source, |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 proxy_->CreateCallback(&IOThreadImpl::OnStartConnectionTests)); | 508 proxy_->CreateCallback(&IOThreadImpl::OnStartConnectionTests)); |
505 dom_ui_->RegisterMessageCallback( | 509 dom_ui_->RegisterMessageCallback( |
506 "getHttpCacheInfo", | 510 "getHttpCacheInfo", |
507 proxy_->CreateCallback(&IOThreadImpl::OnGetHttpCacheInfo)); | 511 proxy_->CreateCallback(&IOThreadImpl::OnGetHttpCacheInfo)); |
508 dom_ui_->RegisterMessageCallback( | 512 dom_ui_->RegisterMessageCallback( |
509 "getSocketPoolInfo", | 513 "getSocketPoolInfo", |
510 proxy_->CreateCallback(&IOThreadImpl::OnGetSocketPoolInfo)); | 514 proxy_->CreateCallback(&IOThreadImpl::OnGetSocketPoolInfo)); |
511 dom_ui_->RegisterMessageCallback( | 515 dom_ui_->RegisterMessageCallback( |
512 "getSpdySessionInfo", | 516 "getSpdySessionInfo", |
513 proxy_->CreateCallback(&IOThreadImpl::OnGetSpdySessionInfo)); | 517 proxy_->CreateCallback(&IOThreadImpl::OnGetSpdySessionInfo)); |
| 518 dom_ui_->RegisterMessageCallback( |
| 519 "getSpdyStatus", |
| 520 proxy_->CreateCallback(&IOThreadImpl::OnGetSpdyStatus)); |
| 521 dom_ui_->RegisterMessageCallback( |
| 522 "getSpdyAlternateProtocolMappings", |
| 523 proxy_->CreateCallback( |
| 524 &IOThreadImpl::OnGetSpdyAlternateProtocolMappings)); |
514 #ifdef OS_WIN | 525 #ifdef OS_WIN |
515 dom_ui_->RegisterMessageCallback( | 526 dom_ui_->RegisterMessageCallback( |
516 "getServiceProviders", | 527 "getServiceProviders", |
517 proxy_->CreateCallback(&IOThreadImpl::OnGetServiceProviders)); | 528 proxy_->CreateCallback(&IOThreadImpl::OnGetServiceProviders)); |
518 #endif | 529 #endif |
519 | 530 |
520 dom_ui_->RegisterMessageCallback( | 531 dom_ui_->RegisterMessageCallback( |
521 "setLogLevel", | 532 "setLogLevel", |
522 proxy_->CreateCallback(&IOThreadImpl::OnSetLogLevel)); | 533 proxy_->CreateCallback(&IOThreadImpl::OnSetLogLevel)); |
523 } | 534 } |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 995 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
985 | 996 |
986 Value* spdy_info = NULL; | 997 Value* spdy_info = NULL; |
987 if (http_network_session) { | 998 if (http_network_session) { |
988 spdy_info = http_network_session->SpdySessionPoolInfoToValue(); | 999 spdy_info = http_network_session->SpdySessionPoolInfoToValue(); |
989 } | 1000 } |
990 | 1001 |
991 CallJavascriptFunction(L"g_browser.receivedSpdySessionInfo", spdy_info); | 1002 CallJavascriptFunction(L"g_browser.receivedSpdySessionInfo", spdy_info); |
992 } | 1003 } |
993 | 1004 |
| 1005 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus( |
| 1006 const ListValue* list) { |
| 1007 DictionaryValue* status_dict = new DictionaryValue(); |
| 1008 |
| 1009 status_dict->Set("spdy_enabled", |
| 1010 Value::CreateBooleanValue( |
| 1011 net::HttpStreamFactory::spdy_enabled())); |
| 1012 status_dict->Set("use_alternate_protocols", |
| 1013 Value::CreateBooleanValue( |
| 1014 net::HttpStreamFactory::use_alternate_protocols())); |
| 1015 status_dict->Set("force_spdy_over_ssl", |
| 1016 Value::CreateBooleanValue( |
| 1017 net::HttpStreamFactory::force_spdy_over_ssl())); |
| 1018 status_dict->Set("force_spdy_always", |
| 1019 Value::CreateBooleanValue( |
| 1020 net::HttpStreamFactory::force_spdy_always())); |
| 1021 status_dict->Set("next_protos", |
| 1022 Value::CreateStringValue( |
| 1023 *net::HttpStreamFactory::next_protos())); |
| 1024 |
| 1025 CallJavascriptFunction(L"g_browser.receivedSpdyStatus", status_dict); |
| 1026 } |
| 1027 |
| 1028 void |
| 1029 NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings( |
| 1030 const ListValue* list) { |
| 1031 net::HttpNetworkSession* http_network_session = |
| 1032 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
| 1033 |
| 1034 ListValue* dict_list = new ListValue(); |
| 1035 |
| 1036 if (http_network_session) { |
| 1037 const net::HttpAlternateProtocols& http_alternate_protocols = |
| 1038 http_network_session->alternate_protocols(); |
| 1039 const net::HttpAlternateProtocols::ProtocolMap& map = |
| 1040 http_alternate_protocols.protocol_map(); |
| 1041 |
| 1042 for (net::HttpAlternateProtocols::ProtocolMap::const_iterator it = |
| 1043 map.begin(); |
| 1044 it != map.end(); ++it) { |
| 1045 DictionaryValue* dict = new DictionaryValue(); |
| 1046 dict->SetString("host_port_pair", it->first.ToString()); |
| 1047 dict->SetString("alternate_protocol", it->second.ToString()); |
| 1048 dict_list->Append(dict); |
| 1049 } |
| 1050 } |
| 1051 |
| 1052 CallJavascriptFunction(L"g_browser.receivedSpdyAlternateProtocolMappings", |
| 1053 dict_list); |
| 1054 } |
| 1055 |
994 #ifdef OS_WIN | 1056 #ifdef OS_WIN |
995 void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( | 1057 void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( |
996 const ListValue* list) { | 1058 const ListValue* list) { |
997 | 1059 |
998 DictionaryValue* service_providers = new DictionaryValue(); | 1060 DictionaryValue* service_providers = new DictionaryValue(); |
999 | 1061 |
1000 WinsockLayeredServiceProviderList layered_providers; | 1062 WinsockLayeredServiceProviderList layered_providers; |
1001 GetWinsockLayeredServiceProviders(&layered_providers); | 1063 GetWinsockLayeredServiceProviders(&layered_providers); |
1002 ListValue* layered_provider_list = new ListValue(); | 1064 ListValue* layered_provider_list = new ListValue(); |
1003 for (size_t i = 0; i < layered_providers.size(); ++i) { | 1065 for (size_t i = 0; i < layered_providers.size(); ++i) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 //////////////////////////////////////////////////////////////////////////////// | 1219 //////////////////////////////////////////////////////////////////////////////// |
1158 | 1220 |
1159 NetInternalsUI::NetInternalsUI(TabContents* contents) : DOMUI(contents) { | 1221 NetInternalsUI::NetInternalsUI(TabContents* contents) : DOMUI(contents) { |
1160 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); | 1222 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); |
1161 | 1223 |
1162 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); | 1224 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); |
1163 | 1225 |
1164 // Set up the chrome://net-internals/ source. | 1226 // Set up the chrome://net-internals/ source. |
1165 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 1227 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
1166 } | 1228 } |
OLD | NEW |