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

Unified Diff: chrome/browser/download/download_target_determiner.h

Issue 2453633006: [downloads] Move platform specific code out of DownloadTargetDeterminer. (Closed)
Patch Set: . Created 3 years, 9 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: chrome/browser/download/download_target_determiner.h
diff --git a/chrome/browser/download/download_target_determiner.h b/chrome/browser/download/download_target_determiner.h
index 66bca7acd534dbee3e66d21a39e123eaf879f50b..d840d509bf19b736c555422523331120af7a6209 100644
--- a/chrome/browser/download/download_target_determiner.h
+++ b/chrome/browser/download/download_target_determiner.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_
#include <memory>
+#include <string>
#include "base/files/file_path.h"
#include "base/macros.h"
@@ -55,8 +56,8 @@ enum DownloadDangerType;
class DownloadTargetDeterminer
: public content::DownloadItem::Observer {
public:
- typedef base::Callback<void(std::unique_ptr<DownloadTargetInfo>)>
- CompletionCallback;
+ using CompletionCallback =
+ base::Callback<void(std::unique_ptr<DownloadTargetInfo>)>;
// Start the process of determing the target of |download|.
//
@@ -74,11 +75,13 @@ class DownloadTargetDeterminer
// determination is complete or after |download| is destroyed.
//
// Start() should be called on the UI thread.
- static void Start(content::DownloadItem* download,
- const base::FilePath& initial_virtual_path,
- DownloadPrefs* download_prefs,
- DownloadTargetDeterminerDelegate* delegate,
- const CompletionCallback& callback);
+ static void Start(
+ content::DownloadItem* download,
+ const base::FilePath& initial_virtual_path,
+ DownloadPathReservationTracker::FilenameConflictAction conflict_action,
+ DownloadPrefs* download_prefs,
+ DownloadTargetDeterminerDelegate* delegate,
+ const CompletionCallback& callback);
// Returns a .crdownload intermediate path for the |suggested_path|.
static base::FilePath GetCrDownloadPath(const base::FilePath& suggested_path);
@@ -137,11 +140,13 @@ class DownloadTargetDeterminer
// Construct a DownloadTargetDeterminer object. Constraints on the arguments
// are as per Start() above.
- DownloadTargetDeterminer(content::DownloadItem* download,
- const base::FilePath& initial_virtual_path,
- DownloadPrefs* download_prefs,
- DownloadTargetDeterminerDelegate* delegate,
- const CompletionCallback& callback);
+ DownloadTargetDeterminer(
+ content::DownloadItem* download,
+ const base::FilePath& initial_virtual_path,
+ DownloadPathReservationTracker::FilenameConflictAction conflict_action,
+ DownloadPrefs* download_prefs,
+ DownloadTargetDeterminerDelegate* delegate,
+ const CompletionCallback& callback);
~DownloadTargetDeterminer() override;
@@ -179,16 +184,18 @@ class DownloadTargetDeterminer
Result DoReserveVirtualPath();
// Callback invoked after the delegate aquires a path reservation.
- void ReserveVirtualPathDone(const base::FilePath& path, bool verified);
+ void ReserveVirtualPathDone(PathValidationResult result,
+ const base::FilePath& path);
// Presents a file picker to the user if necessary.
// Next state:
// - STATE_DETERMINE_LOCAL_PATH.
- Result DoPromptUserForDownloadPath();
+ Result DoRequestConfirmation();
// Callback invoked after the file picker completes. Cancels the download if
// the user cancels the file picker.
- void PromptUserForDownloadPathDone(const base::FilePath& virtual_path);
+ void RequestConfirmationDone(DownloadConfirmationResult result,
+ const base::FilePath& virtual_path);
// Up until this point, the path that was used is considered to be a virtual
// path. This step determines the local file system path corresponding to this
@@ -270,9 +277,11 @@ class DownloadTargetDeterminer
// Utilities:
- void ScheduleCallbackAndDeleteSelf();
-
- void CancelOnFailureAndDeleteSelf();
+ // Schedules the completion callback to be run on the UI thread and deletes
+ // this object. The determined target info will be passed into the callback
+ // if |interrupt_reason| is NONE. Otherwise, only the interrupt reason will be
+ // passed on.
+ void ScheduleCallbackAndDeleteSelf(content::DownloadInterruptReason result);
Profile* GetProfile() const;
@@ -282,7 +291,8 @@ class DownloadTargetDeterminer
// determination will be based on the interrupt reason. It is assumed that
// download interruptions always occur after the first round of download
// target determination is complete.
- bool ShouldPromptForDownload(const base::FilePath& filename) const;
+ DownloadConfirmationReason ShouldPromptForDownload(
+ const base::FilePath& filename) const;
// Returns true if the user has been prompted for this download at least once
// prior to this target determination operation. This method is only expected
@@ -307,7 +317,7 @@ class DownloadTargetDeterminer
// state
State next_state_;
- bool should_prompt_;
+ DownloadConfirmationReason confirmation_reason_;
bool should_notify_extensions_;
bool create_target_directory_;
DownloadPathReservationTracker::FilenameConflictAction conflict_action_;

Powered by Google App Engine
This is Rietveld 408576698