OLD | NEW |
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> | |
8 #include <list> | 7 #include <list> |
9 #include <string> | 8 #include <string> |
10 #include <utility> | 9 #include <utility> |
11 #include <vector> | 10 #include <vector> |
12 | 11 |
13 #include "base/base64.h" | 12 #include "base/base64.h" |
14 #include "base/bind.h" | 13 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
16 #include "base/command_line.h" | 15 #include "base/command_line.h" |
17 #include "base/file_path.h" | 16 #include "base/file_path.h" |
18 #include "base/file_util.h" | 17 #include "base/file_util.h" |
19 #include "base/memory/singleton.h" | |
20 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
21 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
22 #include "base/path_service.h" | |
23 #include "base/platform_file.h" | 20 #include "base/platform_file.h" |
24 #include "base/sequenced_task_runner_helpers.h" | 21 #include "base/sequenced_task_runner_helpers.h" |
25 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
26 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
27 #include "base/string_split.h" | 24 #include "base/string_split.h" |
28 #include "base/string_util.h" | 25 #include "base/string_util.h" |
29 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
30 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
31 #include "base/values.h" | 28 #include "base/values.h" |
32 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
(...skipping 16 matching lines...) Expand all Loading... |
49 #include "chrome/common/logging_chrome.h" | 46 #include "chrome/common/logging_chrome.h" |
50 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
51 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
52 #include "content/public/browser/browser_thread.h" | 49 #include "content/public/browser/browser_thread.h" |
53 #include "content/public/browser/notification_details.h" | 50 #include "content/public/browser/notification_details.h" |
54 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
55 #include "content/public/browser/web_ui.h" | 52 #include "content/public/browser/web_ui.h" |
56 #include "content/public/browser/web_ui_message_handler.h" | 53 #include "content/public/browser/web_ui_message_handler.h" |
57 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
58 #include "grit/net_internals_resources.h" | 55 #include "grit/net_internals_resources.h" |
59 #include "net/base/escape.h" | |
60 #include "net/base/host_cache.h" | 56 #include "net/base/host_cache.h" |
61 #include "net/base/host_resolver.h" | 57 #include "net/base/host_resolver.h" |
62 #include "net/base/net_errors.h" | 58 #include "net/base/net_errors.h" |
63 #include "net/base/net_util.h" | 59 #include "net/base/net_util.h" |
64 #include "net/base/transport_security_state.h" | 60 #include "net/base/transport_security_state.h" |
65 #include "net/base/x509_cert_types.h" | |
66 #include "net/disk_cache/disk_cache.h" | 61 #include "net/disk_cache/disk_cache.h" |
67 #include "net/http/http_cache.h" | 62 #include "net/http/http_cache.h" |
68 #include "net/http/http_network_layer.h" | 63 #include "net/http/http_network_layer.h" |
69 #include "net/http/http_network_session.h" | 64 #include "net/http/http_network_session.h" |
70 #include "net/http/http_server_properties.h" | 65 #include "net/http/http_server_properties.h" |
71 #include "net/http/http_stream_factory.h" | 66 #include "net/http/http_stream_factory.h" |
72 #include "net/proxy/proxy_service.h" | 67 #include "net/proxy/proxy_service.h" |
73 #include "net/url_request/url_request_context.h" | 68 #include "net/url_request/url_request_context.h" |
74 #include "net/url_request/url_request_context_getter.h" | 69 #include "net/url_request/url_request_context_getter.h" |
75 #include "ui/base/l10n/l10n_util.h" | |
76 #include "ui/base/resource/resource_bundle.h" | 70 #include "ui/base/resource/resource_bundle.h" |
77 | 71 |
78 #ifdef OS_CHROMEOS | 72 #if defined(OS_CHROMEOS) |
79 #include "chrome/browser/chromeos/cros/cros_library.h" | 73 #include "chrome/browser/chromeos/cros/cros_library.h" |
80 #include "chrome/browser/chromeos/cros/network_library.h" | 74 #include "chrome/browser/chromeos/cros/network_library.h" |
81 #include "chrome/browser/chromeos/system/syslogs_provider.h" | 75 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
82 #include "chromeos/dbus/dbus_thread_manager.h" | 76 #include "chromeos/dbus/dbus_thread_manager.h" |
83 #include "chromeos/dbus/debug_daemon_client.h" | 77 #include "chromeos/dbus/debug_daemon_client.h" |
84 #endif | 78 #endif |
85 #ifdef OS_WIN | 79 #if defined(OS_WIN) |
86 #include "chrome/browser/net/service_providers_win.h" | 80 #include "chrome/browser/net/service_providers_win.h" |
87 #endif | 81 #endif |
88 | 82 |
89 using base::PassPlatformFile; | 83 using base::PassPlatformFile; |
90 using base::PlatformFile; | 84 using base::PlatformFile; |
91 using base::PlatformFileError; | 85 using base::PlatformFileError; |
92 using content::BrowserThread; | 86 using content::BrowserThread; |
93 using content::WebContents; | 87 using content::WebContents; |
94 using content::WebUIMessageHandler; | 88 using content::WebUIMessageHandler; |
95 | 89 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 new ChromeWebUIDataSource(chrome::kChromeUINetInternalsHost); | 147 new ChromeWebUIDataSource(chrome::kChromeUINetInternalsHost); |
154 | 148 |
155 source->set_default_resource(IDR_NET_INTERNALS_INDEX_HTML); | 149 source->set_default_resource(IDR_NET_INTERNALS_INDEX_HTML); |
156 source->add_resource_path("help.html", IDR_NET_INTERNALS_HELP_HTML); | 150 source->add_resource_path("help.html", IDR_NET_INTERNALS_HELP_HTML); |
157 source->add_resource_path("help.js", IDR_NET_INTERNALS_HELP_JS); | 151 source->add_resource_path("help.js", IDR_NET_INTERNALS_HELP_JS); |
158 source->add_resource_path("index.js", IDR_NET_INTERNALS_INDEX_JS); | 152 source->add_resource_path("index.js", IDR_NET_INTERNALS_INDEX_JS); |
159 source->set_json_path("strings.js"); | 153 source->set_json_path("strings.js"); |
160 return source; | 154 return source; |
161 } | 155 } |
162 | 156 |
163 #ifdef OS_CHROMEOS | 157 #if defined(OS_CHROMEOS) |
164 // Small helper class used to create temporary log file and pass its | 158 // Small helper class used to create temporary log file and pass its |
165 // handle and error status to callback. | 159 // handle and error status to callback. |
166 // Use case: | 160 // Use case: |
167 // DebugLogFileHelper* helper = new DebugLogFileHelper(); | 161 // DebugLogFileHelper* helper = new DebugLogFileHelper(); |
168 // base::WorkerPool::PostTaskAndReply(FROM_HERE, | 162 // base::WorkerPool::PostTaskAndReply(FROM_HERE, |
169 // base::Bind(&DebugLogFileHelper::DoWork, base::Unretained(helper), ...), | 163 // base::Bind(&DebugLogFileHelper::DoWork, base::Unretained(helper), ...), |
170 // base::Bind(&DebugLogFileHelper::Reply, base::Owned(helper), ...), | 164 // base::Bind(&DebugLogFileHelper::Reply, base::Owned(helper), ...), |
171 // false); | 165 // false); |
172 class DebugLogFileHelper { | 166 class DebugLogFileHelper { |
173 public: | 167 public: |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 DCHECK(!callback.is_null()); | 285 DCHECK(!callback.is_null()); |
292 const FilePath fileshelf = download_util::GetDefaultDownloadDirectory(); | 286 const FilePath fileshelf = download_util::GetDefaultDownloadDirectory(); |
293 DebugLogFileHelper* helper = new DebugLogFileHelper(); | 287 DebugLogFileHelper* helper = new DebugLogFileHelper(); |
294 bool posted = base::WorkerPool::PostTaskAndReply(FROM_HERE, | 288 bool posted = base::WorkerPool::PostTaskAndReply(FROM_HERE, |
295 base::Bind(&DebugLogFileHelper::DoWork, | 289 base::Bind(&DebugLogFileHelper::DoWork, |
296 base::Unretained(helper), fileshelf), | 290 base::Unretained(helper), fileshelf), |
297 base::Bind(&DebugLogFileHelper::Reply, base::Owned(helper), | 291 base::Bind(&DebugLogFileHelper::Reply, base::Owned(helper), |
298 base::Bind(&WriteDebugLogToFile, callback)), false); | 292 base::Bind(&WriteDebugLogToFile, callback)), false); |
299 DCHECK(posted); | 293 DCHECK(posted); |
300 } | 294 } |
301 #endif // OS_CHROMEOS | 295 #endif // defined(OS_CHROMEOS) |
302 | 296 |
303 // This class receives javascript messages from the renderer. | 297 // This class receives javascript messages from the renderer. |
304 // Note that the WebUI infrastructure runs on the UI thread, therefore all of | 298 // Note that the WebUI infrastructure runs on the UI thread, therefore all of |
305 // this class's methods are expected to run on the UI thread. | 299 // this class's methods are expected to run on the UI thread. |
306 // | 300 // |
307 // Since the network code we want to run lives on the IO thread, we proxy | 301 // Since the network code we want to run lives on the IO thread, we proxy |
308 // almost everything over to NetInternalsMessageHandler::IOThreadImpl, which | 302 // almost everything over to NetInternalsMessageHandler::IOThreadImpl, which |
309 // runs on the IO thread. | 303 // runs on the IO thread. |
310 // | 304 // |
311 // TODO(eroman): Can we start on the IO thread to begin with? | 305 // TODO(eroman): Can we start on the IO thread to begin with? |
312 class NetInternalsMessageHandler | 306 class NetInternalsMessageHandler |
313 : public WebUIMessageHandler, | 307 : public WebUIMessageHandler, |
314 public base::SupportsWeakPtr<NetInternalsMessageHandler> { | 308 public base::SupportsWeakPtr<NetInternalsMessageHandler> { |
315 public: | 309 public: |
316 NetInternalsMessageHandler(); | 310 NetInternalsMessageHandler(); |
317 virtual ~NetInternalsMessageHandler(); | 311 virtual ~NetInternalsMessageHandler(); |
318 | 312 |
319 // WebUIMessageHandler implementation. | 313 // WebUIMessageHandler implementation. |
320 virtual void RegisterMessages() OVERRIDE; | 314 virtual void RegisterMessages() OVERRIDE; |
321 | 315 |
322 // Calls g_browser.receive in the renderer, passing in |command| and |arg|. | 316 // Calls g_browser.receive in the renderer, passing in |command| and |arg|. |
323 // Takes ownership of |arg|. If the renderer is displaying a log file, the | 317 // Takes ownership of |arg|. If the renderer is displaying a log file, the |
324 // message will be ignored. | 318 // message will be ignored. |
325 void SendJavascriptCommand(const std::string& command, Value* arg); | 319 void SendJavascriptCommand(const std::string& command, Value* arg); |
326 | 320 |
327 // Javascript message handlers. | 321 // Javascript message handlers. |
328 void OnRendererReady(const ListValue* list); | 322 void OnRendererReady(const ListValue* list); |
329 void OnClearBrowserCache(const ListValue* list); | 323 void OnClearBrowserCache(const ListValue* list); |
330 void OnGetPrerenderInfo(const ListValue* list); | 324 void OnGetPrerenderInfo(const ListValue* list); |
331 #ifdef OS_CHROMEOS | 325 #if defined(OS_CHROMEOS) |
332 void OnRefreshSystemLogs(const ListValue* list); | 326 void OnRefreshSystemLogs(const ListValue* list); |
333 void OnGetSystemLog(const ListValue* list); | 327 void OnGetSystemLog(const ListValue* list); |
334 void OnImportONCFile(const ListValue* list); | 328 void OnImportONCFile(const ListValue* list); |
335 void OnStoreDebugLogs(const ListValue* list); | 329 void OnStoreDebugLogs(const ListValue* list); |
336 void OnStoreDebugLogsCompleted(const FilePath& log_path, bool succeeded); | 330 void OnStoreDebugLogsCompleted(const FilePath& log_path, bool succeeded); |
337 void OnSetNetworkDebugMode(const ListValue* list); | 331 void OnSetNetworkDebugMode(const ListValue* list); |
338 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, | 332 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, |
339 bool succeeded); | 333 bool succeeded); |
340 #endif | 334 #endif |
341 | 335 |
342 private: | 336 private: |
343 class IOThreadImpl; | 337 class IOThreadImpl; |
344 | 338 |
345 #ifdef OS_CHROMEOS | 339 #if defined(OS_CHROMEOS) |
346 // Class that is used for getting network related ChromeOS logs. | 340 // Class that is used for getting network related ChromeOS logs. |
347 // Logs are fetched from ChromeOS libcros on user request, and only when we | 341 // Logs are fetched from ChromeOS libcros on user request, and only when we |
348 // don't yet have a copy of logs. If a copy is present, we send back data from | 342 // don't yet have a copy of logs. If a copy is present, we send back data from |
349 // it, else we save request and answer to it when we get logs from libcros. | 343 // it, else we save request and answer to it when we get logs from libcros. |
350 // If needed, we also send request for system logs to libcros. | 344 // If needed, we also send request for system logs to libcros. |
351 // Logs refresh has to be done explicitly, by deleting old logs and then | 345 // Logs refresh has to be done explicitly, by deleting old logs and then |
352 // loading them again. | 346 // loading them again. |
353 class SystemLogsGetter { | 347 class SystemLogsGetter { |
354 public: | 348 public: |
355 SystemLogsGetter(NetInternalsMessageHandler* handler, | 349 SystemLogsGetter(NetInternalsMessageHandler* handler, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 chromeos::system::SyslogsProvider* syslogs_provider_; | 382 chromeos::system::SyslogsProvider* syslogs_provider_; |
389 // List of postponed requests. | 383 // List of postponed requests. |
390 std::list<SystemLogRequest> requests_; | 384 std::list<SystemLogRequest> requests_; |
391 scoped_ptr<chromeos::system::LogDictionaryType> logs_; | 385 scoped_ptr<chromeos::system::LogDictionaryType> logs_; |
392 bool logs_received_; | 386 bool logs_received_; |
393 bool logs_requested_; | 387 bool logs_requested_; |
394 CancelableRequestConsumer consumer_; | 388 CancelableRequestConsumer consumer_; |
395 // Libcros request handle. | 389 // Libcros request handle. |
396 CancelableRequestProvider::Handle syslogs_request_id_; | 390 CancelableRequestProvider::Handle syslogs_request_id_; |
397 }; | 391 }; |
398 #endif | 392 #endif // defined(OS_CHROMEOS) |
399 | 393 |
400 // This is the "real" message handler, which lives on the IO thread. | 394 // This is the "real" message handler, which lives on the IO thread. |
401 scoped_refptr<IOThreadImpl> proxy_; | 395 scoped_refptr<IOThreadImpl> proxy_; |
402 | 396 |
403 base::WeakPtr<prerender::PrerenderManager> prerender_manager_; | 397 base::WeakPtr<prerender::PrerenderManager> prerender_manager_; |
404 | 398 |
405 #ifdef OS_CHROMEOS | 399 #if defined(OS_CHROMEOS) |
406 // Class that handles getting and filtering system logs. | 400 // Class that handles getting and filtering system logs. |
407 scoped_ptr<SystemLogsGetter> syslogs_getter_; | 401 scoped_ptr<SystemLogsGetter> syslogs_getter_; |
408 #endif | 402 #endif |
409 | 403 |
410 DISALLOW_COPY_AND_ASSIGN(NetInternalsMessageHandler); | 404 DISALLOW_COPY_AND_ASSIGN(NetInternalsMessageHandler); |
411 }; | 405 }; |
412 | 406 |
413 // This class is the "real" message handler. It is allocated and destroyed on | 407 // This class is the "real" message handler. It is allocated and destroyed on |
414 // the UI thread. With the exception of OnAddEntry, OnWebUIDeleted, and | 408 // the UI thread. With the exception of OnAddEntry, OnWebUIDeleted, and |
415 // SendJavascriptCommand, its methods are all expected to be called from the IO | 409 // SendJavascriptCommand, its methods are all expected to be called from the IO |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 void OnHSTSQuery(const ListValue* list); | 460 void OnHSTSQuery(const ListValue* list); |
467 void OnHSTSAdd(const ListValue* list); | 461 void OnHSTSAdd(const ListValue* list); |
468 void OnHSTSDelete(const ListValue* list); | 462 void OnHSTSDelete(const ListValue* list); |
469 void OnGetHttpCacheInfo(const ListValue* list); | 463 void OnGetHttpCacheInfo(const ListValue* list); |
470 void OnGetSocketPoolInfo(const ListValue* list); | 464 void OnGetSocketPoolInfo(const ListValue* list); |
471 void OnCloseIdleSockets(const ListValue* list); | 465 void OnCloseIdleSockets(const ListValue* list); |
472 void OnFlushSocketPools(const ListValue* list); | 466 void OnFlushSocketPools(const ListValue* list); |
473 void OnGetSpdySessionInfo(const ListValue* list); | 467 void OnGetSpdySessionInfo(const ListValue* list); |
474 void OnGetSpdyStatus(const ListValue* list); | 468 void OnGetSpdyStatus(const ListValue* list); |
475 void OnGetSpdyAlternateProtocolMappings(const ListValue* list); | 469 void OnGetSpdyAlternateProtocolMappings(const ListValue* list); |
476 #ifdef OS_WIN | 470 #if defined(OS_WIN) |
477 void OnGetServiceProviders(const ListValue* list); | 471 void OnGetServiceProviders(const ListValue* list); |
478 #endif | 472 #endif |
479 void OnGetHttpPipeliningStatus(const ListValue* list); | 473 void OnGetHttpPipeliningStatus(const ListValue* list); |
480 void OnSetLogLevel(const ListValue* list); | 474 void OnSetLogLevel(const ListValue* list); |
481 | 475 |
482 // ChromeNetLog::ThreadSafeObserver implementation: | 476 // ChromeNetLog::ThreadSafeObserver implementation: |
483 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; | 477 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; |
484 | 478 |
485 // ConnectionTester::Delegate implementation: | 479 // ConnectionTester::Delegate implementation: |
486 virtual void OnStartConnectionTestSuite() OVERRIDE; | 480 virtual void OnStartConnectionTestSuite() OVERRIDE; |
487 virtual void OnStartConnectionTestExperiment( | 481 virtual void OnStartConnectionTestExperiment( |
488 const ConnectionTester::Experiment& experiment) OVERRIDE; | 482 const ConnectionTester::Experiment& experiment) OVERRIDE; |
489 virtual void OnCompletedConnectionTestExperiment( | 483 virtual void OnCompletedConnectionTestExperiment( |
490 const ConnectionTester::Experiment& experiment, | 484 const ConnectionTester::Experiment& experiment, |
491 int result) OVERRIDE; | 485 int result) OVERRIDE; |
492 virtual void OnCompletedConnectionTestSuite() OVERRIDE; | 486 virtual void OnCompletedConnectionTestSuite() OVERRIDE; |
493 | 487 |
494 // Helper that calls g_browser.receive in the renderer, passing in |command| | 488 // Helper that calls g_browser.receive in the renderer, passing in |command| |
495 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log | 489 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log |
496 // file, the message will be ignored. Note that this can be called from any | 490 // file, the message will be ignored. Note that this can be called from any |
497 // thread. | 491 // thread. |
498 void SendJavascriptCommand(const std::string& command, Value* arg); | 492 void SendJavascriptCommand(const std::string& command, Value* arg); |
499 | 493 |
500 // Helper that runs |method| with |arg|, and deletes |arg| on completion. | |
501 void DispatchToMessageHandler(ListValue* arg, MessageHandler method); | |
502 | |
503 private: | 494 private: |
504 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 495 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
505 friend class base::DeleteHelper<IOThreadImpl>; | 496 friend class base::DeleteHelper<IOThreadImpl>; |
506 | 497 |
507 ~IOThreadImpl(); | 498 ~IOThreadImpl(); |
508 | 499 |
509 // Adds |entry| to the queue of pending log entries to be sent to the page via | 500 // Adds |entry| to the queue of pending log entries to be sent to the page via |
510 // Javascript. Must be called on the IO Thread. Also creates a delayed task | 501 // Javascript. Must be called on the IO Thread. Also creates a delayed task |
511 // that will call PostPendingEntries, if there isn't one already. | 502 // that will call PostPendingEntries, if there isn't one already. |
512 void AddEntryToQueue(Value* entry); | 503 void AddEntryToQueue(Value* entry); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 } | 551 } |
561 } | 552 } |
562 | 553 |
563 void NetInternalsMessageHandler::RegisterMessages() { | 554 void NetInternalsMessageHandler::RegisterMessages() { |
564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
565 | 556 |
566 Profile* profile = Profile::FromWebUI(web_ui()); | 557 Profile* profile = Profile::FromWebUI(web_ui()); |
567 | 558 |
568 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), | 559 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), |
569 profile->GetRequestContext()); | 560 profile->GetRequestContext()); |
570 #ifdef OS_CHROMEOS | 561 #if defined(OS_CHROMEOS) |
571 syslogs_getter_.reset(new SystemLogsGetter(this, | 562 syslogs_getter_.reset(new SystemLogsGetter(this, |
572 chromeos::system::SyslogsProvider::GetInstance())); | 563 chromeos::system::SyslogsProvider::GetInstance())); |
573 #endif | 564 #endif |
574 | 565 |
575 prerender::PrerenderManager* prerender_manager = | 566 prerender::PrerenderManager* prerender_manager = |
576 prerender::PrerenderManagerFactory::GetForProfile(profile); | 567 prerender::PrerenderManagerFactory::GetForProfile(profile); |
577 if (prerender_manager) { | 568 if (prerender_manager) { |
578 prerender_manager_ = prerender_manager->AsWeakPtr(); | 569 prerender_manager_ = prerender_manager->AsWeakPtr(); |
579 } else { | 570 } else { |
580 prerender_manager_ = base::WeakPtr<prerender::PrerenderManager>(); | 571 prerender_manager_ = base::WeakPtr<prerender::PrerenderManager>(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 base::Bind(&IOThreadImpl::CallbackHelper, | 644 base::Bind(&IOThreadImpl::CallbackHelper, |
654 &IOThreadImpl::OnGetSpdySessionInfo, proxy_)); | 645 &IOThreadImpl::OnGetSpdySessionInfo, proxy_)); |
655 web_ui()->RegisterMessageCallback( | 646 web_ui()->RegisterMessageCallback( |
656 "getSpdyStatus", | 647 "getSpdyStatus", |
657 base::Bind(&IOThreadImpl::CallbackHelper, | 648 base::Bind(&IOThreadImpl::CallbackHelper, |
658 &IOThreadImpl::OnGetSpdyStatus, proxy_)); | 649 &IOThreadImpl::OnGetSpdyStatus, proxy_)); |
659 web_ui()->RegisterMessageCallback( | 650 web_ui()->RegisterMessageCallback( |
660 "getSpdyAlternateProtocolMappings", | 651 "getSpdyAlternateProtocolMappings", |
661 base::Bind(&IOThreadImpl::CallbackHelper, | 652 base::Bind(&IOThreadImpl::CallbackHelper, |
662 &IOThreadImpl::OnGetSpdyAlternateProtocolMappings, proxy_)); | 653 &IOThreadImpl::OnGetSpdyAlternateProtocolMappings, proxy_)); |
663 #ifdef OS_WIN | 654 #if defined(OS_WIN) |
664 web_ui()->RegisterMessageCallback( | 655 web_ui()->RegisterMessageCallback( |
665 "getServiceProviders", | 656 "getServiceProviders", |
666 base::Bind(&IOThreadImpl::CallbackHelper, | 657 base::Bind(&IOThreadImpl::CallbackHelper, |
667 &IOThreadImpl::OnGetServiceProviders, proxy_)); | 658 &IOThreadImpl::OnGetServiceProviders, proxy_)); |
668 #endif | 659 #endif |
669 | 660 |
670 web_ui()->RegisterMessageCallback( | 661 web_ui()->RegisterMessageCallback( |
671 "getHttpPipeliningStatus", | 662 "getHttpPipeliningStatus", |
672 base::Bind(&IOThreadImpl::CallbackHelper, | 663 base::Bind(&IOThreadImpl::CallbackHelper, |
673 &IOThreadImpl::OnGetHttpPipeliningStatus, proxy_)); | 664 &IOThreadImpl::OnGetHttpPipeliningStatus, proxy_)); |
674 web_ui()->RegisterMessageCallback( | 665 web_ui()->RegisterMessageCallback( |
675 "setLogLevel", | 666 "setLogLevel", |
676 base::Bind(&IOThreadImpl::CallbackHelper, | 667 base::Bind(&IOThreadImpl::CallbackHelper, |
677 &IOThreadImpl::OnSetLogLevel, proxy_)); | 668 &IOThreadImpl::OnSetLogLevel, proxy_)); |
678 web_ui()->RegisterMessageCallback( | 669 web_ui()->RegisterMessageCallback( |
679 "clearBrowserCache", | 670 "clearBrowserCache", |
680 base::Bind(&NetInternalsMessageHandler::OnClearBrowserCache, | 671 base::Bind(&NetInternalsMessageHandler::OnClearBrowserCache, |
681 base::Unretained(this))); | 672 base::Unretained(this))); |
682 web_ui()->RegisterMessageCallback( | 673 web_ui()->RegisterMessageCallback( |
683 "getPrerenderInfo", | 674 "getPrerenderInfo", |
684 base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, | 675 base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, |
685 base::Unretained(this))); | 676 base::Unretained(this))); |
686 #ifdef OS_CHROMEOS | 677 #if defined(OS_CHROMEOS) |
687 web_ui()->RegisterMessageCallback( | 678 web_ui()->RegisterMessageCallback( |
688 "refreshSystemLogs", | 679 "refreshSystemLogs", |
689 base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs, | 680 base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs, |
690 base::Unretained(this))); | 681 base::Unretained(this))); |
691 web_ui()->RegisterMessageCallback( | 682 web_ui()->RegisterMessageCallback( |
692 "getSystemLog", | 683 "getSystemLog", |
693 base::Bind(&NetInternalsMessageHandler::OnGetSystemLog, | 684 base::Bind(&NetInternalsMessageHandler::OnGetSystemLog, |
694 base::Unretained(this))); | 685 base::Unretained(this))); |
695 web_ui()->RegisterMessageCallback( | 686 web_ui()->RegisterMessageCallback( |
696 "importONCFile", | 687 "importONCFile", |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 value = new DictionaryValue(); | 737 value = new DictionaryValue(); |
747 value->SetBoolean("enabled", false); | 738 value->SetBoolean("enabled", false); |
748 value->SetBoolean("omnibox_enabled", false); | 739 value->SetBoolean("omnibox_enabled", false); |
749 } else { | 740 } else { |
750 value = prerender_manager->GetAsValue(); | 741 value = prerender_manager->GetAsValue(); |
751 } | 742 } |
752 SendJavascriptCommand("receivedPrerenderInfo", value); | 743 SendJavascriptCommand("receivedPrerenderInfo", value); |
753 } | 744 } |
754 | 745 |
755 | 746 |
756 #ifdef OS_CHROMEOS | 747 #if defined(OS_CHROMEOS) |
757 //////////////////////////////////////////////////////////////////////////////// | 748 //////////////////////////////////////////////////////////////////////////////// |
758 // | 749 // |
759 // NetInternalsMessageHandler::SystemLogsGetter | 750 // NetInternalsMessageHandler::SystemLogsGetter |
760 // | 751 // |
761 //////////////////////////////////////////////////////////////////////////////// | 752 //////////////////////////////////////////////////////////////////////////////// |
762 | 753 |
763 NetInternalsMessageHandler::SystemLogsGetter::SystemLogsGetter( | 754 NetInternalsMessageHandler::SystemLogsGetter::SystemLogsGetter( |
764 NetInternalsMessageHandler* handler, | 755 NetInternalsMessageHandler* handler, |
765 chromeos::system::SyslogsProvider* syslogs_provider) | 756 chromeos::system::SyslogsProvider* syslogs_provider) |
766 : handler_(handler), | 757 : handler_(handler), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 } else { | 831 } else { |
841 result->SetString("log", "<no relevant lines found>"); | 832 result->SetString("log", "<no relevant lines found>"); |
842 } | 833 } |
843 } else { | 834 } else { |
844 result->SetString("log", "<invalid log name>"); | 835 result->SetString("log", "<invalid log name>"); |
845 } | 836 } |
846 result->SetString("cellId", request.cell_id); | 837 result->SetString("cellId", request.cell_id); |
847 | 838 |
848 handler_->SendJavascriptCommand("getSystemLogCallback", result); | 839 handler_->SendJavascriptCommand("getSystemLogCallback", result); |
849 } | 840 } |
850 #endif | 841 #endif // defined(OS_CHROMEOS) |
| 842 |
851 //////////////////////////////////////////////////////////////////////////////// | 843 //////////////////////////////////////////////////////////////////////////////// |
852 // | 844 // |
853 // NetInternalsMessageHandler::IOThreadImpl | 845 // NetInternalsMessageHandler::IOThreadImpl |
854 // | 846 // |
855 //////////////////////////////////////////////////////////////////////////////// | 847 //////////////////////////////////////////////////////////////////////////////// |
856 | 848 |
857 NetInternalsMessageHandler::IOThreadImpl::IOThreadImpl( | 849 NetInternalsMessageHandler::IOThreadImpl::IOThreadImpl( |
858 const base::WeakPtr<NetInternalsMessageHandler>& handler, | 850 const base::WeakPtr<NetInternalsMessageHandler>& handler, |
859 IOThread* io_thread, | 851 IOThread* io_thread, |
860 net::URLRequestContextGetter* context_getter) | 852 net::URLRequestContextGetter* context_getter) |
861 : handler_(handler), | 853 : handler_(handler), |
862 io_thread_(io_thread), | 854 io_thread_(io_thread), |
863 context_getter_(context_getter), | 855 context_getter_(context_getter), |
864 was_webui_deleted_(false) { | 856 was_webui_deleted_(false) { |
865 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
866 } | 858 } |
867 | 859 |
868 NetInternalsMessageHandler::IOThreadImpl::~IOThreadImpl() { | 860 NetInternalsMessageHandler::IOThreadImpl::~IOThreadImpl() { |
869 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 861 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
870 } | 862 } |
871 | 863 |
872 void NetInternalsMessageHandler::IOThreadImpl::CallbackHelper( | 864 void NetInternalsMessageHandler::IOThreadImpl::CallbackHelper( |
873 MessageHandler method, | 865 MessageHandler method, |
874 scoped_refptr<IOThreadImpl> io_thread, | 866 scoped_refptr<IOThreadImpl> io_thread, |
875 const ListValue* list) { | 867 const ListValue* list) { |
876 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 868 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
877 | 869 |
878 // We need to make a copy of the value in order to pass it over to the IO | 870 // We need to make a copy of the value in order to pass it over to the IO |
879 // thread. We will delete this in IOThreadImpl::DispatchMessageHandler(). | 871 // thread. |list_copy| will be deleted when the task is destroyed. The called |
880 ListValue* list_copy = | 872 // |method| cannot take ownership of |list_copy|. |
881 static_cast<ListValue*>(list ? list->DeepCopy() : NULL); | 873 ListValue* list_copy = (list && list->GetSize()) ? list->DeepCopy() : NULL; |
882 | 874 |
883 if (!BrowserThread::PostTask( | 875 BrowserThread::PostTask( |
884 BrowserThread::IO, FROM_HERE, | 876 BrowserThread::IO, FROM_HERE, |
885 base::Bind(method, io_thread, list_copy))) { | 877 base::Bind(method, io_thread, base::Owned(list_copy))); |
886 // Failed posting the task, avoid leaking |list_copy|. | |
887 delete list_copy; | |
888 } | |
889 } | 878 } |
890 | 879 |
891 void NetInternalsMessageHandler::IOThreadImpl::Detach() { | 880 void NetInternalsMessageHandler::IOThreadImpl::Detach() { |
892 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 881 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
893 // Unregister with network stack to observe events. | 882 // Unregister with network stack to observe events. |
894 if (net_log()) | 883 if (net_log()) |
895 net_log()->RemoveThreadSafeObserver(this); | 884 net_log()->RemoveThreadSafeObserver(this); |
896 | 885 |
897 // Cancel any in-progress connection tests. | 886 // Cancel any in-progress connection tests. |
898 connection_tester_.reset(); | 887 connection_tester_.reset(); |
(...skipping 13 matching lines...) Expand all Loading... |
912 | 901 |
913 if (!net_log()) { | 902 if (!net_log()) { |
914 // Register with network stack to observe events. | 903 // Register with network stack to observe events. |
915 io_thread_->net_log()->AddThreadSafeObserver(this, | 904 io_thread_->net_log()->AddThreadSafeObserver(this, |
916 net::NetLog::LOG_ALL_BUT_BYTES); | 905 net::NetLog::LOG_ALL_BUT_BYTES); |
917 } | 906 } |
918 } | 907 } |
919 | 908 |
920 void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( | 909 void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( |
921 const ListValue* list) { | 910 const ListValue* list) { |
| 911 DCHECK(!list); |
922 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 912 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
923 net::ProxyService* proxy_service = context->proxy_service(); | 913 net::ProxyService* proxy_service = context->proxy_service(); |
924 | 914 |
925 DictionaryValue* dict = new DictionaryValue(); | 915 DictionaryValue* dict = new DictionaryValue(); |
926 if (proxy_service->fetched_config().is_valid()) | 916 if (proxy_service->fetched_config().is_valid()) |
927 dict->Set("original", proxy_service->fetched_config().ToValue()); | 917 dict->Set("original", proxy_service->fetched_config().ToValue()); |
928 if (proxy_service->config().is_valid()) | 918 if (proxy_service->config().is_valid()) |
929 dict->Set("effective", proxy_service->config().ToValue()); | 919 dict->Set("effective", proxy_service->config().ToValue()); |
930 | 920 |
931 SendJavascriptCommand("receivedProxySettings", dict); | 921 SendJavascriptCommand("receivedProxySettings", dict); |
932 } | 922 } |
933 | 923 |
934 void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( | 924 void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( |
935 const ListValue* list) { | 925 const ListValue* list) { |
| 926 DCHECK(!list); |
936 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 927 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
937 context->proxy_service()->ForceReloadProxyConfig(); | 928 context->proxy_service()->ForceReloadProxyConfig(); |
938 | 929 |
939 // Cause the renderer to be notified of the new values. | 930 // Cause the renderer to be notified of the new values. |
940 OnGetProxySettings(NULL); | 931 OnGetProxySettings(NULL); |
941 } | 932 } |
942 | 933 |
943 void NetInternalsMessageHandler::IOThreadImpl::OnGetBadProxies( | 934 void NetInternalsMessageHandler::IOThreadImpl::OnGetBadProxies( |
944 const ListValue* list) { | 935 const ListValue* list) { |
| 936 DCHECK(!list); |
945 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 937 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
946 | 938 |
947 const net::ProxyRetryInfoMap& bad_proxies_map = | 939 const net::ProxyRetryInfoMap& bad_proxies_map = |
948 context->proxy_service()->proxy_retry_info(); | 940 context->proxy_service()->proxy_retry_info(); |
949 | 941 |
950 ListValue* dict_list = new ListValue(); | 942 ListValue* dict_list = new ListValue(); |
951 | 943 |
952 for (net::ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); | 944 for (net::ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); |
953 it != bad_proxies_map.end(); ++it) { | 945 it != bad_proxies_map.end(); ++it) { |
954 const std::string& proxy_uri = it->first; | 946 const std::string& proxy_uri = it->first; |
955 const net::ProxyRetryInfo& retry_info = it->second; | 947 const net::ProxyRetryInfo& retry_info = it->second; |
956 | 948 |
957 DictionaryValue* dict = new DictionaryValue(); | 949 DictionaryValue* dict = new DictionaryValue(); |
958 dict->SetString("proxy_uri", proxy_uri); | 950 dict->SetString("proxy_uri", proxy_uri); |
959 dict->SetString("bad_until", | 951 dict->SetString("bad_until", |
960 net::NetLog::TickCountToString(retry_info.bad_until)); | 952 net::NetLog::TickCountToString(retry_info.bad_until)); |
961 | 953 |
962 dict_list->Append(dict); | 954 dict_list->Append(dict); |
963 } | 955 } |
964 | 956 |
965 SendJavascriptCommand("receivedBadProxies", dict_list); | 957 SendJavascriptCommand("receivedBadProxies", dict_list); |
966 } | 958 } |
967 | 959 |
968 void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( | 960 void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( |
969 const ListValue* list) { | 961 const ListValue* list) { |
| 962 DCHECK(!list); |
970 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 963 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
971 context->proxy_service()->ClearBadProxiesCache(); | 964 context->proxy_service()->ClearBadProxiesCache(); |
972 | 965 |
973 // Cause the renderer to be notified of the new values. | 966 // Cause the renderer to be notified of the new values. |
974 OnGetBadProxies(NULL); | 967 OnGetBadProxies(NULL); |
975 } | 968 } |
976 | 969 |
977 void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( | 970 void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( |
978 const ListValue* list) { | 971 const ListValue* list) { |
| 972 DCHECK(!list); |
979 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 973 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
980 net::HostCache* cache = GetHostResolverCache(context); | 974 net::HostCache* cache = GetHostResolverCache(context); |
981 | 975 |
982 if (!cache) { | 976 if (!cache) { |
983 SendJavascriptCommand("receivedHostResolverInfo", NULL); | 977 SendJavascriptCommand("receivedHostResolverInfo", NULL); |
984 return; | 978 return; |
985 } | 979 } |
986 | 980 |
987 DictionaryValue* dict = new DictionaryValue(); | 981 DictionaryValue* dict = new DictionaryValue(); |
988 | 982 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 } | 1025 } |
1032 | 1026 |
1033 cache_info_dict->Set("entries", entry_list); | 1027 cache_info_dict->Set("entries", entry_list); |
1034 dict->Set("cache", cache_info_dict); | 1028 dict->Set("cache", cache_info_dict); |
1035 | 1029 |
1036 SendJavascriptCommand("receivedHostResolverInfo", dict); | 1030 SendJavascriptCommand("receivedHostResolverInfo", dict); |
1037 } | 1031 } |
1038 | 1032 |
1039 void NetInternalsMessageHandler::IOThreadImpl::OnRunIPv6Probe( | 1033 void NetInternalsMessageHandler::IOThreadImpl::OnRunIPv6Probe( |
1040 const ListValue* list) { | 1034 const ListValue* list) { |
| 1035 DCHECK(!list); |
1041 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 1036 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
1042 net::HostResolver* resolver = context->host_resolver(); | 1037 net::HostResolver* resolver = context->host_resolver(); |
1043 | 1038 |
1044 // Have to set the default address family manually before calling | 1039 // Have to set the default address family manually before calling |
1045 // ProbeIPv6Support. | 1040 // ProbeIPv6Support. |
1046 resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); | 1041 resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); |
1047 resolver->ProbeIPv6Support(); | 1042 resolver->ProbeIPv6Support(); |
1048 } | 1043 } |
1049 | 1044 |
1050 void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( | 1045 void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( |
1051 const ListValue* list) { | 1046 const ListValue* list) { |
| 1047 DCHECK(!list); |
1052 net::HostCache* cache = | 1048 net::HostCache* cache = |
1053 GetHostResolverCache(context_getter_->GetURLRequestContext()); | 1049 GetHostResolverCache(context_getter_->GetURLRequestContext()); |
1054 | 1050 |
1055 if (cache) | 1051 if (cache) |
1056 cache->clear(); | 1052 cache->clear(); |
1057 | 1053 |
1058 // Cause the renderer to be notified of the new values. | 1054 // Cause the renderer to be notified of the new values. |
1059 OnGetHostResolverInfo(NULL); | 1055 OnGetHostResolverInfo(NULL); |
1060 } | 1056 } |
1061 | 1057 |
1062 void NetInternalsMessageHandler::IOThreadImpl::OnEnableIPv6( | 1058 void NetInternalsMessageHandler::IOThreadImpl::OnEnableIPv6( |
1063 const ListValue* list) { | 1059 const ListValue* list) { |
| 1060 DCHECK(!list); |
1064 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 1061 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
1065 net::HostResolver* host_resolver = context->host_resolver(); | 1062 net::HostResolver* host_resolver = context->host_resolver(); |
1066 | 1063 |
1067 host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); | 1064 host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); |
1068 | 1065 |
1069 // Cause the renderer to be notified of the new value. | 1066 // Cause the renderer to be notified of the new value. |
1070 OnGetHostResolverInfo(NULL); | 1067 OnGetHostResolverInfo(NULL); |
1071 } | 1068 } |
1072 | 1069 |
1073 void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( | 1070 void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( |
(...skipping 26 matching lines...) Expand all Loading... |
1100 *string += ","; | 1097 *string += ","; |
1101 *string += "sha1/" + encoded; | 1098 *string += "sha1/" + encoded; |
1102 } | 1099 } |
1103 } | 1100 } |
1104 | 1101 |
1105 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( | 1102 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( |
1106 const ListValue* list) { | 1103 const ListValue* list) { |
1107 // |list| should be: [<domain to query>]. | 1104 // |list| should be: [<domain to query>]. |
1108 std::string domain; | 1105 std::string domain; |
1109 CHECK(list->GetString(0, &domain)); | 1106 CHECK(list->GetString(0, &domain)); |
1110 DictionaryValue* result = new(DictionaryValue); | 1107 DictionaryValue* result = new DictionaryValue(); |
1111 | 1108 |
1112 if (!IsStringASCII(domain)) { | 1109 if (!IsStringASCII(domain)) { |
1113 result->SetString("error", "non-ASCII domain name"); | 1110 result->SetString("error", "non-ASCII domain name"); |
1114 } else { | 1111 } else { |
1115 net::TransportSecurityState* transport_security_state = | 1112 net::TransportSecurityState* transport_security_state = |
1116 context_getter_->GetURLRequestContext()->transport_security_state(); | 1113 context_getter_->GetURLRequestContext()->transport_security_state(); |
1117 if (!transport_security_state) { | 1114 if (!transport_security_state) { |
1118 result->SetString("error", "no TransportSecurityState active"); | 1115 result->SetString("error", "no TransportSecurityState active"); |
1119 } else { | 1116 } else { |
1120 net::TransportSecurityState::DomainState state; | 1117 net::TransportSecurityState::DomainState state; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 if (!transport_security_state) | 1161 if (!transport_security_state) |
1165 return; | 1162 return; |
1166 | 1163 |
1167 net::TransportSecurityState::DomainState state; | 1164 net::TransportSecurityState::DomainState state; |
1168 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); | 1165 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); |
1169 state.include_subdomains = include_subdomains; | 1166 state.include_subdomains = include_subdomains; |
1170 if (!hashes_str.empty()) { | 1167 if (!hashes_str.empty()) { |
1171 std::vector<std::string> type_and_b64s; | 1168 std::vector<std::string> type_and_b64s; |
1172 base::SplitString(hashes_str, ',', &type_and_b64s); | 1169 base::SplitString(hashes_str, ',', &type_and_b64s); |
1173 for (std::vector<std::string>::const_iterator | 1170 for (std::vector<std::string>::const_iterator |
1174 i = type_and_b64s.begin(); i != type_and_b64s.end(); i++) { | 1171 i = type_and_b64s.begin(); i != type_and_b64s.end(); ++i) { |
1175 std::string type_and_b64; | 1172 std::string type_and_b64; |
1176 RemoveChars(*i, " \t\r\n", &type_and_b64); | 1173 RemoveChars(*i, " \t\r\n", &type_and_b64); |
1177 net::SHA1Fingerprint hash; | 1174 net::SHA1Fingerprint hash; |
1178 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) | 1175 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) |
1179 continue; | 1176 continue; |
1180 | 1177 |
1181 state.dynamic_spki_hashes.push_back(hash); | 1178 state.dynamic_spki_hashes.push_back(hash); |
1182 } | 1179 } |
1183 } | 1180 } |
1184 | 1181 |
(...skipping 12 matching lines...) Expand all Loading... |
1197 net::TransportSecurityState* transport_security_state = | 1194 net::TransportSecurityState* transport_security_state = |
1198 context_getter_->GetURLRequestContext()->transport_security_state(); | 1195 context_getter_->GetURLRequestContext()->transport_security_state(); |
1199 if (!transport_security_state) | 1196 if (!transport_security_state) |
1200 return; | 1197 return; |
1201 | 1198 |
1202 transport_security_state->DeleteHost(domain); | 1199 transport_security_state->DeleteHost(domain); |
1203 } | 1200 } |
1204 | 1201 |
1205 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( | 1202 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( |
1206 const ListValue* list) { | 1203 const ListValue* list) { |
| 1204 DCHECK(!list); |
1207 DictionaryValue* info_dict = new DictionaryValue(); | 1205 DictionaryValue* info_dict = new DictionaryValue(); |
1208 DictionaryValue* stats_dict = new DictionaryValue(); | 1206 DictionaryValue* stats_dict = new DictionaryValue(); |
1209 | 1207 |
1210 disk_cache::Backend* disk_cache = GetDiskCacheBackend( | 1208 disk_cache::Backend* disk_cache = GetDiskCacheBackend( |
1211 context_getter_->GetURLRequestContext()); | 1209 context_getter_->GetURLRequestContext()); |
1212 | 1210 |
1213 if (disk_cache) { | 1211 if (disk_cache) { |
1214 // Extract the statistics key/value pairs from the backend. | 1212 // Extract the statistics key/value pairs from the backend. |
1215 std::vector<std::pair<std::string, std::string> > stats; | 1213 std::vector<std::pair<std::string, std::string> > stats; |
1216 disk_cache->GetStats(&stats); | 1214 disk_cache->GetStats(&stats); |
1217 for (size_t i = 0; i < stats.size(); ++i) { | 1215 for (size_t i = 0; i < stats.size(); ++i) { |
1218 stats_dict->Set(stats[i].first, | 1216 stats_dict->Set(stats[i].first, |
1219 Value::CreateStringValue(stats[i].second)); | 1217 Value::CreateStringValue(stats[i].second)); |
1220 } | 1218 } |
1221 } | 1219 } |
1222 | 1220 |
1223 info_dict->Set("stats", stats_dict); | 1221 info_dict->Set("stats", stats_dict); |
1224 | 1222 |
1225 SendJavascriptCommand("receivedHttpCacheInfo", info_dict); | 1223 SendJavascriptCommand("receivedHttpCacheInfo", info_dict); |
1226 } | 1224 } |
1227 | 1225 |
1228 void NetInternalsMessageHandler::IOThreadImpl::OnGetSocketPoolInfo( | 1226 void NetInternalsMessageHandler::IOThreadImpl::OnGetSocketPoolInfo( |
1229 const ListValue* list) { | 1227 const ListValue* list) { |
| 1228 DCHECK(!list); |
1230 net::HttpNetworkSession* http_network_session = | 1229 net::HttpNetworkSession* http_network_session = |
1231 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1230 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1232 | 1231 |
1233 Value* socket_pool_info = NULL; | 1232 Value* socket_pool_info = NULL; |
1234 if (http_network_session) | 1233 if (http_network_session) |
1235 socket_pool_info = http_network_session->SocketPoolInfoToValue(); | 1234 socket_pool_info = http_network_session->SocketPoolInfoToValue(); |
1236 | 1235 |
1237 SendJavascriptCommand("receivedSocketPoolInfo", socket_pool_info); | 1236 SendJavascriptCommand("receivedSocketPoolInfo", socket_pool_info); |
1238 } | 1237 } |
1239 | 1238 |
1240 | 1239 |
1241 void NetInternalsMessageHandler::IOThreadImpl::OnFlushSocketPools( | 1240 void NetInternalsMessageHandler::IOThreadImpl::OnFlushSocketPools( |
1242 const ListValue* list) { | 1241 const ListValue* list) { |
| 1242 DCHECK(!list); |
1243 net::HttpNetworkSession* http_network_session = | 1243 net::HttpNetworkSession* http_network_session = |
1244 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1244 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1245 | 1245 |
1246 if (http_network_session) | 1246 if (http_network_session) |
1247 http_network_session->CloseAllConnections(); | 1247 http_network_session->CloseAllConnections(); |
1248 } | 1248 } |
1249 | 1249 |
1250 void NetInternalsMessageHandler::IOThreadImpl::OnCloseIdleSockets( | 1250 void NetInternalsMessageHandler::IOThreadImpl::OnCloseIdleSockets( |
1251 const ListValue* list) { | 1251 const ListValue* list) { |
| 1252 DCHECK(!list); |
1252 net::HttpNetworkSession* http_network_session = | 1253 net::HttpNetworkSession* http_network_session = |
1253 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1254 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1254 | 1255 |
1255 if (http_network_session) | 1256 if (http_network_session) |
1256 http_network_session->CloseIdleConnections(); | 1257 http_network_session->CloseIdleConnections(); |
1257 } | 1258 } |
1258 | 1259 |
1259 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdySessionInfo( | 1260 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdySessionInfo( |
1260 const ListValue* list) { | 1261 const ListValue* list) { |
| 1262 DCHECK(!list); |
1261 net::HttpNetworkSession* http_network_session = | 1263 net::HttpNetworkSession* http_network_session = |
1262 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1264 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1263 | 1265 |
1264 Value* spdy_info = NULL; | 1266 Value* spdy_info = http_network_session ? |
1265 if (http_network_session) { | 1267 http_network_session->SpdySessionPoolInfoToValue() : NULL; |
1266 spdy_info = http_network_session->SpdySessionPoolInfoToValue(); | |
1267 } | |
1268 | |
1269 SendJavascriptCommand("receivedSpdySessionInfo", spdy_info); | 1268 SendJavascriptCommand("receivedSpdySessionInfo", spdy_info); |
1270 } | 1269 } |
1271 | 1270 |
1272 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus( | 1271 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus( |
1273 const ListValue* list) { | 1272 const ListValue* list) { |
| 1273 DCHECK(!list); |
1274 DictionaryValue* status_dict = new DictionaryValue(); | 1274 DictionaryValue* status_dict = new DictionaryValue(); |
1275 | 1275 |
1276 status_dict->Set("spdy_enabled", | 1276 status_dict->Set("spdy_enabled", |
1277 Value::CreateBooleanValue( | 1277 Value::CreateBooleanValue( |
1278 net::HttpStreamFactory::spdy_enabled())); | 1278 net::HttpStreamFactory::spdy_enabled())); |
1279 status_dict->Set("use_alternate_protocols", | 1279 status_dict->Set("use_alternate_protocols", |
1280 Value::CreateBooleanValue( | 1280 Value::CreateBooleanValue( |
1281 net::HttpStreamFactory::use_alternate_protocols())); | 1281 net::HttpStreamFactory::use_alternate_protocols())); |
1282 status_dict->Set("force_spdy_over_ssl", | 1282 status_dict->Set("force_spdy_over_ssl", |
1283 Value::CreateBooleanValue( | 1283 Value::CreateBooleanValue( |
(...skipping 11 matching lines...) Expand all Loading... |
1295 next_protos_value = Value::CreateStringValue(""); | 1295 next_protos_value = Value::CreateStringValue(""); |
1296 } | 1296 } |
1297 status_dict->Set("next_protos", next_protos_value); | 1297 status_dict->Set("next_protos", next_protos_value); |
1298 | 1298 |
1299 SendJavascriptCommand("receivedSpdyStatus", status_dict); | 1299 SendJavascriptCommand("receivedSpdyStatus", status_dict); |
1300 } | 1300 } |
1301 | 1301 |
1302 void | 1302 void |
1303 NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings( | 1303 NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings( |
1304 const ListValue* list) { | 1304 const ListValue* list) { |
| 1305 DCHECK(!list); |
1305 ListValue* dict_list = new ListValue(); | 1306 ListValue* dict_list = new ListValue(); |
1306 | 1307 |
1307 const net::HttpServerProperties& http_server_properties = | 1308 const net::HttpServerProperties& http_server_properties = |
1308 *context_getter_->GetURLRequestContext()->http_server_properties(); | 1309 *context_getter_->GetURLRequestContext()->http_server_properties(); |
1309 | 1310 |
1310 const net::AlternateProtocolMap& map = | 1311 const net::AlternateProtocolMap& map = |
1311 http_server_properties.alternate_protocol_map(); | 1312 http_server_properties.alternate_protocol_map(); |
1312 | 1313 |
1313 for (net::AlternateProtocolMap::const_iterator it = map.begin(); | 1314 for (net::AlternateProtocolMap::const_iterator it = map.begin(); |
1314 it != map.end(); ++it) { | 1315 it != map.end(); ++it) { |
1315 DictionaryValue* dict = new DictionaryValue(); | 1316 DictionaryValue* dict = new DictionaryValue(); |
1316 dict->SetString("host_port_pair", it->first.ToString()); | 1317 dict->SetString("host_port_pair", it->first.ToString()); |
1317 dict->SetString("alternate_protocol", it->second.ToString()); | 1318 dict->SetString("alternate_protocol", it->second.ToString()); |
1318 dict_list->Append(dict); | 1319 dict_list->Append(dict); |
1319 } | 1320 } |
1320 | 1321 |
1321 SendJavascriptCommand("receivedSpdyAlternateProtocolMappings", dict_list); | 1322 SendJavascriptCommand("receivedSpdyAlternateProtocolMappings", dict_list); |
1322 } | 1323 } |
1323 | 1324 |
1324 #ifdef OS_WIN | 1325 #if defined(OS_WIN) |
1325 void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( | 1326 void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( |
1326 const ListValue* list) { | 1327 const ListValue* list) { |
| 1328 DCHECK(!list); |
1327 | 1329 |
1328 DictionaryValue* service_providers = new DictionaryValue(); | 1330 DictionaryValue* service_providers = new DictionaryValue(); |
1329 | 1331 |
1330 WinsockLayeredServiceProviderList layered_providers; | 1332 WinsockLayeredServiceProviderList layered_providers; |
1331 GetWinsockLayeredServiceProviders(&layered_providers); | 1333 GetWinsockLayeredServiceProviders(&layered_providers); |
1332 ListValue* layered_provider_list = new ListValue(); | 1334 ListValue* layered_provider_list = new ListValue(); |
1333 for (size_t i = 0; i < layered_providers.size(); ++i) { | 1335 for (size_t i = 0; i < layered_providers.size(); ++i) { |
1334 DictionaryValue* service_dict = new DictionaryValue(); | 1336 DictionaryValue* service_dict = new DictionaryValue(); |
1335 service_dict->SetString("name", layered_providers[i].name); | 1337 service_dict->SetString("name", layered_providers[i].name); |
1336 service_dict->SetInteger("version", layered_providers[i].version); | 1338 service_dict->SetInteger("version", layered_providers[i].version); |
(...skipping 18 matching lines...) Expand all Loading... |
1355 namespace_dict->SetInteger("type", namespace_providers[i].type); | 1357 namespace_dict->SetInteger("type", namespace_providers[i].type); |
1356 | 1358 |
1357 namespace_list->Append(namespace_dict); | 1359 namespace_list->Append(namespace_dict); |
1358 } | 1360 } |
1359 service_providers->Set("namespace_providers", namespace_list); | 1361 service_providers->Set("namespace_providers", namespace_list); |
1360 | 1362 |
1361 SendJavascriptCommand("receivedServiceProviders", service_providers); | 1363 SendJavascriptCommand("receivedServiceProviders", service_providers); |
1362 } | 1364 } |
1363 #endif | 1365 #endif |
1364 | 1366 |
1365 #ifdef OS_CHROMEOS | 1367 #if defined(OS_CHROMEOS) |
1366 void NetInternalsMessageHandler::OnRefreshSystemLogs(const ListValue* list) { | 1368 void NetInternalsMessageHandler::OnRefreshSystemLogs(const ListValue* list) { |
| 1369 DCHECK(!list); |
1367 DCHECK(syslogs_getter_.get()); | 1370 DCHECK(syslogs_getter_.get()); |
1368 syslogs_getter_->DeleteSystemLogs(); | 1371 syslogs_getter_->DeleteSystemLogs(); |
1369 syslogs_getter_->LoadSystemLogs(); | 1372 syslogs_getter_->LoadSystemLogs(); |
1370 } | 1373 } |
1371 | 1374 |
1372 void NetInternalsMessageHandler::OnGetSystemLog(const ListValue* list) { | 1375 void NetInternalsMessageHandler::OnGetSystemLog(const ListValue* list) { |
1373 DCHECK(syslogs_getter_.get()); | 1376 DCHECK(syslogs_getter_.get()); |
1374 syslogs_getter_->RequestSystemLog(list); | 1377 syslogs_getter_->RequestSystemLog(list); |
1375 } | 1378 } |
1376 | 1379 |
(...skipping 15 matching lines...) Expand all Loading... |
1392 | 1395 |
1393 // Now that we've added the networks, we need to rescan them so they'll be | 1396 // Now that we've added the networks, we need to rescan them so they'll be |
1394 // available from the menu more immediately. | 1397 // available from the menu more immediately. |
1395 cros_network->RequestNetworkScan(); | 1398 cros_network->RequestNetworkScan(); |
1396 | 1399 |
1397 SendJavascriptCommand("receivedONCFileParse", | 1400 SendJavascriptCommand("receivedONCFileParse", |
1398 Value::CreateStringValue(error)); | 1401 Value::CreateStringValue(error)); |
1399 } | 1402 } |
1400 | 1403 |
1401 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { | 1404 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { |
| 1405 DCHECK(!list); |
1402 StoreDebugLogs( | 1406 StoreDebugLogs( |
1403 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, | 1407 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
1404 AsWeakPtr())); | 1408 AsWeakPtr())); |
1405 } | 1409 } |
1406 | 1410 |
1407 void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( | 1411 void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( |
1408 const FilePath& log_path, bool succeeded) { | 1412 const FilePath& log_path, bool succeeded) { |
1409 std::string status; | 1413 std::string status; |
1410 if (succeeded) | 1414 if (succeeded) |
1411 status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe(); | 1415 status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe(); |
(...skipping 20 matching lines...) Expand all Loading... |
1432 const std::string& subsystem, | 1436 const std::string& subsystem, |
1433 bool succeeded) { | 1437 bool succeeded) { |
1434 std::string status; | 1438 std::string status; |
1435 if (succeeded) | 1439 if (succeeded) |
1436 status = "Debug mode is changed to " + subsystem; | 1440 status = "Debug mode is changed to " + subsystem; |
1437 else | 1441 else |
1438 status = "Failed to change debug mode to " + subsystem; | 1442 status = "Failed to change debug mode to " + subsystem; |
1439 SendJavascriptCommand("receivedSetNetworkDebugMode", | 1443 SendJavascriptCommand("receivedSetNetworkDebugMode", |
1440 Value::CreateStringValue(status)); | 1444 Value::CreateStringValue(status)); |
1441 } | 1445 } |
1442 #endif | 1446 #endif // defined(OS_CHROMEOS) |
1443 | 1447 |
1444 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus( | 1448 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus( |
1445 const ListValue* list) { | 1449 const ListValue* list) { |
| 1450 DCHECK(!list); |
1446 DictionaryValue* status_dict = new DictionaryValue(); | 1451 DictionaryValue* status_dict = new DictionaryValue(); |
1447 | 1452 |
1448 status_dict->Set("pipelining_enabled", | 1453 status_dict->Set("pipelining_enabled", |
1449 Value::CreateBooleanValue( | 1454 Value::CreateBooleanValue( |
1450 net::HttpStreamFactory::http_pipelining_enabled())); | 1455 net::HttpStreamFactory::http_pipelining_enabled())); |
1451 | 1456 |
1452 net::HttpNetworkSession* http_network_session = | 1457 net::HttpNetworkSession* http_network_session = |
1453 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1458 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1454 Value* pipelined_connection_info = NULL; | 1459 Value* pipelined_connection_info = NULL; |
1455 if (http_network_session) { | 1460 if (http_network_session) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 dict); | 1570 dict); |
1566 } | 1571 } |
1567 | 1572 |
1568 void | 1573 void |
1569 NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestSuite() { | 1574 NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestSuite() { |
1570 SendJavascriptCommand( | 1575 SendJavascriptCommand( |
1571 "receivedCompletedConnectionTestSuite", | 1576 "receivedCompletedConnectionTestSuite", |
1572 NULL); | 1577 NULL); |
1573 } | 1578 } |
1574 | 1579 |
1575 void NetInternalsMessageHandler::IOThreadImpl::DispatchToMessageHandler( | |
1576 ListValue* arg, MessageHandler method) { | |
1577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
1578 (this->*method)(arg); | |
1579 delete arg; | |
1580 } | |
1581 | |
1582 // Note that this can be called from ANY THREAD. | 1580 // Note that this can be called from ANY THREAD. |
1583 void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand( | 1581 void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand( |
1584 const std::string& command, | 1582 const std::string& command, |
1585 Value* arg) { | 1583 Value* arg) { |
1586 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 1584 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
1587 if (handler_ && !was_webui_deleted_) { | 1585 if (handler_ && !was_webui_deleted_) { |
1588 // We check |handler_| in case it was deleted on the UI thread earlier | 1586 // We check |handler_| in case it was deleted on the UI thread earlier |
1589 // while we were running on the IO thread. | 1587 // while we were running on the IO thread. |
1590 handler_->SendJavascriptCommand(command, arg); | 1588 handler_->SendJavascriptCommand(command, arg); |
1591 } else { | 1589 } else { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 } | 1743 } |
1746 | 1744 |
1747 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1745 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1748 : WebUIController(web_ui) { | 1746 : WebUIController(web_ui) { |
1749 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1747 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1750 | 1748 |
1751 // Set up the chrome://net-internals/ source. | 1749 // Set up the chrome://net-internals/ source. |
1752 Profile* profile = Profile::FromWebUI(web_ui); | 1750 Profile* profile = Profile::FromWebUI(web_ui); |
1753 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); | 1751 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); |
1754 } | 1752 } |
OLD | NEW |