OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/download_resource_handler.h" | 5 #include "content/browser/download/download_resource_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // Success & not range response; if we asked for a range, we didn't | 232 // Success & not range response; if we asked for a range, we didn't |
233 // get it--reset the file pointers to reflect that. | 233 // get it--reset the file pointers to reflect that. |
234 info->save_info->offset = 0; | 234 info->save_info->offset = 0; |
235 info->save_info->hash_state = ""; | 235 info->save_info->hash_state = ""; |
236 } | 236 } |
237 | 237 |
238 if (!headers->GetMimeType(&info->original_mime_type)) | 238 if (!headers->GetMimeType(&info->original_mime_type)) |
239 info->original_mime_type.clear(); | 239 info->original_mime_type.clear(); |
240 } | 240 } |
241 | 241 |
| 242 // Blink verifies that the requester of this download is allowed to set a |
| 243 // suggested name for the security origin of the downlaod URL. However, this |
| 244 // assumption doesn't hold if there were cross origin redirects. Therefore, |
| 245 // clear the suggested_name for such requests. |
| 246 if (info->url_chain.size() > 1 && |
| 247 info->url_chain.front().GetOrigin() != info->url_chain.back().GetOrigin()) |
| 248 info->save_info->suggested_name.clear(); |
| 249 |
242 BrowserThread::PostTask( | 250 BrowserThread::PostTask( |
243 BrowserThread::UI, FROM_HERE, | 251 BrowserThread::UI, FROM_HERE, |
244 base::Bind(&StartOnUIThread, | 252 base::Bind(&StartOnUIThread, |
245 base::Passed(&info), | 253 base::Passed(&info), |
246 base::Owned(tab_info_), | 254 base::Owned(tab_info_), |
247 base::Passed(&stream_reader), | 255 base::Passed(&stream_reader), |
248 // Pass to StartOnUIThread so that variable | 256 // Pass to StartOnUIThread so that variable |
249 // access is always on IO thread but function | 257 // access is always on IO thread but function |
250 // is called on UI thread. | 258 // is called on UI thread. |
251 started_cb_)); | 259 started_cb_)); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // tab_info_ must be destroyed on UI thread, since | 541 // tab_info_ must be destroyed on UI thread, since |
534 // InitializeDownloadTabInfoOnUIThread might still be using it. | 542 // InitializeDownloadTabInfoOnUIThread might still be using it. |
535 if (tab_info_) | 543 if (tab_info_) |
536 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, tab_info_); | 544 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, tab_info_); |
537 | 545 |
538 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 546 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", |
539 base::TimeTicks::Now() - download_start_time_); | 547 base::TimeTicks::Now() - download_start_time_); |
540 } | 548 } |
541 | 549 |
542 } // namespace content | 550 } // namespace content |
OLD | NEW |