Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1617)

Unified Diff: chrome/browser/download/download_manager.cc

Issue 7212017: Add save package download items to history. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/save_page_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_manager.cc
===================================================================
--- chrome/browser/download/download_manager.cc (revision 91035)
+++ chrome/browser/download/download_manager.cc (working copy)
@@ -524,7 +524,7 @@
SelectFileDialog::FileTypeInfo file_type_info;
FilePath::StringType extension = suggested_path.Extension();
if (!extension.empty()) {
- extension.erase(extension.begin()); // drop the .
+ extension.erase(extension.begin()); // drop the .
file_type_info.extensions.resize(1);
file_type_info.extensions[0].push_back(extension);
}
@@ -975,11 +975,14 @@
return RemoveDownloadsBetween(base::Time(), base::Time());
}
-void DownloadManager::SavePageAsDownloadStarted(DownloadItem* download_item) {
+void DownloadManager::SavePageAsDownloadStarted(DownloadItem* download) {
#if !defined(NDEBUG)
- save_page_as_downloads_.insert(download_item);
+ save_page_as_downloads_.insert(download);
#endif
- downloads_.insert(download_item);
+ downloads_.insert(download);
+ // Add to history and notify observers.
+ AddDownloadItemToHistory(download, DownloadHistory::kUninitializedHandle);
+ NotifyModelChanged();
}
// Initiate a download of a specific URL. We send the request to the
@@ -1163,20 +1166,10 @@
CheckForHistoryFilesRemoval();
}
-// Once the new DownloadItem's creation info has been committed to the history
-// service, we associate the DownloadItem with the db handle, update our
-// 'history_downloads_' map and inform observers.
-void DownloadManager::OnCreateDownloadEntryComplete(int32 download_id,
- int64 db_handle) {
+void DownloadManager::AddDownloadItemToHistory(DownloadItem* download,
+ int64 db_handle) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DownloadItem* download = GetActiveDownloadItem(download_id);
- if (!download)
- return;
- VLOG(20) << __FUNCTION__ << "()" << " db_handle = " << db_handle
- << " download_id = " << download_id
- << " download = " << download->DebugString(true);
-
// It's not immediately obvious, but HistoryBackend::CreateDownload() can
// call this function with an invalid |db_handle|. For instance, this can
// happen when the history database is offline. We cannot have multiple
@@ -1194,7 +1187,24 @@
DCHECK(!ContainsKey(history_downloads_, download->db_handle()));
history_downloads_[download->db_handle()] = download;
+}
+// Once the new DownloadItem's creation info has been committed to the history
+// service, we associate the DownloadItem with the db handle, update our
+// 'history_downloads_' map and inform observers.
+void DownloadManager::OnCreateDownloadEntryComplete(int32 download_id,
+ int64 db_handle) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DownloadItem* download = GetActiveDownloadItem(download_id);
+ if (!download)
+ return;
+
+ VLOG(20) << __FUNCTION__ << "()" << " db_handle = " << db_handle
+ << " download_id = " << download_id
+ << " download = " << download->DebugString(true);
+
+ AddDownloadItemToHistory(download, db_handle);
+
// Show in the appropriate browser UI.
// This includes buttons to save or cancel, for a dangerous download.
ShowDownloadInBrowser(download);
@@ -1222,7 +1232,6 @@
}
void DownloadManager::ShowDownloadInBrowser(DownloadItem* download) {
-
// The 'contents' may no longer exist if the user closed the tab before we
// get this start completion event. If it does, tell the origin TabContents
// to display its download shelf.
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/save_page_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698