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

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

Issue 12850002: Move download filename determintion into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 8 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_file_picker.h
diff --git a/chrome/browser/download/download_file_picker.h b/chrome/browser/download/download_file_picker.h
index b7dc8b42f4c78cb1f277fa33b551f4cb805cb582..be27c9237106db151b1320da7370646738a12964 100644
--- a/chrome/browser/download/download_file_picker.h
+++ b/chrome/browser/download/download_file_picker.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_
-#include "chrome/browser/download/chrome_download_manager_delegate.h"
+#include "base/callback.h"
#include "ui/shell_dialogs/select_file_dialog.h"
namespace base {
@@ -21,16 +21,27 @@ class WebContents;
// Handles showing a dialog to the user to ask for the filename for a download.
class DownloadFilePicker : public ui::SelectFileDialog::Listener {
public:
- DownloadFilePicker();
+ // Callback used to pass the user selection back to the owner of this
+ // object. If the user selection is successful, the arguments will be as
+ // follows:
+ // |virtual_path|: The opaque path representing the virtual target chosen by
+ // the user. If the target is local file system, then this will be same as
+ // |local_path|.
+ // |local_path|: The path on the local file system to use for storing the
+ // downloaded file.
+ //
+ // If the path selection is successful, both paths will be non-empty and
+ // valid. Otherwise, if the user cancels the selection, both paths will be
+ // empty.
+ typedef base::Callback<void(
+ const base::FilePath& virtual_path,
+ const base::FilePath& local_path)> FileSelectedCallback;
+
+ DownloadFilePicker(content::DownloadItem* item,
+ const base::FilePath& suggested_path,
+ const FileSelectedCallback& callback);
virtual ~DownloadFilePicker();
- void Init(content::DownloadManager* download_manager,
- content::DownloadItem* item,
- const base::FilePath& suggested_path,
- const ChromeDownloadManagerDelegate::FileSelectedCallback&
- callback);
-
- protected:
// On ChromeOS |suggested_path| might be a temporary local filename. This
// method should be overridden to set the correct suggested path to prompt the
// user.
@@ -41,8 +52,10 @@ class DownloadFilePicker : public ui::SelectFileDialog::Listener {
suggested_path_ = suggested_path;
}
- // Runs |file_selected_callback_| with |path| and then deletes this object.
- void OnFileSelected(const base::FilePath& path);
+ // Runs |file_selected_callback_| with |virtual_path| and |local_path| and
+ // then deletes this object.
+ void OnFileSelected(const base::FilePath& virtual_path,
+ const base::FilePath& local_path);
void RecordFileSelected(const base::FilePath& path);
@@ -58,7 +71,7 @@ class DownloadFilePicker : public ui::SelectFileDialog::Listener {
base::FilePath suggested_path_;
- ChromeDownloadManagerDelegate::FileSelectedCallback file_selected_callback_;
+ FileSelectedCallback file_selected_callback_;
// For managing select file dialogs.
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
@@ -66,4 +79,12 @@ class DownloadFilePicker : public ui::SelectFileDialog::Listener {
DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker);
};
+class DownloadFilePickerFactory {
+ public:
+ virtual ~DownloadFilePickerFactory();
+ virtual void Create(content::DownloadItem* item,
+ const base::FilePath& suggested_path,
+ const DownloadFilePicker::FileSelectedCallback& callback);
+};
+
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_

Powered by Google App Engine
This is Rietveld 408576698