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

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: 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
(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/devtools/devtools_frontend_host_impl.h"
6
7 #include "content/common/devtools_messages.h"
8 #include "content/public/browser/navigation_entry.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h"
11
12 namespace content {
13
14 // static
15 DevToolsFrontendHost* DevToolsFrontendHost::Create(
16 WebContents* frontend_web_contents,
17 DevToolsFrontendHost::Delegate* delegate) {
18 return new DevToolsFrontendHostImpl(frontend_web_contents, delegate);
19 }
20
21 DevToolsFrontendHostImpl::DevToolsFrontendHostImpl(
22 WebContents* web_contents,
23 DevToolsFrontendHost::Delegate* delegate)
24 : WebContentsObserver(web_contents),
25 delegate_(delegate) {
26 if (web_contents->GetController().GetVisibleEntry()) {
27 GURL url = web_contents->GetController().GetVisibleEntry()->GetURL();
28 if (delegate_->ShouldSetupDevToolsFrontendForUrl(url)) {
pfeldman 2014/07/31 11:47:25 Why would you do that here? You already do this un
dgozman 2014/07/31 13:05:31 As discussed offline, this check is left in embedd
29 RenderViewHost* rvh = web_contents->GetRenderViewHost();
30 rvh->Send(new DevToolsMsg_SetupDevToolsClient(
31 rvh->GetRoutingID()));
32 }
33 }
34 }
35
36 DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() {
37 }
38
39 void DevToolsFrontendHostImpl::DispatchOnDevToolsFrontend(
40 const std::string& message) {
41 if (!web_contents())
42 return;
43 RenderViewHost* target_host = web_contents()->GetRenderViewHost();
44 target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(
45 target_host->GetRoutingID(),
46 message));
47 }
48
49 bool DevToolsFrontendHostImpl::OnMessageReceived(
50 const IPC::Message& message) {
51 bool handled = true;
52 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHostImpl, message)
53 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
54 OnDispatchOnInspectorBackend)
55 IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder,
56 OnDispatchOnEmbedder)
57 IPC_MESSAGE_UNHANDLED(handled = false)
58 IPC_END_MESSAGE_MAP()
59 return handled;
60 }
61
62 void DevToolsFrontendHostImpl::AboutToNavigateRenderView(
63 RenderViewHost* render_view_host) {
64 if (delegate_->ShouldSetupDevToolsFrontendForUrl(
65 web_contents()->GetController().GetVisibleEntry()->GetURL())) {
66 render_view_host->Send(new DevToolsMsg_SetupDevToolsClient(
67 render_view_host->GetRoutingID()));
68 }
69 }
70
71 void DevToolsFrontendHostImpl::OnDispatchOnInspectorBackend(
72 const std::string& message) {
73 delegate_->HandleMessageFromDevToolsFrontendToBackend(message);
74 }
75
76 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder(
77 const std::string& message) {
78 delegate_->HandleMessageFromDevToolsFrontend(message);
79 }
80
81 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698