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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.os.SystemClock; 10 import android.os.SystemClock;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 * @param x The amount scrolled in the X direction. 330 * @param x The amount scrolled in the X direction.
331 * @param y The amount scrolled in the Y direction. 331 * @param y The amount scrolled in the Y direction.
332 * @return Whether or not the UI consumed and handled this event. 332 * @return Whether or not the UI consumed and handled this event.
333 */ 333 */
334 boolean didUIStealScroll(float x, float y); 334 boolean didUIStealScroll(float x, float y);
335 335
336 /** 336 /**
337 * Show the zoom picker UI. 337 * Show the zoom picker UI.
338 */ 338 */
339 public void invokeZoomPicker(); 339 public void invokeZoomPicker();
340
341 /**
342 * 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.
343 */
344 public void sendActionAfterDoubleTapUMA(
345 ContentViewCore.UMAActionAfterDoubleTap type,
346 boolean clickDelayEnabled);
347
348 /**
349 * Send single tap UMA
350 */
351 public void sendSingleTapUMA(ContentViewCore.UMASingleTapType type);
340 } 352 }
341 353
342 ContentViewGestureHandler( 354 ContentViewGestureHandler(
343 Context context, MotionEventDelegate delegate, ZoomManager zoomManag er, 355 Context context, MotionEventDelegate delegate, ZoomManager zoomManag er,
344 int inputEventDeliveryMode) { 356 int inputEventDeliveryMode) {
345 mExtraParamBundleSingleTap = new Bundle(); 357 mExtraParamBundleSingleTap = new Bundle();
346 mExtraParamBundleFling = new Bundle(); 358 mExtraParamBundleFling = new Bundle();
347 mExtraParamBundleScroll = new Bundle(); 359 mExtraParamBundleScroll = new Bundle();
348 mExtraParamBundleDoubleTapDragZoom = new Bundle(); 360 mExtraParamBundleDoubleTapDragZoom = new Bundle();
349 mExtraParamBundlePinchBy = new Bundle(); 361 mExtraParamBundlePinchBy = new Bundle();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 537 }
526 538
527 @Override 539 @Override
528 public boolean onSingleTapConfirmed(MotionEvent e) { 540 public boolean onSingleTapConfirmed(MotionEvent e) {
529 // Long taps in the edges of the screen have their event s delayed by 541 // Long taps in the edges of the screen have their event s delayed by
530 // ContentViewHolder for tab swipe operations. As a cons equence of the delay 542 // ContentViewHolder for tab swipe operations. As a cons equence of the delay
531 // this method might be called after receiving the up ev ent. 543 // this method might be called after receiving the up ev ent.
532 // These corner cases should be ignored. 544 // These corner cases should be ignored.
533 if (mLongPressDetector.isInLongPress() || mIgnoreSingleT ap) return true; 545 if (mLongPressDetector.isInLongPress() || mIgnoreSingleT ap) return true;
534 546
547 if (!isDoubleTapDisabled() && !mDisableClickDelay)
548 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.
549 ContentViewCore.UMASingleTapType.DELAYED_TAP );
550 else
551 mMotionEventDelegate.sendSingleTapUMA(
552 ContentViewCore.UMASingleTapType.UNDELAYED_T AP);
553
535 int x = (int) e.getX(); 554 int x = (int) e.getX();
536 int y = (int) e.getY(); 555 int y = (int) e.getY();
537 mExtraParamBundleSingleTap.putBoolean(SHOW_PRESS, mShowP ressIsCalled); 556 mExtraParamBundleSingleTap.putBoolean(SHOW_PRESS, mShowP ressIsCalled);
538 assert mExtraParamBundleSingleTap.size() == 1; 557 assert mExtraParamBundleSingleTap.size() == 1;
539 if (sendMotionEventAsGesture(GESTURE_SINGLE_TAP_CONFIRME D, e, 558 if (sendMotionEventAsGesture(GESTURE_SINGLE_TAP_CONFIRME D, e,
540 mExtraParamBundleSingleTap)) { 559 mExtraParamBundleSingleTap)) {
541 mIgnoreSingleTap = true; 560 mIgnoreSingleTap = true;
542 } 561 }
543 562
544 setClickXAndY(x, y); 563 setClickXAndY(x, y);
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 mNoTouchHandlerForGesture = false; 1149 mNoTouchHandlerForGesture = false;
1131 trySendPendingEventsToNative(); 1150 trySendPendingEventsToNative();
1132 } 1151 }
1133 1152
1134 private void recycleEvent(MotionEvent event) { 1153 private void recycleEvent(MotionEvent event) {
1135 event.recycle(); 1154 event.recycle();
1136 } 1155 }
1137 1156
1138 private boolean sendMotionEventAsGesture( 1157 private boolean sendMotionEventAsGesture(
1139 int type, MotionEvent event, Bundle extraParams) { 1158 int type, MotionEvent event, Bundle extraParams) {
1140 return mMotionEventDelegate.sendGesture(type, event.getEventTime(), 1159 return sendGesture(type, event.getEventTime(),
1141 (int) event.getX(), (int) event.getY(), extraParams); 1160 (int) event.getX(), (int) event.getY(), extraParams);
1142 } 1161 }
1143 1162
1144 private boolean sendGesture( 1163 private boolean sendGesture(
1145 int type, long timeMs, int x, int y, Bundle extraParams) { 1164 int type, long timeMs, int x, int y, Bundle extraParams) {
1165 updateDoubleTapUmaTimer();
1166
1167 if (type == GESTURE_DOUBLE_TAP)
1168 reportDoubleTap();
1169
1146 return mMotionEventDelegate.sendGesture(type, timeMs, x, y, extraParams) ; 1170 return mMotionEventDelegate.sendGesture(type, timeMs, x, y, extraParams) ;
1147 } 1171 }
1148 1172
1149 private boolean sendGestureAndRequestVSync( 1173 private boolean sendGestureAndRequestVSync(
1150 int type, long timeMs, int x, int y, Bundle extraParams) { 1174 int type, long timeMs, int x, int y, Bundle extraParams) {
1151 // VSync should only be signalled if the sent gesture was generated from a touch event. 1175 // VSync should only be signalled if the sent gesture was generated from a touch event.
1152 mSentGestureNeedsVSync = mInputEventsDeliveredAtVSync && mTouchEventHand lingStackDepth > 0; 1176 mSentGestureNeedsVSync = mInputEventsDeliveredAtVSync && mTouchEventHand lingStackDepth > 0;
1153 mLastVSyncGestureTimeMs = timeMs; 1177 mLastVSyncGestureTimeMs = timeMs;
1154 return mMotionEventDelegate.sendGesture(type, timeMs, x, y, extraParams) ; 1178 return sendGesture(type, timeMs, x, y, extraParams);
1155 } 1179 }
1156 1180
1157 void sendShowPressCancelIfNecessary(MotionEvent e) { 1181 void sendShowPressCancelIfNecessary(MotionEvent e) {
1158 if (!mShowPressIsCalled) return; 1182 if (!mShowPressIsCalled) return;
1159 1183
1160 if (sendMotionEventAsGesture(GESTURE_SHOW_PRESS_CANCEL, e, null)) { 1184 if (sendMotionEventAsGesture(GESTURE_SHOW_PRESS_CANCEL, e, null)) {
1161 mShowPressIsCalled = false; 1185 mShowPressIsCalled = false;
1162 mLastLongPressEvent = null; 1186 mLastLongPressEvent = null;
1163 } 1187 }
1164 } 1188 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 private void updateDoubleTapListener() { 1284 private void updateDoubleTapListener() {
1261 if (isDoubleTapDisabled()) { 1285 if (isDoubleTapDisabled()) {
1262 // Defer nulling the DoubleTapListener until the double tap gesture is complete. 1286 // Defer nulling the DoubleTapListener until the double tap gesture is complete.
1263 if (isDoubleTapActive()) return; 1287 if (isDoubleTapActive()) return;
1264 mGestureDetector.setOnDoubleTapListener(null); 1288 mGestureDetector.setOnDoubleTapListener(null);
1265 } else { 1289 } else {
1266 mGestureDetector.setOnDoubleTapListener(mDoubleTapListener); 1290 mGestureDetector.setOnDoubleTapListener(mDoubleTapListener);
1267 } 1291 }
1268 1292
1269 } 1293 }
1294
1295 public void reportDoubleTap() {
1296 // Make sure repeated double taps don't get silently dropped from
1297 // the statistics.
1298 if (mLastDoubleTapTimeMs > 0)
1299 mMotionEventDelegate.sendActionAfterDoubleTapUMA(
1300 ContentViewCore.UMAActionAfterDoubleTap.NO_ACTION,
1301 !mDisableClickDelay);
1302
1303 mLastDoubleTapTimeMs = SystemClock.uptimeMillis();
1304 }
1305
1306 public void reportActionAfterDoubleTapUMA(
1307 ContentViewCore.UMAActionAfterDoubleTap type) {
1308 updateDoubleTapUmaTimer();
1309
1310 if (mLastDoubleTapTimeMs == 0)
1311 return;
1312
1313 long nowMs = SystemClock.uptimeMillis();
1314 if ((nowMs - mLastDoubleTapTimeMs)
1315 < ACTION_AFTER_DOUBLE_TAP_WINDOW_MS) {
1316 mMotionEventDelegate.sendActionAfterDoubleTapUMA(
1317 type, !mDisableClickDelay);
1318 mLastDoubleTapTimeMs = 0;
1319 }
1320 }
1321
1322 // Watch for the UMA "action after double tap" timer expiring and reset
1323 // the timer if necessary.
1324 private void updateDoubleTapUmaTimer() {
1325 if (mLastDoubleTapTimeMs == 0)
1326 return;
1327
1328 long nowMs = SystemClock.uptimeMillis();
1329 if ((nowMs - mLastDoubleTapTimeMs)
1330 >= ACTION_AFTER_DOUBLE_TAP_WINDOW_MS) {
1331 // Time expired, user took no action (that we care about).
1332 mMotionEventDelegate.sendActionAfterDoubleTapUMA(
1333 ContentViewCore.UMAActionAfterDoubleTap.NO_ACTION,
1334 !mDisableClickDelay);
1335 mLastDoubleTapTimeMs = 0;
1336 }
1337 }
1338
1339 // Used for tracking UMA ActionAfterDoubleTap to tell user's immediate
1340 // action after a double tap.
1341 private long mLastDoubleTapTimeMs = 0;
1342 private static final long ACTION_AFTER_DOUBLE_TAP_WINDOW_MS = 5000;
1270 } 1343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698