diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/download/download_manager.h | 3 | ||||
-rw-r--r-- | chrome/browser/download/save_package.cc | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h index f4dc78d..4bbf49a 100644 --- a/chrome/browser/download/download_manager.h +++ b/chrome/browser/download/download_manager.h @@ -135,7 +135,8 @@ class DownloadManager // deleted is returned back to the caller. int RemoveAllDownloads(); - // Called when a Save Page As download is started. + // Called when a Save Page As download is started. Transfers ownership + // of |download_item| to the DownloadManager. void SavePageAsDownloadStarted(DownloadItem* download_item); // Download the object at the URL. Used in cases such as "Save Link As..." diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index 9fccd6e..f624e44 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -370,9 +370,17 @@ bool SavePackage::Init() { request_context_getter_ = profile->GetRequestContext(); // Create the fake DownloadItem and display the view. - download_ = new DownloadItem(tab_contents_->profile()->GetDownloadManager(), - saved_main_file_path_, page_url_, + DownloadManager* download_manager = + tab_contents_->profile()->GetDownloadManager(); + download_ = new DownloadItem(download_manager, + saved_main_file_path_, + page_url_, profile->IsOffTheRecord()); + + // Transfer the ownership to the download manager. We need the DownloadItem + // to be alive as long as the Profile is alive. + download_manager->SavePageAsDownloadStarted(download_); + tab_contents_->OnStartDownload(download_); // Check save type and process the save page job. |