Skip to content

Commit

Permalink
Expand comments on ExternalNavigationHandler#shouldKeepIntentRedirect…
Browse files Browse the repository at this point in the history
…InApp

I was having trouble figuring out what this function was for and whether
it was still necessary (it is). So I've re-written the comments and
expanded on them to hopefully be clearer.

Change-Id: Iceaa8db9a76d7c8f2e3a3112c0e478307a0a713a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3774834
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Commit-Queue: Yaron Friedman <yfriedman@chromium.org>
Auto-Submit: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1026215}
  • Loading branch information
Michael Thiessen authored and Chromium LUCI CQ committed Jul 20, 2022
1 parent 688a46b commit 2323b14
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1403,11 +1403,15 @@ private void onUserDecidedWhetherToLaunchIncognitoIntent(final boolean shouldLau
}

/**
* If some third-party app launched this app with an intent, and the URL got redirected, and the
* user explicitly chose this app over other intent handlers, stay in the app unless there was a
* new intent handler after redirection or the app cannot handle it internally any more.
* Custom tabs are an exception to this rule, since at no point, the user sees an intent picker
* and "picking the Chrome app" is handled inside the support library.
* If another app, or the user, chose to launch this app for an intent, we should keep that
* navigation within this app through redirects until it resolves to a new app or external
* protocol given this app was intentionally chosen. Custom tabs always explicitly target the
* browser and this issue is handled elsewhere through
* {@link RedirectHandler#intentPrefersToStayInChrome()}.
*
* Usually this covers cases like https://www.youtube.com/ redirecting to
* https://m.youtube.com/. Note that this isn't covered by {@link #shouldStayWithinHost()} as
* for intent navigation there is no previously committed URL.
*/
private boolean shouldKeepIntentRedirectInApp(ExternalNavigationParams params,
boolean incomingIntentRedirect, List<ResolveInfo> resolvingInfos,
Expand All @@ -1416,7 +1420,7 @@ private boolean shouldKeepIntentRedirectInApp(ExternalNavigationParams params,
&& !params.getRedirectHandler().isFromCustomTabIntent()
&& !params.getRedirectHandler().hasNewResolver(
resolvingInfos, (Intent intent) -> queryIntentActivities(intent))) {
if (DEBUG) Log.i(TAG, "Custom tab redirect no handled");
if (DEBUG) Log.i(TAG, "Intent navigation with no new handlers.");
return true;
}
return false;
Expand Down

0 comments on commit 2323b14

Please sign in to comment.