| 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/ui/webui/net_internals_ui.h" | 5 #include "chrome/browser/ui/webui/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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 NetInternalsMessageHandler(); | 155 NetInternalsMessageHandler(); |
| 156 virtual ~NetInternalsMessageHandler(); | 156 virtual ~NetInternalsMessageHandler(); |
| 157 | 157 |
| 158 // WebUIMessageHandler implementation. | 158 // WebUIMessageHandler implementation. |
| 159 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; | 159 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
| 160 virtual void RegisterMessages() OVERRIDE; | 160 virtual void RegisterMessages() OVERRIDE; |
| 161 | 161 |
| 162 // Calls g_browser.receive in the renderer, passing in |command| and |arg|. | 162 // Calls g_browser.receive in the renderer, passing in |command| and |arg|. |
| 163 // Takes ownership of |arg|. If the renderer is displaying a log file, the | 163 // Takes ownership of |arg|. If the renderer is displaying a log file, the |
| 164 // message will be ignored. | 164 // message will be ignored. |
| 165 void SendJavascriptCommand(const std::wstring& command, Value* arg); | 165 void SendJavascriptCommand(const std::string& command, Value* arg); |
| 166 | 166 |
| 167 // NotificationObserver implementation. | 167 // NotificationObserver implementation. |
| 168 virtual void Observe(int type, | 168 virtual void Observe(int type, |
| 169 const NotificationSource& source, | 169 const NotificationSource& source, |
| 170 const NotificationDetails& details) OVERRIDE; | 170 const NotificationDetails& details) OVERRIDE; |
| 171 | 171 |
| 172 // Javascript message handlers. | 172 // Javascript message handlers. |
| 173 void OnRendererReady(const ListValue* list); | 173 void OnRendererReady(const ListValue* list); |
| 174 void OnEnableHttpThrottling(const ListValue* list); | 174 void OnEnableHttpThrottling(const ListValue* list); |
| 175 #ifdef OS_CHROMEOS | 175 #ifdef OS_CHROMEOS |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 const ConnectionTester::Experiment& experiment); | 342 const ConnectionTester::Experiment& experiment); |
| 343 virtual void OnCompletedConnectionTestExperiment( | 343 virtual void OnCompletedConnectionTestExperiment( |
| 344 const ConnectionTester::Experiment& experiment, | 344 const ConnectionTester::Experiment& experiment, |
| 345 int result); | 345 int result); |
| 346 virtual void OnCompletedConnectionTestSuite(); | 346 virtual void OnCompletedConnectionTestSuite(); |
| 347 | 347 |
| 348 // Helper that calls g_browser.receive in the renderer, passing in |command| | 348 // Helper that calls g_browser.receive in the renderer, passing in |command| |
| 349 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log | 349 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log |
| 350 // file, the message will be ignored. Note that this can be called from any | 350 // file, the message will be ignored. Note that this can be called from any |
| 351 // thread. | 351 // thread. |
| 352 void SendJavascriptCommand(const std::wstring& command, Value* arg); | 352 void SendJavascriptCommand(const std::string& command, Value* arg); |
| 353 | 353 |
| 354 // Helper that runs |method| with |arg|, and deletes |arg| on completion. | 354 // Helper that runs |method| with |arg|, and deletes |arg| on completion. |
| 355 void DispatchToMessageHandler(ListValue* arg, MessageHandler method); | 355 void DispatchToMessageHandler(ListValue* arg, MessageHandler method); |
| 356 | 356 |
| 357 private: | 357 private: |
| 358 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 358 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 359 friend class DeleteTask<IOThreadImpl>; | 359 friend class DeleteTask<IOThreadImpl>; |
| 360 | 360 |
| 361 ~IOThreadImpl(); | 361 ~IOThreadImpl(); |
| 362 | 362 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 "enableHttpThrottling", | 548 "enableHttpThrottling", |
| 549 base::Bind(&NetInternalsMessageHandler::OnEnableHttpThrottling, | 549 base::Bind(&NetInternalsMessageHandler::OnEnableHttpThrottling, |
| 550 base::Unretained(this))); | 550 base::Unretained(this))); |
| 551 web_ui_->RegisterMessageCallback( | 551 web_ui_->RegisterMessageCallback( |
| 552 "getPrerenderInfo", | 552 "getPrerenderInfo", |
| 553 base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, | 553 base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, |
| 554 base::Unretained(this))); | 554 base::Unretained(this))); |
| 555 } | 555 } |
| 556 | 556 |
| 557 void NetInternalsMessageHandler::SendJavascriptCommand( | 557 void NetInternalsMessageHandler::SendJavascriptCommand( |
| 558 const std::wstring& command, | 558 const std::string& command, |
| 559 Value* arg) { | 559 Value* arg) { |
| 560 scoped_ptr<Value> command_value( | 560 scoped_ptr<Value> command_value(Value::CreateStringValue(command)); |
| 561 Value::CreateStringValue(WideToASCII(command))); | |
| 562 scoped_ptr<Value> value(arg); | 561 scoped_ptr<Value> value(arg); |
| 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 562 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 564 if (value.get()) { | 563 if (value.get()) { |
| 565 web_ui_->CallJavascriptFunction("g_browser.receive", | 564 web_ui_->CallJavascriptFunction("g_browser.receive", |
| 566 *command_value.get(), | 565 *command_value.get(), |
| 567 *value.get()); | 566 *value.get()); |
| 568 } else { | 567 } else { |
| 569 web_ui_->CallJavascriptFunction("g_browser.receive", | 568 web_ui_->CallJavascriptFunction("g_browser.receive", |
| 570 *command_value.get()); | 569 *command_value.get()); |
| 571 } | 570 } |
| 572 } | 571 } |
| 573 | 572 |
| 574 void NetInternalsMessageHandler::Observe(int type, | 573 void NetInternalsMessageHandler::Observe(int type, |
| 575 const NotificationSource& source, | 574 const NotificationSource& source, |
| 576 const NotificationDetails& details) { | 575 const NotificationDetails& details) { |
| 577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 576 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 578 DCHECK_EQ(type, chrome::NOTIFICATION_PREF_CHANGED); | 577 DCHECK_EQ(type, chrome::NOTIFICATION_PREF_CHANGED); |
| 579 | 578 |
| 580 std::string* pref_name = Details<std::string>(details).ptr(); | 579 std::string* pref_name = Details<std::string>(details).ptr(); |
| 581 if (*pref_name == prefs::kHttpThrottlingEnabled) { | 580 if (*pref_name == prefs::kHttpThrottlingEnabled) { |
| 582 SendJavascriptCommand( | 581 SendJavascriptCommand( |
| 583 L"receivedHttpThrottlingEnabledPrefChanged", | 582 "receivedHttpThrottlingEnabledPrefChanged", |
| 584 Value::CreateBooleanValue(*http_throttling_enabled_)); | 583 Value::CreateBooleanValue(*http_throttling_enabled_)); |
| 585 } | 584 } |
| 586 } | 585 } |
| 587 | 586 |
| 588 void NetInternalsMessageHandler::OnRendererReady(const ListValue* list) { | 587 void NetInternalsMessageHandler::OnRendererReady(const ListValue* list) { |
| 589 IOThreadImpl::CallbackHelper(&IOThreadImpl::OnRendererReady, proxy_, list); | 588 IOThreadImpl::CallbackHelper(&IOThreadImpl::OnRendererReady, proxy_, list); |
| 590 | 589 |
| 591 SendJavascriptCommand( | 590 SendJavascriptCommand( |
| 592 L"receivedHttpThrottlingEnabledPrefChanged", | 591 "receivedHttpThrottlingEnabledPrefChanged", |
| 593 Value::CreateBooleanValue(*http_throttling_enabled_)); | 592 Value::CreateBooleanValue(*http_throttling_enabled_)); |
| 594 } | 593 } |
| 595 | 594 |
| 596 void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) { | 595 void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) { |
| 597 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 596 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 598 | 597 |
| 599 bool enable = false; | 598 bool enable = false; |
| 600 if (!list->GetBoolean(0, &enable)) { | 599 if (!list->GetBoolean(0, &enable)) { |
| 601 NOTREACHED(); | 600 NOTREACHED(); |
| 602 return; | 601 return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 618 | 617 |
| 619 DictionaryValue* value = NULL; | 618 DictionaryValue* value = NULL; |
| 620 prerender::PrerenderManager* prerender_manager = prerender_manager_.get(); | 619 prerender::PrerenderManager* prerender_manager = prerender_manager_.get(); |
| 621 if (!prerender_manager) { | 620 if (!prerender_manager) { |
| 622 value = new DictionaryValue(); | 621 value = new DictionaryValue(); |
| 623 value->SetBoolean("enabled", false); | 622 value->SetBoolean("enabled", false); |
| 624 value->SetBoolean("omnibox_enabled", false); | 623 value->SetBoolean("omnibox_enabled", false); |
| 625 } else { | 624 } else { |
| 626 value = prerender_manager->GetAsValue(); | 625 value = prerender_manager->GetAsValue(); |
| 627 } | 626 } |
| 628 SendJavascriptCommand(L"receivedPrerenderInfo", value); | 627 SendJavascriptCommand("receivedPrerenderInfo", value); |
| 629 } | 628 } |
| 630 | 629 |
| 631 | 630 |
| 632 #ifdef OS_CHROMEOS | 631 #ifdef OS_CHROMEOS |
| 633 //////////////////////////////////////////////////////////////////////////////// | 632 //////////////////////////////////////////////////////////////////////////////// |
| 634 // | 633 // |
| 635 // NetInternalsMessageHandler::SystemLogsGetter | 634 // NetInternalsMessageHandler::SystemLogsGetter |
| 636 // | 635 // |
| 637 //////////////////////////////////////////////////////////////////////////////// | 636 //////////////////////////////////////////////////////////////////////////////// |
| 638 | 637 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 if (!log_it->second.empty()) { | 713 if (!log_it->second.empty()) { |
| 715 result->SetString("log", log_it->second); | 714 result->SetString("log", log_it->second); |
| 716 } else { | 715 } else { |
| 717 result->SetString("log", "<no relevant lines found>"); | 716 result->SetString("log", "<no relevant lines found>"); |
| 718 } | 717 } |
| 719 } else { | 718 } else { |
| 720 result->SetString("log", "<invalid log name>"); | 719 result->SetString("log", "<invalid log name>"); |
| 721 } | 720 } |
| 722 result->SetString("cellId", request.cell_id); | 721 result->SetString("cellId", request.cell_id); |
| 723 | 722 |
| 724 handler_->SendJavascriptCommand(L"getSystemLogCallback", result); | 723 handler_->SendJavascriptCommand("getSystemLogCallback", result); |
| 725 } | 724 } |
| 726 #endif | 725 #endif |
| 727 //////////////////////////////////////////////////////////////////////////////// | 726 //////////////////////////////////////////////////////////////////////////////// |
| 728 // | 727 // |
| 729 // NetInternalsMessageHandler::IOThreadImpl | 728 // NetInternalsMessageHandler::IOThreadImpl |
| 730 // | 729 // |
| 731 //////////////////////////////////////////////////////////////////////////////// | 730 //////////////////////////////////////////////////////////////////////////////// |
| 732 | 731 |
| 733 NetInternalsMessageHandler::IOThreadImpl::IOThreadImpl( | 732 NetInternalsMessageHandler::IOThreadImpl::IOThreadImpl( |
| 734 const base::WeakPtr<NetInternalsMessageHandler>& handler, | 733 const base::WeakPtr<NetInternalsMessageHandler>& handler, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 for (size_t i = 0; i < passive_entries.size(); ++i) { | 784 for (size_t i = 0; i < passive_entries.size(); ++i) { |
| 786 const ChromeNetLog::Entry& e = passive_entries[i]; | 785 const ChromeNetLog::Entry& e = passive_entries[i]; |
| 787 dict_list->Append(net::NetLog::EntryToDictionaryValue(e.type, | 786 dict_list->Append(net::NetLog::EntryToDictionaryValue(e.type, |
| 788 e.time, | 787 e.time, |
| 789 e.source, | 788 e.source, |
| 790 e.phase, | 789 e.phase, |
| 791 e.params, | 790 e.params, |
| 792 false)); | 791 false)); |
| 793 } | 792 } |
| 794 | 793 |
| 795 SendJavascriptCommand(L"receivedPassiveLogEntries", dict_list); | 794 SendJavascriptCommand("receivedPassiveLogEntries", dict_list); |
| 796 } | 795 } |
| 797 | 796 |
| 798 void NetInternalsMessageHandler::IOThreadImpl::OnWebUIDeleted() { | 797 void NetInternalsMessageHandler::IOThreadImpl::OnWebUIDeleted() { |
| 799 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 798 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 800 was_webui_deleted_ = true; | 799 was_webui_deleted_ = true; |
| 801 } | 800 } |
| 802 | 801 |
| 803 void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( | 802 void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( |
| 804 const ListValue* list) { | 803 const ListValue* list) { |
| 805 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 804 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 806 DCHECK(!is_observing_log_) << "notifyReady called twice"; | 805 DCHECK(!is_observing_log_) << "notifyReady called twice"; |
| 807 | 806 |
| 808 SendJavascriptCommand(L"receivedConstants", | 807 SendJavascriptCommand("receivedConstants", |
| 809 NetInternalsUI::GetConstants()); | 808 NetInternalsUI::GetConstants()); |
| 810 | 809 |
| 811 // Register with network stack to observe events. | 810 // Register with network stack to observe events. |
| 812 is_observing_log_ = true; | 811 is_observing_log_ = true; |
| 813 ChromeNetLog::EntryList entries; | 812 ChromeNetLog::EntryList entries; |
| 814 AddAsObserverAndGetAllPassivelyCapturedEvents(io_thread_->net_log(), | 813 AddAsObserverAndGetAllPassivelyCapturedEvents(io_thread_->net_log(), |
| 815 &entries); | 814 &entries); |
| 816 SendPassiveLogEntries(entries); | 815 SendPassiveLogEntries(entries); |
| 817 } | 816 } |
| 818 | 817 |
| 819 void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( | 818 void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( |
| 820 const ListValue* list) { | 819 const ListValue* list) { |
| 821 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 820 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
| 822 net::ProxyService* proxy_service = context->proxy_service(); | 821 net::ProxyService* proxy_service = context->proxy_service(); |
| 823 | 822 |
| 824 DictionaryValue* dict = new DictionaryValue(); | 823 DictionaryValue* dict = new DictionaryValue(); |
| 825 if (proxy_service->fetched_config().is_valid()) | 824 if (proxy_service->fetched_config().is_valid()) |
| 826 dict->Set("original", proxy_service->fetched_config().ToValue()); | 825 dict->Set("original", proxy_service->fetched_config().ToValue()); |
| 827 if (proxy_service->config().is_valid()) | 826 if (proxy_service->config().is_valid()) |
| 828 dict->Set("effective", proxy_service->config().ToValue()); | 827 dict->Set("effective", proxy_service->config().ToValue()); |
| 829 | 828 |
| 830 SendJavascriptCommand(L"receivedProxySettings", dict); | 829 SendJavascriptCommand("receivedProxySettings", dict); |
| 831 } | 830 } |
| 832 | 831 |
| 833 void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( | 832 void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( |
| 834 const ListValue* list) { | 833 const ListValue* list) { |
| 835 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 834 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
| 836 context->proxy_service()->ForceReloadProxyConfig(); | 835 context->proxy_service()->ForceReloadProxyConfig(); |
| 837 | 836 |
| 838 // Cause the renderer to be notified of the new values. | 837 // Cause the renderer to be notified of the new values. |
| 839 OnGetProxySettings(NULL); | 838 OnGetProxySettings(NULL); |
| 840 } | 839 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 854 const net::ProxyRetryInfo& retry_info = it->second; | 853 const net::ProxyRetryInfo& retry_info = it->second; |
| 855 | 854 |
| 856 DictionaryValue* dict = new DictionaryValue(); | 855 DictionaryValue* dict = new DictionaryValue(); |
| 857 dict->SetString("proxy_uri", proxy_uri); | 856 dict->SetString("proxy_uri", proxy_uri); |
| 858 dict->SetString("bad_until", | 857 dict->SetString("bad_until", |
| 859 net::NetLog::TickCountToString(retry_info.bad_until)); | 858 net::NetLog::TickCountToString(retry_info.bad_until)); |
| 860 | 859 |
| 861 dict_list->Append(dict); | 860 dict_list->Append(dict); |
| 862 } | 861 } |
| 863 | 862 |
| 864 SendJavascriptCommand(L"receivedBadProxies", dict_list); | 863 SendJavascriptCommand("receivedBadProxies", dict_list); |
| 865 } | 864 } |
| 866 | 865 |
| 867 void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( | 866 void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( |
| 868 const ListValue* list) { | 867 const ListValue* list) { |
| 869 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 868 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
| 870 context->proxy_service()->ClearBadProxiesCache(); | 869 context->proxy_service()->ClearBadProxiesCache(); |
| 871 | 870 |
| 872 // Cause the renderer to be notified of the new values. | 871 // Cause the renderer to be notified of the new values. |
| 873 OnGetBadProxies(NULL); | 872 OnGetBadProxies(NULL); |
| 874 } | 873 } |
| 875 | 874 |
| 876 void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( | 875 void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( |
| 877 const ListValue* list) { | 876 const ListValue* list) { |
| 878 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 877 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
| 879 net::HostCache* cache = GetHostResolverCache(context); | 878 net::HostCache* cache = GetHostResolverCache(context); |
| 880 | 879 |
| 881 if (!cache) { | 880 if (!cache) { |
| 882 SendJavascriptCommand(L"receivedHostResolverInfo", NULL); | 881 SendJavascriptCommand("receivedHostResolverInfo", NULL); |
| 883 return; | 882 return; |
| 884 } | 883 } |
| 885 | 884 |
| 886 DictionaryValue* dict = new DictionaryValue(); | 885 DictionaryValue* dict = new DictionaryValue(); |
| 887 | 886 |
| 888 dict->SetInteger( | 887 dict->SetInteger( |
| 889 "default_address_family", | 888 "default_address_family", |
| 890 static_cast<int>(context->host_resolver()->GetDefaultAddressFamily())); | 889 static_cast<int>(context->host_resolver()->GetDefaultAddressFamily())); |
| 891 | 890 |
| 892 DictionaryValue* cache_info_dict = new DictionaryValue(); | 891 DictionaryValue* cache_info_dict = new DictionaryValue(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 } | 930 } |
| 932 entry_dict->Set("addresses", address_list); | 931 entry_dict->Set("addresses", address_list); |
| 933 } | 932 } |
| 934 | 933 |
| 935 entry_list->Append(entry_dict); | 934 entry_list->Append(entry_dict); |
| 936 } | 935 } |
| 937 | 936 |
| 938 cache_info_dict->Set("entries", entry_list); | 937 cache_info_dict->Set("entries", entry_list); |
| 939 dict->Set("cache", cache_info_dict); | 938 dict->Set("cache", cache_info_dict); |
| 940 | 939 |
| 941 SendJavascriptCommand(L"receivedHostResolverInfo", dict); | 940 SendJavascriptCommand("receivedHostResolverInfo", dict); |
| 942 } | 941 } |
| 943 | 942 |
| 944 void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( | 943 void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( |
| 945 const ListValue* list) { | 944 const ListValue* list) { |
| 946 net::HostCache* cache = | 945 net::HostCache* cache = |
| 947 GetHostResolverCache(context_getter_->GetURLRequestContext()); | 946 GetHostResolverCache(context_getter_->GetURLRequestContext()); |
| 948 | 947 |
| 949 if (cache) | 948 if (cache) |
| 950 cache->clear(); | 949 cache->clear(); |
| 951 | 950 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 std::string b64; | 1014 std::string b64; |
| 1016 base::Base64Encode(hash_str, &b64); | 1015 base::Base64Encode(hash_str, &b64); |
| 1017 part += b64; | 1016 part += b64; |
| 1018 parts.push_back(part); | 1017 parts.push_back(part); |
| 1019 } | 1018 } |
| 1020 result->SetString("public_key_hashes", JoinString(parts, ',')); | 1019 result->SetString("public_key_hashes", JoinString(parts, ',')); |
| 1021 } | 1020 } |
| 1022 } | 1021 } |
| 1023 } | 1022 } |
| 1024 | 1023 |
| 1025 SendJavascriptCommand(L"receivedHSTSResult", result); | 1024 SendJavascriptCommand("receivedHSTSResult", result); |
| 1026 } | 1025 } |
| 1027 | 1026 |
| 1028 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( | 1027 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( |
| 1029 const ListValue* list) { | 1028 const ListValue* list) { |
| 1030 // |list| should be: [<domain to query>, <include subdomains>, <cert pins>]. | 1029 // |list| should be: [<domain to query>, <include subdomains>, <cert pins>]. |
| 1031 std::string domain; | 1030 std::string domain; |
| 1032 CHECK(list->GetString(0, &domain)); | 1031 CHECK(list->GetString(0, &domain)); |
| 1033 if (!IsStringASCII(domain)) { | 1032 if (!IsStringASCII(domain)) { |
| 1034 // Silently fail. The user will get a helpful error if they query for the | 1033 // Silently fail. The user will get a helpful error if they query for the |
| 1035 // name. | 1034 // name. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 std::vector<std::pair<std::string, std::string> > stats; | 1102 std::vector<std::pair<std::string, std::string> > stats; |
| 1104 disk_cache->GetStats(&stats); | 1103 disk_cache->GetStats(&stats); |
| 1105 for (size_t i = 0; i < stats.size(); ++i) { | 1104 for (size_t i = 0; i < stats.size(); ++i) { |
| 1106 stats_dict->Set(stats[i].first, | 1105 stats_dict->Set(stats[i].first, |
| 1107 Value::CreateStringValue(stats[i].second)); | 1106 Value::CreateStringValue(stats[i].second)); |
| 1108 } | 1107 } |
| 1109 } | 1108 } |
| 1110 | 1109 |
| 1111 info_dict->Set("stats", stats_dict); | 1110 info_dict->Set("stats", stats_dict); |
| 1112 | 1111 |
| 1113 SendJavascriptCommand(L"receivedHttpCacheInfo", info_dict); | 1112 SendJavascriptCommand("receivedHttpCacheInfo", info_dict); |
| 1114 } | 1113 } |
| 1115 | 1114 |
| 1116 void NetInternalsMessageHandler::IOThreadImpl::OnGetSocketPoolInfo( | 1115 void NetInternalsMessageHandler::IOThreadImpl::OnGetSocketPoolInfo( |
| 1117 const ListValue* list) { | 1116 const ListValue* list) { |
| 1118 net::HttpNetworkSession* http_network_session = | 1117 net::HttpNetworkSession* http_network_session = |
| 1119 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1118 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
| 1120 | 1119 |
| 1121 Value* socket_pool_info = NULL; | 1120 Value* socket_pool_info = NULL; |
| 1122 if (http_network_session) | 1121 if (http_network_session) |
| 1123 socket_pool_info = http_network_session->SocketPoolInfoToValue(); | 1122 socket_pool_info = http_network_session->SocketPoolInfoToValue(); |
| 1124 | 1123 |
| 1125 SendJavascriptCommand(L"receivedSocketPoolInfo", socket_pool_info); | 1124 SendJavascriptCommand("receivedSocketPoolInfo", socket_pool_info); |
| 1126 } | 1125 } |
| 1127 | 1126 |
| 1128 | 1127 |
| 1129 void NetInternalsMessageHandler::IOThreadImpl::OnFlushSocketPools( | 1128 void NetInternalsMessageHandler::IOThreadImpl::OnFlushSocketPools( |
| 1130 const ListValue* list) { | 1129 const ListValue* list) { |
| 1131 net::HttpNetworkSession* http_network_session = | 1130 net::HttpNetworkSession* http_network_session = |
| 1132 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1131 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
| 1133 | 1132 |
| 1134 if (http_network_session) | 1133 if (http_network_session) |
| 1135 http_network_session->CloseAllConnections(); | 1134 http_network_session->CloseAllConnections(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1147 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdySessionInfo( | 1146 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdySessionInfo( |
| 1148 const ListValue* list) { | 1147 const ListValue* list) { |
| 1149 net::HttpNetworkSession* http_network_session = | 1148 net::HttpNetworkSession* http_network_session = |
| 1150 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1149 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
| 1151 | 1150 |
| 1152 Value* spdy_info = NULL; | 1151 Value* spdy_info = NULL; |
| 1153 if (http_network_session) { | 1152 if (http_network_session) { |
| 1154 spdy_info = http_network_session->SpdySessionPoolInfoToValue(); | 1153 spdy_info = http_network_session->SpdySessionPoolInfoToValue(); |
| 1155 } | 1154 } |
| 1156 | 1155 |
| 1157 SendJavascriptCommand(L"receivedSpdySessionInfo", spdy_info); | 1156 SendJavascriptCommand("receivedSpdySessionInfo", spdy_info); |
| 1158 } | 1157 } |
| 1159 | 1158 |
| 1160 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus( | 1159 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus( |
| 1161 const ListValue* list) { | 1160 const ListValue* list) { |
| 1162 DictionaryValue* status_dict = new DictionaryValue(); | 1161 DictionaryValue* status_dict = new DictionaryValue(); |
| 1163 | 1162 |
| 1164 status_dict->Set("spdy_enabled", | 1163 status_dict->Set("spdy_enabled", |
| 1165 Value::CreateBooleanValue( | 1164 Value::CreateBooleanValue( |
| 1166 net::HttpStreamFactory::spdy_enabled())); | 1165 net::HttpStreamFactory::spdy_enabled())); |
| 1167 status_dict->Set("use_alternate_protocols", | 1166 status_dict->Set("use_alternate_protocols", |
| 1168 Value::CreateBooleanValue( | 1167 Value::CreateBooleanValue( |
| 1169 net::HttpStreamFactory::use_alternate_protocols())); | 1168 net::HttpStreamFactory::use_alternate_protocols())); |
| 1170 status_dict->Set("force_spdy_over_ssl", | 1169 status_dict->Set("force_spdy_over_ssl", |
| 1171 Value::CreateBooleanValue( | 1170 Value::CreateBooleanValue( |
| 1172 net::HttpStreamFactory::force_spdy_over_ssl())); | 1171 net::HttpStreamFactory::force_spdy_over_ssl())); |
| 1173 status_dict->Set("force_spdy_always", | 1172 status_dict->Set("force_spdy_always", |
| 1174 Value::CreateBooleanValue( | 1173 Value::CreateBooleanValue( |
| 1175 net::HttpStreamFactory::force_spdy_always())); | 1174 net::HttpStreamFactory::force_spdy_always())); |
| 1176 | 1175 |
| 1177 // The next_protos may not be specified for certain configurations of SPDY. | 1176 // The next_protos may not be specified for certain configurations of SPDY. |
| 1178 Value* next_protos_value = net::HttpStreamFactory::next_protos() ? | 1177 Value* next_protos_value = net::HttpStreamFactory::next_protos() ? |
| 1179 Value::CreateStringValue(*net::HttpStreamFactory::next_protos()) : | 1178 Value::CreateStringValue(*net::HttpStreamFactory::next_protos()) : |
| 1180 Value::CreateStringValue(""); | 1179 Value::CreateStringValue(""); |
| 1181 | 1180 |
| 1182 status_dict->Set("next_protos", next_protos_value); | 1181 status_dict->Set("next_protos", next_protos_value); |
| 1183 | 1182 |
| 1184 SendJavascriptCommand(L"receivedSpdyStatus", status_dict); | 1183 SendJavascriptCommand("receivedSpdyStatus", status_dict); |
| 1185 } | 1184 } |
| 1186 | 1185 |
| 1187 void | 1186 void |
| 1188 NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings( | 1187 NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings( |
| 1189 const ListValue* list) { | 1188 const ListValue* list) { |
| 1190 ListValue* dict_list = new ListValue(); | 1189 ListValue* dict_list = new ListValue(); |
| 1191 | 1190 |
| 1192 const net::HttpServerProperties& http_server_properties = | 1191 const net::HttpServerProperties& http_server_properties = |
| 1193 *context_getter_->GetURLRequestContext()->http_server_properties(); | 1192 *context_getter_->GetURLRequestContext()->http_server_properties(); |
| 1194 | 1193 |
| 1195 const net::AlternateProtocolMap& map = | 1194 const net::AlternateProtocolMap& map = |
| 1196 http_server_properties.alternate_protocol_map(); | 1195 http_server_properties.alternate_protocol_map(); |
| 1197 | 1196 |
| 1198 for (net::AlternateProtocolMap::const_iterator it = map.begin(); | 1197 for (net::AlternateProtocolMap::const_iterator it = map.begin(); |
| 1199 it != map.end(); ++it) { | 1198 it != map.end(); ++it) { |
| 1200 DictionaryValue* dict = new DictionaryValue(); | 1199 DictionaryValue* dict = new DictionaryValue(); |
| 1201 dict->SetString("host_port_pair", it->first.ToString()); | 1200 dict->SetString("host_port_pair", it->first.ToString()); |
| 1202 dict->SetString("alternate_protocol", it->second.ToString()); | 1201 dict->SetString("alternate_protocol", it->second.ToString()); |
| 1203 dict_list->Append(dict); | 1202 dict_list->Append(dict); |
| 1204 } | 1203 } |
| 1205 | 1204 |
| 1206 SendJavascriptCommand(L"receivedSpdyAlternateProtocolMappings", dict_list); | 1205 SendJavascriptCommand("receivedSpdyAlternateProtocolMappings", dict_list); |
| 1207 } | 1206 } |
| 1208 | 1207 |
| 1209 #ifdef OS_WIN | 1208 #ifdef OS_WIN |
| 1210 void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( | 1209 void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( |
| 1211 const ListValue* list) { | 1210 const ListValue* list) { |
| 1212 | 1211 |
| 1213 DictionaryValue* service_providers = new DictionaryValue(); | 1212 DictionaryValue* service_providers = new DictionaryValue(); |
| 1214 | 1213 |
| 1215 WinsockLayeredServiceProviderList layered_providers; | 1214 WinsockLayeredServiceProviderList layered_providers; |
| 1216 GetWinsockLayeredServiceProviders(&layered_providers); | 1215 GetWinsockLayeredServiceProviders(&layered_providers); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1236 DictionaryValue* namespace_dict = new DictionaryValue(); | 1235 DictionaryValue* namespace_dict = new DictionaryValue(); |
| 1237 namespace_dict->SetString("name", namespace_providers[i].name); | 1236 namespace_dict->SetString("name", namespace_providers[i].name); |
| 1238 namespace_dict->SetBoolean("active", namespace_providers[i].active); | 1237 namespace_dict->SetBoolean("active", namespace_providers[i].active); |
| 1239 namespace_dict->SetInteger("version", namespace_providers[i].version); | 1238 namespace_dict->SetInteger("version", namespace_providers[i].version); |
| 1240 namespace_dict->SetInteger("type", namespace_providers[i].type); | 1239 namespace_dict->SetInteger("type", namespace_providers[i].type); |
| 1241 | 1240 |
| 1242 namespace_list->Append(namespace_dict); | 1241 namespace_list->Append(namespace_dict); |
| 1243 } | 1242 } |
| 1244 service_providers->Set("namespace_providers", namespace_list); | 1243 service_providers->Set("namespace_providers", namespace_list); |
| 1245 | 1244 |
| 1246 SendJavascriptCommand(L"receivedServiceProviders", service_providers); | 1245 SendJavascriptCommand("receivedServiceProviders", service_providers); |
| 1247 } | 1246 } |
| 1248 #endif | 1247 #endif |
| 1249 | 1248 |
| 1250 #ifdef OS_CHROMEOS | 1249 #ifdef OS_CHROMEOS |
| 1251 void NetInternalsMessageHandler::OnRefreshSystemLogs(const ListValue* list) { | 1250 void NetInternalsMessageHandler::OnRefreshSystemLogs(const ListValue* list) { |
| 1252 DCHECK(syslogs_getter_.get()); | 1251 DCHECK(syslogs_getter_.get()); |
| 1253 syslogs_getter_->DeleteSystemLogs(); | 1252 syslogs_getter_->DeleteSystemLogs(); |
| 1254 syslogs_getter_->LoadSystemLogs(); | 1253 syslogs_getter_->LoadSystemLogs(); |
| 1255 } | 1254 } |
| 1256 | 1255 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 BrowserThread::PostDelayedTask( | 1296 BrowserThread::PostDelayedTask( |
| 1298 BrowserThread::IO, FROM_HERE, | 1297 BrowserThread::IO, FROM_HERE, |
| 1299 base::Bind(&IOThreadImpl::PostPendingEntries, this), | 1298 base::Bind(&IOThreadImpl::PostPendingEntries, this), |
| 1300 kNetLogEventDelayMilliseconds); | 1299 kNetLogEventDelayMilliseconds); |
| 1301 } | 1300 } |
| 1302 pending_entries_->Append(entry); | 1301 pending_entries_->Append(entry); |
| 1303 } | 1302 } |
| 1304 | 1303 |
| 1305 void NetInternalsMessageHandler::IOThreadImpl::PostPendingEntries() { | 1304 void NetInternalsMessageHandler::IOThreadImpl::PostPendingEntries() { |
| 1306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1305 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1307 SendJavascriptCommand(L"receivedLogEntries", pending_entries_.release()); | 1306 SendJavascriptCommand("receivedLogEntries", pending_entries_.release()); |
| 1308 } | 1307 } |
| 1309 | 1308 |
| 1310 void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTestSuite() { | 1309 void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTestSuite() { |
| 1311 SendJavascriptCommand(L"receivedStartConnectionTestSuite", NULL); | 1310 SendJavascriptCommand("receivedStartConnectionTestSuite", NULL); |
| 1312 } | 1311 } |
| 1313 | 1312 |
| 1314 void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTestExperiment( | 1313 void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTestExperiment( |
| 1315 const ConnectionTester::Experiment& experiment) { | 1314 const ConnectionTester::Experiment& experiment) { |
| 1316 SendJavascriptCommand( | 1315 SendJavascriptCommand( |
| 1317 L"receivedStartConnectionTestExperiment", | 1316 "receivedStartConnectionTestExperiment", |
| 1318 ExperimentToValue(experiment)); | 1317 ExperimentToValue(experiment)); |
| 1319 } | 1318 } |
| 1320 | 1319 |
| 1321 void | 1320 void |
| 1322 NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestExperiment( | 1321 NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestExperiment( |
| 1323 const ConnectionTester::Experiment& experiment, | 1322 const ConnectionTester::Experiment& experiment, |
| 1324 int result) { | 1323 int result) { |
| 1325 DictionaryValue* dict = new DictionaryValue(); | 1324 DictionaryValue* dict = new DictionaryValue(); |
| 1326 | 1325 |
| 1327 dict->Set("experiment", ExperimentToValue(experiment)); | 1326 dict->Set("experiment", ExperimentToValue(experiment)); |
| 1328 dict->SetInteger("result", result); | 1327 dict->SetInteger("result", result); |
| 1329 | 1328 |
| 1330 SendJavascriptCommand( | 1329 SendJavascriptCommand( |
| 1331 L"receivedCompletedConnectionTestExperiment", | 1330 "receivedCompletedConnectionTestExperiment", |
| 1332 dict); | 1331 dict); |
| 1333 } | 1332 } |
| 1334 | 1333 |
| 1335 void | 1334 void |
| 1336 NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestSuite() { | 1335 NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestSuite() { |
| 1337 SendJavascriptCommand( | 1336 SendJavascriptCommand( |
| 1338 L"receivedCompletedConnectionTestSuite", | 1337 "receivedCompletedConnectionTestSuite", |
| 1339 NULL); | 1338 NULL); |
| 1340 } | 1339 } |
| 1341 | 1340 |
| 1342 void NetInternalsMessageHandler::IOThreadImpl::DispatchToMessageHandler( | 1341 void NetInternalsMessageHandler::IOThreadImpl::DispatchToMessageHandler( |
| 1343 ListValue* arg, MessageHandler method) { | 1342 ListValue* arg, MessageHandler method) { |
| 1344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1345 (this->*method)(arg); | 1344 (this->*method)(arg); |
| 1346 delete arg; | 1345 delete arg; |
| 1347 } | 1346 } |
| 1348 | 1347 |
| 1349 // Note that this can be called from ANY THREAD. | 1348 // Note that this can be called from ANY THREAD. |
| 1350 void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand( | 1349 void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand( |
| 1351 const std::wstring& command, | 1350 const std::string& command, |
| 1352 Value* arg) { | 1351 Value* arg) { |
| 1353 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 1352 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 1354 if (handler_ && !was_webui_deleted_) { | 1353 if (handler_ && !was_webui_deleted_) { |
| 1355 // We check |handler_| in case it was deleted on the UI thread earlier | 1354 // We check |handler_| in case it was deleted on the UI thread earlier |
| 1356 // while we were running on the IO thread. | 1355 // while we were running on the IO thread. |
| 1357 handler_->SendJavascriptCommand(command, arg); | 1356 handler_->SendJavascriptCommand(command, arg); |
| 1358 } else { | 1357 } else { |
| 1359 delete arg; | 1358 delete arg; |
| 1360 } | 1359 } |
| 1361 return; | 1360 return; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 return constants_dict; | 1529 return constants_dict; |
| 1531 } | 1530 } |
| 1532 | 1531 |
| 1533 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { | 1532 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { |
| 1534 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); | 1533 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); |
| 1535 | 1534 |
| 1536 // Set up the chrome://net-internals/ source. | 1535 // Set up the chrome://net-internals/ source. |
| 1537 GetProfile()->GetChromeURLDataManager()->AddDataSource( | 1536 GetProfile()->GetChromeURLDataManager()->AddDataSource( |
| 1538 CreateNetInternalsHTMLSource()); | 1537 CreateNetInternalsHTMLSource()); |
| 1539 } | 1538 } |
| OLD | NEW |