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 "ui/gfx/geometry/size_f.h"
14 class CompositorFrameMetadata
;
23 class RenderWidgetHostImpl
;
30 typedef DevToolsProtocolClient::Response Response
;
33 virtual ~InputHandler();
35 void SetRenderWidgetHost(RenderWidgetHostImpl
* host
);
36 void SetClient(scoped_ptr
<Client
> client
);
37 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata
& frame_metadata
);
39 Response
DispatchKeyEvent(const std::string
& type
,
41 const double* timestamp
,
42 const std::string
* text
,
43 const std::string
* unmodified_text
,
44 const std::string
* key_identifier
,
45 const std::string
* code
,
46 const std::string
* key
,
47 const int* windows_virtual_key_code
,
48 const int* native_virtual_key_code
,
49 const bool* auto_repeat
,
50 const bool* is_keypad
,
51 const bool* is_system_key
);
53 Response
DispatchMouseEvent(const std::string
& type
,
57 const double* timestamp
,
58 const std::string
* button
,
59 const int* click_count
);
61 Response
EmulateTouchFromMouseEvent(const std::string
& type
,
65 const std::string
& button
,
71 Response
SynthesizePinchGesture(DevToolsCommandId command_id
,
75 const int* relative_speed
,
76 const std::string
* gesture_source_type
);
78 Response
SynthesizeScrollGesture(DevToolsCommandId command_id
,
81 const int* x_distance
,
82 const int* y_distance
,
83 const int* x_overscroll
,
84 const int* y_overscroll
,
85 const bool* prevent_fling
,
87 const std::string
* gesture_source_type
);
89 Response
SynthesizeTapGesture(DevToolsCommandId command_id
,
94 const std::string
* gesture_source_type
);
97 void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id
,
98 SyntheticGesture::Result result
);
100 void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id
,
101 SyntheticGesture::Result result
);
103 void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id
,
105 SyntheticGesture::Result result
);
107 RenderWidgetHostImpl
* host_
;
108 scoped_ptr
<Client
> client_
;
109 float page_scale_factor_
;
110 gfx::SizeF scrollable_viewport_size_
;
111 base::WeakPtrFactory
<InputHandler
> weak_factory_
;
113 DISALLOW_COPY_AND_ASSIGN(InputHandler
);
117 } // namespace devtools
118 } // namespace content
120 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_