Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| index e4075f56ebd0d9943cb0317218848331c3cbefb3..6037b4a1a8649d7e8bfadc35251de9ee73d28a2c 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| @@ -23,6 +23,7 @@ import android.os.Build; |
| import android.os.Bundle; |
| import android.os.Handler; |
| import android.os.ResultReceiver; |
| +import android.os.SystemClock; |
| import android.provider.Browser; |
| import android.provider.Settings; |
| import android.text.Editable; |
| @@ -67,6 +68,7 @@ import org.chromium.content.browser.input.InputMethodManagerWrapper; |
| import org.chromium.content.browser.input.InsertionHandleController; |
| import org.chromium.content.browser.input.SelectPopupDialog; |
| import org.chromium.content.browser.input.SelectionHandleController; |
| +import org.chromium.content.common.CommandLine; |
| import org.chromium.content.common.TraceEvent; |
| import org.chromium.ui.ViewAndroid; |
| import org.chromium.ui.ViewAndroidDelegate; |
| @@ -451,6 +453,12 @@ public class ContentViewCore |
| private ViewAndroid mViewAndroid; |
| + // Used for tracking UMA ActionAfterDoubleTap to tell user's immediate action after |
| + // a double tap. |
| + private long mLastDoubleTapTime = 0; |
| + private static final long ACTION_AFTER_DOUBLE_TAP_WINDOW = 5000; |
|
Rick Byers
2013/10/31 17:53:10
add an _MS suffix to make it clear this is millise
bokan
2013/10/31 22:31:58
Done.
|
| + private static boolean mHasClickDelay; |
| + |
| /** |
| * Constructs a new ContentViewCore. Embedders must call initialize() after constructing |
| @@ -768,6 +776,8 @@ public class ContentViewCore |
| mPid = nativeGetCurrentRenderProcessId(mNativeContentViewCore); |
| sendOrientationChangeEvent(); |
| + |
| + mHasClickDelay = !CommandLine.getInstance().hasSwitch(CommandLine.DISABLE_CLICK_DELAY); |
|
Rick Byers
2013/10/31 17:53:10
If you move the logic in this file into ContentVie
bokan
2013/10/31 22:31:58
Done.
|
| } |
| @CalledByNative |
| @@ -1307,12 +1317,47 @@ public class ContentViewCore |
| } |
| } |
| + // Enum for immediate user action after a double tap UMA stat. |
| + // Be sure to update histograms.xml and the SendActionAfterDoubleTapUma |
| + // native method if you change these |
| + public static class ActionAfterDoubleTap { |
| + public static final int NAVIGATE_BACK = 0; |
| + public static final int NAVIGATE_STOP = 1; |
| + public static final int NO_ACTION = 2; |
| + } |
| + |
| + public void updateActionAfterDoubleTapUMA(int actionType) { |
| + long now = SystemClock.uptimeMillis(); |
| + if (mLastDoubleTapTime > 0 |
| + && (now - mLastDoubleTapTime) < ACTION_AFTER_DOUBLE_TAP_WINDOW) { |
| + nativeSendActionAfterDoubleTapUma( |
| + mNativeContentViewCore, |
| + actionType, |
| + mHasClickDelay); |
| + } |
| + |
| + mLastDoubleTapTime = 0; |
| + } |
| + |
| + private void updateDoubleTapUmaTimer(long curTimeMs) { |
| + if (mLastDoubleTapTime > 0 |
| + && curTimeMs - mLastDoubleTapTime >= ACTION_AFTER_DOUBLE_TAP_WINDOW) { |
| + // Time expired, user took no action (that we care about) |
| + nativeSendActionAfterDoubleTapUma( |
| + mNativeContentViewCore, |
| + ActionAfterDoubleTap.NO_ACTION, |
| + mHasClickDelay); |
| + mLastDoubleTapTime = 0; |
| + } |
| + } |
| + |
| @Override |
| public boolean sendGesture(int type, long timeMs, int x, int y, Bundle b) { |
| if (offerGestureToEmbedder(type)) return false; |
| if (mNativeContentViewCore == 0) return false; |
| updateTextHandlesForGesture(type); |
| updateGestureStateListener(type, b); |
| + updateDoubleTapUmaTimer(timeMs); |
|
Rick Byers
2013/10/31 17:53:10
what exactly is this timeMs here - the original ev
bokan
2013/10/31 22:31:58
It was supposed to be the current time. I've chang
|
| switch (type) { |
| case ContentViewGestureHandler.GESTURE_SHOW_PRESSED_STATE: |
| nativeShowPressState(mNativeContentViewCore, timeMs, x, y); |
| @@ -1324,6 +1369,7 @@ public class ContentViewCore |
| nativeTapDown(mNativeContentViewCore, timeMs, x, y); |
| return true; |
| case ContentViewGestureHandler.GESTURE_DOUBLE_TAP: |
| + mLastDoubleTapTime = timeMs; |
|
Rick Byers
2013/10/31 17:53:10
If we didn't report an UMA above but mLastDoubleTa
bokan
2013/10/31 22:31:58
Done.
|
| nativeDoubleTap(mNativeContentViewCore, timeMs, x, y); |
| return true; |
| case ContentViewGestureHandler.GESTURE_SINGLE_TAP_UP: |
| @@ -3352,4 +3398,7 @@ public class ContentViewCore |
| private native void nativeSetAccessibilityEnabled( |
| int nativeContentViewCoreImpl, boolean enabled); |
| + |
| + private native void nativeSendActionAfterDoubleTapUma(int nativeContentViewCoreImpl, |
| + int type, boolean hasDelay); |
| } |