Chromium Code Reviews| 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..7f40406fe810820119d1f75f953c10d6670afe6d 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,44 +21,44 @@ 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(); |
| - 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. |
| - virtual void InitSuggestedPath(content::DownloadItem* item, |
| - const base::FilePath& suggested_path); |
| + // Callback used to pass the user selection back to the owner of this |
| + // object. |
| + // |virtual_path|: The path chosen by the user. If the user cancels the file |
| + // selection, then this parameter will be the empty path. On Chrome OS, |
| + // this path may contain virtual mount points if the user chose a virtual |
| + // path (e.g. Google Drive). |
| + typedef base::Callback<void(const base::FilePath& virtual_path)> |
| + FileSelectedCallback; |
| + |
| + // Display a file picker dialog for |item|. The |suggested_path| will be used |
| + // as the initial path displayed to the user. |callback| will always be |
| + // invoked even if |item| is destroyed prior to the file picker completing. |
| + static void ShowFilePicker(content::DownloadItem* item, |
| + const base::FilePath& suggested_path, |
| + const FileSelectedCallback& callback); |
| - void set_suggested_path(const base::FilePath& suggested_path) { |
| - suggested_path_ = suggested_path; |
| - } |
| - |
| - // Runs |file_selected_callback_| with |path| and then deletes this object. |
| - void OnFileSelected(const base::FilePath& path); |
| - |
| - void RecordFileSelected(const base::FilePath& path); |
| + private: |
| + DownloadFilePicker(content::DownloadItem* item, |
| + const base::FilePath& suggested_path, |
| + const FileSelectedCallback& callback); |
| + virtual ~DownloadFilePicker(); |
| - scoped_refptr<content::DownloadManager> download_manager_; |
| - int32 download_id_; |
| + // Runs |file_selected_callback_| with |virtual_path| and then deletes this |
| + // object. |
| + void OnFileSelected(const base::FilePath& virtual_path); |
| - private: |
| // SelectFileDialog::Listener implementation. |
| virtual void FileSelected(const base::FilePath& path, |
| int index, |
| void* params) OVERRIDE; |
| virtual void FileSelectionCanceled(void* params) OVERRIDE; |
| + // Initially suggested path. |
| base::FilePath suggested_path_; |
| - ChromeDownloadManagerDelegate::FileSelectedCallback file_selected_callback_; |
| + FileSelectedCallback file_selected_callback_; |
| + |
| + scoped_refptr<content::DownloadManager> download_manager_; |
|
Randy Smith (Not in Mondays)
2013/04/26 19:05:46
Suggestion: It looks as if this is only included t
asanka
2013/04/29 18:43:20
Good suggestion! Done.
|
| // For managing select file dialogs. |
| scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |