| 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 f96e79cf9549c3474d072c8f2b13dc37664627fb..3294d4dbc2f3868dbde0b8e45b3515cf20b44e57 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"
|
| @@ -21,7 +22,6 @@
|
| #include "content/public/browser/download_item.h"
|
| #include "content/public/browser/download_manager_delegate.h"
|
|
|
| -class ChromeDownloadManagerDelegate;
|
| class Profile;
|
| class DownloadPrefs;
|
|
|
| @@ -55,8 +55,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 +74,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 +139,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 +183,18 @@ class DownloadTargetDeterminer
|
| Result DoReserveVirtualPath();
|
|
|
| // Callback invoked after the delegate aquires a path reservation.
|
| - void ReserveVirtualPathDone(const base::FilePath& path, bool verified);
|
| + void ReserveVirtualPathDone(const base::FilePath& path,
|
| + DownloadTargetResult result);
|
|
|
| // 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 +276,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(DownloadTargetResult result);
|
|
|
| Profile* GetProfile() const;
|
|
|
| @@ -282,7 +290,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 +316,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_;
|
| @@ -318,6 +327,7 @@ class DownloadTargetDeterminer
|
| base::FilePath intermediate_path_;
|
| std::string mime_type_;
|
| bool is_filetype_handled_safely_;
|
| + DownloadTargetResult result_;
|
|
|
| content::DownloadItem* download_;
|
| const bool is_resumption_;
|
|
|