OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_impl.h" | 5 #include "content/browser/devtools/devtools_frontend_host_impl.h" |
6 | 6 |
7 #include "content/common/devtools_messages.h" | 7 #include "content/common/devtools_messages.h" |
8 #include "content/public/browser/navigation_entry.h" | 8 #include "content/public/browser/navigation_entry.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 // static | 14 // static |
15 DevToolsFrontendHost* DevToolsFrontendHost::Create( | 15 DevToolsFrontendHost* DevToolsFrontendHost::Create( |
16 RenderViewHost* frontend_rvh, | 16 WebContents* frontend_web_contents, |
17 DevToolsFrontendHost::Delegate* delegate) { | 17 DevToolsFrontendHost::Delegate* delegate) { |
18 return new DevToolsFrontendHostImpl(frontend_rvh, delegate); | 18 return new DevToolsFrontendHostImpl(frontend_web_contents, delegate); |
19 } | 19 } |
20 | 20 |
21 DevToolsFrontendHostImpl::DevToolsFrontendHostImpl( | 21 DevToolsFrontendHostImpl::DevToolsFrontendHostImpl( |
22 RenderViewHost* frontend_rvh, | 22 WebContents* frontend_web_contents, |
23 DevToolsFrontendHost::Delegate* delegate) | 23 DevToolsFrontendHost::Delegate* delegate) |
24 : WebContentsObserver(WebContents::FromRenderViewHost(frontend_rvh)), | 24 : WebContentsObserver(frontend_web_contents), delegate_(delegate) { |
25 delegate_(delegate) { | 25 RenderFrameHost* main_frame_host = web_contents()->GetMainFrame(); |
26 frontend_rvh->Send(new DevToolsMsg_SetupDevToolsClient( | 26 main_frame_host->Send( |
27 frontend_rvh->GetRoutingID())); | 27 new DevToolsMsg_SetupDevToolsClient(main_frame_host->GetRoutingID())); |
28 } | 28 } |
29 | 29 |
30 DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() { | 30 DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() { |
31 } | 31 } |
32 | 32 |
33 bool DevToolsFrontendHostImpl::OnMessageReceived( | 33 bool DevToolsFrontendHostImpl::OnMessageReceived( |
34 const IPC::Message& message) { | 34 const IPC::Message& message, |
35 RenderFrameHost* render_frame_host) { | |
Charlie Reis
2014/11/24 17:46:26
Would it make sense to return early from this if r
yurys
2014/11/25 09:47:20
Yes, that makes sense to me. Added an early return
| |
35 bool handled = true; | 36 bool handled = true; |
36 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHostImpl, message) | 37 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHostImpl, message) |
37 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, | 38 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, |
38 OnDispatchOnInspectorBackend) | 39 OnDispatchOnInspectorBackend) |
39 IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder, | 40 IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder, |
40 OnDispatchOnEmbedder) | 41 OnDispatchOnEmbedder) |
41 IPC_MESSAGE_UNHANDLED(handled = false) | 42 IPC_MESSAGE_UNHANDLED(handled = false) |
42 IPC_END_MESSAGE_MAP() | 43 IPC_END_MESSAGE_MAP() |
43 return handled; | 44 return handled; |
44 } | 45 } |
45 | 46 |
46 void DevToolsFrontendHostImpl::OnDispatchOnInspectorBackend( | 47 void DevToolsFrontendHostImpl::OnDispatchOnInspectorBackend( |
47 const std::string& message) { | 48 const std::string& message) { |
48 delegate_->HandleMessageFromDevToolsFrontendToBackend(message); | 49 delegate_->HandleMessageFromDevToolsFrontendToBackend(message); |
49 } | 50 } |
50 | 51 |
51 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder( | 52 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder( |
52 const std::string& message) { | 53 const std::string& message) { |
53 delegate_->HandleMessageFromDevToolsFrontend(message); | 54 delegate_->HandleMessageFromDevToolsFrontend(message); |
54 } | 55 } |
55 | 56 |
56 } // namespace content | 57 } // namespace content |
OLD | NEW |