Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/callback.h" | |
| 9 #include "chrome/browser/ui/select_file_dialog.h" | 10 #include "chrome/browser/ui/select_file_dialog.h" |
| 10 | 11 |
| 11 class FilePath; | 12 class FilePath; |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 class DownloadItem; | 15 class DownloadItem; |
| 15 class DownloadManager; | 16 class DownloadManager; |
| 16 class WebContents; | 17 class WebContents; |
| 17 } | 18 } |
| 18 | 19 |
| 19 // Handles showing a dialog to the user to ask for the filename for a download. | 20 // Handles showing a dialog to the user to ask for the filename for a download. |
| 20 class DownloadFilePicker : public SelectFileDialog::Listener { | 21 class DownloadFilePicker : public SelectFileDialog::Listener { |
| 21 public: | 22 public: |
| 23 // Callback invoked when the user chooses a download path. If the user cancels | |
| 24 // the operation, |selected_path| will be empty. | |
| 25 typedef base::Callback<void(const FilePath& selected_path)> | |
| 26 FileSelectedCallback; | |
| 27 | |
| 22 DownloadFilePicker(); | 28 DownloadFilePicker(); |
| 23 virtual ~DownloadFilePicker(); | 29 virtual ~DownloadFilePicker(); |
| 24 | 30 |
| 25 void Init(content::DownloadManager* download_manager, | 31 void Init(content::DownloadManager* download_manager, |
| 26 content::DownloadItem* item); | 32 content::DownloadItem* item, |
| 33 const FilePath& suggested_path, | |
| 34 const FileSelectedCallback& callback); | |
| 27 | 35 |
| 28 protected: | 36 protected: |
| 29 // On ChromeOS, DownloadItem::GetTargetPath is a temporary local filename. | 37 // On ChromeOS, DownloadItem::GetTargetPath is a temporary local filename. |
|
Randy Smith (Not in Mondays)
2012/07/12 17:01:22
I don't see the relationship of this comment to th
asanka
2012/07/18 21:50:56
It was stale. Fixed.
| |
| 30 virtual void InitSuggestedPath(content::DownloadItem* item); | 38 virtual void InitSuggestedPath(content::DownloadItem* item, |
| 39 const FilePath& suggested_path); | |
| 31 void set_suggested_path(const FilePath& suggested_path) { | 40 void set_suggested_path(const FilePath& suggested_path) { |
| 32 suggested_path_ = suggested_path; | 41 suggested_path_ = suggested_path; |
| 33 } | 42 } |
| 34 | 43 |
| 44 // Runs |file_selected_callback_| with |path| and then deletes this object. | |
| 45 void OnFileSelected(const FilePath& path); | |
| 46 | |
| 35 void RecordFileSelected(const FilePath& path); | 47 void RecordFileSelected(const FilePath& path); |
| 36 | 48 |
| 37 scoped_refptr<content::DownloadManager> download_manager_; | 49 scoped_refptr<content::DownloadManager> download_manager_; |
| 38 int32 download_id_; | 50 int32 download_id_; |
| 39 | 51 |
| 40 private: | 52 private: |
| 41 // SelectFileDialog::Listener implementation. | 53 // SelectFileDialog::Listener implementation. |
| 42 virtual void FileSelected(const FilePath& path, | 54 virtual void FileSelected(const FilePath& path, |
| 43 int index, | 55 int index, |
| 44 void* params) OVERRIDE; | 56 void* params) OVERRIDE; |
| 45 virtual void FileSelectionCanceled(void* params) OVERRIDE; | 57 virtual void FileSelectionCanceled(void* params) OVERRIDE; |
| 46 | 58 |
| 47 FilePath suggested_path_; | 59 FilePath suggested_path_; |
| 48 | 60 |
| 61 FileSelectedCallback file_selected_callback_; | |
| 62 | |
| 49 // For managing select file dialogs. | 63 // For managing select file dialogs. |
| 50 scoped_refptr<SelectFileDialog> select_file_dialog_; | 64 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 51 | 65 |
| 52 DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker); | 66 DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker); |
| 53 }; | 67 }; |
| 54 | 68 |
| 55 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ | 69 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ |
| OLD | NEW |