| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/devtools/devtools_agent.h" | 5 #include "content/renderer/devtools/devtools_agent.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // Called on the Renderer thread. | 82 // Called on the Renderer thread. |
| 83 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { | 83 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { |
| 84 bool handled = true; | 84 bool handled = true; |
| 85 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) | 85 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) |
| 86 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) | 86 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) |
| 87 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) | 87 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) |
| 88 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) | 88 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) |
| 89 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, | 89 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, |
| 90 OnDispatchOnInspectorBackend) | 90 OnDispatchOnInspectorBackend) |
| 91 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) | 91 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) |
| 92 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_AddMessageToConsole, | |
| 93 OnAddMessageToConsole) | |
| 94 IPC_MESSAGE_HANDLER(DevToolsMsg_SetupDevToolsClient, OnSetupDevToolsClient) | 92 IPC_MESSAGE_HANDLER(DevToolsMsg_SetupDevToolsClient, OnSetupDevToolsClient) |
| 95 IPC_MESSAGE_UNHANDLED(handled = false) | 93 IPC_MESSAGE_UNHANDLED(handled = false) |
| 96 IPC_END_MESSAGE_MAP() | 94 IPC_END_MESSAGE_MAP() |
| 97 | 95 |
| 98 if (message.type() == FrameMsg_Navigate::ID) | 96 if (message.type() == FrameMsg_Navigate::ID) |
| 99 ContinueProgram(); // Don't want to swallow the message. | 97 ContinueProgram(); // Don't want to swallow the message. |
| 100 | 98 |
| 101 return handled; | 99 return handled; |
| 102 } | 100 } |
| 103 | 101 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 void DevToolsAgent::OnInspectElement( | 221 void DevToolsAgent::OnInspectElement( |
| 224 const std::string& host_id, int x, int y) { | 222 const std::string& host_id, int x, int y) { |
| 225 WebDevToolsAgent* web_agent = GetWebAgent(); | 223 WebDevToolsAgent* web_agent = GetWebAgent(); |
| 226 if (web_agent) { | 224 if (web_agent) { |
| 227 web_agent->attach(WebString::fromUTF8(host_id)); | 225 web_agent->attach(WebString::fromUTF8(host_id)); |
| 228 web_agent->inspectElementAt(WebPoint(x, y)); | 226 web_agent->inspectElementAt(WebPoint(x, y)); |
| 229 is_attached_ = true; | 227 is_attached_ = true; |
| 230 } | 228 } |
| 231 } | 229 } |
| 232 | 230 |
| 233 void DevToolsAgent::OnAddMessageToConsole(ConsoleMessageLevel level, | 231 void DevToolsAgent::AddMessageToConsole(ConsoleMessageLevel level, |
| 234 const std::string& message) { | 232 const std::string& message) { |
| 235 WebLocalFrame* web_frame = frame_->GetWebFrame(); | 233 WebLocalFrame* web_frame = frame_->GetWebFrame(); |
| 236 if (!web_frame) | 234 if (!web_frame) |
| 237 return; | 235 return; |
| 238 | 236 |
| 239 WebConsoleMessage::Level target_level = WebConsoleMessage::LevelLog; | 237 WebConsoleMessage::Level target_level = WebConsoleMessage::LevelLog; |
| 240 switch (level) { | 238 switch (level) { |
| 241 case CONSOLE_MESSAGE_LEVEL_DEBUG: | 239 case CONSOLE_MESSAGE_LEVEL_DEBUG: |
| 242 target_level = WebConsoleMessage::LevelDebug; | 240 target_level = WebConsoleMessage::LevelDebug; |
| 243 break; | 241 break; |
| 244 case CONSOLE_MESSAGE_LEVEL_LOG: | 242 case CONSOLE_MESSAGE_LEVEL_LOG: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 273 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { | 271 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { |
| 274 WebLocalFrame* web_frame = frame_->GetWebFrame(); | 272 WebLocalFrame* web_frame = frame_->GetWebFrame(); |
| 275 return web_frame ? web_frame->devToolsAgent() : nullptr; | 273 return web_frame ? web_frame->devToolsAgent() : nullptr; |
| 276 } | 274 } |
| 277 | 275 |
| 278 bool DevToolsAgent::IsAttached() { | 276 bool DevToolsAgent::IsAttached() { |
| 279 return is_attached_; | 277 return is_attached_; |
| 280 } | 278 } |
| 281 | 279 |
| 282 } // namespace content | 280 } // namespace content |
| OLD | NEW |