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_view_host.h"
10 #include "content/public/browser/web_contents.h"
15 DevToolsFrontendHost
* DevToolsFrontendHost::Create(
16 RenderViewHost
* frontend_rvh
,
17 DevToolsFrontendHost::Delegate
* delegate
) {
18 return new DevToolsFrontendHostImpl(frontend_rvh
, delegate
);
21 DevToolsFrontendHostImpl::DevToolsFrontendHostImpl(
22 RenderViewHost
* frontend_rvh
,
23 DevToolsFrontendHost::Delegate
* delegate
)
24 : WebContentsObserver(WebContents::FromRenderViewHost(frontend_rvh
)),
26 frontend_rvh
->Send(new DevToolsMsg_SetupDevToolsClient(
27 frontend_rvh
->GetRoutingID()));
30 DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() {
33 bool DevToolsFrontendHostImpl::OnMessageReceived(
34 const IPC::Message
& message
) {
36 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHostImpl
, message
)
37 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend
,
38 OnDispatchOnInspectorBackend
)
39 IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder
,
41 IPC_MESSAGE_UNHANDLED(handled
= false)
46 void DevToolsFrontendHostImpl::OnDispatchOnInspectorBackend(
47 const std::string
& message
) {
48 delegate_
->HandleMessageFromDevToolsFrontendToBackend(message
);
51 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder(
52 const std::string
& message
) {
53 delegate_
->HandleMessageFromDevToolsFrontend(message
);
56 } // namespace content