1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_
#define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_
#include "base/memory/weak_ptr.h"
#include "content/browser/devtools/protocol/devtools_protocol_handler.h"
#include "content/browser/renderer_host/input/synthetic_gesture.h"
#include "ui/gfx/geometry/size_f.h"
namespace cc {
class CompositorFrameMetadata;
}
namespace gfx {
class Point;
}
namespace content {
class RenderWidgetHostImpl;
namespace devtools {
namespace input {
class InputHandler {
public:
typedef DevToolsProtocolClient::Response Response;
InputHandler();
virtual ~InputHandler();
void SetRenderWidgetHost(RenderWidgetHostImpl* host);
void SetClient(scoped_ptr<Client> client);
void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata);
Response DispatchKeyEvent(const std::string& type,
const int* modifiers,
const double* timestamp,
const std::string* text,
const std::string* unmodified_text,
const std::string* key_identifier,
const std::string* code,
const int* windows_virtual_key_code,
const int* native_virtual_key_code,
const bool* auto_repeat,
const bool* is_keypad,
const bool* is_system_key);
Response DispatchMouseEvent(const std::string& type,
int x,
int y,
const int* modifiers,
const double* timestamp,
const std::string* button,
const int* click_count);
Response EmulateTouchFromMouseEvent(const std::string& type,
int x,
int y,
double timestamp,
const std::string& button,
double* delta_x,
double* delta_y,
int* modifiers,
int* click_count);
Response SynthesizePinchGesture(DevToolsCommandId command_id,
int x,
int y,
double scale_factor,
const int* relative_speed,
const std::string* gesture_source_type);
Response SynthesizeScrollGesture(DevToolsCommandId command_id,
int x,
int y,
const int* x_distance,
const int* y_distance,
const int* x_overscroll,
const int* y_overscroll,
const bool* prevent_fling,
const int* speed,
const std::string* gesture_source_type);
Response SynthesizeTapGesture(DevToolsCommandId command_id,
int x,
int y,
const int* duration,
const int* tap_count,
const std::string* gesture_source_type);
private:
void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id,
SyntheticGesture::Result result);
void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id,
SyntheticGesture::Result result);
void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id,
bool send_success,
SyntheticGesture::Result result);
RenderWidgetHostImpl* host_;
scoped_ptr<Client> client_;
float page_scale_factor_;
gfx::SizeF scrollable_viewport_size_;
base::WeakPtrFactory<InputHandler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(InputHandler);
};
} // namespace input
} // namespace devtools
} // namespace content
#endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_
|