• Colin Blundell's avatar
    [WebLayer] Check for intent launching via NavigationThrottle · 877ff8e1
    Colin Blundell authored
    The current mechanism via which WebLayer intercepts navigations in order
    to handle launching of external intents is based on WebView's. It turns
    out that this mechanism
    (ContentBrowserClient::ShouldOverrideUrlLoading()) was added only due to
    specific complexities in WebView. It is not the mechanism used in
    Chrome, and as WebLayer does not inherit WebView's complexities here, it
    is desirable to instead use Chrome's model for intercepting these
    navigations.
    
    This CL changes WebLayer to follow that model, which is a
    NavigationThrottle-based approach. As part of this change, we also
    adapt //weblayer's ExternalNavigationHandler.java where necessary to more
    closely follow the //components-level that //chrome uses. The current
    WebLayer logic for determining when to override the navigation (which was
    also adapted from WebView) is preserved with two exceptions:
    
    1. The current short-circut out if the navigation is not a redirect and
       is either browser-initiated or a back-forward navigation is changed
       to be a short-circuit out if the navigation is a back-forward
       navigation. The reason is that this simplified check follows what
       //chrome does; nowhere in //chrome's InterceptNavigationDelegateImpl
       or ExternalNavigationHandler does it check anything about the
       navigation being browser-initiated, and its ExternalNavigationHandler
       short-circuit on back-forward navigations does not check whether the
       navigation is a redirect.
    2. There is no longer any check against the request method. Again, in
       //chrome's navigation interception there is also no such check.
    
    These minor changes were made in light of the overall goal of moving
    WebLayer's logic for intent launching to follow Chrome's; WebLayer will
    *share* this logic (including these checks) once it is using the
    //components-level ExternalNavigationHandler rather than the current
    custom one. This CL also will enable WebLayer to easily adapt
    (and potentially share) logic in //chrome's
    InterceptNavigationDelegateImpl.java in followup work.
    
    I verified manually that basic intenting out of WebLayer works after
    this change.
    
    Change-Id: I2ca54a802430496f9b9852e7a024eb979c49c93b
    Bug: 1031465
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102652Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
    Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
    Commit-Queue: Colin Blundell <blundell@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#750969}
    877ff8e1
BUILD.gn 16.1 KB