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 | 7 |
| 8 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
8 #include "chrome/browser/ui/select_file_dialog.h" | 9 #include "chrome/browser/ui/select_file_dialog.h" |
9 | 10 |
10 class FilePath; | 11 class FilePath; |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 class DownloadItem; | 14 class DownloadItem; |
14 class DownloadManager; | 15 class DownloadManager; |
15 class WebContents; | 16 class WebContents; |
16 } | 17 } |
17 | 18 |
18 // Handles showing a dialog to the user to ask for the filename for a download. | 19 // Handles showing a dialog to the user to ask for the filename for a download. |
19 class DownloadFilePicker : public SelectFileDialog::Listener { | 20 class DownloadFilePicker : public SelectFileDialog::Listener { |
20 public: | 21 public: |
21 DownloadFilePicker(); | 22 DownloadFilePicker(); |
22 virtual ~DownloadFilePicker(); | 23 virtual ~DownloadFilePicker(); |
23 | 24 |
24 void Init(content::DownloadManager* download_manager, | 25 void Init(content::DownloadManager* download_manager, |
25 content::DownloadItem* item); | 26 content::DownloadItem* item, |
| 27 const FilePath& suggested_path, |
| 28 const ChromeDownloadManagerDelegate::FileSelectedCallback& |
| 29 callback); |
26 | 30 |
27 protected: | 31 protected: |
28 // On ChromeOS, DownloadItem::GetTargetPath is a temporary local filename. | 32 // On ChromeOS |suggested_path| might be a temporary local filename. This |
29 virtual void InitSuggestedPath(content::DownloadItem* item); | 33 // method should be overridden to set the correct suggested path to prompt the |
| 34 // user. |
| 35 virtual void InitSuggestedPath(content::DownloadItem* item, |
| 36 const FilePath& suggested_path); |
| 37 |
30 void set_suggested_path(const FilePath& suggested_path) { | 38 void set_suggested_path(const FilePath& suggested_path) { |
31 suggested_path_ = suggested_path; | 39 suggested_path_ = suggested_path; |
32 } | 40 } |
33 | 41 |
| 42 // Runs |file_selected_callback_| with |path| and then deletes this object. |
| 43 void OnFileSelected(const FilePath& path); |
| 44 |
34 void RecordFileSelected(const FilePath& path); | 45 void RecordFileSelected(const FilePath& path); |
35 | 46 |
36 scoped_refptr<content::DownloadManager> download_manager_; | 47 scoped_refptr<content::DownloadManager> download_manager_; |
37 int32 download_id_; | 48 int32 download_id_; |
38 | 49 |
39 private: | 50 private: |
40 // SelectFileDialog::Listener implementation. | 51 // SelectFileDialog::Listener implementation. |
41 virtual void FileSelected(const FilePath& path, | 52 virtual void FileSelected(const FilePath& path, |
42 int index, | 53 int index, |
43 void* params) OVERRIDE; | 54 void* params) OVERRIDE; |
44 virtual void FileSelectionCanceled(void* params) OVERRIDE; | 55 virtual void FileSelectionCanceled(void* params) OVERRIDE; |
45 | 56 |
46 FilePath suggested_path_; | 57 FilePath suggested_path_; |
47 | 58 |
| 59 ChromeDownloadManagerDelegate::FileSelectedCallback file_selected_callback_; |
| 60 |
48 // For managing select file dialogs. | 61 // For managing select file dialogs. |
49 scoped_refptr<SelectFileDialog> select_file_dialog_; | 62 scoped_refptr<SelectFileDialog> select_file_dialog_; |
50 | 63 |
51 DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker); | 64 DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker); |
52 }; | 65 }; |
53 | 66 |
54 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ | 67 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ |
OLD | NEW |