b1f3e07acad3907fa7999efe6363ac4a85b10b68
[platform/framework/web/crosswalk.git] / src / content / browser / devtools / render_view_devtools_agent_host.h
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.
4
5 #ifndef CONTENT_BROWSER_DEVTOOLS_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_
6 #define CONTENT_BROWSER_DEVTOOLS_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_
7
8 #include <map>
9
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"
18
19 namespace cc {
20 class CompositorFrameMetadata;
21 }
22
23 namespace content {
24
25 class DevToolsPowerHandler;
26 class DevToolsTracingHandler;
27 class RendererOverridesHandler;
28 class RenderViewHost;
29
30 #if defined(OS_ANDROID)
31 class PowerSaveBlockerImpl;
32 #endif
33
34 class CONTENT_EXPORT RenderViewDevToolsAgentHost
35     : public IPCDevToolsAgentHost,
36       private WebContentsObserver,
37       public NotificationObserver {
38  public:
39   static void OnCancelPendingNavigation(RenderViewHost* pending,
40                                         RenderViewHost* current);
41
42   RenderViewDevToolsAgentHost(RenderViewHost*);
43
44   void SynchronousSwapCompositorFrame(
45       const cc::CompositorFrameMetadata& frame_metadata);
46
47   // DevTooolsAgentHost overrides.
48   virtual void DisconnectWebContents() OVERRIDE;
49   virtual void ConnectWebContents(WebContents* web_contents) OVERRIDE;
50   virtual WebContents* GetWebContents() OVERRIDE;
51
52  private:
53   friend class DevToolsAgentHost;
54   virtual ~RenderViewDevToolsAgentHost();
55
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;
61
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;
72
73   // NotificationObserver overrides:
74   virtual void Observe(int type,
75                        const NotificationSource& source,
76                        const NotificationDetails& details) OVERRIDE;
77
78   void DisconnectRenderViewHost();
79   void ConnectRenderViewHost(RenderViewHost* rvh);
80   void ReattachToRenderViewHost(RenderViewHost* rvh);
81
82   bool DispatchIPCMessage(const IPC::Message& message);
83
84   void SetRenderViewHost(RenderViewHost* rvh);
85   void ClearRenderViewHost();
86
87   void RenderViewCrashed();
88   void OnSwapCompositorFrame(const IPC::Message& message);
89   bool OnSetTouchEventEmulationEnabled(const IPC::Message& message);
90
91   void OnDispatchOnInspectorFrontend(const std::string& message);
92   void OnSaveAgentRuntimeState(const std::string& state);
93
94   void ClientDetachedFromRenderer();
95
96   void InnerOnClientAttached();
97   void InnerClientDetachedFromRenderer();
98
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_;
105 #endif
106   std::string state_;
107   NotificationRegistrar registrar_;
108   bool reattaching_;
109
110   DISALLOW_COPY_AND_ASSIGN(RenderViewDevToolsAgentHost);
111 };
112
113 }  // namespace content
114
115 #endif  // CONTENT_BROWSER_DEVTOOLS_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_