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