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.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_RENDER_FRAME_DEVTOOLS_AGENT_HOST_H_
6 #define CONTENT_BROWSER_DEVTOOLS_RENDER_FRAME_DEVTOOLS_AGENT_HOST_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/browser/devtools/ipc_devtools_agent_host.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/browser/web_contents_observer.h"
20 class CompositorFrameMetadata
;
26 class DevToolsFrameTraceRecorder
;
27 class DevToolsProtocolHandler
;
28 class RenderFrameHost
;
29 class RenderFrameHostImpl
;
31 #if defined(OS_ANDROID)
32 class PowerSaveBlockerImpl
;
36 namespace dom
{ class DOMHandler
; }
37 namespace input
{ class InputHandler
; }
38 namespace inspector
{ class InspectorHandler
; }
39 namespace network
{ class NetworkHandler
; }
40 namespace page
{ class PageHandler
; }
41 namespace power
{ class PowerHandler
; }
42 namespace tracing
{ class TracingHandler
; }
45 class CONTENT_EXPORT RenderFrameDevToolsAgentHost
46 : public IPCDevToolsAgentHost
,
47 private WebContentsObserver
,
48 public NotificationObserver
{
50 static void OnCancelPendingNavigation(RenderFrameHost
* pending
,
51 RenderFrameHost
* current
);
53 void SynchronousSwapCompositorFrame(
54 const cc::CompositorFrameMetadata
& frame_metadata
);
56 bool HasRenderFrameHost(RenderFrameHost
* host
);
58 // DevTooolsAgentHost overrides.
59 void DisconnectWebContents() override
;
60 void ConnectWebContents(WebContents
* web_contents
) override
;
61 BrowserContext
* GetBrowserContext() override
;
62 WebContents
* GetWebContents() override
;
63 Type
GetType() override
;
64 std::string
GetTitle() override
;
65 GURL
GetURL() override
;
66 bool Activate() override
;
67 bool Close() override
;
70 friend class DevToolsAgentHost
;
71 explicit RenderFrameDevToolsAgentHost(RenderFrameHost
*);
72 ~RenderFrameDevToolsAgentHost() override
;
74 // IPCDevToolsAgentHost overrides.
75 void DispatchProtocolMessage(const std::string
& message
) override
;
76 void SendMessageToAgent(IPC::Message
* msg
) override
;
77 void OnClientAttached() override
;
78 void OnClientDetached() override
;
80 // WebContentsObserver overrides.
81 void AboutToNavigateRenderFrame(RenderFrameHost
* old_host
,
82 RenderFrameHost
* new_host
) override
;
83 void RenderFrameHostChanged(RenderFrameHost
* old_host
,
84 RenderFrameHost
* new_host
) override
;
85 void FrameDeleted(RenderFrameHost
* rfh
) override
;
86 void RenderProcessGone(base::TerminationStatus status
) override
;
87 bool OnMessageReceived(const IPC::Message
& message
,
88 RenderFrameHost
* render_frame_host
) override
;
89 bool OnMessageReceived(const IPC::Message
& message
) override
;
90 void DidAttachInterstitialPage() override
;
91 void DidDetachInterstitialPage() override
;
92 void TitleWasSet(NavigationEntry
* entry
, bool explicit_set
) override
;
93 void NavigationEntryCommitted(
94 const LoadCommittedDetails
& load_details
) override
;
96 // NotificationObserver overrides:
97 void Observe(int type
,
98 const NotificationSource
& source
,
99 const NotificationDetails
& details
) override
;
101 void DisconnectRenderFrameHost();
102 void ConnectRenderFrameHost(RenderFrameHost
* rvh
);
103 void ReattachToRenderFrameHost(RenderFrameHost
* rvh
);
105 void SetRenderFrameHost(RenderFrameHost
* rvh
);
106 void ClearRenderFrameHost();
108 void RenderFrameCrashed();
109 void OnSwapCompositorFrame(const IPC::Message
& message
);
110 bool OnSetTouchEventEmulationEnabled(const IPC::Message
& message
);
112 void OnDispatchOnInspectorFrontend(const DevToolsMessageChunk
& message
);
113 void DispatchOnInspectorFrontend(const std::string
& message
);
115 void ClientDetachedFromRenderer();
117 void InnerOnClientAttached();
118 void InnerClientDetachedFromRenderer();
120 RenderFrameHostImpl
* render_frame_host_
;
121 scoped_ptr
<devtools::dom::DOMHandler
> dom_handler_
;
122 scoped_ptr
<devtools::input::InputHandler
> input_handler_
;
123 scoped_ptr
<devtools::inspector::InspectorHandler
> inspector_handler_
;
124 scoped_ptr
<devtools::network::NetworkHandler
> network_handler_
;
125 scoped_ptr
<devtools::page::PageHandler
> page_handler_
;
126 scoped_ptr
<devtools::power::PowerHandler
> power_handler_
;
127 scoped_ptr
<devtools::tracing::TracingHandler
> tracing_handler_
;
128 scoped_ptr
<DevToolsProtocolHandler
> protocol_handler_
;
129 scoped_ptr
<DevToolsFrameTraceRecorder
> frame_trace_recorder_
;
130 #if defined(OS_ANDROID)
131 scoped_ptr
<PowerSaveBlockerImpl
> power_save_blocker_
;
133 NotificationRegistrar registrar_
;
136 DISALLOW_COPY_AND_ASSIGN(RenderFrameDevToolsAgentHost
);
139 } // namespace content
141 #endif // CONTENT_BROWSER_DEVTOOLS_RENDER_FRAME_DEVTOOLS_AGENT_HOST_H_