OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/download/download_manager.h" | 5 #include "chrome/browser/download/download_manager.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // Same as above, delete the download if it is not in 'downloads_' (as the | 120 // Same as above, delete the download if it is not in 'downloads_' (as the |
121 // Remove() call above won't have deleted it). | 121 // Remove() call above won't have deleted it). |
122 if (handle == DownloadHistory::kUninitializedHandle) | 122 if (handle == DownloadHistory::kUninitializedHandle) |
123 delete download; | 123 delete download; |
124 } | 124 } |
125 to_remove.clear(); | 125 to_remove.clear(); |
126 | 126 |
127 in_progress_.clear(); | 127 in_progress_.clear(); |
128 dangerous_finished_.clear(); | 128 dangerous_finished_.clear(); |
129 STLDeleteValues(&downloads_); | 129 STLDeleteValues(&downloads_); |
| 130 STLDeleteContainerPointers(save_page_downloads_.begin(), |
| 131 save_page_downloads_.end()); |
130 | 132 |
131 file_manager_ = NULL; | 133 file_manager_ = NULL; |
132 | 134 |
133 // Make sure the save as dialog doesn't notify us back if we're gone before | 135 // Make sure the save as dialog doesn't notify us back if we're gone before |
134 // it returns. | 136 // it returns. |
135 if (select_file_dialog_.get()) | 137 if (select_file_dialog_.get()) |
136 select_file_dialog_->ListenerDestroyed(); | 138 select_file_dialog_->ListenerDestroyed(); |
137 | 139 |
138 download_history_.reset(); | 140 download_history_.reset(); |
139 | 141 |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 int DownloadManager::RemoveAllDownloads() { | 782 int DownloadManager::RemoveAllDownloads() { |
781 if (this != profile_->GetOriginalProfile()->GetDownloadManager()) { | 783 if (this != profile_->GetOriginalProfile()->GetDownloadManager()) { |
782 // This is an incognito downloader. Clear All should clear main download | 784 // This is an incognito downloader. Clear All should clear main download |
783 // manager as well. | 785 // manager as well. |
784 profile_->GetOriginalProfile()->GetDownloadManager()->RemoveAllDownloads(); | 786 profile_->GetOriginalProfile()->GetDownloadManager()->RemoveAllDownloads(); |
785 } | 787 } |
786 // The null times make the date range unbounded. | 788 // The null times make the date range unbounded. |
787 return RemoveDownloadsBetween(base::Time(), base::Time()); | 789 return RemoveDownloadsBetween(base::Time(), base::Time()); |
788 } | 790 } |
789 | 791 |
| 792 void DownloadManager::SavePageAsDownloadStarted(DownloadItem* download_item) { |
| 793 save_page_downloads_.push_back(download_item); |
| 794 } |
| 795 |
790 // Initiate a download of a specific URL. We send the request to the | 796 // Initiate a download of a specific URL. We send the request to the |
791 // ResourceDispatcherHost, and let it send us responses like a regular | 797 // ResourceDispatcherHost, and let it send us responses like a regular |
792 // download. | 798 // download. |
793 void DownloadManager::DownloadUrl(const GURL& url, | 799 void DownloadManager::DownloadUrl(const GURL& url, |
794 const GURL& referrer, | 800 const GURL& referrer, |
795 const std::string& referrer_charset, | 801 const std::string& referrer_charset, |
796 TabContents* tab_contents) { | 802 TabContents* tab_contents) { |
797 DownloadUrlToFile(url, referrer, referrer_charset, DownloadSaveInfo(), | 803 DownloadUrlToFile(url, referrer, referrer_charset, DownloadSaveInfo(), |
798 tab_contents); | 804 tab_contents); |
799 } | 805 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 observed_download_manager_->RemoveObserver(this); | 999 observed_download_manager_->RemoveObserver(this); |
994 } | 1000 } |
995 | 1001 |
996 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1002 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
997 observing_download_manager_->NotifyModelChanged(); | 1003 observing_download_manager_->NotifyModelChanged(); |
998 } | 1004 } |
999 | 1005 |
1000 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1006 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
1001 observed_download_manager_ = NULL; | 1007 observed_download_manager_ = NULL; |
1002 } | 1008 } |
OLD | NEW |