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
3 // found in the LICENSE file.
5 #include "content/browser/devtools/devtools_frontend_host_impl.h"
7 #include "content/common/devtools_messages.h"
8 #include "content/public/browser/navigation_entry.h"
9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/web_contents.h"
15 DevToolsFrontendHost
* DevToolsFrontendHost::Create(
16 RenderFrameHost
* frontend_main_frame
,
17 DevToolsFrontendHost::Delegate
* delegate
) {
18 return new DevToolsFrontendHostImpl(frontend_main_frame
, delegate
);
21 DevToolsFrontendHostImpl::DevToolsFrontendHostImpl(
22 RenderFrameHost
* frontend_main_frame
,
23 DevToolsFrontendHost::Delegate
* delegate
)
24 : WebContentsObserver(
25 WebContents::FromRenderFrameHost(frontend_main_frame
)),
27 frontend_main_frame
->Send(
28 new DevToolsMsg_SetupDevToolsClient(frontend_main_frame
->GetRoutingID()));
31 DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() {
34 bool DevToolsFrontendHostImpl::OnMessageReceived(
35 const IPC::Message
& message
,
36 RenderFrameHost
* render_frame_host
) {
37 if (render_frame_host
!= web_contents()->GetMainFrame())
40 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHostImpl
, message
)
41 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend
,
42 OnDispatchOnInspectorBackend
)
43 IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder
,
45 IPC_MESSAGE_UNHANDLED(handled
= false)
50 void DevToolsFrontendHostImpl::OnDispatchOnInspectorBackend(
51 const std::string
& message
) {
52 delegate_
->HandleMessageFromDevToolsFrontendToBackend(message
);
55 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder(
56 const std::string
& message
) {
57 delegate_
->HandleMessageFromDevToolsFrontend(message
);
60 } // namespace content