| 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" |    7 #include "base/json_reader.h" | 
|    8 #include "base/string_util.h" |    8 #include "base/string_util.h" | 
|    9 #include "base/values.h" |    9 #include "base/values.h" | 
|   10 #include "chrome/browser/browser.h" |   10 #include "chrome/browser/browser.h" | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|   29 } |   29 } | 
|   30  |   30  | 
|   31 void DevToolsClientHostImpl::SendMessageToClient( |   31 void DevToolsClientHostImpl::SendMessageToClient( | 
|   32     const IPC::Message& msg) { |   32     const IPC::Message& msg) { | 
|   33   IPC_BEGIN_MESSAGE_MAP(DevToolsClientHostImpl, msg) |   33   IPC_BEGIN_MESSAGE_MAP(DevToolsClientHostImpl, msg) | 
|   34     IPC_MESSAGE_HANDLER(DevToolsClientMsg_RpcMessage, OnRpcMessage); |   34     IPC_MESSAGE_HANDLER(DevToolsClientMsg_RpcMessage, OnRpcMessage); | 
|   35     IPC_MESSAGE_UNHANDLED_ERROR() |   35     IPC_MESSAGE_UNHANDLED_ERROR() | 
|   36   IPC_END_MESSAGE_MAP() |   36   IPC_END_MESSAGE_MAP() | 
|   37 } |   37 } | 
|   38  |   38  | 
|   39 void DevToolsClientHostImpl::OnRpcMessage(const std::string& msg) { |   39 void DevToolsClientHostImpl::OnRpcMessage(const std::string& class_name, | 
 |   40                                           const std::string& message_name, | 
 |   41                                           const std::string& msg) { | 
|   40   static const std::string kDebuggerAgentDelegate = "DebuggerAgentDelegate"; |   42   static const std::string kDebuggerAgentDelegate = "DebuggerAgentDelegate"; | 
|   41   static const std::string kToolsAgentDelegate = "ToolsAgentDelegate"; |   43   static const std::string kToolsAgentDelegate = "ToolsAgentDelegate"; | 
|   42   static const std::string kDebuggerOutput = "DebuggerOutput"; |   44   static const std::string kDebuggerOutput = "DebuggerOutput"; | 
|   43   static const std::string kFrameNavigate = "FrameNavigate"; |   45   static const std::string kFrameNavigate = "FrameNavigate"; | 
|   44  |   46  | 
|   45   scoped_ptr<Value> message(JSONReader::Read(msg, false)); |   47   scoped_ptr<Value> message(JSONReader::Read(msg, false)); | 
|   46   if (!message->IsType(Value::TYPE_LIST)) { |   48   if (!message->IsType(Value::TYPE_LIST)) { | 
|   47     NOTREACHED();  // The RPC protocol has changed :( |   49     NOTREACHED();  // The RPC protocol has changed :( | 
|   48     return; |   50     return; | 
|   49   } |   51   } | 
|   50   ListValue* list_msg = static_cast<ListValue*>(message.get()); |   52   ListValue* list_msg = static_cast<ListValue*>(message.get()); | 
|   51   std::string class_name; |  | 
|   52   list_msg->GetString(0, &class_name); |  | 
|   53   std::string message_name; |  | 
|   54   list_msg->GetString(1, &message_name); |  | 
|   55   if (class_name == kDebuggerAgentDelegate && message_name == kDebuggerOutput) { |   53   if (class_name == kDebuggerAgentDelegate && message_name == kDebuggerOutput) { | 
|   56     std::string str; |   54     std::string str; | 
|   57     list_msg->GetString(2, &str); |   55     list_msg->GetString(0, &str); | 
|   58     DebuggerOutput(str); |   56     DebuggerOutput(str); | 
|   59   } else if (class_name == kToolsAgentDelegate && |   57   } else if (class_name == kToolsAgentDelegate && | 
|   60              message_name == kFrameNavigate) { |   58              message_name == kFrameNavigate) { | 
|   61     std::string url; |   59     std::string url; | 
|   62     list_msg->GetString(2, &url); |   60     list_msg->GetString(0, &url); | 
|   63     FrameNavigate(url); |   61     FrameNavigate(url); | 
|   64   } |   62   } | 
|   65 } |   63 } | 
|   66  |   64  | 
|   67 void DevToolsClientHostImpl::DebuggerOutput(const std::string& msg) { |   65 void DevToolsClientHostImpl::DebuggerOutput(const std::string& msg) { | 
|   68   service_->DebuggerOutput(id_, msg); |   66   service_->DebuggerOutput(id_, msg); | 
|   69 } |   67 } | 
|   70  |   68  | 
|   71 void DevToolsClientHostImpl::FrameNavigate(const std::string& url) { |   69 void DevToolsClientHostImpl::FrameNavigate(const std::string& url) { | 
|   72   service_->FrameNavigate(id_, url); |   70   service_->FrameNavigate(id_, url); | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  110   return client_host; |  108   return client_host; | 
|  111 } |  109 } | 
|  112  |  110  | 
|  113 void InspectableTabProxy::OnRemoteDebuggerDetached() { |  111 void InspectableTabProxy::OnRemoteDebuggerDetached() { | 
|  114   while (id_to_client_host_map_.size() > 0) { |  112   while (id_to_client_host_map_.size() > 0) { | 
|  115     IdToClientHostMap::iterator it = id_to_client_host_map_.begin(); |  113     IdToClientHostMap::iterator it = id_to_client_host_map_.begin(); | 
|  116     it->second->debugger_remote_service()->DetachFromTab(IntToString(it->first), |  114     it->second->debugger_remote_service()->DetachFromTab(IntToString(it->first), | 
|  117                                                          NULL); |  115                                                          NULL); | 
|  118   } |  116   } | 
|  119 } |  117 } | 
| OLD | NEW |