Index: content/browser/download/url_downloader.cc |
diff --git a/content/browser/download/url_downloader.cc b/content/browser/download/url_downloader.cc |
index b178a1d4b2654f52099ef953e1b179b18ed5554a..f708fe515f48498daf97f188ed5d141b76c261b0 100644 |
--- a/content/browser/download/url_downloader.cc |
+++ b/content/browser/download/url_downloader.cc |
@@ -146,6 +146,15 @@ void UrlDownloader::OnReceivedRedirect(net::URLRequest* request, |
const net::RedirectInfo& redirect_info, |
bool* defer_redirect) { |
DVLOG(1) << "OnReceivedRedirect: " << request_->url().spec(); |
+ handler_.OnRequestRedirected(redirect_info); |
+ |
+ // We are going to block redirects even if DownloadRequestCore allows it. No |
+ // redirects are expected for download requests that are made without a |
+ // renderer, which are currently exclusively resumption requests. Since there |
+ // is no security policy being applied here, it's safer to block redirects and |
+ // revisit if some previously unknown legitimate use case arises for redirects |
+ // while resuming. |
+ CallStartedCallbackOnFailure(DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE); |
request_->CancelWithError(net::ERR_ABORTED); |
svaldez
2016/01/13 17:29:18
Might actually want to change this to a more appro
asanka
2016/01/28 02:24:17
Changed to ERR_UNSAFE_REDIRECT which is the error
|
} |
@@ -160,7 +169,13 @@ void UrlDownloader::OnResponseStarted(net::URLRequest* request) { |
scoped_ptr<DownloadCreateInfo> create_info; |
scoped_ptr<ByteStreamReader> stream_reader; |
- handler_.OnResponseStarted(&create_info, &stream_reader); |
+ DownloadInterruptReason result = |
+ handler_.OnResponseStarted(&create_info, &stream_reader); |
+ if (result != DOWNLOAD_INTERRUPT_REASON_NONE) { |
+ CallStartedCallbackOnFailure(result); |
+ Done(); |
+ return; |
+ } |
create_info->download_id = download_id_; |
create_info->request_handle.reset( |
@@ -252,9 +267,7 @@ void UrlDownloader::ResponseCompleted() { |
DVLOG(1) << "ResponseCompleted: " << request_->url().spec(); |
handler_.OnResponseCompleted(request_->status()); |
- BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, |
- base::Bind(&DownloadManagerImpl::RemoveUrlDownloader, manager_, this)); |
+ Done(); |
} |
void UrlDownloader::ResumeReading() { |
@@ -283,6 +296,10 @@ void UrlDownloader::ResumeRequest() { |
} |
void UrlDownloader::CancelRequest() { |
+ Done(); |
+} |
+ |
+void UrlDownloader::Done() { |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
base::Bind(&DownloadManagerImpl::RemoveUrlDownloader, manager_, this)); |