DevTools: Protocol handler generator for content
[chromium-blink-merge.git] / content / browser / devtools / renderer_overrides_handler.h
blob988a7c259bdc43dcb4f6f8de050b3974b0de970b
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"
17 #include "content/public/browser/render_widget_host.h"
18 #include "third_party/skia/include/core/SkBitmap.h"
20 class SkBitmap;
22 namespace IPC {
23 class Message;
26 namespace blink {
27 class WebMouseEvent;
30 namespace content {
32 class DevToolsTracingHandler;
33 class RenderViewHostImpl;
35 // Overrides Inspector commands before they are sent to the renderer.
36 // May override the implementation completely, ignore it, or handle
37 // additional browser process implementation details.
38 class CONTENT_EXPORT RendererOverridesHandler
39 : public DevToolsProtocol::Handler {
40 public:
41 RendererOverridesHandler();
42 virtual ~RendererOverridesHandler();
44 void OnClientDetached();
45 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata);
46 void OnVisibilityChanged(bool visible);
47 void SetRenderViewHost(RenderViewHostImpl* host);
48 void ClearRenderViewHost();
49 void DidAttachInterstitialPage();
50 void DidDetachInterstitialPage();
52 private:
53 void InnerSwapCompositorFrame();
55 // DOM domain.
56 scoped_refptr<DevToolsProtocol::Response>
57 GrantPermissionsForSetFileInputFiles(
58 scoped_refptr<DevToolsProtocol::Command> command);
60 // Network domain.
61 scoped_refptr<DevToolsProtocol::Response> CanEmulateNetworkConditions(
62 scoped_refptr<DevToolsProtocol::Command> command);
63 scoped_refptr<DevToolsProtocol::Response> ClearBrowserCache(
64 scoped_refptr<DevToolsProtocol::Command> command);
65 scoped_refptr<DevToolsProtocol::Response> ClearBrowserCookies(
66 scoped_refptr<DevToolsProtocol::Command> command);
68 // Page domain.
69 scoped_refptr<DevToolsProtocol::Response> PageEnable(
70 scoped_refptr<DevToolsProtocol::Command> command);
71 scoped_refptr<DevToolsProtocol::Response> PageDisable(
72 scoped_refptr<DevToolsProtocol::Command> command);
73 scoped_refptr<DevToolsProtocol::Response> PageHandleJavaScriptDialog(
74 scoped_refptr<DevToolsProtocol::Command> command);
75 scoped_refptr<DevToolsProtocol::Response> PageNavigate(
76 scoped_refptr<DevToolsProtocol::Command> command);
77 scoped_refptr<DevToolsProtocol::Response> PageReload(
78 scoped_refptr<DevToolsProtocol::Command> command);
79 scoped_refptr<DevToolsProtocol::Response> PageGetNavigationHistory(
80 scoped_refptr<DevToolsProtocol::Command> command);
81 scoped_refptr<DevToolsProtocol::Response> PageNavigateToHistoryEntry(
82 scoped_refptr<DevToolsProtocol::Command> command);
83 scoped_refptr<DevToolsProtocol::Response> PageSetTouchEmulationEnabled(
84 scoped_refptr<DevToolsProtocol::Command> command);
85 scoped_refptr<DevToolsProtocol::Response> PageCanEmulate(
86 scoped_refptr<DevToolsProtocol::Command> command);
87 scoped_refptr<DevToolsProtocol::Response> PageCanScreencast(
88 scoped_refptr<DevToolsProtocol::Command> command);
89 scoped_refptr<DevToolsProtocol::Response> PageStartScreencast(
90 scoped_refptr<DevToolsProtocol::Command> command);
91 scoped_refptr<DevToolsProtocol::Response> PageStopScreencast(
92 scoped_refptr<DevToolsProtocol::Command> command);
93 scoped_refptr<DevToolsProtocol::Response> PageQueryUsageAndQuota(
94 scoped_refptr<DevToolsProtocol::Command>);
95 scoped_refptr<DevToolsProtocol::Response> PageSetColorPickerEnabled(
96 scoped_refptr<DevToolsProtocol::Command>);
98 void ScreencastFrameCaptured(
99 const std::string& format,
100 int quality,
101 const cc::CompositorFrameMetadata& metadata,
102 bool success,
103 const SkBitmap& bitmap);
105 void PageQueryUsageAndQuotaCompleted(
106 scoped_refptr<DevToolsProtocol::Command>,
107 scoped_ptr<base::DictionaryValue> response_data);
109 void NotifyScreencastVisibility(bool visible);
110 void SetColorPickerEnabled(bool enabled);
111 void UpdateColorPickerFrame();
112 void ResetColorPickerFrame();
113 void ColorPickerFrameUpdated(bool succeeded, const SkBitmap& bitmap);
114 bool HandleMouseEvent(const blink::WebMouseEvent& event);
115 void UpdateColorPickerCursor();
117 void UpdateTouchEventEmulationState();
119 RenderViewHostImpl* host_;
120 bool page_domain_enabled_;
121 scoped_refptr<DevToolsProtocol::Command> screencast_command_;
122 bool has_last_compositor_frame_metadata_;
123 cc::CompositorFrameMetadata last_compositor_frame_metadata_;
124 base::TimeTicks last_frame_time_;
125 int capture_retry_count_;
126 bool touch_emulation_enabled_;
127 bool color_picker_enabled_;
128 SkBitmap color_picker_frame_;
129 int last_cursor_x_;
130 int last_cursor_y_;
131 RenderWidgetHost::MouseEventCallback mouse_event_callback_;
132 base::WeakPtrFactory<RendererOverridesHandler> weak_factory_;
133 DISALLOW_COPY_AND_ASSIGN(RendererOverridesHandler);
136 } // namespace content
138 #endif // CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_