OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/download/url_downloader.h" | 5 #include "content/browser/download/url_downloader.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/threading/sequenced_task_runner_handle.h" | 10 #include "base/threading/sequenced_task_runner_handle.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return; | 109 return; |
110 | 110 |
111 request_->set_delegate(this); | 111 request_->set_delegate(this); |
112 request_->Start(); | 112 request_->Start(); |
113 } | 113 } |
114 | 114 |
115 void UrlDownloader::OnReceivedRedirect(net::URLRequest* request, | 115 void UrlDownloader::OnReceivedRedirect(net::URLRequest* request, |
116 const net::RedirectInfo& redirect_info, | 116 const net::RedirectInfo& redirect_info, |
117 bool* defer_redirect) { | 117 bool* defer_redirect) { |
118 DVLOG(1) << "OnReceivedRedirect: " << request_->url().spec(); | 118 DVLOG(1) << "OnReceivedRedirect: " << request_->url().spec(); |
119 request_->CancelWithError(net::ERR_ABORTED); | 119 |
| 120 // We are going to block redirects even if DownloadRequestCore allows it. No |
| 121 // redirects are expected for download requests that are made without a |
| 122 // renderer, which are currently exclusively resumption requests. Since there |
| 123 // is no security policy being applied here, it's safer to block redirects and |
| 124 // revisit if some previously unknown legitimate use case arises for redirects |
| 125 // while resuming. |
| 126 core_.OnWillAbort(DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE); |
| 127 request_->CancelWithError(net::ERR_UNSAFE_REDIRECT); |
120 } | 128 } |
121 | 129 |
122 void UrlDownloader::OnResponseStarted(net::URLRequest* request) { | 130 void UrlDownloader::OnResponseStarted(net::URLRequest* request) { |
123 DVLOG(1) << "OnResponseStarted: " << request_->url().spec(); | 131 DVLOG(1) << "OnResponseStarted: " << request_->url().spec(); |
124 | 132 |
125 if (!request_->status().is_success()) { | 133 if (!request_->status().is_success()) { |
126 ResponseCompleted(); | 134 ResponseCompleted(); |
127 return; | 135 return; |
128 } | 136 } |
129 | 137 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 Destroy(); | 250 Destroy(); |
243 } | 251 } |
244 | 252 |
245 void UrlDownloader::Destroy() { | 253 void UrlDownloader::Destroy() { |
246 BrowserThread::PostTask( | 254 BrowserThread::PostTask( |
247 BrowserThread::UI, FROM_HERE, | 255 BrowserThread::UI, FROM_HERE, |
248 base::Bind(&DownloadManagerImpl::RemoveUrlDownloader, manager_, this)); | 256 base::Bind(&DownloadManagerImpl::RemoveUrlDownloader, manager_, this)); |
249 } | 257 } |
250 | 258 |
251 } // namespace content | 259 } // namespace content |
OLD | NEW |