select_file_dialog_lacros.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2019 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_SELECT_FILE_DIALOG_LACROS_H_
  5. #define UI_SHELL_DIALOGS_SELECT_FILE_DIALOG_LACROS_H_
  6. #include <vector>
  7. #include "base/memory/raw_ptr.h"
  8. #include "chromeos/crosapi/mojom/select_file.mojom-forward.h"
  9. #include "ui/shell_dialogs/select_file_dialog.h"
  10. #include "ui/shell_dialogs/select_file_dialog_factory.h"
  11. #include "ui/shell_dialogs/shell_dialogs_export.h"
  12. namespace ui {
  13. // SelectFileDialogLacros implements file open and save dialogs for the
  14. // lacros-chrome binary. The dialog itself is handled by the file manager in
  15. // ash-chrome.
  16. class SHELL_DIALOGS_EXPORT SelectFileDialogLacros : public SelectFileDialog {
  17. public:
  18. class SHELL_DIALOGS_EXPORT Factory : public SelectFileDialogFactory {
  19. public:
  20. Factory();
  21. Factory(const Factory&) = delete;
  22. Factory& operator=(const Factory&) = delete;
  23. ~Factory() override;
  24. // SelectFileDialogFactory:
  25. ui::SelectFileDialog* Create(
  26. ui::SelectFileDialog::Listener* listener,
  27. std::unique_ptr<ui::SelectFilePolicy> policy) override;
  28. };
  29. SelectFileDialogLacros(Listener* listener,
  30. std::unique_ptr<SelectFilePolicy> policy);
  31. SelectFileDialogLacros(const SelectFileDialogLacros&) = delete;
  32. SelectFileDialogLacros& operator=(const SelectFileDialogLacros&) = delete;
  33. // SelectFileDialog:
  34. void SelectFileImpl(Type type,
  35. const std::u16string& title,
  36. const base::FilePath& default_path,
  37. const FileTypeInfo* file_types,
  38. int file_type_index,
  39. const base::FilePath::StringType& default_extension,
  40. gfx::NativeWindow owning_window,
  41. void* params) override;
  42. bool HasMultipleFileTypeChoicesImpl() override;
  43. bool IsRunning(gfx::NativeWindow owning_window) const override;
  44. void ListenerDestroyed() override;
  45. private:
  46. // Private because SelectFileDialog is ref-counted.
  47. ~SelectFileDialogLacros() override;
  48. // Callback for file selection.
  49. void OnSelected(crosapi::mojom::SelectFileResult result,
  50. std::vector<crosapi::mojom::SelectedFileInfoPtr> files,
  51. int file_type_index);
  52. // Cached parameters from the call to SelectFileImpl.
  53. raw_ptr<void> params_ = nullptr;
  54. // The unique ID of the wayland shell surface that owns this dialog.
  55. std::string owning_shell_window_id_;
  56. };
  57. } // namespace ui
  58. #endif // UI_SHELL_DIALOGS_SELECT_FILE_DIALOG_LACROS_H_