Index: content/browser/renderer_host/input/synthetic_pointer_action_controller.cc |
diff --git a/content/browser/renderer_host/input/synthetic_pointer_action_controller.cc b/content/browser/renderer_host/input/synthetic_pointer_action_controller.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b653caeaa81a3c90dc6b5abb0e2ac8448eef3915 |
--- /dev/null |
+++ b/content/browser/renderer_host/input/synthetic_pointer_action_controller.cc |
@@ -0,0 +1,65 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/renderer_host/input/synthetic_pointer_action_controller.h" |
+ |
+namespace content { |
+ |
+SyntheticPointerActionController::SyntheticPointerActionController() |
+ : action_param_list_(new std::vector<SyntheticPointerActionParams>()) { |
+ std::fill(index_map_.begin(), index_map_.end(), -1); |
+} |
+SyntheticPointerActionController::~SyntheticPointerActionController() {} |
+ |
+std::unique_ptr<SyntheticGesture> |
+SyntheticPointerActionController::CreateSyntheticPointerAction( |
+ const SyntheticPointerActionParams& gesture_params) { |
+ DCHECK(gesture_params.pointer_action_type() != |
+ SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED); |
+ DCHECK(action_param_list_.get()); |
+ std::unique_ptr<SyntheticGesture> synthetic_gesture; |
+ if (gesture_params.pointer_action_type() != |
+ SyntheticPointerActionParams::PointerActionType::PROCESS) { |
+ action_param_list_->push_back(gesture_params); |
+ } |
+ |
+ if (gesture_params.pointer_action_type() == |
+ SyntheticPointerActionParams::PointerActionType::PROCESS || |
+ gesture_params.pointer_action_type() == |
+ SyntheticPointerActionParams::PointerActionType::FINISH) { |
+ // TODO(lanwei): Will support multiple pointer types in the same stream |
+ // later, see https://crbug.com/613303. |
+ if (!action_param_list_->empty()) { |
+ if (!synthetic_pointer_) |
+ SetSyntheticPointer(gesture_params); |
+ |
+ synthetic_gesture = std::unique_ptr<SyntheticGesture>( |
tdresser
2016/05/31 13:44:26
You can replace = std::unique_ptr<SyntheticGesture
lanwei
2016/06/02 13:26:27
Yes, thanks!
|
+ new SyntheticPointerAction(std::move(action_param_list_), |
+ synthetic_pointer_.get(), &index_map_)); |
+ action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); |
+ } |
+ } |
+ return synthetic_gesture; |
+} |
+ |
+void SyntheticPointerActionController::SetSyntheticPointer( |
+ const SyntheticPointerActionParams& gesture_params) { |
+ SyntheticGestureParams::GestureSourceType gesture_source_type = |
+ gesture_params.gesture_source_type; |
+ if (gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) |
+ gesture_source_type = default_type_; |
+ DCHECK_NE(gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); |
+ synthetic_pointer_ = SyntheticPointer::Create(gesture_source_type); |
+} |
+ |
+void SyntheticPointerActionController::ResetSyntheticPointer() { |
+ synthetic_pointer_.reset(); |
+} |
+ |
+void SyntheticPointerActionController::SetDefaultGestureSourceType( |
+ SyntheticGestureParams::GestureSourceType default_type) { |
+ default_type_ = default_type; |
+} |
+ |
+} // namespace content |