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/web_contents_observer.h"
18 class CompositorFrameMetadata
;
24 class DevToolsFrameTraceRecorder
;
25 class RenderFrameHost
;
26 class RenderFrameHostImpl
;
28 #if defined(OS_ANDROID)
29 class PowerSaveBlockerImpl
;
33 namespace dom
{ class DOMHandler
; }
34 namespace emulation
{ class EmulationHandler
; }
35 namespace input
{ class InputHandler
; }
36 namespace inspector
{ class InspectorHandler
; }
37 namespace network
{ class NetworkHandler
; }
38 namespace page
{ class PageHandler
; }
39 namespace power
{ class PowerHandler
; }
40 namespace service_worker
{ class ServiceWorkerHandler
; }
41 namespace tracing
{ class TracingHandler
; }
44 class CONTENT_EXPORT RenderFrameDevToolsAgentHost
45 : public IPCDevToolsAgentHost
,
46 private WebContentsObserver
{
48 static void AddAllAgentHosts(DevToolsAgentHost::List
* result
);
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 static scoped_refptr
<DevToolsAgentHost
> GetOrCreateFor(RenderFrameHost
* host
);
75 static void AppendAgentHostForFrameIfApplicable(
76 DevToolsAgentHost::List
* result
,
77 RenderFrameHost
* host
);
79 // IPCDevToolsAgentHost overrides.
80 void SendMessageToAgent(IPC::Message
* msg
) override
;
81 void OnClientAttached(bool reattached
) override
;
82 void OnClientDetached() override
;
84 // WebContentsObserver overrides.
85 void AboutToNavigateRenderFrame(RenderFrameHost
* old_host
,
86 RenderFrameHost
* new_host
) override
;
87 void RenderFrameHostChanged(RenderFrameHost
* old_host
,
88 RenderFrameHost
* new_host
) override
;
89 void FrameDeleted(RenderFrameHost
* rfh
) override
;
90 void RenderProcessGone(base::TerminationStatus status
) override
;
91 bool OnMessageReceived(const IPC::Message
& message
,
92 RenderFrameHost
* render_frame_host
) override
;
93 bool OnMessageReceived(const IPC::Message
& message
) override
;
94 void DidAttachInterstitialPage() override
;
95 void DidDetachInterstitialPage() override
;
96 void DidCommitProvisionalLoadForFrame(
97 RenderFrameHost
* render_frame_host
,
99 ui::PageTransition transition_type
) 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
);
114 void ClientDetachedFromRenderer();
116 void InnerOnClientAttached();
117 void InnerClientDetachedFromRenderer();
120 void DestroyOnRenderFrameGone();
122 RenderFrameHostImpl
* render_frame_host_
;
123 scoped_ptr
<devtools::dom::DOMHandler
> dom_handler_
;
124 scoped_ptr
<devtools::input::InputHandler
> input_handler_
;
125 scoped_ptr
<devtools::inspector::InspectorHandler
> inspector_handler_
;
126 scoped_ptr
<devtools::network::NetworkHandler
> network_handler_
;
127 scoped_ptr
<devtools::page::PageHandler
> page_handler_
;
128 scoped_ptr
<devtools::power::PowerHandler
> power_handler_
;
129 scoped_ptr
<devtools::service_worker::ServiceWorkerHandler
>
130 service_worker_handler_
;
131 scoped_ptr
<devtools::tracing::TracingHandler
> tracing_handler_
;
132 scoped_ptr
<devtools::emulation::EmulationHandler
> emulation_handler_
;
133 scoped_ptr
<DevToolsFrameTraceRecorder
> frame_trace_recorder_
;
134 #if defined(OS_ANDROID)
135 scoped_ptr
<PowerSaveBlockerImpl
> power_save_blocker_
;
139 DISALLOW_COPY_AND_ASSIGN(RenderFrameDevToolsAgentHost
);
142 } // namespace content
144 #endif // CONTENT_BROWSER_DEVTOOLS_RENDER_FRAME_DEVTOOLS_AGENT_HOST_H_