• Yao Xiao's avatar
    Fix multiple download protection for <a download> x-origin redirect · dc5ed103
    Yao Xiao authored
    The bug: multiple downloads protection is bypassed when there are multiple
    <a download> download attempts and they end up triggering a x-origin redirect
    to another download.
    
    The cause: Each x-origin redirect following the <a download> is being treated as
    a navigation. (See DownloadManagerImpl::InterceptDownload() (NetworkService
    enabled), DownloadResourceHandler::OnRequestRedirected() (NetworkService
    disabled)). The navigation will hit
    DownloadRequestLimiter::TabDownloadState::DidStartNavigation that resets some
    state of the limiter, and future downloads won't be prevented.
    
    The solution: plumb |from_download_cross_origin_redirect| to NavigationRequest,
    and skip resetting the limiter state when the flag is true.
    
    Bug: 959640
    Change-Id: I7d8aca09670be5258e149e34e3e6f2f3107442ff
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627209Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
    Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
    Commit-Queue: Yao Xiao <yaoxia@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#665973}
    dc5ed103
mock_navigation_handle.h 7.12 KB