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 DevToolsPowerHandler;
26 class DevToolsTracingHandler;
27 class RendererOverridesHandler;
30 #if defined(OS_ANDROID)
31 class PowerSaveBlockerImpl;
34 class CONTENT_EXPORT RenderViewDevToolsAgentHost
35 : public IPCDevToolsAgentHost,
36 private WebContentsObserver,
37 public NotificationObserver {
39 static void OnCancelPendingNavigation(RenderViewHost* pending,
40 RenderViewHost* current);
42 RenderViewDevToolsAgentHost(RenderViewHost*);
44 void SynchronousSwapCompositorFrame(
45 const cc::CompositorFrameMetadata& frame_metadata);
47 // DevTooolsAgentHost overrides.
48 virtual void DisconnectWebContents() OVERRIDE;
49 virtual void ConnectWebContents(WebContents* web_contents) OVERRIDE;
50 virtual WebContents* GetWebContents() OVERRIDE;
53 friend class DevToolsAgentHost;
54 virtual ~RenderViewDevToolsAgentHost();
56 // IPCDevToolsAgentHost overrides.
57 virtual void DispatchOnInspectorBackend(const std::string& message) OVERRIDE;
58 virtual void SendMessageToAgent(IPC::Message* msg) OVERRIDE;
59 virtual void OnClientAttached() OVERRIDE;
60 virtual void OnClientDetached() OVERRIDE;
62 // WebContentsObserver overrides.
63 virtual void AboutToNavigateRenderView(RenderViewHost* dest_rvh) OVERRIDE;
64 virtual void RenderViewHostChanged(RenderViewHost* old_host,
65 RenderViewHost* new_host) OVERRIDE;
66 virtual void RenderViewDeleted(RenderViewHost* rvh) OVERRIDE;
67 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
68 virtual bool OnMessageReceived(const IPC::Message& message,
69 RenderFrameHost* render_frame_host) OVERRIDE;
70 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
71 virtual void DidAttachInterstitialPage() OVERRIDE;
73 // NotificationObserver overrides:
74 virtual void Observe(int type,
75 const NotificationSource& source,
76 const NotificationDetails& details) OVERRIDE;
78 void DisconnectRenderViewHost();
79 void ConnectRenderViewHost(RenderViewHost* rvh);
80 void ReattachToRenderViewHost(RenderViewHost* rvh);
82 bool DispatchIPCMessage(const IPC::Message& message);
84 void SetRenderViewHost(RenderViewHost* rvh);
85 void ClearRenderViewHost();
87 void RenderViewCrashed();
88 void OnSwapCompositorFrame(const IPC::Message& message);
89 bool OnSetTouchEventEmulationEnabled(const IPC::Message& message);
91 void OnDispatchOnInspectorFrontend(const std::string& message);
92 void OnSaveAgentRuntimeState(const std::string& state);
94 void ClientDetachedFromRenderer();
96 void InnerOnClientAttached();
97 void InnerClientDetachedFromRenderer();
99 RenderViewHost* render_view_host_;
100 scoped_ptr<RendererOverridesHandler> overrides_handler_;
101 scoped_ptr<DevToolsTracingHandler> tracing_handler_;
102 scoped_ptr<DevToolsPowerHandler> power_handler_;
103 #if defined(OS_ANDROID)
104 scoped_ptr<PowerSaveBlockerImpl> power_save_blocker_;
107 NotificationRegistrar registrar_;
110 DISALLOW_COPY_AND_ASSIGN(RenderViewDevToolsAgentHost);
113 } // namespace content
115 #endif // CONTENT_BROWSER_DEVTOOLS_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_