execute_select_file_win.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_SHELL_DIALOGS_EXECUTE_SELECT_FILE_WIN_H_
  5. #define UI_SHELL_DIALOGS_EXECUTE_SELECT_FILE_WIN_H_
  6. #include <string>
  7. #include <utility>
  8. #include <vector>
  9. #include "base/callback_forward.h"
  10. #include "base/win/windows_types.h"
  11. #include "ui/shell_dialogs/select_file_dialog.h"
  12. #include "ui/shell_dialogs/shell_dialogs_export.h"
  13. namespace base {
  14. class FilePath;
  15. }
  16. namespace ui {
  17. // Describes a filter for a file dialog.
  18. struct FileFilterSpec {
  19. // A human readable description of this filter. E.g. "HTML Files."
  20. std::u16string description;
  21. // The different extensions that map to this spec. This is a semicolon-
  22. // separated list of extensions that contains a wildcard and the separator.
  23. // E.g. "*.html;*.htm"
  24. std::u16string extension_spec;
  25. };
  26. using OnSelectFileExecutedCallback =
  27. base::OnceCallback<void(const std::vector<base::FilePath>&, int)>;
  28. // Shows the file selection dialog modal to |owner| returns the selected file(s)
  29. // and file type index using the |on_select_file_executed_callback|. The file
  30. // path vector will be empty on failure.
  31. SHELL_DIALOGS_EXPORT
  32. void ExecuteSelectFile(
  33. SelectFileDialog::Type type,
  34. const std::u16string& title,
  35. const base::FilePath& default_path,
  36. const std::vector<FileFilterSpec>& filter,
  37. int file_type_index,
  38. const std::wstring& default_extension,
  39. HWND owner,
  40. OnSelectFileExecutedCallback on_select_file_executed_callback);
  41. } // namespace ui
  42. #endif // UI_SHELL_DIALOGS_EXECUTE_SELECT_FILE_WIN_H_