| OLD | NEW | 
|   1 // Copyright 2016 The Chromium Authors. All rights reserved. |   1 // Copyright 2016 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_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |   5 #ifndef CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ | 
|   6 #define CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |   6 #define CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ | 
|   7  |   7  | 
|   8 #include "base/logging.h" |   8 #include "base/logging.h" | 
|   9 #include "content/common/content_export.h" |   9 #include "content/common/content_export.h" | 
|  10 #include "content/common/input/input_param_traits.h" |  10 #include "content/common/input/input_param_traits.h" | 
|  11 #include "content/common/input/synthetic_gesture_params.h" |  11 #include "content/common/input/synthetic_gesture_params.h" | 
|  12 #include "ui/gfx/geometry/point_f.h" |  12 #include "ui/gfx/geometry/point_f.h" | 
|  13  |  13  | 
|  14 namespace ipc_fuzzer { |  14 namespace ipc_fuzzer { | 
|  15 template <class T> |  15 template <class T> | 
|  16 struct FuzzTraits; |  16 struct FuzzTraits; | 
|  17 }  // namespace ipc_fuzzer |  17 }  // namespace ipc_fuzzer | 
|  18  |  18  | 
|  19 namespace content { |  19 namespace content { | 
|  20  |  20  | 
|  21 struct CONTENT_EXPORT SyntheticPointerActionParams |  21 struct CONTENT_EXPORT SyntheticPointerActionParams | 
|  22     : public SyntheticGestureParams { |  22     : public SyntheticGestureParams { | 
|  23  public: |  23  public: | 
|  24   // Actions are queued up until we receive a PROCESS action, at which point |  24   // Actions are queued up until we receive a PROCESS action, at which point | 
|  25   // we'll dispatch all queued events. |  25   // we'll dispatch all queued events. A FINISH action will be received when | 
 |  26   // we reach the end of the action sequence. | 
|  26   enum class PointerActionType { |  27   enum class PointerActionType { | 
|  27     NOT_INITIALIZED, |  28     NOT_INITIALIZED, | 
|  28     PRESS, |  29     PRESS, | 
|  29     MOVE, |  30     MOVE, | 
|  30     RELEASE, |  31     RELEASE, | 
|  31     PROCESS, |  32     PROCESS, | 
|  32     POINTER_ACTION_TYPE_MAX = PROCESS |  33     FINISH, | 
 |  34     POINTER_ACTION_TYPE_MAX = FINISH | 
|  33   }; |  35   }; | 
|  34  |  36  | 
|  35   SyntheticPointerActionParams(); |  37   SyntheticPointerActionParams(); | 
|  36   explicit SyntheticPointerActionParams(PointerActionType type); |  38   explicit SyntheticPointerActionParams(PointerActionType type); | 
|  37   SyntheticPointerActionParams(const SyntheticPointerActionParams& other); |  39   SyntheticPointerActionParams(const SyntheticPointerActionParams& other); | 
|  38   ~SyntheticPointerActionParams() override; |  40   ~SyntheticPointerActionParams() override; | 
|  39  |  41  | 
|  40   GestureType GetGestureType() const override; |  42   GestureType GetGestureType() const override; | 
|  41  |  43  | 
|  42   static const SyntheticPointerActionParams* Cast( |  44   static const SyntheticPointerActionParams* Cast( | 
|  43       const SyntheticGestureParams* gesture_params); |  45       const SyntheticGestureParams* gesture_params); | 
|  44  |  46  | 
|  45   void set_pointer_action_type(PointerActionType pointer_action_type) { |  47   void set_pointer_action_type(PointerActionType pointer_action_type) { | 
|  46     pointer_action_type_ = pointer_action_type; |  48     pointer_action_type_ = pointer_action_type; | 
|  47   } |  49   } | 
|  48  |  50  | 
|  49   void set_index(int index) { |  51   void set_index(int index) { | 
|  50     DCHECK(pointer_action_type_ != PointerActionType::PROCESS); |  52     DCHECK(pointer_action_type_ != PointerActionType::PROCESS && | 
 |  53            pointer_action_type_ != PointerActionType::FINISH); | 
|  51     index_ = index; |  54     index_ = index; | 
|  52   } |  55   } | 
|  53  |  56  | 
|  54   void set_position(const gfx::PointF& position) { |  57   void set_position(const gfx::PointF& position) { | 
|  55     DCHECK(pointer_action_type_ == PointerActionType::PRESS || |  58     DCHECK(pointer_action_type_ == PointerActionType::PRESS || | 
|  56            pointer_action_type_ == PointerActionType::MOVE); |  59            pointer_action_type_ == PointerActionType::MOVE); | 
|  57     position_ = position; |  60     position_ = position; | 
|  58   } |  61   } | 
|  59  |  62  | 
|  60   PointerActionType pointer_action_type() const { return pointer_action_type_; } |  63   PointerActionType pointer_action_type() const { return pointer_action_type_; } | 
|  61  |  64  | 
|  62   int index() const { |  65   int index() const { | 
|  63     DCHECK(pointer_action_type_ != PointerActionType::PROCESS); |  66     DCHECK(pointer_action_type_ != PointerActionType::PROCESS && | 
 |  67            pointer_action_type_ != PointerActionType::FINISH); | 
|  64     return index_; |  68     return index_; | 
|  65   } |  69   } | 
|  66  |  70  | 
|  67   gfx::PointF position() const { |  71   gfx::PointF position() const { | 
|  68     DCHECK(pointer_action_type_ == PointerActionType::PRESS || |  72     DCHECK(pointer_action_type_ == PointerActionType::PRESS || | 
|  69            pointer_action_type_ == PointerActionType::MOVE); |  73            pointer_action_type_ == PointerActionType::MOVE); | 
|  70     return position_; |  74     return position_; | 
|  71   } |  75   } | 
|  72  |  76  | 
|  73  private: |  77  private: | 
|  74   friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; |  78   friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; | 
|  75   friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; |  79   friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; | 
|  76  |  80  | 
|  77   PointerActionType pointer_action_type_; |  81   PointerActionType pointer_action_type_; | 
|  78   // Pass a position value when sending a press or move action. |  82   // Pass a position value when sending a press or move action. | 
|  79   gfx::PointF position_; |  83   gfx::PointF position_; | 
|  80   // Pass an index value except if the pointer_action_type_ is PROCESS. |  84   // Pass an index value except if the pointer_action_type_ is PROCESS. | 
|  81   int index_; |  85   int index_; | 
|  82 }; |  86 }; | 
|  83  |  87  | 
|  84 }  // namespace content |  88 }  // namespace content | 
|  85  |  89  | 
|  86 #endif  // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |  90 #endif  // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ | 
| OLD | NEW |