diff options
-rw-r--r-- | chrome/browser/browser_process.h | 6 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 33 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.h | 14 | ||||
-rw-r--r-- | chrome/browser/debugger/debugger_wrapper.cc | 40 | ||||
-rw-r--r-- | chrome/browser/debugger/debugger_wrapper.h | 34 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_http_protocol_handler.cc | 58 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_http_protocol_handler.h | 14 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_protocol_handler.cc | 21 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_protocol_handler.h | 10 | ||||
-rw-r--r-- | chrome/browser/ui/browser_init.cc | 17 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 | ||||
-rw-r--r-- | chrome/test/testing_browser_process.h | 7 |
12 files changed, 128 insertions, 128 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h index 3b9ec5e..d419d87 100644 --- a/chrome/browser/browser_process.h +++ b/chrome/browser/browser_process.h @@ -123,7 +123,11 @@ class BrowserProcess { virtual AutomationProviderList* InitAutomationProviderList() = 0; - virtual void InitDebuggerWrapper(int port, bool useHttp) = 0; + virtual void InitDevToolsHttpProtocolHandler( + int port, + const std::string& frontend_url) = 0; + + virtual void InitDevToolsLegacyProtocolHandler(int port) = 0; virtual unsigned int AddRefModule() = 0; virtual unsigned int ReleaseModule() = 0; diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index cc62f0c..a8efdb4 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -20,8 +20,9 @@ #include "chrome/browser/browser_process_sub_thread.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/browser_trial.h" -#include "chrome/browser/debugger/debugger_wrapper.h" +#include "chrome/browser/debugger/devtools_http_protocol_handler.h" #include "chrome/browser/debugger/devtools_manager.h" +#include "chrome/browser/debugger/devtools_protocol_handler.h" #include "chrome/browser/download/download_file_manager.h" #include "chrome/browser/download/save_file_manager.h" #include "chrome/browser/first_run/first_run.h" @@ -97,7 +98,6 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) created_profile_manager_(false), created_local_state_(false), created_icon_manager_(false), - created_debugger_wrapper_(false), created_devtools_manager_(false), created_sidebar_manager_(false), created_configuration_policy_provider_keeper_(false), @@ -166,7 +166,14 @@ BrowserProcessImpl::~BrowserProcessImpl() { profile_manager_.reset(); // Debugger must be cleaned up before IO thread and NotificationService. - debugger_wrapper_ = NULL; + if (devtools_http_handler_.get()) { + devtools_http_handler_->Stop(); + devtools_http_handler_ = NULL; + } + if (devtools_legacy_handler_.get()) { + devtools_legacy_handler_->Stop(); + devtools_legacy_handler_ = NULL; + } if (resource_dispatcher_host_.get()) { // Need to tell Safe Browsing Service that the IO thread is going away @@ -452,10 +459,17 @@ AutomationProviderList* BrowserProcessImpl::InitAutomationProviderList() { return automation_provider_list_.get(); } -void BrowserProcessImpl::InitDebuggerWrapper(int port, bool useHttp) { +void BrowserProcessImpl::InitDevToolsHttpProtocolHandler( + int port, + const std::string& frontend_url) { + DCHECK(CalledOnValidThread()); + devtools_http_handler_ = + DevToolsHttpProtocolHandler::Start(port, frontend_url); +} + +void BrowserProcessImpl::InitDevToolsLegacyProtocolHandler(int port) { DCHECK(CalledOnValidThread()); - if (!created_debugger_wrapper_) - CreateDebuggerWrapper(port, useHttp); + devtools_legacy_handler_ = DevToolsProtocolHandler::Start(port); } bool BrowserProcessImpl::IsShuttingDown() { @@ -733,13 +747,6 @@ void BrowserProcessImpl::CreateIconManager() { icon_manager_.reset(new IconManager); } -void BrowserProcessImpl::CreateDebuggerWrapper(int port, bool useHttp) { - DCHECK(debugger_wrapper_.get() == NULL); - created_debugger_wrapper_ = true; - - debugger_wrapper_ = new DebuggerWrapper(port, useHttp); -} - void BrowserProcessImpl::CreateDevToolsManager() { DCHECK(devtools_manager_.get() == NULL); created_devtools_manager_ = true; diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index d3c03c5..5a19629 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -28,7 +28,8 @@ class ChromeNetLog; class CommandLine; -class DebuggerWrapper; +class DevToolsHttpProtocolHandler; +class DevToolsProtocolHandler; class FilePath; class NotificationService; class PluginDataRemover; @@ -66,7 +67,10 @@ class BrowserProcessImpl : public BrowserProcess, virtual IconManager* icon_manager(); virtual ThumbnailGenerator* GetThumbnailGenerator(); virtual AutomationProviderList* InitAutomationProviderList(); - virtual void InitDebuggerWrapper(int port, bool useHttp); + virtual void InitDevToolsHttpProtocolHandler( + int port, + const std::string& frontend_url); + virtual void InitDevToolsLegacyProtocolHandler(int port); virtual unsigned int AddRefModule(); virtual unsigned int ReleaseModule(); virtual bool IsShuttingDown(); @@ -121,7 +125,6 @@ class BrowserProcessImpl : public BrowserProcess, void CreateLocalState(); void CreateViewedPageTracker(); void CreateIconManager(); - void CreateDebuggerWrapper(int port, bool useHttp); void CreateDevToolsManager(); void CreateSidebarManager(); void CreateGoogleURLTracker(); @@ -172,8 +175,9 @@ class BrowserProcessImpl : public BrowserProcess, bool created_icon_manager_; scoped_ptr<IconManager> icon_manager_; - bool created_debugger_wrapper_; - scoped_refptr<DebuggerWrapper> debugger_wrapper_; + scoped_refptr<DevToolsHttpProtocolHandler> devtools_http_handler_; + + scoped_refptr<DevToolsProtocolHandler> devtools_legacy_handler_; bool created_devtools_manager_; scoped_refptr<DevToolsManager> devtools_manager_; diff --git a/chrome/browser/debugger/debugger_wrapper.cc b/chrome/browser/debugger/debugger_wrapper.cc deleted file mode 100644 index 644bf05..0000000 --- a/chrome/browser/debugger/debugger_wrapper.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/debugger/debugger_wrapper.h" - -#include "chrome/browser/debugger/devtools_http_protocol_handler.h" -#include "chrome/browser/debugger/debugger_remote_service.h" -#include "chrome/browser/debugger/devtools_protocol_handler.h" -#include "chrome/browser/debugger/devtools_remote_service.h" -#include "chrome/browser/debugger/extension_ports_remote_service.h" - -DebuggerWrapper::DebuggerWrapper(int port, bool useHttp) { - if (port > 0) { - if (useHttp) { - http_handler_ = new DevToolsHttpProtocolHandler(port); - http_handler_->Start(); - } else { - proto_handler_ = new DevToolsProtocolHandler(port); - proto_handler_->RegisterDestination( - new DevToolsRemoteService(proto_handler_), - DevToolsRemoteService::kToolName); - proto_handler_->RegisterDestination( - new DebuggerRemoteService(proto_handler_), - DebuggerRemoteService::kToolName); - proto_handler_->RegisterDestination( - new ExtensionPortsRemoteService(proto_handler_), - ExtensionPortsRemoteService::kToolName); - proto_handler_->Start(); - } - } -} - -DebuggerWrapper::~DebuggerWrapper() { - if (proto_handler_.get() != NULL) - proto_handler_->Stop(); - - if (http_handler_.get() != NULL) - http_handler_->Stop(); -} diff --git a/chrome/browser/debugger/debugger_wrapper.h b/chrome/browser/debugger/debugger_wrapper.h deleted file mode 100644 index a9cf7bf..0000000 --- a/chrome/browser/debugger/debugger_wrapper.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Include this file if you need to access the Debugger outside of the debugger -// project. Don't include debugger.h directly. If there's functionality from -// Debugger needed, add new wrapper methods to this file. - -#ifndef CHROME_BROWSER_DEBUGGER_DEBUGGER_WRAPPER_H_ -#define CHROME_BROWSER_DEBUGGER_DEBUGGER_WRAPPER_H_ -#pragma once - -#include "base/basictypes.h" -#include "base/ref_counted.h" - -class DebuggerHost; -class DevToolsHttpProtocolHandler; -class DevToolsProtocolHandler; -class DevToolsRemoteListenSocket; - -class DebuggerWrapper : public base::RefCountedThreadSafe<DebuggerWrapper> { - public: - DebuggerWrapper(int port, bool useHttp); - - private: - friend class base::RefCountedThreadSafe<DebuggerWrapper>; - - virtual ~DebuggerWrapper(); - - scoped_refptr<DevToolsProtocolHandler> proto_handler_; - scoped_refptr<DevToolsHttpProtocolHandler> http_handler_; -}; - -#endif // CHROME_BROWSER_DEBUGGER_DEBUGGER_WRAPPER_H_ diff --git a/chrome/browser/debugger/devtools_http_protocol_handler.cc b/chrome/browser/debugger/devtools_http_protocol_handler.cc index 910027a..5d63cb1 100644 --- a/chrome/browser/debugger/devtools_http_protocol_handler.cc +++ b/chrome/browser/debugger/devtools_http_protocol_handler.cc @@ -71,6 +71,17 @@ class DevToolsClientHostImpl : public DevToolsClientHost { } // namespace + +// static +scoped_refptr<DevToolsHttpProtocolHandler> DevToolsHttpProtocolHandler::Start( + int port, + const std::string& frontend_url) { + scoped_refptr<DevToolsHttpProtocolHandler> http_handler = + new DevToolsHttpProtocolHandler(port, frontend_url); + http_handler->Start(); + return http_handler; +} + DevToolsHttpProtocolHandler::~DevToolsHttpProtocolHandler() { // Stop() must be called prior to this being called DCHECK(server_.get() == NULL); @@ -170,7 +181,22 @@ void DevToolsHttpProtocolHandler::OnClose(HttpListenSocket* socket) { void DevToolsHttpProtocolHandler::OnHttpRequestUI( HttpListenSocket* socket, const HttpServerRequestInfo& info) { - std::string response = "<html><body>"; + std::string response = "<html><body><script>" + "function addTab(id, url, attached, frontendUrl) {" + " if (!attached) {" + " var a = document.createElement('a');" + " a.textContent = url;" + " a.href = frontendUrl + '?remotehost=' + window.location.host +" + " '&page=' + id;" + " document.body.appendChild(a);" + " } else {" + " var span = document.createElement('span');" + " span.textContent = url + ' (attached)';" + " document.body.appendChild(span);" + " }" + " document.body.appendChild(document.createElement('br'));" + "}"; + for (BrowserList::const_iterator it = BrowserList::begin(), end = BrowserList::end(); it != end; ++it) { TabStripModel* model = (*it)->tabstrip_model(); @@ -187,21 +213,15 @@ void DevToolsHttpProtocolHandler::OnHttpRequestUI( DevToolsClientHost* client_host = DevToolsManager::GetInstance()-> GetDevToolsClientHostFor(tab_contents->tab_contents()-> render_view_host()); - if (!client_host) { - response += StringPrintf( - "<a href='/devtools/devtools.html?page=%d'>%s (%s)</a><br>", - controller.session_id().id(), - UTF16ToUTF8(entry->title()).c_str(), - entry->url().spec().c_str()); - } else { - response += StringPrintf( - "%s (%s)<br>", - UTF16ToUTF8(entry->title()).c_str(), - entry->url().spec().c_str()); - } + response += StringPrintf( + "addTab(%d, '%s', %s, '%s');\n", + controller.session_id().id(), + entry->url().spec().c_str(), + client_host ? "true" : "false", + overriden_frontend_url_.c_str()); } } - response += "</body></html>"; + response += "</script></body></html>"; Send200(socket, response, "text/html; charset=UTF-8"); } @@ -340,9 +360,14 @@ void DevToolsHttpProtocolHandler::OnReadCompleted(net::URLRequest* request, RequestCompleted(request); } -DevToolsHttpProtocolHandler::DevToolsHttpProtocolHandler(int port) +DevToolsHttpProtocolHandler::DevToolsHttpProtocolHandler( + int port, + const std::string& frontend_host) : port_(port), + overriden_frontend_url_(frontend_host), server_(NULL) { + if (overriden_frontend_url_.empty()) + overriden_frontend_url_ = "/devtools/devtools.html"; } void DevToolsHttpProtocolHandler::Init() { @@ -428,8 +453,9 @@ TabContents* DevToolsHttpProtocolHandler::GetTabContents(int session_id) { end = BrowserList::end(); it != end; ++it) { TabStripModel* model = (*it)->tabstrip_model(); for (int i = 0, size = model->count(); i < size; ++i) { + TabContentsWrapper* tab_contents = model->GetTabContentsAt(i); NavigationController& controller = - model->GetTabContentsAt(i)->controller(); + tab_contents->controller(); if (controller.session_id().id() == session_id) return controller.tab_contents(); } diff --git a/chrome/browser/debugger/devtools_http_protocol_handler.h b/chrome/browser/debugger/devtools_http_protocol_handler.h index c5c485f..e28da6a 100644 --- a/chrome/browser/debugger/devtools_http_protocol_handler.h +++ b/chrome/browser/debugger/devtools_http_protocol_handler.h @@ -22,17 +22,20 @@ class DevToolsHttpProtocolHandler public net::URLRequest::Delegate, public base::RefCountedThreadSafe<DevToolsHttpProtocolHandler> { public: - explicit DevToolsHttpProtocolHandler(int port); + static scoped_refptr<DevToolsHttpProtocolHandler> Start( + int port, + const std::string& frontend_url); - // This method should be called after the object construction. - void Start(); - - // This method should be called before the object destruction. + // Called from the main thread in order to stop protocol handler. + // Will schedule tear down task on IO thread. void Stop(); private: friend class base::RefCountedThreadSafe<DevToolsHttpProtocolHandler>; + + DevToolsHttpProtocolHandler(int port, const std::string& frontend_url); virtual ~DevToolsHttpProtocolHandler(); + void Start(); // HttpListenSocket::Delegate implementation. virtual void OnHttpRequest(HttpListenSocket* socket, @@ -73,6 +76,7 @@ class DevToolsHttpProtocolHandler TabContents* GetTabContents(int session_id); int port_; + std::string overriden_frontend_url_; scoped_refptr<HttpListenSocket> server_; typedef std::map<net::URLRequest*, HttpListenSocket*> RequestToSocketMap; diff --git a/chrome/browser/debugger/devtools_protocol_handler.cc b/chrome/browser/debugger/devtools_protocol_handler.cc index 6e72ef0..0024164 100644 --- a/chrome/browser/debugger/devtools_protocol_handler.cc +++ b/chrome/browser/debugger/devtools_protocol_handler.cc @@ -7,8 +7,29 @@ #include "base/logging.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/debugger/inspectable_tab_proxy.h" +#include "chrome/browser/debugger/debugger_remote_service.h" #include "chrome/browser/debugger/devtools_remote_message.h" #include "chrome/browser/debugger/devtools_remote_listen_socket.h" +#include "chrome/browser/debugger/devtools_remote_service.h" +#include "chrome/browser/debugger/extension_ports_remote_service.h" + +// static +scoped_refptr<DevToolsProtocolHandler> DevToolsProtocolHandler::Start( + int port) { + scoped_refptr<DevToolsProtocolHandler> proto_handler = + new DevToolsProtocolHandler(port); + proto_handler->RegisterDestination( + new DevToolsRemoteService(proto_handler), + DevToolsRemoteService::kToolName); + proto_handler->RegisterDestination( + new DebuggerRemoteService(proto_handler), + DebuggerRemoteService::kToolName); + proto_handler->RegisterDestination( + new ExtensionPortsRemoteService(proto_handler), + ExtensionPortsRemoteService::kToolName); + proto_handler->Start(); + return proto_handler; +} DevToolsProtocolHandler::DevToolsProtocolHandler(int port) : port_(port), diff --git a/chrome/browser/debugger/devtools_protocol_handler.h b/chrome/browser/debugger/devtools_protocol_handler.h index 92889cc..a91cefb 100644 --- a/chrome/browser/debugger/devtools_protocol_handler.h +++ b/chrome/browser/debugger/devtools_protocol_handler.h @@ -27,12 +27,10 @@ class DevToolsProtocolHandler typedef base::hash_map< std::string, scoped_refptr<DevToolsRemoteListener> > ToolToListenerMap; - explicit DevToolsProtocolHandler(int port); - - // This method should be called after the object construction. - void Start(); + static scoped_refptr<DevToolsProtocolHandler> Start(int port); - // This method should be called before the object destruction. + // Called from the main thread in order to stop protocol handler. + // Will schedule tear down task on IO thread. void Stop(); // Registers a |listener| to handle messages for a certain |tool_name| Tool. @@ -61,7 +59,9 @@ class DevToolsProtocolHandler virtual void Send(const DevToolsRemoteMessage& message); private: + explicit DevToolsProtocolHandler(int port); virtual ~DevToolsProtocolHandler(); + void Start(); void Init(); void Teardown(); diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 2cf9d62..be770c8 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -604,18 +604,23 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile, std::string port_str = command_line_.GetSwitchValueASCII(switches::kRemoteShellPort); int64 port; - if (base::StringToInt64(port_str, &port) && port > 0 && port < 65535) - g_browser_process->InitDebuggerWrapper(static_cast<int>(port), false); - else + if (base::StringToInt64(port_str, &port) && port > 0 && port < 65535) { + g_browser_process->InitDevToolsLegacyProtocolHandler( + static_cast<int>(port)); + } else { DLOG(WARNING) << "Invalid remote shell port number " << port; + } } else if (command_line_.HasSwitch(switches::kRemoteDebuggingPort)) { std::string port_str = command_line_.GetSwitchValueASCII(switches::kRemoteDebuggingPort); int64 port; - if (base::StringToInt64(port_str, &port) && port > 0 && port < 65535) - g_browser_process->InitDebuggerWrapper(static_cast<int>(port), true); - else + if (base::StringToInt64(port_str, &port) && port > 0 && port < 65535) { + g_browser_process->InitDevToolsHttpProtocolHandler( + static_cast<int>(port), + ""); + } else { DLOG(WARNING) << "Invalid http debugger port number " << port; + } } if (command_line_.HasSwitch(switches::kUserAgent)) { diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 4455b2f..775a4a9 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -510,8 +510,6 @@ 'sources': [ 'browser/debugger/debugger_remote_service.cc', 'browser/debugger/debugger_remote_service.h', - 'browser/debugger/debugger_wrapper.cc', - 'browser/debugger/debugger_wrapper.h', 'browser/debugger/devtools_client_host.cc', 'browser/debugger/devtools_client_host.h', 'browser/debugger/devtools_http_protocol_handler.cc', diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h index 5feada8..9655d5a 100644 --- a/chrome/test/testing_browser_process.h +++ b/chrome/test/testing_browser_process.h @@ -149,7 +149,12 @@ class TestingBrowserProcess : public BrowserProcess { return NULL; } - virtual void InitDebuggerWrapper(int port, bool useHttp) { + virtual void InitDevToolsHttpProtocolHandler( + int port, + const std::string& frontend_url) { + } + + virtual void InitDevToolsLegacyProtocolHandler(int port) { } virtual unsigned int AddRefModule() { |