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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java

Issue 53283003: Added UMA stat for tracking accidental navigations on double tap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
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 2ccf09bb4166257089adeb5c709153c5df5d0a6b..0ee9e6a41929197cf90915dd65277681addab7d0 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
@@ -336,6 +336,11 @@ class ContentViewGestureHandler implements LongPressDelegate {
* Show the zoom picker UI.
*/
public void invokeZoomPicker();
+
+ /**
+ * Send user action for UMA stat tracking
+ */
+ public void sendUserActionUMA(int actionType, boolean clickDelayEnabled);
}
ContentViewGestureHandler(
@@ -531,6 +536,9 @@ class ContentViewGestureHandler implements LongPressDelegate {
// These corner cases should be ignored.
if (mLongPressDetector.isInLongPress() || mIgnoreSingleTap) return true;
+ if (!isDoubleTapDisabled() && !mDisableClickDelay)
+ reportActionForUMA(ContentViewCore.UMAUserAction.DELAYED_TAP);
+
int x = (int) e.getX();
int y = (int) e.getY();
mExtraParamBundleSingleTap.putBoolean(SHOW_PRESS, mShowPressIsCalled);
@@ -1136,12 +1144,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)
+ reportActionForUMA(ContentViewCore.UMAUserAction.DOUBLE_TAP);
+
return mMotionEventDelegate.sendGesture(type, timeMs, x, y, extraParams);
}
@@ -1150,7 +1163,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 +1280,56 @@ class ContentViewGestureHandler implements LongPressDelegate {
}
}
+
+
+ public void reportActionForUMA(int actionType) {
+ updateDoubleTapUmaTimer();
+
+ if (actionType == ContentViewCore.UMAUserAction.DOUBLE_TAP) {
Rick Byers 2013/11/01 14:45:09 I think it would be cleaner to just handle this ca
bokan 2013/11/01 18:52:44 Done.
+ // Make sure repeated double taps don't get silently dropped from
+ // the statistics.
+ if (mLastDoubleTapTimeMs > 0)
+ mMotionEventDelegate.sendUserActionUMA(
+ ContentViewCore.UMAUserAction.NO_ACTION,
+ !mDisableClickDelay);
+
+ mLastDoubleTapTimeMs = SystemClock.uptimeMillis();
+ } else if (actionType == ContentViewCore.UMAUserAction.DELAYED_TAP) {
+ mMotionEventDelegate.sendUserActionUMA(
+ actionType, !mDisableClickDelay);
+ } else {
+ if (mLastDoubleTapTimeMs == 0)
+ return;
+
+ long nowMs = SystemClock.uptimeMillis();
+ if ((nowMs - mLastDoubleTapTimeMs)
+ < ACTION_AFTER_DOUBLE_TAP_WINDOW_MS) {
+ mMotionEventDelegate.sendUserActionUMA(
+ actionType, !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.sendUserActionUMA(
+ ContentViewCore.UMAUserAction.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;
}

Powered by Google App Engine
This is Rietveld 408576698