diff options
author | apavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-19 13:22:44 +0000 |
---|---|---|
committer | apavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-19 13:22:44 +0000 |
commit | 8a145534a11fd90651c3b26f7f37dbc6b0a5a626 (patch) | |
tree | 8ea4d53c39974e9e7da801de5e19d408a30e1d9e /chrome/browser/debugger | |
parent | 09f334c4b2b26dc7a861eb960cb37184a48046b3 (diff) | |
download | chromium_src-8a145534a11fd90651c3b26f7f37dbc6b0a5a626.zip chromium_src-8a145534a11fd90651c3b26f7f37dbc6b0a5a626.tar.gz chromium_src-8a145534a11fd90651c3b26f7f37dbc6b0a5a626.tar.bz2 |
Review URL: http://codereview.chromium.org/113533
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16368 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger')
-rw-r--r-- | chrome/browser/debugger/debugger_remote_service.cc | 37 | ||||
-rw-r--r-- | chrome/browser/debugger/debugger_remote_service.h | 12 | ||||
-rw-r--r-- | chrome/browser/debugger/inspectable_tab_proxy.cc | 20 | ||||
-rw-r--r-- | chrome/browser/debugger/inspectable_tab_proxy.h | 2 |
4 files changed, 65 insertions, 6 deletions
diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc index f2a0b68..7fffe4b 100644 --- a/chrome/browser/debugger/debugger_remote_service.cc +++ b/chrome/browser/debugger/debugger_remote_service.cc @@ -32,6 +32,11 @@ static const std::wstring kDataWide = L"data"; // DictionaryValue field (which requires a wide string). static const std::wstring kResultWide = L"result"; +// A constant for the "command" JSON message field. +// The type is wstring because the constant is used to get a +// DictionaryValue field (which requires a wide string). +static const std::wstring kCommandWide = L"command"; + } // namespace const std::string DebuggerRemoteServiceCommand::kAttach = "attach"; @@ -40,6 +45,10 @@ const std::string DebuggerRemoteServiceCommand::kDebuggerCommand = "debugger_command"; const std::string DebuggerRemoteServiceCommand::kEvaluateJavascript = "evaluate_javascript"; +const std::string DebuggerRemoteServiceCommand::kFrameNavigate = + "navigated"; +const std::string DebuggerRemoteServiceCommand::kTabClosed = + "closed"; const std::string DebuggerRemoteService::kToolName = "V8Debugger"; @@ -55,7 +64,6 @@ DebuggerRemoteService::~DebuggerRemoteService() {} // V8 debugger via DevToolsClientHost. void DebuggerRemoteService::HandleMessage( const DevToolsRemoteMessage& message) { - static const std::wstring kCommandWide = L"command"; const std::string destination = message.destination(); scoped_ptr<Value> request(JSONReader::Read(message.content(), true)); if (request.get() == NULL) { @@ -152,7 +160,7 @@ TabContents* DebuggerRemoteService::ToTabContents(int32 tab_uid) { // a message from the V8 VM debugger corresponding to |tab_id| is received. // Composes a Chrome Developer Tools Protocol JSON response and sends it // to the remote debugger. -void DebuggerRemoteService::DebuggerOutput(int32 tab_id, +void DebuggerRemoteService::DebuggerOutput(int32 tab_uid, const std::string& message) { std::string content = StringPrintf( "{\"command\":\"%s\",\"result\":%s,\"data\":%s}", @@ -162,11 +170,34 @@ void DebuggerRemoteService::DebuggerOutput(int32 tab_id, scoped_ptr<DevToolsRemoteMessage> response_message( DevToolsRemoteMessageBuilder::instance().Create( kToolName, - IntToString(tab_id), + IntToString(tab_uid), content)); delegate_->Send(*(response_message.get())); } +// Gets invoked from a DevToolsClientHost callback whenever +// a tab corresponding to |tab_id| changes its URL. |url| is the new +// URL of the tab (may be the same as the previous one if the tab is reloaded). +// Sends the corresponding message to the remote debugger. +void DebuggerRemoteService::FrameNavigate(int32 tab_uid, + const std::string& url) { + DictionaryValue value; + value.SetString(kCommandWide, DebuggerRemoteServiceCommand::kFrameNavigate); + value.SetInteger(kResultWide, RESULT_OK); + value.SetString(kDataWide, url); + SendResponse(value, kToolName, IntToString(tab_uid)); +} + +// Gets invoked from a DevToolsClientHost callback whenever +// a tab corresponding to |tab_id| gets closed. +// Sends the corresponding message to the remote debugger. +void DebuggerRemoteService::TabClosed(int32 tab_id) { + DictionaryValue value; + value.SetString(kCommandWide, DebuggerRemoteServiceCommand::kTabClosed); + value.SetInteger(kResultWide, RESULT_OK); + SendResponse(value, kToolName, IntToString(tab_id)); +} + // Attaches a remote debugger to the target tab specified by |destination| // by posting the DevToolsAgentMsg_Attach message and sends a response // to the remote debugger immediately. diff --git a/chrome/browser/debugger/debugger_remote_service.h b/chrome/browser/debugger/debugger_remote_service.h index 67342f4..8498e454 100644 --- a/chrome/browser/debugger/debugger_remote_service.h +++ b/chrome/browser/debugger/debugger_remote_service.h @@ -27,6 +27,8 @@ struct DebuggerRemoteServiceCommand { static const std::string kDetach; static const std::string kDebuggerCommand; static const std::string kEvaluateJavascript; + static const std::string kFrameNavigate; // navigation event + static const std::string kTabClosed; // tab closing event }; // Handles V8 debugger-related messages from the remote debugger (like @@ -41,8 +43,14 @@ class DebuggerRemoteService : public DevToolsRemoteListener { explicit DebuggerRemoteService(DevToolsProtocolHandler* delegate); virtual ~DebuggerRemoteService(); - // Handles a JSON message from the tab_id-associated V8 debugger. - void DebuggerOutput(int32 tab_id, const std::string& message); + // Handles a JSON message from the tab_uid-associated V8 debugger. + void DebuggerOutput(int32 tab_uid, const std::string& message); + + // Handles a frame navigation event. + void FrameNavigate(int32 tab_uid, const std::string& url); + + // Handles a tab closing event. + void TabClosed(int32 tab_uid); // Detaches the remote debugger from the tab specified by |destination|. // It is public so that we can detach from the tab on the remote debugger diff --git a/chrome/browser/debugger/inspectable_tab_proxy.cc b/chrome/browser/debugger/inspectable_tab_proxy.cc index 8c0caa0..13bff6d 100644 --- a/chrome/browser/debugger/inspectable_tab_proxy.cc +++ b/chrome/browser/debugger/inspectable_tab_proxy.cc @@ -17,12 +17,14 @@ #include "chrome/common/devtools_messages.h" void DevToolsClientHostImpl::InspectedTabClosing() { + static const std::string kEmptyUrl = ""; + TabClosed(); NotifyCloseListener(); delete this; } void DevToolsClientHostImpl::SetInspectedTabUrl(const std::string& url) { - //TODO(apavlov): Notify debugger on the url update. + // TODO(apavlov): Notify debugger on the url update if necessary. } void DevToolsClientHostImpl::SendMessageToClient( @@ -35,7 +37,10 @@ void DevToolsClientHostImpl::SendMessageToClient( void DevToolsClientHostImpl::OnRpcMessage(const std::string& msg) { static const std::string kDebuggerAgentDelegate = "DebuggerAgentDelegate"; + static const std::string kToolsAgentDelegate = "ToolsAgentDelegate"; static const std::string kDebuggerOutput = "DebuggerOutput"; + static const std::string kFrameNavigate = "FrameNavigate"; + scoped_ptr<Value> message(JSONReader::Read(msg, false)); if (!message->IsType(Value::TYPE_LIST)) { NOTREACHED(); // The RPC protocol has changed :( @@ -50,6 +55,11 @@ void DevToolsClientHostImpl::OnRpcMessage(const std::string& msg) { std::string str; list_msg->GetString(2, &str); DebuggerOutput(str); + } else if (class_name == kToolsAgentDelegate && + message_name == kFrameNavigate) { + std::string url; + list_msg->GetString(2, &url); + FrameNavigate(url); } } @@ -57,6 +67,14 @@ void DevToolsClientHostImpl::DebuggerOutput(const std::string& msg) { service_->DebuggerOutput(id_, msg); } +void DevToolsClientHostImpl::FrameNavigate(const std::string& url) { + service_->FrameNavigate(id_, url); +} + +void DevToolsClientHostImpl::TabClosed() { + service_->TabClosed(id_); +} + const InspectableTabProxy::ControllersMap& InspectableTabProxy::controllers_map() { controllers_map_.clear(); diff --git a/chrome/browser/debugger/inspectable_tab_proxy.h b/chrome/browser/debugger/inspectable_tab_proxy.h index 6729cda..0361c2d 100644 --- a/chrome/browser/debugger/inspectable_tab_proxy.h +++ b/chrome/browser/debugger/inspectable_tab_proxy.h @@ -79,6 +79,8 @@ class DevToolsClientHostImpl : public DevToolsClientHost { // Message handling routines void OnRpcMessage(const std::string& msg); void DebuggerOutput(const std::string& msg); + void FrameNavigate(const std::string& url); + void TabClosed(); int32 id_; DebuggerRemoteService* service_; |