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
;
25 class DevToolsProtocolHandlerImpl
;
27 class RenderViewHostImpl
;
29 #if defined(OS_ANDROID)
30 class PowerSaveBlockerImpl
;
34 namespace dom
{ class DOMHandler
; }
35 namespace input
{ class InputHandler
; }
36 namespace network
{ class NetworkHandler
; }
37 namespace page
{ class PageHandler
; }
38 namespace power
{ class PowerHandler
; }
39 namespace tracing
{ class TracingHandler
; }
42 class CONTENT_EXPORT RenderViewDevToolsAgentHost
43 : public IPCDevToolsAgentHost
,
44 private WebContentsObserver
,
45 public NotificationObserver
{
47 static void OnCancelPendingNavigation(RenderViewHost
* pending
,
48 RenderViewHost
* current
);
50 RenderViewDevToolsAgentHost(RenderViewHost
*);
52 void SynchronousSwapCompositorFrame(
53 const cc::CompositorFrameMetadata
& frame_metadata
);
55 // DevTooolsAgentHost overrides.
56 void DisconnectWebContents() override
;
57 void ConnectWebContents(WebContents
* web_contents
) override
;
58 WebContents
* GetWebContents() override
;
59 Type
GetType() override
;
60 std::string
GetTitle() override
;
61 GURL
GetURL() override
;
62 bool Activate() override
;
63 bool Close() override
;
66 friend class DevToolsAgentHost
;
67 ~RenderViewDevToolsAgentHost() override
;
69 // IPCDevToolsAgentHost overrides.
70 void DispatchProtocolMessage(const std::string
& message
) override
;
71 void SendMessageToAgent(IPC::Message
* msg
) override
;
72 void OnClientAttached() override
;
73 void OnClientDetached() override
;
75 // WebContentsObserver overrides.
76 void AboutToNavigateRenderView(RenderViewHost
* dest_rvh
) override
;
77 void RenderViewHostChanged(RenderViewHost
* old_host
,
78 RenderViewHost
* new_host
) override
;
79 void RenderViewDeleted(RenderViewHost
* rvh
) override
;
80 void RenderProcessGone(base::TerminationStatus status
) override
;
81 bool OnMessageReceived(const IPC::Message
& message
,
82 RenderFrameHost
* render_frame_host
) override
;
83 bool OnMessageReceived(const IPC::Message
& message
) override
;
84 void DidAttachInterstitialPage() override
;
85 void DidDetachInterstitialPage() override
;
86 void TitleWasSet(NavigationEntry
* entry
, bool explicit_set
) override
;
87 void NavigationEntryCommitted(
88 const LoadCommittedDetails
& load_details
) override
;
90 // NotificationObserver overrides:
91 void Observe(int type
,
92 const NotificationSource
& source
,
93 const NotificationDetails
& details
) override
;
95 void DisconnectRenderViewHost();
96 void ConnectRenderViewHost(RenderViewHost
* rvh
);
97 void ReattachToRenderViewHost(RenderViewHost
* rvh
);
99 bool DispatchIPCMessage(const IPC::Message
& message
);
101 void SetRenderViewHost(RenderViewHost
* rvh
);
102 void ClearRenderViewHost();
104 void RenderViewCrashed();
105 void OnSwapCompositorFrame(const IPC::Message
& message
);
106 bool OnSetTouchEventEmulationEnabled(const IPC::Message
& message
);
108 void OnDispatchOnInspectorFrontend(const std::string
& message
,
110 void DispatchOnInspectorFrontend(const std::string
& message
);
111 void OnSaveAgentRuntimeState(const std::string
& state
);
113 void ClientDetachedFromRenderer();
115 void InnerOnClientAttached();
116 void InnerClientDetachedFromRenderer();
118 RenderViewHostImpl
* render_view_host_
;
119 scoped_ptr
<devtools::dom::DOMHandler
> dom_handler_
;
120 scoped_ptr
<devtools::input::InputHandler
> input_handler_
;
121 scoped_ptr
<devtools::network::NetworkHandler
> network_handler_
;
122 scoped_ptr
<devtools::page::PageHandler
> page_handler_
;
123 scoped_ptr
<devtools::power::PowerHandler
> power_handler_
;
124 scoped_ptr
<devtools::tracing::TracingHandler
> tracing_handler_
;
125 scoped_ptr
<DevToolsProtocolHandlerImpl
> handler_impl_
;
126 #if defined(OS_ANDROID)
127 scoped_ptr
<PowerSaveBlockerImpl
> power_save_blocker_
;
130 NotificationRegistrar registrar_
;
133 DISALLOW_COPY_AND_ASSIGN(RenderViewDevToolsAgentHost
);
136 } // namespace content
138 #endif // CONTENT_BROWSER_DEVTOOLS_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_