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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
9 #include "chrome/common/devtools_messages.h" | 9 #include "chrome/common/devtools_messages.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 web_agent->didNavigate(); | 71 web_agent->didNavigate(); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 // Called on the Renderer thread. | 75 // Called on the Renderer thread. |
76 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { | 76 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { |
77 bool handled = true; | 77 bool handled = true; |
78 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) | 78 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) |
79 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) | 79 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) |
80 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) | 80 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) |
| 81 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_FrontendLoaded, OnFrontendLoaded) |
81 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, | 82 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, |
82 OnDispatchOnInspectorBackend) | 83 OnDispatchOnInspectorBackend) |
83 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) | 84 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) |
84 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_SetApuAgentEnabled, | 85 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_SetApuAgentEnabled, |
85 OnSetApuAgentEnabled) | 86 OnSetApuAgentEnabled) |
86 IPC_MESSAGE_UNHANDLED(handled = false) | 87 IPC_MESSAGE_UNHANDLED(handled = false) |
87 IPC_END_MESSAGE_MAP() | 88 IPC_END_MESSAGE_MAP() |
88 return handled; | 89 return handled; |
89 } | 90 } |
90 | 91 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 web_agent->attach(); | 171 web_agent->attach(); |
171 for (std::vector<std::string>::const_iterator it = runtime_features.begin(); | 172 for (std::vector<std::string>::const_iterator it = runtime_features.begin(); |
172 it != runtime_features.end(); ++it) { | 173 it != runtime_features.end(); ++it) { |
173 web_agent->setRuntimeFeatureEnabled(WebString::fromUTF8(*it), true); | 174 web_agent->setRuntimeFeatureEnabled(WebString::fromUTF8(*it), true); |
174 } | 175 } |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 void DevToolsAgent::OnDetach() { | 179 void DevToolsAgent::OnDetach() { |
179 WebDevToolsAgent* web_agent = GetWebAgent(); | 180 WebDevToolsAgent* web_agent = GetWebAgent(); |
180 if (web_agent) { | 181 if (web_agent) |
181 web_agent->detach(); | 182 web_agent->detach(); |
182 } | 183 } |
| 184 |
| 185 void DevToolsAgent::OnFrontendLoaded() { |
| 186 WebDevToolsAgent* web_agent = GetWebAgent(); |
| 187 if (web_agent) |
| 188 web_agent->frontendLoaded(); |
183 } | 189 } |
184 | 190 |
185 void DevToolsAgent::OnDispatchOnInspectorBackend(const std::string& message) { | 191 void DevToolsAgent::OnDispatchOnInspectorBackend(const std::string& message) { |
186 WebDevToolsAgent* web_agent = GetWebAgent(); | 192 WebDevToolsAgent* web_agent = GetWebAgent(); |
187 if (web_agent) | 193 if (web_agent) |
188 web_agent->dispatchOnInspectorBackend(WebString::fromUTF8(message)); | 194 web_agent->dispatchOnInspectorBackend(WebString::fromUTF8(message)); |
189 } | 195 } |
190 | 196 |
191 void DevToolsAgent::OnInspectElement(int x, int y) { | 197 void DevToolsAgent::OnInspectElement(int x, int y) { |
192 WebDevToolsAgent* web_agent = GetWebAgent(); | 198 WebDevToolsAgent* web_agent = GetWebAgent(); |
193 if (web_agent) { | 199 if (web_agent) { |
194 web_agent->attach(); | 200 web_agent->attach(); |
195 web_agent->inspectElementAt(WebPoint(x, y)); | 201 web_agent->inspectElementAt(WebPoint(x, y)); |
196 } | 202 } |
197 } | 203 } |
198 | 204 |
199 void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) { | 205 void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) { |
200 WebDevToolsAgent* web_agent = GetWebAgent(); | 206 WebDevToolsAgent* web_agent = GetWebAgent(); |
201 if (web_agent) | 207 if (web_agent) |
202 web_agent->setRuntimeFeatureEnabled("apu-agent", enabled); | 208 web_agent->setRuntimeFeatureEnabled("apu-agent", enabled); |
203 } | 209 } |
204 | 210 |
205 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { | 211 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { |
206 WebView* web_view = render_view_->webview(); | 212 WebView* web_view = render_view_->webview(); |
207 if (!web_view) | 213 if (!web_view) |
208 return NULL; | 214 return NULL; |
209 return web_view->devToolsAgent(); | 215 return web_view->devToolsAgent(); |
210 } | 216 } |
OLD | NEW |