Commit 4320b396 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Apply UserGesture token to intents from incognito.

This doesn't fix any known (to me) bugs (and please revert if it breaks
anything).

However, it does two things:
1. It makes the code more consistent.
2. It fixes what might be a bad incognito detection method? The dialog
probably makes this too obnoxious to use in practice, but it might give
a site a way to know if the user is in incognito.

The user gesture code was added in
https://codereview.chromium.org/1243253004/, which doesn't mention
incognito at all, so I'm thinking it was probably just an oversight
that the gesture token doesn't get applied while in incognito?

Bug: 1006927
Change-Id: I74458549cea9f4aec65c6c41c0a73b4869d44115
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832699
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702309}
parent 65e801cc
......@@ -674,6 +674,12 @@ public class ExternalNavigationHandler {
// Make sure this extra is not sent unless we've done the verification.
targetIntent.removeExtra(InstantAppsHandler.IS_GOOGLE_SEARCH_REFERRER);
}
// The intent can be used to launch Chrome itself, record the user
// gesture here so that it can be used later.
if (params.hasUserGesture()) {
IntentWithGesturesHandler.getInstance().onNewIntentWithGesture(targetIntent);
}
}
private @OverrideUrlLoadingResult int shouldOverrideUrlLoadingInternal(
......@@ -822,12 +828,6 @@ public class ExternalNavigationHandler {
}
}
// The intent can be used to launch Chrome itself, record the user
// gesture here so that it can be used later.
if (params.hasUserGesture()) {
IntentWithGesturesHandler.getInstance().onNewIntentWithGesture(targetIntent);
}
switch (launchWebApkIfSoleIntentHandler(params, resolvingInfos, targetIntent)) {
case WebApkLaunchDecision.ALREADY_IN_WEBAPK:
if (DEBUG) Log.i(TAG, "Already in WebAPK");
......
......@@ -1557,6 +1557,39 @@ public class ExternalNavigationHandlerTest {
Assert.assertFalse(mDelegate.startIncognitoIntentCalled);
}
@Test
@SmallTest
public void testUserGesture_Regular() {
// IMDB app is installed.
mDelegate.add(new IntentActivity("imdb:", INTENT_APP_PACKAGE_NAME));
checkUrl(INTENT_URL_WITH_FALLBACK_URL)
.withReferrer(SEARCH_RESULT_URL_FOR_TOM_HANKS)
.withHasUserGesture(true)
.expecting(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT,
START_OTHER_ACTIVITY);
Assert.assertTrue(IntentWithGesturesHandler.getInstance().getUserGestureAndClear(
mDelegate.startActivityIntent));
Assert.assertFalse(mDelegate.startIncognitoIntentCalled);
}
@Test
@SmallTest
public void testUserGesture_Incognito() {
// IMDB app is installed.
mDelegate.add(new IntentActivity("imdb:", INTENT_APP_PACKAGE_NAME));
checkUrl(INTENT_URL_WITH_FALLBACK_URL)
.withReferrer(SEARCH_RESULT_URL_FOR_TOM_HANKS)
.withHasUserGesture(true)
.withIsIncognito(true)
.expecting(OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION,
START_INCOGNITO | START_OTHER_ACTIVITY);
Assert.assertTrue(IntentWithGesturesHandler.getInstance().getUserGestureAndClear(
mDelegate.startActivityIntent));
Assert.assertTrue(mDelegate.startIncognitoIntentCalled);
}
private static ResolveInfo newResolveInfo(String packageName) {
ActivityInfo ai = new ActivityInfo();
ai.packageName = packageName;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment