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_COMMON_INPUT_SYNTHETIC_GESTURE_PARAMS_H_ 6 #define CONTENT_COMMON_INPUT_SYNTHETIC_GESTURE_PARAMS_H_ 7 8 #include "base/memory/scoped_ptr.h" 9 #include "content/common/content_export.h" 10 11 namespace content { 12 13 // Base class for storing parameters of synthetic gestures. Sending an object 14 // over IPC is handled by encapsulating it in a SyntheticGesturePacket object. 15 // 16 // The subclasses of this class only store data on synthetic gestures. 17 // The logic for dispatching input events that implement the gesture lives 18 // in separate classes in content/browser/renderer_host/input/. 19 // 20 // Adding new gesture types involves the following steps: 21 // 1) Create a new sub-type of SyntheticGestureParams with the parameters 22 // needed for the new gesture. 23 // 2) Use IPC macros to create serialization methods for the new type in 24 // content/common/input_messages.h. 25 // 3) Extend ParamTraits<content::SyntheticGesturePacket>::Write/Read/Log in 26 // content/common/input/input_param_traits.cc. 27 // 4) Add a new unit test to make sure that sending the type over IPC works 28 // correctly. 29 // The details of each step should become clear when looking at other types. 30 struct CONTENT_EXPORT SyntheticGestureParams { 31 SyntheticGestureParams(); 32 SyntheticGestureParams(const SyntheticGestureParams& other); 33 virtual ~SyntheticGestureParams(); 34 35 // Describes which type of input events synthetic gesture objects should 36 // generate. When specifying DEFAULT_INPUT the platform will be queried for 37 // the preferred input event type. 38 enum GestureSourceType { 39 DEFAULT_INPUT, 40 TOUCH_INPUT, 41 MOUSE_INPUT, 42 GESTURE_SOURCE_TYPE_MAX = MOUSE_INPUT 43 }; 44 GestureSourceType gesture_source_type; 45 46 enum GestureType { 47 SMOOTH_SCROLL_GESTURE, 48 PINCH_GESTURE, 49 TAP_GESTURE, 50 SYNTHETIC_GESTURE_TYPE_MAX = TAP_GESTURE 51 }; 52 virtual GestureType GetGestureType() const = 0; 53 54 // Returns true if the specific gesture source type is supported on this 55 // platform. 56 static bool IsGestureSourceTypeSupported( 57 GestureSourceType gesture_source_type); 58 }; 59 60 } // namespace content 61 62 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_GESTURE_PARAMS_H_ 63