Index: content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java |
index a680c9823e2a5198f97fca9f9ba0447bd16c0985..09375a97f9217df18ff47ab67814deab683e4679 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java |
@@ -337,6 +337,21 @@ class ContentViewGestureHandler implements LongPressDelegate { |
* Show the zoom picker UI. |
*/ |
public void invokeZoomPicker(); |
+ |
+ /** |
+ * Send action after dobule tap for UMA stat tracking. |
+ * @param type The action that occured |
+ * @param clickDelayEnabled Whether the tap down delay is active |
+ */ |
+ public void sendActionAfterDoubleTapUMA( |
+ ContentViewCore.UMAActionAfterDoubleTap type, |
+ boolean clickDelayEnabled); |
+ |
+ /** |
+ * Send single tap UMA. |
+ * @param type The tap type: delayed or undelayed |
+ */ |
+ public void sendSingleTapUMA(ContentViewCore.UMASingleTapType type); |
} |
ContentViewGestureHandler( |
@@ -532,6 +547,11 @@ class ContentViewGestureHandler implements LongPressDelegate { |
// These corner cases should be ignored. |
if (mLongPressDetector.isInLongPress() || mIgnoreSingleTap) return true; |
+ mMotionEventDelegate.sendSingleTapUMA( |
+ isDoubleTapDisabled() || mDisableClickDelay ? |
jdduke (slow)
2013/11/01 20:17:46
I'm not sure it makes complete sense to group |isD
WRONG-USE-chromium
2013/11/02 12:58:45
The idea with this metric is completely separate f
bokan
2013/11/04 20:01:08
Agreed. Since this statistic is unrelated to accid
|
+ ContentViewCore.UMASingleTapType.UNDELAYED_TAP : |
+ ContentViewCore.UMASingleTapType.DELAYED_TAP); |
+ |
int x = (int) e.getX(); |
int y = (int) e.getY(); |
mExtraParamBundleSingleTap.putBoolean(SHOW_PRESS, mShowPressIsCalled); |
@@ -1137,12 +1157,17 @@ class ContentViewGestureHandler implements LongPressDelegate { |
private boolean sendMotionEventAsGesture( |
int type, MotionEvent event, Bundle extraParams) { |
- return mMotionEventDelegate.sendGesture(type, event.getEventTime(), |
+ return sendGesture(type, event.getEventTime(), |
(int) event.getX(), (int) event.getY(), extraParams); |
} |
private boolean sendGesture( |
int type, long timeMs, int x, int y, Bundle extraParams) { |
+ updateDoubleTapUmaTimer(); |
+ |
+ if (type == GESTURE_DOUBLE_TAP) |
+ reportDoubleTap(); |
+ |
return mMotionEventDelegate.sendGesture(type, timeMs, x, y, extraParams); |
} |
@@ -1151,7 +1176,7 @@ class ContentViewGestureHandler implements LongPressDelegate { |
// VSync should only be signalled if the sent gesture was generated from a touch event. |
mSentGestureNeedsVSync = mInputEventsDeliveredAtVSync && mTouchEventHandlingStackDepth > 0; |
mLastVSyncGestureTimeMs = timeMs; |
- return mMotionEventDelegate.sendGesture(type, timeMs, x, y, extraParams); |
+ return sendGesture(type, timeMs, x, y, extraParams); |
} |
void sendShowPressCancelIfNecessary(MotionEvent e) { |
@@ -1267,4 +1292,53 @@ class ContentViewGestureHandler implements LongPressDelegate { |
} |
} |
+ |
+ public void reportDoubleTap() { |
+ // Make sure repeated double taps don't get silently dropped from |
+ // the statistics. |
+ if (mLastDoubleTapTimeMs > 0) |
+ mMotionEventDelegate.sendActionAfterDoubleTapUMA( |
+ ContentViewCore.UMAActionAfterDoubleTap.NO_ACTION, |
+ !mDisableClickDelay); |
+ |
+ mLastDoubleTapTimeMs = SystemClock.uptimeMillis(); |
+ } |
+ |
+ public void reportActionAfterDoubleTapUMA( |
+ ContentViewCore.UMAActionAfterDoubleTap type) { |
+ updateDoubleTapUmaTimer(); |
+ |
+ if (mLastDoubleTapTimeMs == 0) |
+ return; |
+ |
+ long nowMs = SystemClock.uptimeMillis(); |
+ if ((nowMs - mLastDoubleTapTimeMs) |
+ < ACTION_AFTER_DOUBLE_TAP_WINDOW_MS) { |
+ mMotionEventDelegate.sendActionAfterDoubleTapUMA( |
+ type, !mDisableClickDelay); |
+ mLastDoubleTapTimeMs = 0; |
+ } |
+ } |
+ |
+ // Watch for the UMA "action after double tap" timer expiring and reset |
+ // the timer if necessary. |
+ private void updateDoubleTapUmaTimer() { |
+ if (mLastDoubleTapTimeMs == 0) |
+ return; |
+ |
+ long nowMs = SystemClock.uptimeMillis(); |
+ if ((nowMs - mLastDoubleTapTimeMs) |
+ >= ACTION_AFTER_DOUBLE_TAP_WINDOW_MS) { |
+ // Time expired, user took no action (that we care about). |
+ mMotionEventDelegate.sendActionAfterDoubleTapUMA( |
+ ContentViewCore.UMAActionAfterDoubleTap.NO_ACTION, |
+ !mDisableClickDelay); |
+ mLastDoubleTapTimeMs = 0; |
+ } |
+ } |
+ |
+ // Used for tracking UMA ActionAfterDoubleTap to tell user's immediate |
+ // action after a double tap. |
+ private long mLastDoubleTapTimeMs = 0; |
+ private static final long ACTION_AFTER_DOUBLE_TAP_WINDOW_MS = 5000; |
} |