Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: content/browser/devtools/protocol/input_handler.h

Issue 2575513004: [DevTools] Migrate input domain to new generator. (Closed)
Patch Set: fixed review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/input.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 "ui/gfx/geometry/size_f.h" 13 #include "ui/gfx/geometry/size_f.h"
14 14
15 namespace cc { 15 namespace cc {
16 class CompositorFrameMetadata; 16 class CompositorFrameMetadata;
17 } 17 }
18 18
19 namespace content { 19 namespace content {
20 20
21 class RenderWidgetHostImpl; 21 class RenderFrameHostImpl;
22 22
23 namespace devtools { 23 namespace protocol {
24 namespace input {
25 24
26 class InputHandler { 25 class InputHandler : public Input::Backend {
27 public: 26 public:
28 typedef DevToolsProtocolClient::Response Response; 27 InputHandler();
28 ~InputHandler() override;
29 29
30 InputHandler(); 30 void Wire(UberDispatcher*);
31 virtual ~InputHandler(); 31 void SetRenderFrameHost(RenderFrameHostImpl* host);
32
33 void SetRenderWidgetHost(RenderWidgetHostImpl* host);
34 void SetClient(std::unique_ptr<Client> client);
35 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); 32 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata);
33 Response Disable() override;
36 34
37 Response DispatchKeyEvent(const std::string& type, 35 Response DispatchKeyEvent(const std::string& type,
38 const int* modifiers, 36 Maybe<int> modifiers,
39 const double* timestamp, 37 Maybe<double> timestamp,
40 const std::string* text, 38 Maybe<std::string> text,
41 const std::string* unmodified_text, 39 Maybe<std::string> unmodified_text,
42 const std::string* key_identifier, 40 Maybe<std::string> key_identifier,
43 const std::string* code, 41 Maybe<std::string> code,
44 const std::string* key, 42 Maybe<std::string> key,
45 const int* windows_virtual_key_code, 43 Maybe<int> windows_virtual_key_code,
46 const int* native_virtual_key_code, 44 Maybe<int> native_virtual_key_code,
47 const bool* auto_repeat, 45 Maybe<bool> auto_repeat,
48 const bool* is_keypad, 46 Maybe<bool> is_keypad,
49 const bool* is_system_key); 47 Maybe<bool> is_system_key) override;
50 48
51 Response DispatchMouseEvent(const std::string& type, 49 Response DispatchMouseEvent(const std::string& type,
52 int x, 50 int x,
53 int y, 51 int y,
54 const int* modifiers, 52 Maybe<int> modifiers,
55 const double* timestamp, 53 Maybe<double> timestamp,
56 const std::string* button, 54 Maybe<std::string> button,
57 const int* click_count); 55 Maybe<int> click_count) override;
58 56
59 Response EmulateTouchFromMouseEvent(const std::string& type, 57 Response EmulateTouchFromMouseEvent(const std::string& type,
60 int x, 58 int x,
61 int y, 59 int y,
62 double timestamp, 60 double timestamp,
63 const std::string& button, 61 const std::string& button,
64 double* delta_x, 62 Maybe<double> delta_x,
65 double* delta_y, 63 Maybe<double> delta_y,
66 int* modifiers, 64 Maybe<int> modifiers,
67 int* click_count); 65 Maybe<int> click_count) override;
68 66
69 Response SynthesizePinchGesture(DevToolsCommandId command_id, 67 void SynthesizePinchGesture(
70 int x, 68 int x,
71 int y, 69 int y,
72 double scale_factor, 70 double scale_factor,
73 const int* relative_speed, 71 Maybe<int> relative_speed,
74 const std::string* gesture_source_type); 72 Maybe<std::string> gesture_source_type,
73 std::unique_ptr<SynthesizePinchGestureCallback> callback) override;
75 74
76 Response SynthesizeScrollGesture(DevToolsCommandId command_id, 75 void SynthesizeScrollGesture(
77 int x, 76 int x,
78 int y, 77 int y,
79 const int* x_distance, 78 Maybe<int> x_distance,
80 const int* y_distance, 79 Maybe<int> y_distance,
81 const int* x_overscroll, 80 Maybe<int> x_overscroll,
82 const int* y_overscroll, 81 Maybe<int> y_overscroll,
83 const bool* prevent_fling, 82 Maybe<bool> prevent_fling,
84 const int* speed, 83 Maybe<int> speed,
85 const std::string* gesture_source_type, 84 Maybe<std::string> gesture_source_type,
86 const int* repeat_count, 85 Maybe<int> repeat_count,
87 const int* repeat_delay_ms, 86 Maybe<int> repeat_delay_ms,
88 const std::string* interaction_marker_name); 87 Maybe<std::string> interaction_marker_name,
88 std::unique_ptr<SynthesizeScrollGestureCallback> callback) override;
89 89
90 Response SynthesizeTapGesture(DevToolsCommandId command_id, 90 void SynthesizeTapGesture(
91 int x, 91 int x,
92 int y, 92 int y,
93 const int* duration, 93 Maybe<int> duration,
94 const int* tap_count, 94 Maybe<int> tap_count,
95 const std::string* gesture_source_type); 95 Maybe<std::string> gesture_source_type,
96 96 std::unique_ptr<SynthesizeTapGestureCallback> callback) override;
97 Response DispatchTouchEvent(
98 const std::string& type,
99 const std::vector<std::unique_ptr<base::DictionaryValue>>& touch_points,
100 const int* modifiers,
101 const double* timestamp);
102 97
103 private: 98 private:
104 void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id,
105 SyntheticGesture::Result result);
106
107 void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id,
108 SyntheticGesture::Result result);
109
110 void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id,
111 bool send_success,
112 SyntheticGesture::Result result);
113
114 void SynthesizeRepeatingScroll( 99 void SynthesizeRepeatingScroll(
115 SyntheticSmoothScrollGestureParams gesture_params, 100 SyntheticSmoothScrollGestureParams gesture_params,
116 int repeat_count, 101 int repeat_count,
117 base::TimeDelta repeat_delay, 102 base::TimeDelta repeat_delay,
118 std::string interaction_marker_name, 103 std::string interaction_marker_name,
119 DevToolsCommandId command_id); 104 int id,
105 std::unique_ptr<SynthesizeScrollGestureCallback> callback);
120 106
121 void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params, 107 void OnScrollFinished(
122 int repeat_count, 108 SyntheticSmoothScrollGestureParams gesture_params,
123 base::TimeDelta repeat_delay, 109 int repeat_count,
124 std::string interaction_marker_name, 110 base::TimeDelta repeat_delay,
125 DevToolsCommandId command_id, 111 std::string interaction_marker_name,
126 SyntheticGesture::Result result); 112 int id,
113 std::unique_ptr<SynthesizeScrollGestureCallback> callback,
114 SyntheticGesture::Result result);
127 115
128 RenderWidgetHostImpl* host_; 116 RenderFrameHostImpl* host_;
129 std::unique_ptr<Client> client_;
130 float page_scale_factor_; 117 float page_scale_factor_;
131 gfx::SizeF scrollable_viewport_size_; 118 gfx::SizeF scrollable_viewport_size_;
119 int last_id_;
132 base::WeakPtrFactory<InputHandler> weak_factory_; 120 base::WeakPtrFactory<InputHandler> weak_factory_;
133 121
134 DISALLOW_COPY_AND_ASSIGN(InputHandler); 122 DISALLOW_COPY_AND_ASSIGN(InputHandler);
135 }; 123 };
136 124
137 } // namespace input 125 } // namespace protocol
138 } // namespace devtools
139 } // namespace content 126 } // namespace content
140 127
141 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ 128 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698