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_VIEW_DEVTOOLS_AGENT_HOST_H_
6 #define CONTENT_BROWSER_DEVTOOLS_RENDER_VIEW_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 DevToolsProtocolHandler
;
28 class RenderViewHostImpl
;
30 #if defined(OS_ANDROID)
31 class PowerSaveBlockerImpl
;
35 namespace dom
{ class DOMHandler
; }
36 namespace input
{ class InputHandler
; }
37 namespace inspector
{ class InspectorHandler
; }
38 namespace network
{ class NetworkHandler
; }
39 namespace page
{ class PageHandler
; }
40 namespace power
{ class PowerHandler
; }
41 namespace tracing
{ class TracingHandler
; }
44 class CONTENT_EXPORT RenderViewDevToolsAgentHost
45 : public IPCDevToolsAgentHost
,
46 private WebContentsObserver
,
47 public NotificationObserver
{
49 static void OnCancelPendingNavigation(RenderViewHost
* pending
,
50 RenderViewHost
* current
);
52 RenderViewDevToolsAgentHost(RenderViewHost
*);
54 void SynchronousSwapCompositorFrame(
55 const cc::CompositorFrameMetadata
& frame_metadata
);
57 // DevTooolsAgentHost overrides.
58 void DisconnectWebContents() override
;
59 void ConnectWebContents(WebContents
* web_contents
) override
;
60 BrowserContext
* GetBrowserContext() override
;
61 WebContents
* GetWebContents() override
;
62 Type
GetType() override
;
63 std::string
GetTitle() override
;
64 GURL
GetURL() override
;
65 bool Activate() override
;
66 bool Close() override
;
69 friend class DevToolsAgentHost
;
70 ~RenderViewDevToolsAgentHost() override
;
72 // IPCDevToolsAgentHost overrides.
73 void DispatchProtocolMessage(const std::string
& message
) override
;
74 void SendMessageToAgent(IPC::Message
* msg
) override
;
75 void OnClientAttached() override
;
76 void OnClientDetached() override
;
78 // WebContentsObserver overrides.
79 void AboutToNavigateRenderFrame(RenderFrameHost
* render_frame_host
) override
;
80 void RenderViewHostChanged(RenderViewHost
* old_host
,
81 RenderViewHost
* new_host
) override
;
82 void RenderViewDeleted(RenderViewHost
* rvh
) override
;
83 void RenderProcessGone(base::TerminationStatus status
) override
;
84 bool OnMessageReceived(const IPC::Message
& message
,
85 RenderFrameHost
* render_frame_host
) override
;
86 bool OnMessageReceived(const IPC::Message
& message
) override
;
87 void DidAttachInterstitialPage() override
;
88 void DidDetachInterstitialPage() override
;
89 void TitleWasSet(NavigationEntry
* entry
, bool explicit_set
) override
;
90 void NavigationEntryCommitted(
91 const LoadCommittedDetails
& load_details
) override
;
93 // NotificationObserver overrides:
94 void Observe(int type
,
95 const NotificationSource
& source
,
96 const NotificationDetails
& details
) override
;
98 void DisconnectRenderViewHost();
99 void ConnectRenderViewHost(RenderViewHost
* rvh
);
100 void ReattachToRenderViewHost(RenderViewHost
* rvh
);
102 void SetRenderViewHost(RenderViewHost
* rvh
);
103 void ClearRenderViewHost();
105 void RenderViewCrashed();
106 void OnSwapCompositorFrame(const IPC::Message
& message
);
107 bool OnSetTouchEventEmulationEnabled(const IPC::Message
& message
);
109 void OnDispatchOnInspectorFrontend(const std::string
& message
,
111 void DispatchOnInspectorFrontend(const std::string
& message
);
112 void OnSaveAgentRuntimeState(const std::string
& state
);
114 void ClientDetachedFromRenderer();
116 void InnerOnClientAttached();
117 void InnerClientDetachedFromRenderer();
119 RenderViewHostImpl
* render_view_host_
;
120 scoped_ptr
<devtools::dom::DOMHandler
> dom_handler_
;
121 scoped_ptr
<devtools::input::InputHandler
> input_handler_
;
122 scoped_ptr
<devtools::inspector::InspectorHandler
> inspector_handler_
;
123 scoped_ptr
<devtools::network::NetworkHandler
> network_handler_
;
124 scoped_ptr
<devtools::page::PageHandler
> page_handler_
;
125 scoped_ptr
<devtools::power::PowerHandler
> power_handler_
;
126 scoped_ptr
<devtools::tracing::TracingHandler
> tracing_handler_
;
127 scoped_ptr
<DevToolsProtocolHandler
> protocol_handler_
;
128 #if defined(OS_ANDROID)
129 scoped_ptr
<PowerSaveBlockerImpl
> power_save_blocker_
;
132 NotificationRegistrar registrar_
;
135 DISALLOW_COPY_AND_ASSIGN(RenderViewDevToolsAgentHost
);
138 } // namespace content
140 #endif // CONTENT_BROWSER_DEVTOOLS_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_