• Emily Stark's avatar
    Fix HTTP auth cancellation tracking when there's no visible entry · 93781c70
    Emily Stark authored
    When an HTTP auth prompt is cancelled, we close the prompt and refresh
    the page to retrieve the 401 error body from the server. There is some
    logic in LoginNavigationThrottle/LoginTabHelper that tracks/detects
    these refreshes to handle them specially, i.e. not re-show an auth
    prompt when the refresh commits. This logic was looking at
    NavigationController:GetVisibleEntry() to determine when an observed
    navigation was one of these refresh navigations -- but a visible entry
    is not always guaranteed to exist, leading to crashes. One correct fix
    would be to check for a null visible entry, but instead we now look at
    the pending entry. This is more specific because the pending entry is
    the one that would be for the refresh.
    
    Note: this fix relies on the assumption that GetPendingEntry() will
    always be non-null during a main-frame WillProcessResponse(). I think
    this condition is guaranteed, but if I'm wrong, it will show up as
    crashes when dereferencing GetPendingEntry(). In that case we'll need
    to add a check for a null GetPendingEntry().
    
    Bug: 1005096
    Change-Id: If4a72ca903e14da588c0ee515648e8d2694f8612
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1819331
    Commit-Queue: Emily Stark <estark@chromium.org>
    Reviewed-by: default avatarCarlos IL <carlosil@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#699074}
    93781c70
login_handler_browsertest.cc 74.2 KB