| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/debugger/inspectable_tab_proxy.h" | 5 #include "chrome/browser/debugger/inspectable_tab_proxy.h" |
| 6 | 6 |
| 7 #include "base/json_reader.h" | |
| 8 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 9 #include "base/values.h" | |
| 10 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 11 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 12 #include "chrome/browser/debugger/debugger_remote_service.h" | 10 #include "chrome/browser/debugger/debugger_remote_service.h" |
| 13 #include "chrome/browser/debugger/devtools_client_host.h" | 11 #include "chrome/browser/debugger/devtools_client_host.h" |
| 14 #include "chrome/browser/sessions/session_id.h" | 12 #include "chrome/browser/sessions/session_id.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 16 #include "chrome/browser/tabs/tab_strip_model.h" | 14 #include "chrome/browser/tabs/tab_strip_model.h" |
| 17 #include "chrome/common/devtools_messages.h" | 15 #include "chrome/common/devtools_messages.h" |
| 18 | 16 |
| 19 // The debugged tab has closed. | 17 // The debugged tab has closed. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 void DevToolsClientHostImpl::SendMessageToClient( | 29 void DevToolsClientHostImpl::SendMessageToClient( |
| 32 const IPC::Message& msg) { | 30 const IPC::Message& msg) { |
| 33 IPC_BEGIN_MESSAGE_MAP(DevToolsClientHostImpl, msg) | 31 IPC_BEGIN_MESSAGE_MAP(DevToolsClientHostImpl, msg) |
| 34 IPC_MESSAGE_HANDLER(DevToolsClientMsg_RpcMessage, OnRpcMessage); | 32 IPC_MESSAGE_HANDLER(DevToolsClientMsg_RpcMessage, OnRpcMessage); |
| 35 IPC_MESSAGE_UNHANDLED_ERROR() | 33 IPC_MESSAGE_UNHANDLED_ERROR() |
| 36 IPC_END_MESSAGE_MAP() | 34 IPC_END_MESSAGE_MAP() |
| 37 } | 35 } |
| 38 | 36 |
| 39 void DevToolsClientHostImpl::OnRpcMessage(const std::string& class_name, | 37 void DevToolsClientHostImpl::OnRpcMessage(const std::string& class_name, |
| 40 const std::string& message_name, | 38 const std::string& message_name, |
| 41 const std::string& msg) { | 39 const std::string& param1, |
| 40 const std::string& param2, |
| 41 const std::string& param3) { |
| 42 static const std::string kDebuggerAgentDelegate = "DebuggerAgentDelegate"; | 42 static const std::string kDebuggerAgentDelegate = "DebuggerAgentDelegate"; |
| 43 static const std::string kToolsAgentDelegate = "ToolsAgentDelegate"; | 43 static const std::string kToolsAgentDelegate = "ToolsAgentDelegate"; |
| 44 static const std::string kDebuggerOutput = "DebuggerOutput"; | 44 static const std::string kDebuggerOutput = "DebuggerOutput"; |
| 45 static const std::string kFrameNavigate = "FrameNavigate"; | 45 static const std::string kFrameNavigate = "FrameNavigate"; |
| 46 | 46 |
| 47 scoped_ptr<Value> message(JSONReader::Read(msg, false)); | |
| 48 if (!message->IsType(Value::TYPE_LIST)) { | |
| 49 NOTREACHED(); // The RPC protocol has changed :( | |
| 50 return; | |
| 51 } | |
| 52 ListValue* list_msg = static_cast<ListValue*>(message.get()); | |
| 53 if (class_name == kDebuggerAgentDelegate && message_name == kDebuggerOutput) { | 47 if (class_name == kDebuggerAgentDelegate && message_name == kDebuggerOutput) { |
| 54 std::string str; | 48 DebuggerOutput(param1); |
| 55 if (!list_msg->GetString(0, &str)) | |
| 56 return; | |
| 57 DebuggerOutput(str); | |
| 58 } else if (class_name == kToolsAgentDelegate && | 49 } else if (class_name == kToolsAgentDelegate && |
| 59 message_name == kFrameNavigate) { | 50 message_name == kFrameNavigate) { |
| 60 std::string url; | 51 FrameNavigate(param1); |
| 61 if (!list_msg->GetString(0, &url)) { | |
| 62 NOTREACHED(); | |
| 63 return; | |
| 64 } | |
| 65 FrameNavigate(url); | |
| 66 } | 52 } |
| 67 } | 53 } |
| 68 | 54 |
| 69 void DevToolsClientHostImpl::DebuggerOutput(const std::string& msg) { | 55 void DevToolsClientHostImpl::DebuggerOutput(const std::string& msg) { |
| 70 service_->DebuggerOutput(id_, msg); | 56 service_->DebuggerOutput(id_, msg); |
| 71 } | 57 } |
| 72 | 58 |
| 73 void DevToolsClientHostImpl::FrameNavigate(const std::string& url) { | 59 void DevToolsClientHostImpl::FrameNavigate(const std::string& url) { |
| 74 service_->FrameNavigate(id_, url); | 60 service_->FrameNavigate(id_, url); |
| 75 } | 61 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return client_host; | 98 return client_host; |
| 113 } | 99 } |
| 114 | 100 |
| 115 void InspectableTabProxy::OnRemoteDebuggerDetached() { | 101 void InspectableTabProxy::OnRemoteDebuggerDetached() { |
| 116 while (id_to_client_host_map_.size() > 0) { | 102 while (id_to_client_host_map_.size() > 0) { |
| 117 IdToClientHostMap::iterator it = id_to_client_host_map_.begin(); | 103 IdToClientHostMap::iterator it = id_to_client_host_map_.begin(); |
| 118 it->second->debugger_remote_service()->DetachFromTab(IntToString(it->first), | 104 it->second->debugger_remote_service()->DetachFromTab(IntToString(it->first), |
| 119 NULL); | 105 NULL); |
| 120 } | 106 } |
| 121 } | 107 } |
| OLD | NEW |