select_file_dialog_linux.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2022 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. //
  5. // This file implements common select dialog functionality between GTK and KDE.
  6. #include "ui/shell_dialogs/select_file_dialog_linux.h"
  7. #include "base/files/file_util.h"
  8. #include "base/notreached.h"
  9. #include "base/threading/thread_restrictions.h"
  10. namespace ui {
  11. base::FilePath* SelectFileDialogLinux::last_saved_path_ = nullptr;
  12. base::FilePath* SelectFileDialogLinux::last_opened_path_ = nullptr;
  13. SelectFileDialogLinux::SelectFileDialogLinux(
  14. Listener* listener,
  15. std::unique_ptr<ui::SelectFilePolicy> policy)
  16. : SelectFileDialog(listener, std::move(policy)) {
  17. if (!last_saved_path_) {
  18. last_saved_path_ = new base::FilePath();
  19. last_opened_path_ = new base::FilePath();
  20. }
  21. }
  22. SelectFileDialogLinux::~SelectFileDialogLinux() = default;
  23. void SelectFileDialogLinux::ListenerDestroyed() {
  24. listener_ = nullptr;
  25. }
  26. bool SelectFileDialogLinux::CallDirectoryExistsOnUIThread(
  27. const base::FilePath& path) {
  28. base::ThreadRestrictions::ScopedAllowIO allow_io;
  29. return base::DirectoryExists(path);
  30. }
  31. } // namespace ui