1 // Copyright (c) 2013 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_RENDERER_OVERRIDES_HANDLER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted_memory.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "cc/output/compositor_frame_metadata.h"
15 #include "content/browser/devtools/devtools_protocol.h"
16 #include "content/common/content_export.h"
26 class DevToolsAgentHost;
27 class DevToolsTracingHandler;
28 class RenderViewHostImpl;
30 // Overrides Inspector commands before they are sent to the renderer.
31 // May override the implementation completely, ignore it, or handle
32 // additional browser process implementation details.
33 class CONTENT_EXPORT RendererOverridesHandler
34 : public DevToolsProtocol::Handler {
36 explicit RendererOverridesHandler(DevToolsAgentHost* agent);
37 virtual ~RendererOverridesHandler();
39 void OnClientDetached();
40 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata);
41 void OnVisibilityChanged(bool visible);
42 void OnRenderViewHostChanged();
43 bool OnSetTouchEventEmulationEnabled();
46 void InnerSwapCompositorFrame();
49 scoped_refptr<DevToolsProtocol::Response>
50 GrantPermissionsForSetFileInputFiles(
51 scoped_refptr<DevToolsProtocol::Command> command);
54 scoped_refptr<DevToolsProtocol::Response> ClearBrowserCache(
55 scoped_refptr<DevToolsProtocol::Command> command);
56 scoped_refptr<DevToolsProtocol::Response> ClearBrowserCookies(
57 scoped_refptr<DevToolsProtocol::Command> command);
60 scoped_refptr<DevToolsProtocol::Response> PageDisable(
61 scoped_refptr<DevToolsProtocol::Command> command);
62 scoped_refptr<DevToolsProtocol::Response> PageHandleJavaScriptDialog(
63 scoped_refptr<DevToolsProtocol::Command> command);
64 scoped_refptr<DevToolsProtocol::Response> PageNavigate(
65 scoped_refptr<DevToolsProtocol::Command> command);
66 scoped_refptr<DevToolsProtocol::Response> PageReload(
67 scoped_refptr<DevToolsProtocol::Command> command);
68 scoped_refptr<DevToolsProtocol::Response> PageGetNavigationHistory(
69 scoped_refptr<DevToolsProtocol::Command> command);
70 scoped_refptr<DevToolsProtocol::Response> PageNavigateToHistoryEntry(
71 scoped_refptr<DevToolsProtocol::Command> command);
72 scoped_refptr<DevToolsProtocol::Response> PageCaptureScreenshot(
73 scoped_refptr<DevToolsProtocol::Command> command);
74 scoped_refptr<DevToolsProtocol::Response> PageCanScreencast(
75 scoped_refptr<DevToolsProtocol::Command> command);
76 scoped_refptr<DevToolsProtocol::Response> PageStartScreencast(
77 scoped_refptr<DevToolsProtocol::Command> command);
78 scoped_refptr<DevToolsProtocol::Response> PageStopScreencast(
79 scoped_refptr<DevToolsProtocol::Command> command);
80 scoped_refptr<DevToolsProtocol::Response> PageQueryUsageAndQuota(
81 scoped_refptr<DevToolsProtocol::Command>);
83 void ScreenshotCaptured(
84 scoped_refptr<DevToolsProtocol::Command> command,
85 const unsigned char* png_data,
88 void ScreencastFrameCaptured(
89 const std::string& format,
91 const cc::CompositorFrameMetadata& metadata,
93 const SkBitmap& bitmap);
95 void PageQueryUsageAndQuotaCompleted(
96 scoped_refptr<DevToolsProtocol::Command>,
97 scoped_ptr<base::DictionaryValue> response_data);
99 void NotifyScreencastVisibility(bool visible);
102 scoped_refptr<DevToolsProtocol::Response> InputEmulateTouchFromMouseEvent(
103 scoped_refptr<DevToolsProtocol::Command> command);
105 RenderViewHostImpl* GetRenderViewHostImpl();
107 DevToolsAgentHost* agent_;
108 scoped_refptr<DevToolsProtocol::Command> screencast_command_;
109 bool has_last_compositor_frame_metadata_;
110 cc::CompositorFrameMetadata last_compositor_frame_metadata_;
111 base::TimeTicks last_frame_time_;
112 int capture_retry_count_;
113 base::WeakPtrFactory<RendererOverridesHandler> weak_factory_;
114 DISALLOW_COPY_AND_ASSIGN(RendererOverridesHandler);
117 } // namespace content
119 #endif // CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_