| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/devtools_client.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/message_loop.h" | |
| 9 #include "base/utf_string_conversions.h" | |
| 10 #include "content/common/devtools_messages.h" | |
| 11 #include "content/public/common/content_switches.h" | |
| 12 #include "content/renderer/render_thread_impl.h" | |
| 13 #include "content/renderer/render_view_impl.h" | |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsFrontend.h
" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin
t.h" | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | |
| 17 #include "ui/base/ui_base_switches.h" | |
| 18 | |
| 19 using WebKit::WebDevToolsFrontend; | |
| 20 using WebKit::WebString; | |
| 21 | |
| 22 namespace content { | |
| 23 | |
| 24 DevToolsClient::DevToolsClient(RenderViewImpl* render_view) | |
| 25 : RenderViewObserver(render_view) { | |
| 26 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 27 web_tools_frontend_.reset( | |
| 28 WebDevToolsFrontend::create( | |
| 29 render_view->webview(), | |
| 30 this, | |
| 31 ASCIIToUTF16(command_line.GetSwitchValueASCII(switches::kLang)))); | |
| 32 } | |
| 33 | |
| 34 DevToolsClient::~DevToolsClient() { | |
| 35 } | |
| 36 | |
| 37 bool DevToolsClient::OnMessageReceived(const IPC::Message& message) { | |
| 38 DCHECK(RenderThreadImpl::current()); | |
| 39 | |
| 40 bool handled = true; | |
| 41 IPC_BEGIN_MESSAGE_MAP(DevToolsClient, message) | |
| 42 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, | |
| 43 OnDispatchOnInspectorFrontend) | |
| 44 IPC_MESSAGE_UNHANDLED(handled = false); | |
| 45 IPC_END_MESSAGE_MAP() | |
| 46 | |
| 47 return handled; | |
| 48 } | |
| 49 | |
| 50 void DevToolsClient::sendMessageToBackend(const WebString& message) { | |
| 51 Send(new DevToolsAgentMsg_DispatchOnInspectorBackend(routing_id(), | |
| 52 message.utf8())); | |
| 53 } | |
| 54 | |
| 55 void DevToolsClient::activateWindow() { | |
| 56 Send(new DevToolsHostMsg_ActivateWindow(routing_id())); | |
| 57 } | |
| 58 | |
| 59 void DevToolsClient::closeWindow() { | |
| 60 Send(new DevToolsHostMsg_CloseWindow(routing_id())); | |
| 61 } | |
| 62 | |
| 63 void DevToolsClient::moveWindowBy(const WebKit::WebFloatPoint& offset) { | |
| 64 Send(new DevToolsHostMsg_MoveWindow(routing_id(), offset.x, offset.y)); | |
| 65 } | |
| 66 | |
| 67 void DevToolsClient::requestSetDockSide(const WebKit::WebString& side) { | |
| 68 Send(new DevToolsHostMsg_RequestSetDockSide(routing_id(), side.utf8())); | |
| 69 } | |
| 70 | |
| 71 void DevToolsClient::openInNewTab(const WebKit::WebString& url) { | |
| 72 Send(new DevToolsHostMsg_OpenInNewTab(routing_id(), | |
| 73 url.utf8())); | |
| 74 } | |
| 75 | |
| 76 void DevToolsClient::save(const WebKit::WebString& url, | |
| 77 const WebKit::WebString& content, | |
| 78 bool save_as) { | |
| 79 Send(new DevToolsHostMsg_Save(routing_id(), | |
| 80 url.utf8(), | |
| 81 content.utf8(), | |
| 82 save_as)); | |
| 83 } | |
| 84 | |
| 85 void DevToolsClient::append(const WebKit::WebString& url, | |
| 86 const WebKit::WebString& content) { | |
| 87 Send(new DevToolsHostMsg_Append(routing_id(), | |
| 88 url.utf8(), | |
| 89 content.utf8())); | |
| 90 } | |
| 91 | |
| 92 void DevToolsClient::OnDispatchOnInspectorFrontend(const std::string& message) { | |
| 93 web_tools_frontend_->dispatchOnInspectorFrontend( | |
| 94 WebString::fromUTF8(message)); | |
| 95 } | |
| 96 | |
| 97 } // namespace content | |
| OLD | NEW |