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