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

Unified Diff: content/browser/download/download_item_impl.cc

Issue 14947007: [Downloads] Allow acquiring dangerous download file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r201622 Created 7 years, 7 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
Index: content/browser/download/download_item_impl.cc
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index 6f06e3252d6d50b2bc89f8cd68d821edf547cb3b..8116a3f3b3b8ab40eb1b9c1497505108db14dd6a 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -68,9 +68,12 @@ void DeleteDownloadedFile(const base::FilePath& path) {
// Wrapper around DownloadFile::Detach and DownloadFile::Cancel that
// takes ownership of the DownloadFile and hence implicitly destroys it
// at the end of the function.
-static void DownloadFileDetach(scoped_ptr<DownloadFile> download_file) {
+static base::FilePath DownloadFileDetach(
+ scoped_ptr<DownloadFile> download_file) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ base::FilePath full_path = download_file->FullPath();
download_file->Detach();
+ return full_path;
}
static void DownloadFileCancel(scoped_ptr<DownloadFile> download_file) {
@@ -402,6 +405,23 @@ void DownloadItemImpl::Delete(DeleteReason reason) {
// We have now been deleted.
}
+void DownloadItemImpl::AcquireFileAndDeleteDownload(
+ const AcquireFileCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (download_file_) {
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&DownloadFileDetach, base::Passed(&download_file_)),
+ callback);
+ } else {
+ callback.Run(current_path_);
Randy Smith (Not in Mondays) 2013/05/23 13:56:43 Under what circumstances will we take this path?
asanka 2013/05/24 01:17:11 It could also be interrupted.
+ }
+ current_path_.clear();
+ Delete(DELETE_DUE_TO_USER_DISCARD);
+}
+
void DownloadItemImpl::Remove() {
VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true);
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -1398,10 +1418,11 @@ void DownloadItemImpl::ReleaseDownloadFile(bool destroy_file) {
// current_path_.
current_path_.clear();
} else {
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- // Will be deleted at end of task execution.
- base::Bind(&DownloadFileDetach, base::Passed(&download_file_)));
+ BrowserThread::PostTask(BrowserThread::FILE,
+ FROM_HERE,
+ // Will be deleted at end of task execution.
Randy Smith (Not in Mondays) 2013/05/23 13:56:43 Could you move this comment down a line to make cl
asanka 2013/05/24 01:17:11 Done.
+ base::Bind(base::IgnoreResult(&DownloadFileDetach),
+ base::Passed(&download_file_)));
}
// Don't accept any more messages from the DownloadFile, and null
// out any previous "all data received". This also breaks links to

Powered by Google App Engine
This is Rietveld 408576698