Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture.cc

Issue 1349813002: Enable pinch-zoom telemetry on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@telemetry
Patch Set: fix test macro issue Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/browser/renderer_host/input/synthetic_gesture.h" 5 #include "content/browser/renderer_host/input/synthetic_gesture.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
9 #include "content/browser/renderer_host/input/synthetic_pinch_gesture.h"
10 #include "content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h" 9 #include "content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h"
11 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h" 10 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
12 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" 11 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h"
12 #include "content/browser/renderer_host/input/synthetic_touchpad_pinch_gesture.h "
13 #include "content/browser/renderer_host/input/synthetic_touchscreen_pinch_gestur e.h"
13 14
14 namespace content { 15 namespace content {
15 namespace { 16 namespace {
16 17
17 template <typename GestureType, typename GestureParamsType> 18 template <typename GestureType, typename GestureParamsType>
18 static scoped_ptr<SyntheticGesture> CreateGesture( 19 static scoped_ptr<SyntheticGesture> CreateGesture(
19 const SyntheticGestureParams& gesture_params) { 20 const SyntheticGestureParams& gesture_params) {
20 return scoped_ptr<SyntheticGesture>( 21 return scoped_ptr<SyntheticGesture>(
21 new GestureType(*GestureParamsType::Cast(&gesture_params))); 22 new GestureType(*GestureParamsType::Cast(&gesture_params)));
22 } 23 }
23 24
24 } // namespace 25 } // namespace
25 26
26 SyntheticGesture::SyntheticGesture() {} 27 SyntheticGesture::SyntheticGesture() {}
27 28
28 SyntheticGesture::~SyntheticGesture() {} 29 SyntheticGesture::~SyntheticGesture() {}
29 30
30 scoped_ptr<SyntheticGesture> SyntheticGesture::Create( 31 scoped_ptr<SyntheticGesture> SyntheticGesture::Create(
31 const SyntheticGestureParams& gesture_params) { 32 const SyntheticGestureParams& gesture_params) {
32 switch (gesture_params.GetGestureType()) { 33 switch (gesture_params.GetGestureType()) {
33 case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: 34 case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE:
34 return CreateGesture<SyntheticSmoothScrollGesture, 35 return CreateGesture<SyntheticSmoothScrollGesture,
35 SyntheticSmoothScrollGestureParams>(gesture_params); 36 SyntheticSmoothScrollGestureParams>(gesture_params);
36 case SyntheticGestureParams::SMOOTH_DRAG_GESTURE: 37 case SyntheticGestureParams::SMOOTH_DRAG_GESTURE:
37 return CreateGesture<SyntheticSmoothDragGesture, 38 return CreateGesture<SyntheticSmoothDragGesture,
38 SyntheticSmoothDragGestureParams>(gesture_params); 39 SyntheticSmoothDragGestureParams>(gesture_params);
39 case SyntheticGestureParams::PINCH_GESTURE: 40 case SyntheticGestureParams::PINCH_GESTURE:
40 return CreateGesture<SyntheticPinchGesture, 41 // TODO(ericrk): Wire this all the way through to the python/js libraries
41 SyntheticPinchGestureParams>(gesture_params); 42 // and create a SyntheticTouchscreenGestureParams/
43 // SyntheticTouchpadGestureParams, removing the need for any
44 // special-casing.
45 if (SyntheticGestureParams::IsGestureSourceTypeSupported(
jdduke (slow) 2015/09/22 18:52:37 Hmm, in theory |gesture_params| can specify either
ericrk 2015/09/22 21:46:26 Makes sense. Went with the thin wrapper approach,
46 SyntheticGestureParams::TOUCH_INPUT)) {
47 // Only create a touchscreen gesture if we have touch input. If we
48 // report default or mouse input, create a touchpad gesture.
49 return CreateGesture<SyntheticTouchscreenPinchGesture,
50 SyntheticPinchGestureParams>(gesture_params);
51 } else {
52 return CreateGesture<SyntheticTouchpadPinchGesture,
53 SyntheticPinchGestureParams>(gesture_params);
54 }
42 case SyntheticGestureParams::TAP_GESTURE: 55 case SyntheticGestureParams::TAP_GESTURE:
43 return CreateGesture<SyntheticTapGesture, 56 return CreateGesture<SyntheticTapGesture,
44 SyntheticTapGestureParams>(gesture_params); 57 SyntheticTapGestureParams>(gesture_params);
45 } 58 }
46 NOTREACHED() << "Invalid synthetic gesture type"; 59 NOTREACHED() << "Invalid synthetic gesture type";
47 return scoped_ptr<SyntheticGesture>(); 60 return scoped_ptr<SyntheticGesture>();
48 } 61 }
49 62
50 // static 63 // static
51 double SyntheticGesture::ConvertTimestampToSeconds( 64 double SyntheticGesture::ConvertTimestampToSeconds(
52 const base::TimeTicks& timestamp) { 65 const base::TimeTicks& timestamp) {
53 return (timestamp - base::TimeTicks()).InSecondsF(); 66 return (timestamp - base::TimeTicks()).InSecondsF();
54 } 67 }
55 68
56 } // namespace content 69 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698