Avoid launching apps for HTTP navigations not initiated by the user#8520
Draft
kzar wants to merge 1 commit into
Draft
Avoid launching apps for HTTP navigations not initiated by the user#8520kzar wants to merge 1 commit into
kzar wants to merge 1 commit into
Conversation
The Wall Street Journal (WSJ) app sometimes loads articles inside a Chrome Custom Tab (CCT)[1]. When it does, if the user's default browser was set to DuckDuckGo, they could sometimes be trapped in a CCT -> App Link redirection loop, as their phone switched from the DuckDuckGo browser, back to the WSJ, and back again repeatedly. It turns out, that Chromium has some logic[2] to ensure that such navigations are user-initiated before opening the registered app for it. Let's do the same. Notes: - The isUserQuery() check allows navigations that were initiated by the user via the address bar to then be opened in an app. - Non-HTTP App Links are handled via `handleNonHttpAppLink` which isn't changed here. Chromium seems to force a user prompt for non-user-initiated non-HTTP navigations, we could consider doing the same in the future. 1 - https://developer.chrome.com/docs/android/custom-tabs 2 - https://source.chromium.org/chromium/chromium/src/+/09aafe21bc1b6c78e92fa4197d4e3c8401caaee9:components/external_intents/android/java/src/org/chromium/components/external_intents/ExternalNavigationHandler.java;l=1230-1235
839a1c7 to
fa6117e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task/Issue URL: https://app.asana.com/1/137249556945/inbox/1200776578788342/item/1211781703927439/story/1214682781164811?focus=true
Description
The Wall Street Journal (WSJ) app sometimes loads articles inside a Chrome
Custom Tab (CCT)[1]. When it does, if the user's default browser was set to
DuckDuckGo, they could sometimes be trapped in a CCT -> App Link redirection
loop, as their phone switched from the DuckDuckGo browser, back to the WSJ, and
back again repeatedly.
It turns out, that Chromium has some logic[2] to ensure that such navigations
are user-initiated before opening the registered app for it. Let's do the same.
Notes:
via the address bar to then be opened in an app.
handleNonHttpAppLinkwhich isn't changedhere. Chromium seems to force a user prompt for non-user-initiated non-HTTP
navigations, we could consider doing the same in the future.
1 - https://developer.chrome.com/docs/android/custom-tabs
2 - https://source.chromium.org/chromium/chromium/src/+/09aafe21bc1b6c78e92fa4197d4e3c8401caaee9:components/external_intents/android/java/src/org/chromium/components/external_intents/ExternalNavigationHandler.java;l=1230-1235
Steps to test this PR