| 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_filter.h" | 5 #include "chrome/renderer/devtools_agent_filter.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "chrome/common/devtools_messages.h" | 8 #include "chrome/common/devtools_messages.h" |
| 9 #include "chrome/renderer/devtools_agent.h" | 9 #include "chrome/renderer/devtools_agent.h" |
| 10 #include "chrome/renderer/plugin_channel_host.h" | 10 #include "chrome/renderer/plugin_channel_host.h" |
| 11 #include "chrome/renderer/render_view.h" | 11 #include "chrome/renderer/render_view.h" |
| 12 #include "webkit/api/public/WebDevToolsAgent.h" |
| 12 #include "webkit/api/public/WebString.h" | 13 #include "webkit/api/public/WebString.h" |
| 13 #include "webkit/glue/webdevtoolsagent.h" | |
| 14 | 14 |
| 15 using WebKit::WebDevToolsAgent; |
| 15 using WebKit::WebString; | 16 using WebKit::WebString; |
| 16 | 17 |
| 17 // static | 18 // static |
| 18 void DevToolsAgentFilter::DispatchMessageLoop() { | 19 void DevToolsAgentFilter::DispatchMessageLoop() { |
| 19 MessageLoop* current = MessageLoop::current(); | 20 MessageLoop* current = MessageLoop::current(); |
| 20 bool old_state = current->NestableTasksAllowed(); | 21 bool old_state = current->NestableTasksAllowed(); |
| 21 current->SetNestableTasksAllowed(true); | 22 current->SetNestableTasksAllowed(true); |
| 22 current->RunAllPending(); | 23 current->RunAllPending(); |
| 23 current->SetNestableTasksAllowed(old_state); | 24 current->SetNestableTasksAllowed(old_state); |
| 24 } | 25 } |
| 25 | 26 |
| 26 DevToolsAgentFilter::DevToolsAgentFilter() | 27 DevToolsAgentFilter::DevToolsAgentFilter() |
| 27 : current_routing_id_(0) { | 28 : current_routing_id_(0) { |
| 28 WebDevToolsAgent::SetMessageLoopDispatchHandler( | 29 WebDevToolsAgent::setMessageLoopDispatchHandler( |
| 29 &DevToolsAgentFilter::DispatchMessageLoop); | 30 &DevToolsAgentFilter::DispatchMessageLoop); |
| 30 } | 31 } |
| 31 | 32 |
| 32 DevToolsAgentFilter::~DevToolsAgentFilter() { | 33 DevToolsAgentFilter::~DevToolsAgentFilter() { |
| 33 } | 34 } |
| 34 | 35 |
| 35 bool DevToolsAgentFilter::OnMessageReceived(const IPC::Message& message) { | 36 bool DevToolsAgentFilter::OnMessageReceived(const IPC::Message& message) { |
| 36 if (message.type() == DevToolsAgentMsg_DebuggerCommand::ID) { | 37 if (message.type() == DevToolsAgentMsg_DebuggerCommand::ID) { |
| 37 // Dispatch command directly from IO. | 38 // Dispatch command directly from IO. |
| 38 bool handled = true; | 39 bool handled = true; |
| 39 current_routing_id_ = message.routing_id(); | 40 current_routing_id_ = message.routing_id(); |
| 40 IPC_BEGIN_MESSAGE_MAP(DevToolsAgentFilter, message) | 41 IPC_BEGIN_MESSAGE_MAP(DevToolsAgentFilter, message) |
| 41 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerCommand, OnDebuggerCommand) | 42 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerCommand, OnDebuggerCommand) |
| 42 IPC_MESSAGE_UNHANDLED(handled = false) | 43 IPC_MESSAGE_UNHANDLED(handled = false) |
| 43 IPC_END_MESSAGE_MAP() | 44 IPC_END_MESSAGE_MAP() |
| 44 return handled; | 45 return handled; |
| 45 } else { | 46 } else { |
| 46 return false; | 47 return false; |
| 47 } | 48 } |
| 48 } | 49 } |
| 49 | 50 |
| 50 void DevToolsAgentFilter::OnDebuggerCommand(const std::string& command) { | 51 void DevToolsAgentFilter::OnDebuggerCommand(const std::string& command) { |
| 51 WebDevToolsAgent::ExecuteDebuggerCommand( | 52 WebDevToolsAgent::executeDebuggerCommand( |
| 52 WebString::fromUTF8(command), current_routing_id_); | 53 WebString::fromUTF8(command), current_routing_id_); |
| 53 } | 54 } |
| OLD | NEW |