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/save_package.h" | 5 #include "content/browser/download/save_package.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
12 #include "base/i18n/file_util_icu.h" | 13 #include "base/i18n/file_util_icu.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
17 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 BrowserContext* browser_context = web_contents()->GetBrowserContext(); | 309 BrowserContext* browser_context = web_contents()->GetBrowserContext(); |
309 if (!browser_context) { | 310 if (!browser_context) { |
310 NOTREACHED(); | 311 NOTREACHED(); |
311 return false; | 312 return false; |
312 } | 313 } |
313 | 314 |
314 scoped_ptr<DownloadRequestHandleInterface> request_handle( | 315 scoped_ptr<DownloadRequestHandleInterface> request_handle( |
315 new SavePackageRequestHandle(AsWeakPtr())); | 316 new SavePackageRequestHandle(AsWeakPtr())); |
316 // The download manager keeps ownership but adds us as an observer. | 317 // The download manager keeps ownership but adds us as an observer. |
317 download_manager_->CreateSavePackageDownloadItem( | 318 download_manager_->CreateSavePackageDownloadItem( |
318 saved_main_file_path_, | 319 saved_main_file_path_, page_url_, |
319 page_url_, | 320 ((save_type_ == SAVE_PAGE_TYPE_AS_MHTML) ? "multipart/related" |
320 ((save_type_ == SAVE_PAGE_TYPE_AS_MHTML) ? | 321 : "text/html"), |
321 "multipart/related" : "text/html"), | 322 std::move(request_handle), |
322 request_handle.Pass(), | |
323 base::Bind(&SavePackage::InitWithDownloadItem, AsWeakPtr(), | 323 base::Bind(&SavePackage::InitWithDownloadItem, AsWeakPtr(), |
324 download_created_callback)); | 324 download_created_callback)); |
325 return true; | 325 return true; |
326 } | 326 } |
327 | 327 |
328 void SavePackage::InitWithDownloadItem( | 328 void SavePackage::InitWithDownloadItem( |
329 const SavePackageDownloadCreatedCallback& download_created_callback, | 329 const SavePackageDownloadCreatedCallback& download_created_callback, |
330 DownloadItemImpl* item) { | 330 DownloadItemImpl* item) { |
331 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 331 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
332 DCHECK(item); | 332 DCHECK(item); |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 | 1494 |
1495 void SavePackage::FinalizeDownloadEntry() { | 1495 void SavePackage::FinalizeDownloadEntry() { |
1496 DCHECK(download_); | 1496 DCHECK(download_); |
1497 DCHECK(download_manager_); | 1497 DCHECK(download_manager_); |
1498 | 1498 |
1499 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1499 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1500 StopObservation(); | 1500 StopObservation(); |
1501 } | 1501 } |
1502 | 1502 |
1503 } // namespace content | 1503 } // namespace content |
OLD | NEW |