fix: revert required portal version for file chooser dialogs (#44681)

* feat: add support for configuring xdg portal version at runtime

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* doc: update command-line-switches.md

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* doc: update command-line-switches.md

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

Co-authored-by: Robo <hop2deep@gmail.com>

* doc: required portal version for defaultPath support

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

Co-authored-by: Robo <hop2deep@gmail.com>

* doc: update more occurrances

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* fix: remove warning from save dialogs

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* doc: update command-line-switches.md

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

Co-authored-by: Robo <hop2deep@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
trop[bot] 2024-11-15 11:30:06 -05:00 committed by GitHub
parent 900400e442
commit 2ee65f9c10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 170 additions and 10 deletions

View file

@ -18,6 +18,7 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/promise.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_dialog_linux_portal.h"
#include "ui/shell_dialogs/select_file_policy.h"
#include "ui/shell_dialogs/selected_file_info.h"
@ -58,6 +59,18 @@ ui::SelectFileDialog::FileTypeInfo GetFilterInfo(const Filters& filters) {
return file_type_info;
}
void LogIfNeededAboutUnsupportedPortalFeature(const DialogSettings& settings) {
if (!settings.default_path.empty() &&
ui::SelectFileDialogLinuxPortal::IsPortalAvailable() &&
ui::SelectFileDialogLinuxPortal::GetPortalVersion() < 4) {
LOG(INFO) << "Available portal version "
<< ui::SelectFileDialogLinuxPortal::GetPortalVersion()
<< " does not support defaultPath option, try the non-portal"
<< " file chooser dialogs by launching with"
<< " --xdg-portal-required-version";
}
}
class FileChooserDialog : public ui::SelectFileDialog::Listener {
public:
enum class DialogType { OPEN, SAVE };
@ -200,6 +213,7 @@ class FileChooserDialog : public ui::SelectFileDialog::Listener {
bool ShowOpenDialogSync(const DialogSettings& settings,
std::vector<base::FilePath>* paths) {
LogIfNeededAboutUnsupportedPortalFeature(settings);
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
auto cb = base::BindOnce(
[](base::RepeatingClosure cb, std::vector<base::FilePath>* file_paths,
@ -217,6 +231,7 @@ bool ShowOpenDialogSync(const DialogSettings& settings,
void ShowOpenDialog(const DialogSettings& settings,
gin_helper::Promise<gin_helper::Dictionary> promise) {
LogIfNeededAboutUnsupportedPortalFeature(settings);
FileChooserDialog* dialog = new FileChooserDialog();
dialog->RunOpenDialog(std::move(promise), settings);
}