| 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 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 34 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 35 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 35 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 36 #include "chrome/common/chrome_notification_types.h" | 36 #include "chrome/common/chrome_notification_types.h" |
| 37 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
| 38 #include "chrome/common/chrome_version_info.h" | 38 #include "chrome/common/chrome_version_info.h" |
| 39 #include "chrome/common/jstemplate_builder.h" | 39 #include "chrome/common/jstemplate_builder.h" |
| 40 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| 41 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
| 42 #include "content/browser/browser_thread.h" | 42 #include "content/browser/browser_thread.h" |
| 43 #include "content/browser/tab_contents/tab_contents.h" |
| 43 #include "content/common/notification_details.h" | 44 #include "content/common/notification_details.h" |
| 44 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
| 45 #include "grit/net_internals_resources.h" | 46 #include "grit/net_internals_resources.h" |
| 46 #include "net/base/escape.h" | 47 #include "net/base/escape.h" |
| 47 #include "net/base/host_resolver_impl.h" | 48 #include "net/base/host_resolver_impl.h" |
| 48 #include "net/base/net_errors.h" | 49 #include "net/base/net_errors.h" |
| 49 #include "net/base/net_util.h" | 50 #include "net/base/net_util.h" |
| 50 #include "net/base/sys_addrinfo.h" | 51 #include "net/base/sys_addrinfo.h" |
| 51 #include "net/base/x509_cert_types.h" | 52 #include "net/base/x509_cert_types.h" |
| 52 #include "net/disk_cache/disk_cache.h" | 53 #include "net/disk_cache/disk_cache.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 proxy_.get()->OnWebUIDeleted(); | 459 proxy_.get()->OnWebUIDeleted(); |
| 459 // Notify the handler on the IO thread that the renderer is gone. | 460 // Notify the handler on the IO thread that the renderer is gone. |
| 460 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 461 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 461 NewRunnableMethod(proxy_.get(), &IOThreadImpl::Detach)); | 462 NewRunnableMethod(proxy_.get(), &IOThreadImpl::Detach)); |
| 462 } | 463 } |
| 463 } | 464 } |
| 464 | 465 |
| 465 WebUIMessageHandler* NetInternalsMessageHandler::Attach(WebUI* web_ui) { | 466 WebUIMessageHandler* NetInternalsMessageHandler::Attach(WebUI* web_ui) { |
| 466 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 467 | 468 |
| 468 PrefService* pref_service = web_ui->GetProfile()->GetPrefs(); | 469 Profile* profile = |
| 470 Profile::FromBrowserContext(web_ui->tab_contents()->browser_context()); |
| 471 PrefService* pref_service = profile->GetPrefs(); |
| 469 http_throttling_enabled_.Init( | 472 http_throttling_enabled_.Init( |
| 470 prefs::kHttpThrottlingEnabled, pref_service, this); | 473 prefs::kHttpThrottlingEnabled, pref_service, this); |
| 471 http_throttling_may_experiment_.Init( | 474 http_throttling_may_experiment_.Init( |
| 472 prefs::kHttpThrottlingMayExperiment, pref_service, NULL); | 475 prefs::kHttpThrottlingMayExperiment, pref_service, NULL); |
| 473 | 476 |
| 474 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), | 477 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), |
| 475 web_ui->GetProfile()->GetRequestContext()); | 478 profile->GetRequestContext()); |
| 476 #ifdef OS_CHROMEOS | 479 #ifdef OS_CHROMEOS |
| 477 syslogs_getter_.reset(new SystemLogsGetter(this, | 480 syslogs_getter_.reset(new SystemLogsGetter(this, |
| 478 chromeos::system::SyslogsProvider::GetInstance())); | 481 chromeos::system::SyslogsProvider::GetInstance())); |
| 479 #endif | 482 #endif |
| 480 renderer_ready_io_callback_.reset( | 483 renderer_ready_io_callback_.reset( |
| 481 proxy_->CreateCallback(&IOThreadImpl::OnRendererReady)); | 484 proxy_->CreateCallback(&IOThreadImpl::OnRendererReady)); |
| 482 | 485 |
| 483 prerender::PrerenderManager* prerender_manager = | 486 prerender::PrerenderManager* prerender_manager = |
| 484 web_ui->GetProfile()->GetPrerenderManager(); | 487 profile->GetPrerenderManager(); |
| 485 if (prerender_manager) { | 488 if (prerender_manager) { |
| 486 prerender_manager_ = prerender_manager->AsWeakPtr(); | 489 prerender_manager_ = prerender_manager->AsWeakPtr(); |
| 487 } else { | 490 } else { |
| 488 prerender_manager_ = base::WeakPtr<prerender::PrerenderManager>(); | 491 prerender_manager_ = base::WeakPtr<prerender::PrerenderManager>(); |
| 489 } | 492 } |
| 490 | 493 |
| 491 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); | 494 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); |
| 492 return result; | 495 return result; |
| 493 } | 496 } |
| 494 | 497 |
| (...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 return constants_dict; | 1560 return constants_dict; |
| 1558 } | 1561 } |
| 1559 | 1562 |
| 1560 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { | 1563 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { |
| 1561 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); | 1564 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); |
| 1562 | 1565 |
| 1563 // Set up the chrome://net-internals/ source. | 1566 // Set up the chrome://net-internals/ source. |
| 1564 GetProfile()->GetChromeURLDataManager()->AddDataSource( | 1567 GetProfile()->GetChromeURLDataManager()->AddDataSource( |
| 1565 CreateNetInternalsHTMLSource()); | 1568 CreateNetInternalsHTMLSource()); |
| 1566 } | 1569 } |
| OLD | NEW |