Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: content/browser/devtools/devtools_frontend_host_impl.cc

Issue 427143003: [DevTools] Move DevToolsClientHost functionality out of DevToolsFrontendHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/devtools/devtools_frontend_host.h" 5 #include "content/browser/devtools/devtools_frontend_host_impl.h"
6 6
7 #include "content/browser/devtools/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" 7 #include "content/common/devtools_messages.h"
11 #include "content/public/browser/devtools_client_host.h" 8 #include "content/public/browser/navigation_entry.h"
12 #include "content/public/browser/devtools_frontend_host_delegate.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h"
13 11
14 namespace content { 12 namespace content {
15 13
16 // static 14 // static
17 DevToolsClientHost* DevToolsClientHost::CreateDevToolsFrontendHost( 15 DevToolsFrontendHost* DevToolsFrontendHost::Create(
18 WebContents* client_web_contents, 16 RenderViewHost* frontend_rvh,
19 DevToolsFrontendHostDelegate* delegate) { 17 DevToolsFrontendHost::Delegate* delegate) {
20 return new DevToolsFrontendHost( 18 return new DevToolsFrontendHostImpl(frontend_rvh, delegate);
21 static_cast<WebContentsImpl*>(client_web_contents), delegate);
22 } 19 }
23 20
24 // static 21 DevToolsFrontendHostImpl::DevToolsFrontendHostImpl(
25 void DevToolsClientHost::SetupDevToolsFrontendClient( 22 RenderViewHost* frontend_rvh,
26 RenderViewHost* frontend_rvh) { 23 DevToolsFrontendHost::Delegate* delegate)
24 : WebContentsObserver(WebContents::FromRenderViewHost(frontend_rvh)),
25 delegate_(delegate) {
27 frontend_rvh->Send(new DevToolsMsg_SetupDevToolsClient( 26 frontend_rvh->Send(new DevToolsMsg_SetupDevToolsClient(
28 frontend_rvh->GetRoutingID())); 27 frontend_rvh->GetRoutingID()));
29 } 28 }
30 29
31 DevToolsFrontendHost::DevToolsFrontendHost( 30 DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() {
32 WebContentsImpl* web_contents,
33 DevToolsFrontendHostDelegate* delegate)
34 : WebContentsObserver(web_contents),
35 delegate_(delegate) {
36 } 31 }
37 32
38 DevToolsFrontendHost::~DevToolsFrontendHost() { 33 void DevToolsFrontendHostImpl::DispatchOnDevToolsFrontend(
39 DevToolsManager::GetInstance()->ClientHostClosing(this);
40 }
41
42 void DevToolsFrontendHost::DispatchOnInspectorFrontend(
43 const std::string& message) { 34 const std::string& message) {
44 if (!web_contents()) 35 if (!web_contents())
45 return; 36 return;
46 RenderViewHostImpl* target_host = 37 RenderViewHost* target_host = web_contents()->GetRenderViewHost();
47 static_cast<RenderViewHostImpl*>(web_contents()->GetRenderViewHost());
48 target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( 38 target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(
49 target_host->GetRoutingID(), 39 target_host->GetRoutingID(),
50 message)); 40 message));
51 } 41 }
52 42
53 void DevToolsFrontendHost::InspectedContentsClosing() { 43 bool DevToolsFrontendHostImpl::OnMessageReceived(
54 delegate_->InspectedContentsClosing();
55 }
56
57 void DevToolsFrontendHost::ReplacedWithAnotherClient() {
58 }
59
60 bool DevToolsFrontendHost::OnMessageReceived(
61 const IPC::Message& message) { 44 const IPC::Message& message) {
62 bool handled = true; 45 bool handled = true;
63 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHost, message) 46 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHostImpl, message)
64 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, 47 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
65 OnDispatchOnInspectorBackend) 48 OnDispatchOnInspectorBackend)
66 IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder, 49 IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder,
67 OnDispatchOnEmbedder) 50 OnDispatchOnEmbedder)
68 IPC_MESSAGE_UNHANDLED(handled = false) 51 IPC_MESSAGE_UNHANDLED(handled = false)
69 IPC_END_MESSAGE_MAP() 52 IPC_END_MESSAGE_MAP()
70 return handled; 53 return handled;
71 } 54 }
72 55
73 void DevToolsFrontendHost::RenderProcessGone( 56 void DevToolsFrontendHostImpl::OnDispatchOnInspectorBackend(
74 base::TerminationStatus status) { 57 const std::string& message) {
75 switch(status) { 58 delegate_->HandleMessageFromDevToolsFrontendToBackend(message);
76 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:
77 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED:
78 case base::TERMINATION_STATUS_PROCESS_CRASHED:
79 DevToolsManager::GetInstance()->ClientHostClosing(this);
80 break;
81 default:
82 break;
83 }
84 } 59 }
85 60
86 void DevToolsFrontendHost::OnDispatchOnInspectorBackend( 61 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder(
87 const std::string& message) { 62 const std::string& message) {
88 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorBackend(this, message); 63 delegate_->HandleMessageFromDevToolsFrontend(message);
89 }
90
91 void DevToolsFrontendHost::OnDispatchOnEmbedder(
92 const std::string& message) {
93 delegate_->DispatchOnEmbedder(message);
94 } 64 }
95 65
96 } // namespace content 66 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698