Commit b0ee3ace authored by Max Curran's avatar Max Curran Committed by Commit Bot

Fixed issue where HTML files marked as attachments were failing to download.

Downloaded HTML were being intercepted and being downloaded as Offline Pages. In cases where the headers included "Content-Disposition: attachment", the Offline Page download would fail. I have added an extra constraint when intercepting the download that excludes cases with the specified header.

Bug: 1041209
Change-Id: Ia3c3ca1db4e4526c355700ed661c390a06de2d2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443791
Commit-Queue: Max Curran <curranmax@chromium.org>
Auto-Submit: Max Curran <curranmax@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812957}
parent ef0b673f
......@@ -98,6 +98,7 @@
#include "chrome/browser/download/android/download_utils.h"
#include "chrome/browser/download/android/mixed_content_download_infobar_delegate.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "net/http/http_content_disposition.h"
#else
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
......@@ -689,8 +690,12 @@ bool ChromeDownloadManagerDelegate::InterceptDownloadIfApplicable(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// For background service downloads we don't want offline pages backend to
// intercept the download. |is_transient| flag is used to determine whether
// the download corresponds to background service.
// the download corresponds to background service. Additionally we don't want
// offline pages backend to intercept html files explicitly marked as
// attachments.
if (!is_transient &&
!net::HttpContentDisposition(content_disposition, std::string())
.is_attachment() &&
offline_pages::OfflinePageUtils::CanDownloadAsOfflinePage(url,
mime_type)) {
offline_pages::OfflinePageUtils::ScheduleDownload(
......
......@@ -870,6 +870,11 @@ TEST_F(ChromeDownloadManagerDelegateTest, InterceptDownloadByOfflinePages) {
should_intercept = delegate()->InterceptDownloadIfApplicable(
kUrl, "", "", mime_type, "", 10, true /*is_transient*/, nullptr);
EXPECT_FALSE(should_intercept);
should_intercept = delegate()->InterceptDownloadIfApplicable(
kUrl, "", "attachment" /*content_disposition*/, mime_type, "", 10,
false /*is_transient*/, nullptr);
EXPECT_FALSE(should_intercept);
}
#endif
......
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