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..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); |
|
Ted C
2013/11/07 04:26:08
move up on the previous line
bokan
2013/11/07 06:26:42
Done.
|
| + |
| + /** |
| + * 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(); |
|
Ted C
2013/11/07 04:26:08
in java, braces are always required unless the con
bokan
2013/11/07 06:26:42
Done.
|
| + |
| 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() { |
|
Ted C
2013/11/07 04:26:08
all public methods should have javadoc...that bein
bokan
2013/11/07 06:26:42
Done.
|
| + // Make sure repeated double taps don't get silently dropped from |
| + // the statistics. |
| + if (mLastDoubleTapTimeMs > 0) |
|
Ted C
2013/11/07 04:26:08
braces required
bokan
2013/11/07 06:26:42
Done.
|
| + mMotionEventDelegate.sendActionAfterDoubleTapUMA( |
| + ContentViewCore.UMAActionAfterDoubleTap.NO_ACTION, |
| + !mDisableClickDelay); |
|
Ted C
2013/11/07 04:26:08
with a line length of 100 chars, does this fit on
bokan
2013/11/07 06:26:42
Yup, done.
|
| + |
| + mLastDoubleTapTimeMs = SystemClock.uptimeMillis(); |
| + } |
| + |
| + public void reportActionAfterDoubleTapUMA(int type) { |
|
Ted C
2013/11/07 04:26:08
javadoc
bokan
2013/11/07 06:26:42
Done.
|
| + updateDoubleTapUmaTimer(); |
| + |
| + if (mLastDoubleTapTimeMs == 0) |
|
Ted C
2013/11/07 04:26:08
put return on same line
bokan
2013/11/07 06:26:42
Done.
|
| + 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) |
|
Ted C
2013/11/07 04:26:08
return on this line
bokan
2013/11/07 06:26:42
Done.
|
| + return; |
| + |
| + long nowMs = SystemClock.uptimeMillis(); |
| + if ((nowMs - mLastDoubleTapTimeMs) |
| + >= ACTION_AFTER_DOUBLE_TAP_WINDOW_MS) { |
|
Ted C
2013/11/07 04:26:08
does this not fit under a 100 chars if on the prev
bokan
2013/11/07 06:26:42
It does, I didn't realize the line length in Java
|
| + // Time expired, user took no action (that we care about). |
| + mMotionEventDelegate.sendActionAfterDoubleTapUMA( |
| + ContentViewCore.UMAActionAfterDoubleTap.NO_ACTION, |
| + !mDisableClickDelay); |
|
Ted C
2013/11/07 04:26:08
put on previous line
bokan
2013/11/07 06:26:42
Done.
|
| + mLastDoubleTapTimeMs = 0; |
| + } |
| + } |
| + |
| + // Used for tracking UMA ActionAfterDoubleTap to tell user's immediate |
| + // action after a double tap. |
| + private long mLastDoubleTapTimeMs = 0; |
|
Ted C
2013/11/07 04:26:08
0 is the default so it's not necessary to specify
bokan
2013/11/07 06:26:42
Done.
|
| + private static final long ACTION_AFTER_DOUBLE_TAP_WINDOW_MS = 5000; |
|
Ted C
2013/11/07 04:26:08
local variables at the top of the file (constants
bokan
2013/11/07 06:26:42
Done.
|
| } |