OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
11 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 11 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
13 #include "content/public/browser/render_widget_host.h" | |
14 #include "ui/gfx/geometry/size_f.h" | 13 #include "ui/gfx/geometry/size_f.h" |
15 | 14 |
16 namespace cc { | 15 namespace cc { |
17 class CompositorFrameMetadata; | 16 class CompositorFrameMetadata; |
18 } | 17 } |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 | 20 |
22 class RenderWidgetHostImpl; | 21 class RenderWidgetHostImpl; |
23 | 22 |
24 namespace devtools { | 23 namespace devtools { |
25 namespace input { | 24 namespace input { |
26 | 25 |
27 class InputHandler : public RenderWidgetHost::InputEventObserver { | 26 class InputHandler { |
28 public: | 27 public: |
29 typedef DevToolsProtocolClient::Response Response; | 28 typedef DevToolsProtocolClient::Response Response; |
30 | 29 |
31 InputHandler(); | 30 InputHandler(); |
32 ~InputHandler() override; | 31 virtual ~InputHandler(); |
33 | 32 |
34 void SetRenderWidgetHost(RenderWidgetHostImpl* host); | 33 void SetRenderWidgetHost(RenderWidgetHostImpl* host); |
35 void SetClient(std::unique_ptr<Client> client); | 34 void SetClient(std::unique_ptr<Client> client); |
36 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); | 35 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); |
37 void Detached(); | |
38 | 36 |
39 Response DispatchKeyEvent(DevToolsCommandId command_id, | 37 Response DispatchKeyEvent(const std::string& type, |
40 const std::string& type, | |
41 const int* modifiers, | 38 const int* modifiers, |
42 const double* timestamp, | 39 const double* timestamp, |
43 const std::string* text, | 40 const std::string* text, |
44 const std::string* unmodified_text, | 41 const std::string* unmodified_text, |
45 const std::string* key_identifier, | 42 const std::string* key_identifier, |
46 const std::string* code, | 43 const std::string* code, |
47 const std::string* key, | 44 const std::string* key, |
48 const int* windows_virtual_key_code, | 45 const int* windows_virtual_key_code, |
49 const int* native_virtual_key_code, | 46 const int* native_virtual_key_code, |
50 const bool* auto_repeat, | 47 const bool* auto_repeat, |
51 const bool* is_keypad, | 48 const bool* is_keypad, |
52 const bool* is_system_key); | 49 const bool* is_system_key); |
53 | 50 |
54 Response DispatchMouseEvent(DevToolsCommandId command_id, | 51 Response DispatchMouseEvent(const std::string& type, |
55 const std::string& type, | |
56 int x, | 52 int x, |
57 int y, | 53 int y, |
58 const int* modifiers, | 54 const int* modifiers, |
59 const double* timestamp, | 55 const double* timestamp, |
60 const std::string* button, | 56 const std::string* button, |
61 const int* click_count); | 57 const int* click_count); |
62 | 58 |
63 Response EmulateTouchFromMouseEvent(const std::string& type, | 59 Response EmulateTouchFromMouseEvent(const std::string& type, |
64 int x, | 60 int x, |
65 int y, | 61 int y, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 const int* tap_count, | 94 const int* tap_count, |
99 const std::string* gesture_source_type); | 95 const std::string* gesture_source_type); |
100 | 96 |
101 Response DispatchTouchEvent( | 97 Response DispatchTouchEvent( |
102 const std::string& type, | 98 const std::string& type, |
103 const std::vector<std::unique_ptr<base::DictionaryValue>>& touch_points, | 99 const std::vector<std::unique_ptr<base::DictionaryValue>>& touch_points, |
104 const int* modifiers, | 100 const int* modifiers, |
105 const double* timestamp); | 101 const double* timestamp); |
106 | 102 |
107 private: | 103 private: |
108 // InputEventObserver | |
109 void OnInputEvent(const blink::WebInputEvent& event) override; | |
110 void OnInputEventAck(const blink::WebInputEvent& event) override; | |
111 | |
112 void SendDispatchKeyEventResponse(DevToolsCommandId command_id); | |
113 void SendDispatchMouseEventResponse(DevToolsCommandId command_id); | |
114 | |
115 void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id, | 104 void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id, |
116 SyntheticGesture::Result result); | 105 SyntheticGesture::Result result); |
117 | 106 |
118 void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id, | 107 void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id, |
119 SyntheticGesture::Result result); | 108 SyntheticGesture::Result result); |
120 | 109 |
121 void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id, | 110 void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id, |
122 bool send_success, | 111 bool send_success, |
123 SyntheticGesture::Result result); | 112 SyntheticGesture::Result result); |
124 | 113 |
125 void SynthesizeRepeatingScroll( | 114 void SynthesizeRepeatingScroll( |
126 SyntheticSmoothScrollGestureParams gesture_params, | 115 SyntheticSmoothScrollGestureParams gesture_params, |
127 int repeat_count, | 116 int repeat_count, |
128 base::TimeDelta repeat_delay, | 117 base::TimeDelta repeat_delay, |
129 std::string interaction_marker_name, | 118 std::string interaction_marker_name, |
130 DevToolsCommandId command_id); | 119 DevToolsCommandId command_id); |
131 | 120 |
132 void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params, | 121 void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params, |
133 int repeat_count, | 122 int repeat_count, |
134 base::TimeDelta repeat_delay, | 123 base::TimeDelta repeat_delay, |
135 std::string interaction_marker_name, | 124 std::string interaction_marker_name, |
136 DevToolsCommandId command_id, | 125 DevToolsCommandId command_id, |
137 SyntheticGesture::Result result); | 126 SyntheticGesture::Result result); |
138 | 127 |
139 void ClearPendingKeyCommands(); | |
140 void ClearPendingMouseCommands(); | |
141 | |
142 RenderWidgetHostImpl* host_; | 128 RenderWidgetHostImpl* host_; |
143 std::unique_ptr<Client> client_; | 129 std::unique_ptr<Client> client_; |
144 // DevToolsCommandIds for calls to Input.dispatchKey/MouseEvent that have been | |
145 // sent to the renderer, but that we haven't yet received an ack for. | |
146 bool input_queued_; | |
147 std::deque<DevToolsCommandId> pending_key_command_ids_; | |
148 std::deque<DevToolsCommandId> pending_mouse_command_ids_; | |
149 float page_scale_factor_; | 130 float page_scale_factor_; |
150 gfx::SizeF scrollable_viewport_size_; | 131 gfx::SizeF scrollable_viewport_size_; |
151 base::WeakPtrFactory<InputHandler> weak_factory_; | 132 base::WeakPtrFactory<InputHandler> weak_factory_; |
152 | 133 |
153 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 134 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
154 }; | 135 }; |
155 | 136 |
156 } // namespace input | 137 } // namespace input |
157 } // namespace devtools | 138 } // namespace devtools |
158 } // namespace content | 139 } // namespace content |
159 | 140 |
160 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ | 141 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ |
OLD | NEW |