| 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..26fcbab1c1aa053a0fa1ae752adf89fb91dd5efe 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(
|
| + int type,
|
| + boolean clickDelayEnabled);
|
| +
|
| + /**
|
| + * Send single tap UMA.
|
| + * @param type The tap type: delayed or undelayed
|
| + */
|
| + public void sendSingleTapUMA(int type);
|
| }
|
|
|
| ContentViewGestureHandler(
|
| @@ -509,6 +524,12 @@ class ContentViewGestureHandler implements LongPressDelegate {
|
| mIgnoreSingleTap = true;
|
| }
|
| setClickXAndY((int) x, (int) y);
|
| +
|
| + mMotionEventDelegate.sendSingleTapUMA(
|
| + isDoubleTapDisabled() ?
|
| + ContentViewCore.UMASingleTapType.UNDELAYED_TAP :
|
| + ContentViewCore.UMASingleTapType.DELAYED_TAP);
|
| +
|
| return true;
|
| } else if (isDoubleTapDisabled() || mDisableClickDelay) {
|
| // If double tap has been disabled, there is no need to wait
|
| @@ -532,6 +553,11 @@ class ContentViewGestureHandler implements LongPressDelegate {
|
| // These corner cases should be ignored.
|
| if (mLongPressDetector.isInLongPress() || mIgnoreSingleTap) return true;
|
|
|
| + mMotionEventDelegate.sendSingleTapUMA(
|
| + isDoubleTapDisabled() ?
|
| + 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 +1163,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 +1182,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 +1298,52 @@ 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(int 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;
|
| }
|
|
|