| 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/browser/debugger/devtools_frontend_host.h" |  | 
| 6 |  | 
| 7 #include "content/browser/debugger/devtools_manager_impl.h" |  | 
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" |  | 
| 9 #include "content/browser/web_contents/web_contents_impl.h" |  | 
| 10 #include "content/common/devtools_messages.h" |  | 
| 11 #include "content/public/browser/devtools_client_host.h" |  | 
| 12 #include "content/public/browser/devtools_frontend_host_delegate.h" |  | 
| 13 |  | 
| 14 namespace content { |  | 
| 15 |  | 
| 16 // static |  | 
| 17 DevToolsClientHost* DevToolsClientHost::CreateDevToolsFrontendHost( |  | 
| 18     WebContents* client_web_contents, |  | 
| 19     DevToolsFrontendHostDelegate* delegate) { |  | 
| 20   return new DevToolsFrontendHost( |  | 
| 21       static_cast<WebContentsImpl*>(client_web_contents), delegate); |  | 
| 22 } |  | 
| 23 |  | 
| 24 // static |  | 
| 25 void DevToolsClientHost::SetupDevToolsFrontendClient( |  | 
| 26     RenderViewHost* frontend_rvh) { |  | 
| 27   frontend_rvh->Send(new DevToolsMsg_SetupDevToolsClient( |  | 
| 28       frontend_rvh->GetRoutingID())); |  | 
| 29 } |  | 
| 30 |  | 
| 31 DevToolsFrontendHost::DevToolsFrontendHost( |  | 
| 32     WebContentsImpl* web_contents, |  | 
| 33     DevToolsFrontendHostDelegate* delegate) |  | 
| 34     : RenderViewHostObserver(web_contents->GetRenderViewHost()), |  | 
| 35       web_contents_(web_contents), |  | 
| 36       delegate_(delegate) { |  | 
| 37 } |  | 
| 38 |  | 
| 39 DevToolsFrontendHost::~DevToolsFrontendHost() { |  | 
| 40   DevToolsManager::GetInstance()->ClientHostClosing(this); |  | 
| 41 } |  | 
| 42 |  | 
| 43 void DevToolsFrontendHost::DispatchOnInspectorFrontend( |  | 
| 44     const std::string& message) { |  | 
| 45   RenderViewHostImpl* target_host = |  | 
| 46       static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); |  | 
| 47   target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( |  | 
| 48       target_host->GetRoutingID(), |  | 
| 49       message)); |  | 
| 50 } |  | 
| 51 |  | 
| 52 void DevToolsFrontendHost::InspectedContentsClosing() { |  | 
| 53   delegate_->InspectedContentsClosing(); |  | 
| 54 } |  | 
| 55 |  | 
| 56 void DevToolsFrontendHost::FrameNavigating(const std::string& url) { |  | 
| 57   delegate_->FrameNavigating(url); |  | 
| 58 } |  | 
| 59 |  | 
| 60 void DevToolsFrontendHost::ContentsReplaced(WebContents* new_contents) { |  | 
| 61   delegate_->ContentsReplaced(new_contents); |  | 
| 62 } |  | 
| 63 |  | 
| 64 void DevToolsFrontendHost::ReplacedWithAnotherClient() { |  | 
| 65 } |  | 
| 66 |  | 
| 67 bool DevToolsFrontendHost::OnMessageReceived( |  | 
| 68     const IPC::Message& message) { |  | 
| 69   bool handled = true; |  | 
| 70   IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHost, message) |  | 
| 71     IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, |  | 
| 72                         OnDispatchOnInspectorBackend) |  | 
| 73     IPC_MESSAGE_HANDLER(DevToolsHostMsg_ActivateWindow, OnActivateWindow) |  | 
| 74     IPC_MESSAGE_HANDLER(DevToolsHostMsg_CloseWindow, OnCloseWindow) |  | 
| 75     IPC_MESSAGE_HANDLER(DevToolsHostMsg_MoveWindow, OnMoveWindow) |  | 
| 76     IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestSetDockSide, |  | 
| 77                         OnRequestSetDockSide) |  | 
| 78     IPC_MESSAGE_HANDLER(DevToolsHostMsg_OpenInNewTab, OnOpenInNewTab) |  | 
| 79     IPC_MESSAGE_HANDLER(DevToolsHostMsg_Save, OnSave) |  | 
| 80     IPC_MESSAGE_HANDLER(DevToolsHostMsg_Append, OnAppend) |  | 
| 81     IPC_MESSAGE_UNHANDLED(handled = false) |  | 
| 82   IPC_END_MESSAGE_MAP() |  | 
| 83   return handled; |  | 
| 84 } |  | 
| 85 |  | 
| 86 void DevToolsFrontendHost::OnDispatchOnInspectorBackend( |  | 
| 87     const std::string& message) { |  | 
| 88   DevToolsManagerImpl::GetInstance()->DispatchOnInspectorBackend(this, message); |  | 
| 89 //  delegate_->DispatchOnInspectorBackend(message); |  | 
| 90 } |  | 
| 91 |  | 
| 92 void DevToolsFrontendHost::OnActivateWindow() { |  | 
| 93   delegate_->ActivateWindow(); |  | 
| 94 } |  | 
| 95 |  | 
| 96 void DevToolsFrontendHost::OnCloseWindow() { |  | 
| 97   delegate_->CloseWindow(); |  | 
| 98 } |  | 
| 99 |  | 
| 100 void DevToolsFrontendHost::OnMoveWindow(int x, int y) { |  | 
| 101   delegate_->MoveWindow(x, y); |  | 
| 102 } |  | 
| 103 |  | 
| 104 void DevToolsFrontendHost::OnOpenInNewTab(const std::string& url) { |  | 
| 105   delegate_->OpenInNewTab(url); |  | 
| 106 } |  | 
| 107 |  | 
| 108 void DevToolsFrontendHost::OnSave( |  | 
| 109     const std::string& url, |  | 
| 110     const std::string& content, |  | 
| 111     bool save_as) { |  | 
| 112   delegate_->SaveToFile(url, content, save_as); |  | 
| 113 } |  | 
| 114 |  | 
| 115 void DevToolsFrontendHost::OnAppend( |  | 
| 116     const std::string& url, |  | 
| 117     const std::string& content) { |  | 
| 118   delegate_->AppendToFile(url, content); |  | 
| 119 } |  | 
| 120 |  | 
| 121 void DevToolsFrontendHost::OnRequestSetDockSide(const std::string& side) { |  | 
| 122   delegate_->SetDockSide(side); |  | 
| 123 } |  | 
| 124 |  | 
| 125 }  // namespace content |  | 
| OLD | NEW | 
|---|