Commit 6baa1eae authored by Eugene But's avatar Eugene But Committed by Commit Bot

Handle subsequent download requests if URL is loaded from Omnibox.

Download Manager UI does not support multiple downloads per Tab.
When the second download is requested DM can either prompt the user to
replace the download or just silently drop the request.

Before this CL download request would be silently dropped if the user
typed the url into omnibox. This CL changes the login to prompt the
user.

It is still the desired behavior to silently drop the request if the
download was initiated by the web page to prevent page from spamming
the user.

Bug: 837602
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I262d3ef98c52995229567823e79df355761bff65
Reviewed-on: https://chromium-review.googlesource.com/1033332
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558729}
parent 16c08245
......@@ -49,10 +49,13 @@ void DownloadManagerTabHelper::Download(
}
// Another download is already in progress. Ask the user if current download
// should be replaced if new download was initiated by a link click. Otherwise
// silently drop the download to prevent web pages from spamming the user.
if (!ui::PageTransitionTypeIncludingQualifiersIs(
block_task->GetTransitionType(), ui::PAGE_TRANSITION_LINK)) {
// should be replaced if new download was initiated by a link click or typed
// into the omnibox. Otherwise silently drop the download to prevent web pages
// from spamming the user.
ui::PageTransition transition = block_task->GetTransitionType();
if (!(transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) &&
!ui::PageTransitionTypeIncludingQualifiersIs(transition,
ui::PAGE_TRANSITION_LINK)) {
return;
}
......
......@@ -54,7 +54,7 @@ TEST_F(DownloadManagerTabHelperTest, DownloadCreationForVisibleWebState) {
// Tests creating the second download while the first download is still in
// progress. Second download should be rejected because its transition type is
// not ui::PAGE_TRANSITION_LINK.
// not ui::PAGE_TRANSITION_LINK or ui::PAGE_TRANSITION_FROM_ADDRESS_BAR.
TEST_F(DownloadManagerTabHelperTest, DownloadRejection) {
web_state_->WasShown();
ASSERT_FALSE(delegate_.state);
......@@ -107,7 +107,7 @@ TEST_F(DownloadManagerTabHelperTest, DownloadReplacingViaDelegate) {
auto task2 = std::make_unique<web::FakeDownloadTask>(GURL(kUrl), kMimeType);
const web::FakeDownloadTask* task2_ptr = task2.get();
task2->SetTransitionType(ui::PAGE_TRANSITION_LINK);
task2->SetTransitionType(ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
tab_helper()->Download(std::move(task2));
ASSERT_TRUE(delegate_.state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment