Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/PopupZoomer.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/PopupZoomer.java b/content/public/android/java/src/org/chromium/content/browser/PopupZoomer.java |
| index bec4df581dd348df7631b23d3a57e622c6c2f034..1dfe8f3685e4c5655e76d64c0885f31730445f87 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/PopupZoomer.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/PopupZoomer.java |
| @@ -30,11 +30,14 @@ import android.view.animation.OvershootInterpolator; |
| import org.chromium.base.ApiCompatibilityUtils; |
| import org.chromium.base.Log; |
| +import org.chromium.base.metrics.RecordHistogram; |
| import org.chromium.content.R; |
| /** |
| - * PopupZoomer is used to show the on-demand link zooming popup. It handles manipulation of the |
| - * canvas and touch events to display the on-demand zoom magnifier. |
| + * PopupZoomer is used to show the tap disambiguation popup. When a tap lands ambiguously |
| + * between two tiny touch targets (usually links) on a desktop site viewed on a phone, |
| + * a magnified view of the content is shown, the screen is grayed out and the user |
| + * must re-tap the magnified content in order to clarify their intent. |
| */ |
| class PopupZoomer extends View { |
| private static final String TAG = "cr.PopupZoomer"; |
| @@ -46,6 +49,15 @@ class PopupZoomer extends View { |
| // Time it takes for the animation to finish in ms. |
| private static final long ANIMATION_DURATION = 300; |
| + // Note that these values should be cross-checked against |
| + // tools/metrics/histograms/histograms.xml. |
|
Ilya Sherman
2017/03/24 22:16:56
Please also document that, since it is used to bac
aelias_OOO_until_Jul13
2017/03/24 22:30:31
Done.
|
| + private static final String UMA_TAPDISAMBIGUATION = "PopupZoomer.TapDisambiguation"; |
| + private static final int UMA_TAPDISAMBIGUATION_TAPPEDINSIDE = 0; |
| + private static final int UMA_TAPDISAMBIGUATION_TAPPEDOUTSIDE = 1; |
|
Ilya Sherman
2017/03/24 22:16:56
nit: Why do you not have underscores between "TAP"
aelias_OOO_until_Jul13
2017/03/24 22:30:31
I prefer to use the underscore as a category separ
|
| + private static final int UMA_TAPDISAMBIGUATION_BACKBUTTON = 2; |
| + private static final int UMA_TAPDISAMBIGUATION_OTHER = 3; |
| + private static final int UMA_TAPDISAMBIGUATION_COUNT = 4; |
| + |
| /** |
| * Interface to be implemented to listen for touch events inside the zoomed area. |
| * The MotionEvent coordinates correspond to original unzoomed view. |
| @@ -188,7 +200,7 @@ class PopupZoomer extends View { |
| if (mAnimating) return true; |
| if (isTouchOutsideArea(e1.getX(), e1.getY())) { |
| - hide(true); |
| + tappedOutside(); |
| } else { |
| scroll(distanceX, distanceY); |
| } |
| @@ -211,8 +223,7 @@ class PopupZoomer extends View { |
| float x = e.getX(); |
| float y = e.getY(); |
| if (isTouchOutsideArea(x, y)) { |
| - // User clicked on area outside the popup. |
| - hide(true); |
| + tappedOutside(); |
| } else if (mOnTapListener != null) { |
| PointF converted = convertTouchPoint(x, y); |
| MotionEvent event = MotionEvent.obtainNoHistory(e); |
| @@ -222,7 +233,7 @@ class PopupZoomer extends View { |
| } else { |
| mOnTapListener.onSingleTap(PopupZoomer.this, event); |
| } |
| - hide(true); |
| + tappedInside(); |
| } |
| return true; |
| } |
| @@ -509,18 +520,46 @@ class PopupZoomer extends View { |
| } |
| /** |
| - * Hide the PopupZoomer view. |
| + * Hide the PopupZoomer view because of some external event such as focus |
| + * change, JS-originating scroll, etc. |
| * @param animation true if hide with animation. |
| */ |
| public void hide(boolean animation) { |
| if (!mShowing) return; |
| + RecordHistogram.recordEnumeratedHistogram( |
| + UMA_TAPDISAMBIGUATION, UMA_TAPDISAMBIGUATION_OTHER, UMA_TAPDISAMBIGUATION_COUNT); |
| + |
| if (animation) { |
| startAnimation(false); |
| } else { |
| hideImmediately(); |
| } |
| } |
| + private void tappedInside() { |
| + if (!mShowing) return; |
| + RecordHistogram.recordEnumeratedHistogram(UMA_TAPDISAMBIGUATION, |
| + UMA_TAPDISAMBIGUATION_TAPPEDINSIDE, UMA_TAPDISAMBIGUATION_COUNT); |
| + |
| + startAnimation(false); |
| + } |
| + |
| + private void tappedOutside() { |
| + if (!mShowing) return; |
| + RecordHistogram.recordEnumeratedHistogram(UMA_TAPDISAMBIGUATION, |
| + UMA_TAPDISAMBIGUATION_TAPPEDOUTSIDE, UMA_TAPDISAMBIGUATION_COUNT); |
|
Ilya Sherman
2017/03/24 22:16:57
nit: It's generally a best-practice to have one ca
aelias_OOO_until_Jul13
2017/03/24 22:30:31
Done.
|
| + |
| + startAnimation(false); |
| + } |
| + |
| + public void backButtonPressed() { |
| + if (!mShowing) return; |
| + |
| + RecordHistogram.recordEnumeratedHistogram(UMA_TAPDISAMBIGUATION, |
| + UMA_TAPDISAMBIGUATION_BACKBUTTON, UMA_TAPDISAMBIGUATION_COUNT); |
| + |
| + startAnimation(false); |
| + } |
| /** |
| * Converts the coordinates to a point on the original un-zoomed view. |