1 // Copyright (c) 2011 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 "chrome/browser/debugger/devtools_handler.h" 6 7 #include "chrome/browser/debugger/devtools_manager.h" 8 #include "chrome/common/devtools_messages.h" 9 10 DevToolsHandler::DevToolsHandler(RenderViewHost* render_view_host) 11 : RenderViewHostObserver(render_view_host) { 12 } 13 14 DevToolsHandler::~DevToolsHandler() { 15 } 16 17 bool DevToolsHandler::OnMessageReceived(const IPC::Message& message) { 18 bool handled = true; 19 IPC_BEGIN_MESSAGE_MAP(DevToolsHandler, message) 20 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ForwardToAgent, OnForwardToAgent) 21 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ForwardToClient, OnForwardToClient) 22 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ActivateWindow, OnActivateWindow) 23 IPC_MESSAGE_HANDLER(DevToolsHostMsg_CloseWindow, OnCloseWindow) 24 IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestDockWindow, OnRequestDockWindow) 25 IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestUndockWindow, 26 OnRequestUndockWindow) 27 IPC_MESSAGE_HANDLER(DevToolsHostMsg_RuntimePropertyChanged, 28 OnRuntimePropertyChanged) 29 IPC_MESSAGE_UNHANDLED(handled = false) 30 IPC_END_MESSAGE_MAP() 31 return handled; 32 } 33 34 void DevToolsHandler::OnForwardToAgent(const IPC::Message& message) { 35 DevToolsManager::GetInstance()->ForwardToDevToolsAgent( 36 render_view_host(), message); 37 } 38 39 void DevToolsHandler::OnForwardToClient(const IPC::Message& message) { 40 DevToolsManager::GetInstance()->ForwardToDevToolsClient( 41 render_view_host(), message); 42 } 43 44 void DevToolsHandler::OnActivateWindow() { 45 DevToolsManager::GetInstance()->ActivateWindow(render_view_host()); 46 } 47 48 void DevToolsHandler::OnCloseWindow() { 49 DevToolsManager::GetInstance()->CloseWindow(render_view_host()); 50 } 51 52 void DevToolsHandler::OnRequestDockWindow() { 53 DevToolsManager::GetInstance()->RequestDockWindow(render_view_host()); 54 } 55 56 void DevToolsHandler::OnRequestUndockWindow() { 57 DevToolsManager::GetInstance()->RequestUndockWindow(render_view_host()); 58 } 59 60 void DevToolsHandler::OnRuntimePropertyChanged(const std::string& name, 61 const std::string& value) { 62 DevToolsManager::GetInstance()->RuntimePropertyChanged( 63 render_view_host(), name, value); 64 } 65