OLD | NEW |
| (Empty) |
1 // Copyright 2013 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. | |
4 | |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/time/time.h" | |
10 #include "content/common/content_export.h" | |
11 #include "content/common/input/synthetic_gesture_params.h" | |
12 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
13 | |
14 namespace content { | |
15 | |
16 class SyntheticGestureTarget; | |
17 | |
18 // Base class for synthetic gesture implementations. A synthetic gesture class | |
19 // is responsible for forwaring InputEvents, simulating the gesture, to a | |
20 // SyntheticGestureTarget. | |
21 // | |
22 // Adding new gesture types involved the following steps: | |
23 // 1) Create a sub-type of SyntheticGesture that implements the gesture. | |
24 // 2) Extend SyntheticGesture::Create with the new class. | |
25 // 3) Add at least one unit test per supported input source type (touch, | |
26 // mouse, etc) to SyntheticGestureController unit tests. The unit tests | |
27 // only checks basic functionality and termination. If the gesture is | |
28 // hooked up to Telemetry its correctness can additionally be tested there. | |
29 class CONTENT_EXPORT SyntheticGesture { | |
30 public: | |
31 SyntheticGesture(); | |
32 virtual ~SyntheticGesture(); | |
33 | |
34 static scoped_ptr<SyntheticGesture> Create( | |
35 const SyntheticGestureParams& gesture_params); | |
36 | |
37 enum Result { | |
38 GESTURE_RUNNING, | |
39 GESTURE_FINISHED, | |
40 GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED, | |
41 GESTURE_SOURCE_TYPE_NOT_SUPPORTED_BY_PLATFORM, | |
42 GESTURE_RESULT_MAX = GESTURE_SOURCE_TYPE_NOT_SUPPORTED_BY_PLATFORM | |
43 }; | |
44 | |
45 // Update the state of the gesture and forward the appropriate events to the | |
46 // platform. This function is called repeatedly by the synthetic gesture | |
47 // controller until it stops returning GESTURE_RUNNING. | |
48 virtual Result ForwardInputEvents( | |
49 const base::TimeDelta& interval, SyntheticGestureTarget* target) = 0; | |
50 | |
51 private: | |
52 DISALLOW_COPY_AND_ASSIGN(SyntheticGesture); | |
53 }; | |
54 | |
55 } // namespace content | |
56 | |
57 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_H_ | |
OLD | NEW |