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" |
13 #include "ui/gfx/geometry/size_f.h" | 14 #include "ui/gfx/geometry/size_f.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 class CompositorFrameMetadata; | 17 class CompositorFrameMetadata; |
17 } | 18 } |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 class RenderWidgetHostImpl; | 22 class RenderWidgetHostImpl; |
22 | 23 |
23 namespace devtools { | 24 namespace devtools { |
24 namespace input { | 25 namespace input { |
25 | 26 |
26 class InputHandler { | 27 class InputHandler : public RenderWidgetHost::InputEventObserver { |
27 public: | 28 public: |
28 typedef DevToolsProtocolClient::Response Response; | 29 typedef DevToolsProtocolClient::Response Response; |
29 | 30 |
30 InputHandler(); | 31 InputHandler(); |
31 virtual ~InputHandler(); | 32 ~InputHandler() override; |
32 | 33 |
33 void SetRenderWidgetHost(RenderWidgetHostImpl* host); | 34 void SetRenderWidgetHost(RenderWidgetHostImpl* host); |
34 void SetClient(std::unique_ptr<Client> client); | 35 void SetClient(std::unique_ptr<Client> client); |
35 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); | 36 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); |
| 37 void Detached(); |
36 | 38 |
37 Response DispatchKeyEvent(const std::string& type, | 39 Response DispatchKeyEvent(DevToolsCommandId command_id, |
| 40 const std::string& type, |
38 const int* modifiers, | 41 const int* modifiers, |
39 const double* timestamp, | 42 const double* timestamp, |
40 const std::string* text, | 43 const std::string* text, |
41 const std::string* unmodified_text, | 44 const std::string* unmodified_text, |
42 const std::string* key_identifier, | 45 const std::string* key_identifier, |
43 const std::string* code, | 46 const std::string* code, |
44 const std::string* key, | 47 const std::string* key, |
45 const int* windows_virtual_key_code, | 48 const int* windows_virtual_key_code, |
46 const int* native_virtual_key_code, | 49 const int* native_virtual_key_code, |
47 const bool* auto_repeat, | 50 const bool* auto_repeat, |
48 const bool* is_keypad, | 51 const bool* is_keypad, |
49 const bool* is_system_key); | 52 const bool* is_system_key); |
50 | 53 |
51 Response DispatchMouseEvent(const std::string& type, | 54 Response DispatchMouseEvent(DevToolsCommandId command_id, |
| 55 const std::string& type, |
52 int x, | 56 int x, |
53 int y, | 57 int y, |
54 const int* modifiers, | 58 const int* modifiers, |
55 const double* timestamp, | 59 const double* timestamp, |
56 const std::string* button, | 60 const std::string* button, |
57 const int* click_count); | 61 const int* click_count); |
58 | 62 |
59 Response EmulateTouchFromMouseEvent(const std::string& type, | 63 Response EmulateTouchFromMouseEvent(const std::string& type, |
60 int x, | 64 int x, |
61 int y, | 65 int y, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 const int* tap_count, | 98 const int* tap_count, |
95 const std::string* gesture_source_type); | 99 const std::string* gesture_source_type); |
96 | 100 |
97 Response DispatchTouchEvent( | 101 Response DispatchTouchEvent( |
98 const std::string& type, | 102 const std::string& type, |
99 const std::vector<std::unique_ptr<base::DictionaryValue>>& touch_points, | 103 const std::vector<std::unique_ptr<base::DictionaryValue>>& touch_points, |
100 const int* modifiers, | 104 const int* modifiers, |
101 const double* timestamp); | 105 const double* timestamp); |
102 | 106 |
103 private: | 107 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 |
104 void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id, | 115 void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id, |
105 SyntheticGesture::Result result); | 116 SyntheticGesture::Result result); |
106 | 117 |
107 void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id, | 118 void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id, |
108 SyntheticGesture::Result result); | 119 SyntheticGesture::Result result); |
109 | 120 |
110 void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id, | 121 void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id, |
111 bool send_success, | 122 bool send_success, |
112 SyntheticGesture::Result result); | 123 SyntheticGesture::Result result); |
113 | 124 |
114 void SynthesizeRepeatingScroll( | 125 void SynthesizeRepeatingScroll( |
115 SyntheticSmoothScrollGestureParams gesture_params, | 126 SyntheticSmoothScrollGestureParams gesture_params, |
116 int repeat_count, | 127 int repeat_count, |
117 base::TimeDelta repeat_delay, | 128 base::TimeDelta repeat_delay, |
118 std::string interaction_marker_name, | 129 std::string interaction_marker_name, |
119 DevToolsCommandId command_id); | 130 DevToolsCommandId command_id); |
120 | 131 |
121 void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params, | 132 void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params, |
122 int repeat_count, | 133 int repeat_count, |
123 base::TimeDelta repeat_delay, | 134 base::TimeDelta repeat_delay, |
124 std::string interaction_marker_name, | 135 std::string interaction_marker_name, |
125 DevToolsCommandId command_id, | 136 DevToolsCommandId command_id, |
126 SyntheticGesture::Result result); | 137 SyntheticGesture::Result result); |
127 | 138 |
| 139 void ClearPendingKeyCommands(); |
| 140 void ClearPendingMouseCommands(); |
| 141 |
128 RenderWidgetHostImpl* host_; | 142 RenderWidgetHostImpl* host_; |
129 std::unique_ptr<Client> client_; | 143 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_; |
130 float page_scale_factor_; | 149 float page_scale_factor_; |
131 gfx::SizeF scrollable_viewport_size_; | 150 gfx::SizeF scrollable_viewport_size_; |
132 base::WeakPtrFactory<InputHandler> weak_factory_; | 151 base::WeakPtrFactory<InputHandler> weak_factory_; |
133 | 152 |
134 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 153 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
135 }; | 154 }; |
136 | 155 |
137 } // namespace input | 156 } // namespace input |
138 } // namespace devtools | 157 } // namespace devtools |
139 } // namespace content | 158 } // namespace content |
140 | 159 |
141 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ | 160 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ |
OLD | NEW |