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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_H_
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"
16 class SyntheticGestureTarget
;
18 // Base class for synthetic gesture implementations. A synthetic gesture class
19 // is responsible for forwaring InputEvents, simulating the gesture, to a
20 // SyntheticGestureTarget.
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
{
32 virtual ~SyntheticGesture();
34 static scoped_ptr
<SyntheticGesture
> Create(
35 const SyntheticGestureParams
& gesture_params
);
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
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::TimeTicks
& timestamp
, SyntheticGestureTarget
* target
) = 0;
52 static double ConvertTimestampToSeconds(const base::TimeTicks
& timestamp
);
54 DISALLOW_COPY_AND_ASSIGN(SyntheticGesture
);
57 } // namespace content
59 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_H_