Chromium Code Reviews| 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..29631b4920005883cc8a45fdd298900902f91081 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,18 @@ class ContentViewGestureHandler implements LongPressDelegate { |
| * Show the zoom picker UI. |
| */ |
| public void invokeZoomPicker(); |
| + |
| + /** |
| + * Send action after dobule tap for UMA stat tracking |
|
Rick Byers
2013/11/01 19:27:03
nit - missing period here and below.
Rick Byers
2013/11/01 19:27:03
nit - Looks like convention is to add javadoc comm
bokan
2013/11/01 19:54:02
Done.
bokan
2013/11/01 19:54:02
Done.
|
| + */ |
| + public void sendActionAfterDoubleTapUMA( |
| + ContentViewCore.UMAActionAfterDoubleTap type, |
| + boolean clickDelayEnabled); |
| + |
| + /** |
| + * Send single tap UMA |
| + */ |
| + public void sendSingleTapUMA(ContentViewCore.UMASingleTapType type); |
| } |
| ContentViewGestureHandler( |
| @@ -532,6 +544,13 @@ class ContentViewGestureHandler implements LongPressDelegate { |
| // These corner cases should be ignored. |
| if (mLongPressDetector.isInLongPress() || mIgnoreSingleTap) return true; |
| + if (!isDoubleTapDisabled() && !mDisableClickDelay) |
| + mMotionEventDelegate.sendSingleTapUMA( |
|
Rick Byers
2013/11/01 19:27:03
nit - don't repeat the call to the function, just
bokan
2013/11/01 19:54:02
Done.
|
| + ContentViewCore.UMASingleTapType.DELAYED_TAP); |
| + else |
| + mMotionEventDelegate.sendSingleTapUMA( |
| + ContentViewCore.UMASingleTapType.UNDELAYED_TAP); |
| + |
| int x = (int) e.getX(); |
| int y = (int) e.getY(); |
| mExtraParamBundleSingleTap.putBoolean(SHOW_PRESS, mShowPressIsCalled); |
| @@ -1137,12 +1156,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 +1175,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 +1291,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; |
| } |