[DevTools] Close DevTools when corresponding frame is deleted.
[chromium-blink-merge.git] / content / browser / devtools / render_frame_devtools_agent_host.h
blob15e6dcd36835341e0f6aaa096f5165713d4bbbe8
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_
8 #include <map>
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"
17 namespace cc {
18 class CompositorFrameMetadata;
21 namespace content {
23 class BrowserContext;
24 class DevToolsFrameTraceRecorder;
25 class DevToolsProtocolHandler;
26 class RenderFrameHostImpl;
28 #if defined(OS_ANDROID)
29 class PowerSaveBlockerImpl;
30 #endif
32 namespace devtools {
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 DevToolsAgentHostImpl,
46 private WebContentsObserver {
47 public:
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;
68 bool DispatchProtocolMessage(const std::string& message) override;
70 private:
71 friend class DevToolsAgentHost;
72 explicit RenderFrameDevToolsAgentHost(RenderFrameHostImpl*);
73 ~RenderFrameDevToolsAgentHost() override;
75 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor(
76 RenderFrameHostImpl* host);
77 static void AppendAgentHostForFrameIfApplicable(
78 DevToolsAgentHost::List* result,
79 RenderFrameHost* host);
81 // DevToolsAgentHostImpl overrides.
82 void Attach() override;
83 void Detach() override;
84 void InspectElement(int x, int y) override;
86 // WebContentsObserver overrides.
87 void AboutToNavigateRenderFrame(RenderFrameHost* old_host,
88 RenderFrameHost* new_host) override;
89 void RenderFrameHostChanged(RenderFrameHost* old_host,
90 RenderFrameHost* new_host) override;
91 void FrameDeleted(RenderFrameHost* rfh) override;
92 void RenderFrameDeleted(RenderFrameHost* rfh) override;
93 void RenderProcessGone(base::TerminationStatus status) override;
94 bool OnMessageReceived(const IPC::Message& message,
95 RenderFrameHost* render_frame_host) override;
96 bool OnMessageReceived(const IPC::Message& message) override;
97 void DidAttachInterstitialPage() override;
98 void DidDetachInterstitialPage() override;
99 void DidCommitProvisionalLoadForFrame(
100 RenderFrameHost* render_frame_host,
101 const GURL& url,
102 ui::PageTransition transition_type) override;
103 void DidFailProvisionalLoad(
104 RenderFrameHost* render_frame_host,
105 const GURL& validated_url,
106 int error_code,
107 const base::string16& error_description) override;
109 void SetPending(RenderFrameHostImpl* host);
110 void CommitPending();
111 void DiscardPending();
112 void UpdateProtocolHandlers(RenderFrameHostImpl* host);
114 bool IsChildFrame();
116 void OnClientAttached();
117 void OnClientDetached();
119 void RenderFrameCrashed();
120 void OnSwapCompositorFrame(const IPC::Message& message);
121 void DestroyOnRenderFrameGone();
123 class FrameHostHolder;
125 scoped_ptr<FrameHostHolder> current_;
126 scoped_ptr<FrameHostHolder> pending_;
128 scoped_ptr<devtools::dom::DOMHandler> dom_handler_;
129 scoped_ptr<devtools::input::InputHandler> input_handler_;
130 scoped_ptr<devtools::inspector::InspectorHandler> inspector_handler_;
131 scoped_ptr<devtools::network::NetworkHandler> network_handler_;
132 scoped_ptr<devtools::page::PageHandler> page_handler_;
133 scoped_ptr<devtools::power::PowerHandler> power_handler_;
134 scoped_ptr<devtools::service_worker::ServiceWorkerHandler>
135 service_worker_handler_;
136 scoped_ptr<devtools::tracing::TracingHandler> tracing_handler_;
137 scoped_ptr<devtools::emulation::EmulationHandler> emulation_handler_;
138 scoped_ptr<DevToolsFrameTraceRecorder> frame_trace_recorder_;
139 #if defined(OS_ANDROID)
140 scoped_ptr<PowerSaveBlockerImpl> power_save_blocker_;
141 #endif
142 scoped_ptr<DevToolsProtocolHandler> protocol_handler_;
144 DISALLOW_COPY_AND_ASSIGN(RenderFrameDevToolsAgentHost);
147 } // namespace content
149 #endif // CONTENT_BROWSER_DEVTOOLS_RENDER_FRAME_DEVTOOLS_AGENT_HOST_H_