| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_EXTENSIONS_API_FILE_SYSTEM_FILE_ENTRY_PICKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_ENTRY_PICKER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_ENTRY_PICKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_ENTRY_PICKER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "extensions/browser/api/file_system/file_system_delegate.h" |
| 12 #include "ui/shell_dialogs/select_file_dialog.h" | 13 #include "ui/shell_dialogs/select_file_dialog.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class FilePath; | 16 class FilePath; |
| 16 } // namespace base | 17 } // namespace base |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 class WebContents; | 20 class WebContents; |
| 20 } // namespace content | 21 } // namespace content |
| 21 | 22 |
| 22 namespace extensions { | 23 namespace extensions { |
| 23 | 24 |
| 24 // Shows a dialog to the user to ask for the filename for a file to save or | 25 // Shows a dialog to the user to ask for the filename for a file to save or |
| 25 // open. Deletes itself once the dialog is closed. | 26 // open. Deletes itself once the dialog is closed. |
| 26 class FileEntryPicker : public ui::SelectFileDialog::Listener { | 27 class FileEntryPicker : public ui::SelectFileDialog::Listener { |
| 27 public: | 28 public: |
| 28 using FilesSelectedCallback = | |
| 29 base::OnceCallback<void(const std::vector<base::FilePath>& paths)>; | |
| 30 | |
| 31 // Creates a file picker. After the user picks file(s) or cancels, the | 29 // Creates a file picker. After the user picks file(s) or cancels, the |
| 32 // relevant callback is called and this object deletes itself. | 30 // relevant callback is called and this object deletes itself. |
| 33 // The dialog is modal to the |web_contents|'s window. | 31 // The dialog is modal to the |web_contents|'s window. |
| 34 // See SelectFileDialog::SelectFile for the other parameters. | 32 // See SelectFileDialog::SelectFile for the other parameters. |
| 35 FileEntryPicker(content::WebContents* web_contents, | 33 FileEntryPicker( |
| 36 const base::FilePath& suggested_name, | 34 content::WebContents* web_contents, |
| 37 const ui::SelectFileDialog::FileTypeInfo& file_type_info, | 35 const base::FilePath& suggested_name, |
| 38 ui::SelectFileDialog::Type picker_type, | 36 const ui::SelectFileDialog::FileTypeInfo& file_type_info, |
| 39 FilesSelectedCallback files_selected_callback, | 37 ui::SelectFileDialog::Type picker_type, |
| 40 base::OnceClosure file_selection_canceled_callback); | 38 FileSystemDelegate::FilesSelectedCallback files_selected_callback, |
| 39 base::OnceClosure file_selection_canceled_callback); |
| 41 | 40 |
| 42 private: | 41 private: |
| 43 ~FileEntryPicker() override; // FileEntryPicker deletes itself. | 42 ~FileEntryPicker() override; // FileEntryPicker deletes itself. |
| 44 | 43 |
| 45 // ui::SelectFileDialog::Listener implementation. | 44 // ui::SelectFileDialog::Listener implementation. |
| 46 void FileSelected(const base::FilePath& path, | 45 void FileSelected(const base::FilePath& path, |
| 47 int index, | 46 int index, |
| 48 void* params) override; | 47 void* params) override; |
| 49 void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file, | 48 void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file, |
| 50 int index, | 49 int index, |
| 51 void* params) override; | 50 void* params) override; |
| 52 void MultiFilesSelected(const std::vector<base::FilePath>& files, | 51 void MultiFilesSelected(const std::vector<base::FilePath>& files, |
| 53 void* params) override; | 52 void* params) override; |
| 54 void MultiFilesSelectedWithExtraInfo( | 53 void MultiFilesSelectedWithExtraInfo( |
| 55 const std::vector<ui::SelectedFileInfo>& files, | 54 const std::vector<ui::SelectedFileInfo>& files, |
| 56 void* params) override; | 55 void* params) override; |
| 57 void FileSelectionCanceled(void* params) override; | 56 void FileSelectionCanceled(void* params) override; |
| 58 | 57 |
| 59 FilesSelectedCallback files_selected_callback_; | 58 FileSystemDelegate::FilesSelectedCallback files_selected_callback_; |
| 60 base::OnceClosure file_selection_canceled_callback_; | 59 base::OnceClosure file_selection_canceled_callback_; |
| 61 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 60 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
| 62 | 61 |
| 63 DISALLOW_COPY_AND_ASSIGN(FileEntryPicker); | 62 DISALLOW_COPY_AND_ASSIGN(FileEntryPicker); |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 } // namespace extensions | 65 } // namespace extensions |
| 67 | 66 |
| 68 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_ENTRY_PICKER_H_ | 67 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_ENTRY_PICKER_H_ |
| OLD | NEW |