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

Unified Diff: content/public/browser/download_item.h

Issue 14947007: [Downloads] Allow acquiring dangerous download file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename methods and get rid of Delete() 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/public/browser/download_item.h
diff --git a/content/public/browser/download_item.h b/content/public/browser/download_item.h
index b3003ef9e8aa3997c6a4e7691bca6d192dec0f63..f8d93bba2668d0c35233df55dbbade1521b8f1dc 100644
--- a/content/public/browser/download_item.h
+++ b/content/public/browser/download_item.h
@@ -21,6 +21,7 @@
#include <string>
#include <vector>
+#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "base/string16.h"
#include "base/supports_user_data.h"
@@ -67,12 +68,6 @@ class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
MAX_DOWNLOAD_STATE
};
- // Reason for deleting the download. Passed to Delete().
- enum DeleteReason {
- DELETE_DUE_TO_BROWSER_SHUTDOWN = 0,
- DELETE_DUE_TO_USER_DISCARD
- };
-
// How the final target path should be used.
enum TargetDisposition {
TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists.
@@ -81,6 +76,9 @@ class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
// TARGET_DISPOSITION_OVERWRITE.
};
+ // Callback used with AcquireFileAndDeleteDownload().
+ typedef base::Callback<void(const base::FilePath&)> AcquireFileCallback;
+
static const char kEmptyFileHash[];
// Interface that observers of a particular download must implement in order
@@ -111,7 +109,14 @@ class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
// User Actions --------------------------------------------------------------
// Called when the user has validated the download of a dangerous file.
- virtual void DangerousDownloadValidated() = 0;
+ virtual void ValidateDangerousDownload() = 0;
+
+ // Called to acquire a dangerous download and remove the DownloadItem from
+ // views and history. |callback| will be invoked on the UI thread with the
+ // path to the downloaded file. The caller is responsible for cleanup.
+ // Note: It is important for |callback| to be valid since the downloaded file
+ // will not be cleaned up if the callback fails.
+ virtual void StealDangerousDownload(const AcquireFileCallback& callback) = 0;
// Pause a download. Will have no effect if the download is already
// paused.
@@ -132,11 +137,8 @@ class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
// when resuming a download (assuming the server supports byte ranges).
virtual void Cancel(bool user_cancel) = 0;
- // Deletes the file from disk and removes the download from the views and
- // history.
- virtual void Delete(DeleteReason reason) = 0;
-
- // Removes the download from the views and history.
+ // Removes the download from the views and history. If the download was
+ // in-progress, then the downloaded file will also be deleted.
virtual void Remove() = 0;
// Open the file associated with this download. If the download is
@@ -241,7 +243,7 @@ class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
virtual bool GetFileExternallyRemoved() const = 0;
// True if the file that will be written by the download is dangerous
- // and we will require a call to DangerousDownloadValidated() to complete.
+ // and we will require a call to ValidateDangerousDownload() to complete.
// False if the download is safe or that function has been called.
virtual bool IsDangerous() const = 0;

Powered by Google App Engine
This is Rietveld 408576698