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/renderer/devtools_agent.h" | 5 #include "chrome/renderer/devtools_agent.h" |
6 | 6 |
7 #include "chrome/common/devtools_messages.h" | 7 #include "chrome/common/devtools_messages.h" |
8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
9 #include "chrome/renderer/render_view.h" | 9 #include "chrome/renderer/render_view.h" |
10 #include "webkit/glue/webdevtoolsagent.h" | 10 #include "webkit/glue/webdevtoolsagent.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) | 28 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) |
29 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) | 29 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) |
30 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) | 30 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) |
31 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_RpcMessage, OnRpcMessage) | 31 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_RpcMessage, OnRpcMessage) |
32 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) | 32 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) |
33 IPC_MESSAGE_UNHANDLED(handled = false) | 33 IPC_MESSAGE_UNHANDLED(handled = false) |
34 IPC_END_MESSAGE_MAP() | 34 IPC_END_MESSAGE_MAP() |
35 return handled; | 35 return handled; |
36 } | 36 } |
37 | 37 |
38 void DevToolsAgent::SendMessageToClient(const std::string& raw_msg) { | 38 void DevToolsAgent::SendMessageToClient(const std::string& class_name, |
| 39 const std::string& method_name, |
| 40 const std::string& raw_msg) { |
39 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( | 41 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( |
40 routing_id_, | 42 routing_id_, |
41 DevToolsClientMsg_RpcMessage(raw_msg)); | 43 DevToolsClientMsg_RpcMessage(class_name, method_name, raw_msg)); |
42 view_->Send(m); | 44 view_->Send(m); |
43 } | 45 } |
44 | 46 |
45 int DevToolsAgent::GetHostId() { | 47 int DevToolsAgent::GetHostId() { |
46 return routing_id_; | 48 return routing_id_; |
47 } | 49 } |
48 | 50 |
49 void DevToolsAgent::ForceRepaint() { | 51 void DevToolsAgent::ForceRepaint() { |
50 view_->GenerateFullRepaint(); | 52 view_->GenerateFullRepaint(); |
51 } | 53 } |
(...skipping 15 matching lines...) Expand all Loading... |
67 } | 69 } |
68 } | 70 } |
69 | 71 |
70 void DevToolsAgent::OnDetach() { | 72 void DevToolsAgent::OnDetach() { |
71 WebDevToolsAgent* web_agent = GetWebAgent(); | 73 WebDevToolsAgent* web_agent = GetWebAgent(); |
72 if (web_agent) { | 74 if (web_agent) { |
73 web_agent->Detach(); | 75 web_agent->Detach(); |
74 } | 76 } |
75 } | 77 } |
76 | 78 |
77 void DevToolsAgent::OnRpcMessage(const std::string& raw_msg) { | 79 void DevToolsAgent::OnRpcMessage(const std::string& class_name, |
| 80 const std::string& method_name, |
| 81 const std::string& raw_msg) { |
78 WebDevToolsAgent* web_agent = GetWebAgent(); | 82 WebDevToolsAgent* web_agent = GetWebAgent(); |
79 if (web_agent) { | 83 if (web_agent) { |
80 web_agent->DispatchMessageFromClient(raw_msg); | 84 web_agent->DispatchMessageFromClient(class_name, method_name, raw_msg); |
81 } | 85 } |
82 } | 86 } |
83 | 87 |
84 void DevToolsAgent::OnInspectElement(int x, int y) { | 88 void DevToolsAgent::OnInspectElement(int x, int y) { |
85 WebDevToolsAgent* web_agent = GetWebAgent(); | 89 WebDevToolsAgent* web_agent = GetWebAgent(); |
86 if (web_agent) { | 90 if (web_agent) { |
87 web_agent->Attach(); | 91 web_agent->Attach(); |
88 web_agent->InspectElement(x, y); | 92 web_agent->InspectElement(x, y); |
89 } | 93 } |
90 } | 94 } |
91 | 95 |
92 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { | 96 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { |
93 WebView* web_view = view_->webview(); | 97 WebView* web_view = view_->webview(); |
94 if (!web_view) | 98 if (!web_view) |
95 return NULL; | 99 return NULL; |
96 return web_view->GetWebDevToolsAgent(); | 100 return web_view->GetWebDevToolsAgent(); |
97 } | 101 } |
OLD | NEW |