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/devtools_agent_host_impl.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 DevToolsProtocolHandler
;
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 io
{ class IOHandler
; }
38 namespace network
{ class NetworkHandler
; }
39 namespace page
{ class PageHandler
; }
40 namespace power
{ class PowerHandler
; }
41 namespace security
{ class SecurityHandler
; }
42 namespace service_worker
{ class ServiceWorkerHandler
; }
43 namespace tracing
{ class TracingHandler
; }
46 class CONTENT_EXPORT RenderFrameDevToolsAgentHost
47 : public DevToolsAgentHostImpl
,
48 private WebContentsObserver
{
50 static void AddAllAgentHosts(DevToolsAgentHost::List
* result
);
52 static void OnCancelPendingNavigation(RenderFrameHost
* pending
,
53 RenderFrameHost
* current
);
55 void SynchronousSwapCompositorFrame(
56 const cc::CompositorFrameMetadata
& frame_metadata
);
58 bool HasRenderFrameHost(RenderFrameHost
* host
);
60 // DevTooolsAgentHost overrides.
61 void DisconnectWebContents() override
;
62 void ConnectWebContents(WebContents
* web_contents
) override
;
63 BrowserContext
* GetBrowserContext() override
;
64 WebContents
* GetWebContents() override
;
65 Type
GetType() override
;
66 std::string
GetTitle() override
;
67 GURL
GetURL() override
;
68 bool Activate() override
;
69 bool Close() override
;
70 bool DispatchProtocolMessage(const std::string
& message
) override
;
73 friend class DevToolsAgentHost
;
74 explicit RenderFrameDevToolsAgentHost(RenderFrameHostImpl
*);
75 ~RenderFrameDevToolsAgentHost() override
;
77 static scoped_refptr
<DevToolsAgentHost
> GetOrCreateFor(
78 RenderFrameHostImpl
* host
);
79 static void AppendAgentHostForFrameIfApplicable(
80 DevToolsAgentHost::List
* result
,
81 RenderFrameHost
* host
);
83 // DevToolsAgentHostImpl overrides.
84 void Attach() override
;
85 void Detach() override
;
86 void InspectElement(int x
, int y
) override
;
88 // WebContentsObserver overrides.
89 void AboutToNavigateRenderFrame(RenderFrameHost
* old_host
,
90 RenderFrameHost
* new_host
) override
;
91 void RenderFrameHostChanged(RenderFrameHost
* old_host
,
92 RenderFrameHost
* new_host
) override
;
93 void FrameDeleted(RenderFrameHost
* rfh
) override
;
94 void RenderFrameDeleted(RenderFrameHost
* rfh
) override
;
95 void RenderProcessGone(base::TerminationStatus status
) override
;
96 bool OnMessageReceived(const IPC::Message
& message
,
97 RenderFrameHost
* render_frame_host
) override
;
98 bool OnMessageReceived(const IPC::Message
& message
) override
;
99 void DidAttachInterstitialPage() override
;
100 void DidDetachInterstitialPage() override
;
101 void DidCommitProvisionalLoadForFrame(
102 RenderFrameHost
* render_frame_host
,
104 ui::PageTransition transition_type
) override
;
105 void DidFailProvisionalLoad(
106 RenderFrameHost
* render_frame_host
,
107 const GURL
& validated_url
,
109 const base::string16
& error_description
,
110 bool was_ignored_by_handler
) override
;
112 void SetPending(RenderFrameHostImpl
* host
);
113 void CommitPending();
114 void DiscardPending();
115 void UpdateProtocolHandlers(RenderFrameHostImpl
* host
);
119 void OnClientAttached();
120 void OnClientDetached();
122 void RenderFrameCrashed();
123 void OnSwapCompositorFrame(const IPC::Message
& message
);
124 void DestroyOnRenderFrameGone();
126 class FrameHostHolder
;
128 scoped_ptr
<FrameHostHolder
> current_
;
129 scoped_ptr
<FrameHostHolder
> pending_
;
130 // Stores per-host state between DisconnectWebContents and ConnectWebContents.
131 scoped_ptr
<FrameHostHolder
> disconnected_
;
133 scoped_ptr
<devtools::dom::DOMHandler
> dom_handler_
;
134 scoped_ptr
<devtools::input::InputHandler
> input_handler_
;
135 scoped_ptr
<devtools::inspector::InspectorHandler
> inspector_handler_
;
136 scoped_ptr
<devtools::io::IOHandler
> io_handler_
;
137 scoped_ptr
<devtools::network::NetworkHandler
> network_handler_
;
138 scoped_ptr
<devtools::page::PageHandler
> page_handler_
;
139 scoped_ptr
<devtools::power::PowerHandler
> power_handler_
;
140 scoped_ptr
<devtools::security::SecurityHandler
> security_handler_
;
141 scoped_ptr
<devtools::service_worker::ServiceWorkerHandler
>
142 service_worker_handler_
;
143 scoped_ptr
<devtools::tracing::TracingHandler
> tracing_handler_
;
144 scoped_ptr
<devtools::emulation::EmulationHandler
> emulation_handler_
;
145 scoped_ptr
<DevToolsFrameTraceRecorder
> frame_trace_recorder_
;
146 #if defined(OS_ANDROID)
147 scoped_ptr
<PowerSaveBlockerImpl
> power_save_blocker_
;
149 scoped_ptr
<DevToolsProtocolHandler
> protocol_handler_
;
150 bool current_frame_crashed_
;
152 DISALLOW_COPY_AND_ASSIGN(RenderFrameDevToolsAgentHost
);
155 } // namespace content
157 #endif // CONTENT_BROWSER_DEVTOOLS_RENDER_FRAME_DEVTOOLS_AGENT_HOST_H_