Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / devtools / protocol / input_handler.h
blobcb6a5fcf713961be13014db13d0715b2b82112c3
1 // Copyright 2014 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_PROTOCOL_INPUT_HANDLER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture.h"
11 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
12 #include "ui/gfx/geometry/size_f.h"
14 namespace cc {
15 class CompositorFrameMetadata;
18 namespace gfx {
19 class Point;
22 namespace content {
24 class RenderWidgetHostImpl;
26 namespace devtools {
27 namespace input {
29 class InputHandler {
30 public:
31 typedef DevToolsProtocolClient::Response Response;
33 InputHandler();
34 virtual ~InputHandler();
36 void SetRenderWidgetHost(RenderWidgetHostImpl* host);
37 void SetClient(scoped_ptr<Client> client);
38 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata);
40 Response DispatchKeyEvent(const std::string& type,
41 const int* modifiers,
42 const double* timestamp,
43 const std::string* text,
44 const std::string* unmodified_text,
45 const std::string* key_identifier,
46 const std::string* code,
47 const std::string* key,
48 const int* windows_virtual_key_code,
49 const int* native_virtual_key_code,
50 const bool* auto_repeat,
51 const bool* is_keypad,
52 const bool* is_system_key);
54 Response DispatchMouseEvent(const std::string& type,
55 int x,
56 int y,
57 const int* modifiers,
58 const double* timestamp,
59 const std::string* button,
60 const int* click_count);
62 Response EmulateTouchFromMouseEvent(const std::string& type,
63 int x,
64 int y,
65 double timestamp,
66 const std::string& button,
67 double* delta_x,
68 double* delta_y,
69 int* modifiers,
70 int* click_count);
72 Response SynthesizePinchGesture(DevToolsCommandId command_id,
73 int x,
74 int y,
75 double scale_factor,
76 const int* relative_speed,
77 const std::string* gesture_source_type);
79 Response SynthesizeScrollGesture(DevToolsCommandId command_id,
80 int x,
81 int y,
82 const int* x_distance,
83 const int* y_distance,
84 const int* x_overscroll,
85 const int* y_overscroll,
86 const bool* prevent_fling,
87 const int* speed,
88 const std::string* gesture_source_type,
89 const int* repeat_count,
90 const int* repeat_delay_ms,
91 const std::string* interaction_marker_name);
93 Response SynthesizeTapGesture(DevToolsCommandId command_id,
94 int x,
95 int y,
96 const int* duration,
97 const int* tap_count,
98 const std::string* gesture_source_type);
100 private:
101 void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id,
102 SyntheticGesture::Result result);
104 void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id,
105 SyntheticGesture::Result result);
107 void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id,
108 bool send_success,
109 SyntheticGesture::Result result);
111 void SynthesizeRepeatingScroll(
112 SyntheticSmoothScrollGestureParams gesture_params,
113 int repeat_count,
114 base::TimeDelta repeat_delay,
115 std::string interaction_marker_name,
116 DevToolsCommandId command_id);
118 void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params,
119 int repeat_count,
120 base::TimeDelta repeat_delay,
121 std::string interaction_marker_name,
122 DevToolsCommandId command_id,
123 SyntheticGesture::Result result);
125 RenderWidgetHostImpl* host_;
126 scoped_ptr<Client> client_;
127 float page_scale_factor_;
128 gfx::SizeF scrollable_viewport_size_;
129 base::WeakPtrFactory<InputHandler> weak_factory_;
131 DISALLOW_COPY_AND_ASSIGN(InputHandler);
134 } // namespace input
135 } // namespace devtools
136 } // namespace content
138 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_