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 19namespace cc { 20class CompositorFrameMetadata; 21} 22 23namespace content { 24 25class DevToolsTracingHandler; 26class RendererOverridesHandler; 27class RenderViewHost; 28 29#if defined(OS_ANDROID) 30class PowerSaveBlockerImpl; 31#endif 32 33class CONTENT_EXPORT RenderViewDevToolsAgentHost 34 : public IPCDevToolsAgentHost, 35 private WebContentsObserver, 36 public NotificationObserver { 37 public: 38 static void OnCancelPendingNavigation(RenderViewHost* pending, 39 RenderViewHost* current); 40 41 RenderViewDevToolsAgentHost(RenderViewHost*); 42 43 RenderViewHost* render_view_host() { return render_view_host_; } 44 45 void SynchronousSwapCompositorFrame( 46 const cc::CompositorFrameMetadata& frame_metadata); 47 48 private: 49 friend class DevToolsAgentHost; 50 51 virtual ~RenderViewDevToolsAgentHost(); 52 53 // DevTooolsAgentHost overrides. 54 virtual void DisconnectRenderViewHost() OVERRIDE; 55 virtual void ConnectRenderViewHost(RenderViewHost* rvh) OVERRIDE; 56 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; 57 58 // IPCDevToolsAgentHost overrides. 59 virtual void DispatchOnInspectorBackend(const std::string& message) OVERRIDE; 60 virtual void SendMessageToAgent(IPC::Message* msg) OVERRIDE; 61 virtual void OnClientAttached() OVERRIDE; 62 virtual void OnClientDetached() OVERRIDE; 63 64 // WebContentsObserver overrides. 65 virtual void AboutToNavigateRenderView(RenderViewHost* dest_rvh) OVERRIDE; 66 virtual void RenderViewHostChanged(RenderViewHost* old_host, 67 RenderViewHost* new_host) OVERRIDE; 68 virtual void RenderViewDeleted(RenderViewHost* rvh) OVERRIDE; 69 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; 70 virtual void DidAttachInterstitialPage() OVERRIDE; 71 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 72 73 // NotificationObserver overrides: 74 virtual void Observe(int type, 75 const NotificationSource& source, 76 const NotificationDetails& details) OVERRIDE; 77 78 void SetRenderViewHost(RenderViewHost* rvh); 79 void ClearRenderViewHost(); 80 81 void RenderViewCrashed(); 82 void OnSwapCompositorFrame(const IPC::Message& message); 83 84 void OnDispatchOnInspectorFrontend(const std::string& message); 85 void OnSaveAgentRuntimeState(const std::string& state); 86 void OnClearBrowserCache(); 87 void OnClearBrowserCookies(); 88 89 void ClientDetachedFromRenderer(); 90 91 RenderViewHost* render_view_host_; 92 scoped_ptr<RendererOverridesHandler> overrides_handler_; 93 scoped_ptr<DevToolsTracingHandler> tracing_handler_; 94#if defined(OS_ANDROID) 95 scoped_ptr<PowerSaveBlockerImpl> power_save_blocker_; 96#endif 97 std::string state_; 98 NotificationRegistrar registrar_; 99 100 DISALLOW_COPY_AND_ASSIGN(RenderViewDevToolsAgentHost); 101}; 102 103} // namespace content 104 105#endif // CONTENT_BROWSER_DEVTOOLS_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_ 106