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/api/public/WebString.h" |
10 #include "webkit/glue/webdevtoolsagent.h" | 11 #include "webkit/glue/webdevtoolsagent.h" |
11 | 12 |
| 13 using WebKit::WebString; |
| 14 |
12 // static | 15 // static |
13 std::map<int, DevToolsAgent*> DevToolsAgent::agent_for_routing_id_; | 16 std::map<int, DevToolsAgent*> DevToolsAgent::agent_for_routing_id_; |
14 | 17 |
15 DevToolsAgent::DevToolsAgent(int routing_id, RenderView* view) | 18 DevToolsAgent::DevToolsAgent(int routing_id, RenderView* view) |
16 : routing_id_(routing_id), | 19 : routing_id_(routing_id), |
17 view_(view) { | 20 view_(view) { |
18 agent_for_routing_id_[routing_id] = this; | 21 agent_for_routing_id_[routing_id] = this; |
19 } | 22 } |
20 | 23 |
21 DevToolsAgent::~DevToolsAgent() { | 24 DevToolsAgent::~DevToolsAgent() { |
(...skipping 15 matching lines...) Expand all Loading... |
37 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) | 40 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) |
38 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_RpcMessage, OnRpcMessage) | 41 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_RpcMessage, OnRpcMessage) |
39 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) | 42 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) |
40 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_SetApuAgentEnabled, | 43 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_SetApuAgentEnabled, |
41 OnSetApuAgentEnabled) | 44 OnSetApuAgentEnabled) |
42 IPC_MESSAGE_UNHANDLED(handled = false) | 45 IPC_MESSAGE_UNHANDLED(handled = false) |
43 IPC_END_MESSAGE_MAP() | 46 IPC_END_MESSAGE_MAP() |
44 return handled; | 47 return handled; |
45 } | 48 } |
46 | 49 |
47 void DevToolsAgent::SendMessageToClient(const std::string& class_name, | 50 void DevToolsAgent::SendMessageToClient(const WebKit::WebString& class_name, |
48 const std::string& method_name, | 51 const WebKit::WebString& method_name, |
49 const std::string& param1, | 52 const WebKit::WebString& param1, |
50 const std::string& param2, | 53 const WebKit::WebString& param2, |
51 const std::string& param3) { | 54 const WebKit::WebString& param3) { |
52 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( | 55 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( |
53 routing_id_, | 56 routing_id_, |
54 DevToolsClientMsg_RpcMessage(class_name, method_name, param1, param2, | 57 DevToolsClientMsg_RpcMessage( |
55 param3)); | 58 class_name.utf8(), |
| 59 method_name.utf8(), |
| 60 param1.utf8(), |
| 61 param2.utf8(), |
| 62 param3.utf8())); |
56 view_->Send(m); | 63 view_->Send(m); |
57 } | 64 } |
58 | 65 |
59 int DevToolsAgent::GetHostId() { | 66 int DevToolsAgent::GetHostId() { |
60 return routing_id_; | 67 return routing_id_; |
61 } | 68 } |
62 | 69 |
63 void DevToolsAgent::ForceRepaint() { | 70 void DevToolsAgent::ForceRepaint() { |
64 view_->GenerateFullRepaint(); | 71 view_->GenerateFullRepaint(); |
65 } | 72 } |
(...skipping 22 matching lines...) Expand all Loading... |
88 } | 95 } |
89 } | 96 } |
90 | 97 |
91 void DevToolsAgent::OnRpcMessage(const std::string& class_name, | 98 void DevToolsAgent::OnRpcMessage(const std::string& class_name, |
92 const std::string& method_name, | 99 const std::string& method_name, |
93 const std::string& param1, | 100 const std::string& param1, |
94 const std::string& param2, | 101 const std::string& param2, |
95 const std::string& param3) { | 102 const std::string& param3) { |
96 WebDevToolsAgent* web_agent = GetWebAgent(); | 103 WebDevToolsAgent* web_agent = GetWebAgent(); |
97 if (web_agent) { | 104 if (web_agent) { |
98 web_agent->DispatchMessageFromClient(class_name, method_name, param1, | 105 web_agent->DispatchMessageFromClient( |
99 param2, param3); | 106 WebString::fromUTF8(class_name), |
| 107 WebString::fromUTF8(method_name), |
| 108 WebString::fromUTF8(param1), |
| 109 WebString::fromUTF8(param2), |
| 110 WebString::fromUTF8(param3)); |
100 } | 111 } |
101 } | 112 } |
102 | 113 |
103 void DevToolsAgent::OnInspectElement(int x, int y) { | 114 void DevToolsAgent::OnInspectElement(int x, int y) { |
104 WebDevToolsAgent* web_agent = GetWebAgent(); | 115 WebDevToolsAgent* web_agent = GetWebAgent(); |
105 if (web_agent) { | 116 if (web_agent) { |
106 web_agent->Attach(); | 117 web_agent->Attach(); |
107 web_agent->InspectElement(x, y); | 118 web_agent->InspectElement(x, y); |
108 } | 119 } |
109 } | 120 } |
110 | 121 |
111 void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) { | 122 void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) { |
112 WebDevToolsAgent* web_agent = GetWebAgent(); | 123 WebDevToolsAgent* web_agent = GetWebAgent(); |
113 if (web_agent) { | 124 if (web_agent) { |
114 web_agent->SetApuAgentEnabled(enabled); | 125 web_agent->SetApuAgentEnabled(enabled); |
115 } | 126 } |
116 } | 127 } |
117 | 128 |
118 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { | 129 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { |
119 WebView* web_view = view_->webview(); | 130 WebView* web_view = view_->webview(); |
120 if (!web_view) | 131 if (!web_view) |
121 return NULL; | 132 return NULL; |
122 return web_view->GetWebDevToolsAgent(); | 133 return web_view->GetWebDevToolsAgent(); |
123 } | 134 } |
OLD | NEW |