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"
15 class CompositorFrameMetadata
;
24 class RenderWidgetHostImpl
;
31 typedef DevToolsProtocolClient::Response Response
;
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
,
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
,
58 const double* timestamp
,
59 const std::string
* button
,
60 const int* click_count
);
62 Response
EmulateTouchFromMouseEvent(const std::string
& type
,
66 const std::string
& button
,
72 Response
SynthesizePinchGesture(DevToolsCommandId command_id
,
76 const int* relative_speed
,
77 const std::string
* gesture_source_type
);
79 Response
SynthesizeScrollGesture(DevToolsCommandId command_id
,
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
,
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
,
98 const std::string
* gesture_source_type
);
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
,
109 SyntheticGesture::Result result
);
111 void SynthesizeRepeatingScroll(
112 SyntheticSmoothScrollGestureParams gesture_params
,
114 base::TimeDelta repeat_delay
,
115 std::string interaction_marker_name
,
116 DevToolsCommandId command_id
);
118 void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params
,
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
);
135 } // namespace devtools
136 } // namespace content
138 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_