From d72c6d7f59aaf74d7ba64664fad3acc774e50324 Mon Sep 17 00:00:00 2001
|
From: Tom Anderson <thomasanderson@chromium.org>
|
Date: Sat, 21 May 2022 00:39:44 +0000
|
Subject: [PATCH 14/14] Fix build with use_gtk=false
|
|
shell_dialog_linux still needs to get built even for non-gtk builds. It
|
was originally changed in [1] to fix a build with use_dbus=false. This
|
CL unconditionally includes shell_dialog_linux on Linux, but adds a
|
check for use_dbus before including select_file_dialog_linux_portal.cc.
|
|
[1] https://chromium-review.googlesource.com/c/chromium/src/+/3462233
|
|
R=sky
|
|
Bug: None
|
Change-Id: I54c39f52175e0c4b0784d15822e0fc4125f9e47d
|
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3656243
|
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
|
Reviewed-by: Scott Violet <sky@chromium.org>
|
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
|
Commit-Queue: Scott Violet <sky@chromium.org>
|
Cr-Commit-Position: refs/heads/main@{#1006054}
|
---
|
ui/shell_dialogs/BUILD.gn | 23 ++++---
|
ui/shell_dialogs/shell_dialog_linux.cc | 88 ++++++++++++++++----------
|
2 files changed, 67 insertions(+), 44 deletions(-)
|
|
diff --git a/ui/shell_dialogs/BUILD.gn b/ui/shell_dialogs/BUILD.gn
|
index e1b3041dc..192251bad 100644
|
--- a/ui/shell_dialogs/BUILD.gn
|
+++ b/ui/shell_dialogs/BUILD.gn
|
@@ -3,7 +3,7 @@
|
# found in the LICENSE file.
|
|
import("//build/config/chromeos/ui_mode.gni")
|
-import("//build/config/linux/gtk/gtk.gni")
|
+import("//build/config/features.gni")
|
import("//build/config/ui.gni")
|
import("//testing/test.gni")
|
|
@@ -41,23 +41,28 @@ component("shell_dialogs") {
|
"//url",
|
]
|
|
- if (is_chromeos || (is_linux && !use_gtk)) {
|
+ if (is_chromeos || is_chromecast) {
|
sources += [ "shell_dialog_stub.cc" ]
|
- } else if (is_linux) {
|
+ }
|
+
|
+ if (is_linux && !is_chromecast) {
|
sources += [
|
"select_file_dialog_linux.cc",
|
"select_file_dialog_linux.h",
|
"select_file_dialog_linux_kde.cc",
|
"select_file_dialog_linux_kde.h",
|
- "select_file_dialog_linux_portal.cc",
|
- "select_file_dialog_linux_portal.h",
|
"shell_dialog_linux.cc",
|
"shell_dialog_linux.h",
|
]
|
- deps += [
|
- "//components/dbus/thread_linux",
|
- "//dbus",
|
- ]
|
+ deps += [ "//components/dbus/thread_linux" ]
|
+ if (use_dbus) {
|
+ defines += [ "USE_DBUS" ]
|
+ sources += [
|
+ "select_file_dialog_linux_portal.cc",
|
+ "select_file_dialog_linux_portal.h",
|
+ ]
|
+ deps += [ "//dbus" ]
|
+ }
|
}
|
|
if (is_mac) {
|
diff --git a/ui/shell_dialogs/shell_dialog_linux.cc b/ui/shell_dialogs/shell_dialog_linux.cc
|
index 0f5fa2e55..078fd3b1b 100644
|
--- a/ui/shell_dialogs/shell_dialog_linux.cc
|
+++ b/ui/shell_dialogs/shell_dialog_linux.cc
|
@@ -10,14 +10,26 @@
|
#include "build/chromeos_buildflags.h"
|
#include "ui/shell_dialogs/select_file_dialog_linux.h"
|
#include "ui/shell_dialogs/select_file_dialog_linux_kde.h"
|
-#include "ui/shell_dialogs/select_file_dialog_linux_portal.h"
|
#include "ui/shell_dialogs/select_file_policy.h"
|
|
+#if defined(USE_DBUS)
|
+#include "ui/shell_dialogs/select_file_dialog_linux_portal.h"
|
+#endif
|
+
|
+namespace ui {
|
+
|
namespace {
|
|
-ui::ShellDialogLinux* g_shell_dialog_linux = nullptr;
|
+ShellDialogLinux* g_shell_dialog_linux = nullptr;
|
|
-enum FileDialogChoice { kUnknown, kToolkit, kKde, kPortal };
|
+enum FileDialogChoice {
|
+ kUnknown,
|
+ kToolkit,
|
+ kKde,
|
+#if defined(USE_DBUS)
|
+ kPortal,
|
+#endif
|
+};
|
|
FileDialogChoice dialog_choice_ = kUnknown;
|
|
@@ -26,14 +38,43 @@ std::string& KDialogVersion() {
|
return *version;
|
}
|
|
-} // namespace
|
+FileDialogChoice GetFileDialogChoice() {
|
+#if defined(USE_DBUS)
|
+ // Check to see if the portal is available.
|
+ if (SelectFileDialogLinuxPortal::IsPortalAvailable())
|
+ return kPortal;
|
+ // Make sure to kill the portal connection.
|
+ SelectFileDialogLinuxPortal::DestroyPortalConnection();
|
+#endif
|
+
|
+ // Check to see if KDE is the desktop environment.
|
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
|
+ base::nix::DesktopEnvironment desktop =
|
+ base::nix::GetDesktopEnvironment(env.get());
|
+ if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 ||
|
+ desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
|
+ desktop == base::nix::DESKTOP_ENVIRONMENT_KDE5) {
|
+ // Check to see if the user dislikes the KDE file dialog.
|
+ if (!env->HasVar("NO_CHROME_KDE_FILE_DIALOG")) {
|
+ // Check to see if the KDE dialog works.
|
+ if (SelectFileDialogLinux::CheckKDEDialogWorksOnUIThread(
|
+ KDialogVersion())) {
|
+ return kKde;
|
+ }
|
+ }
|
+ }
|
|
-namespace ui {
|
+ return kToolkit;
|
+}
|
+
|
+} // namespace
|
|
ShellDialogLinux::ShellDialogLinux() = default;
|
|
ShellDialogLinux::~ShellDialogLinux() {
|
+#if defined(USE_DBUS)
|
SelectFileDialogLinuxPortal::DestroyPortalConnection();
|
+#endif
|
}
|
|
void ShellDialogLinux::SetInstance(ShellDialogLinux* instance) {
|
@@ -45,50 +86,27 @@ const ShellDialogLinux* ShellDialogLinux::instance() {
|
}
|
|
void ShellDialogLinux::Initialize() {
|
+#if defined(USE_DBUS)
|
SelectFileDialogLinuxPortal::StartAvailabilityTestInBackground();
|
+#endif
|
}
|
|
SelectFileDialog* CreateSelectFileDialog(
|
SelectFileDialog::Listener* listener,
|
std::unique_ptr<SelectFilePolicy> policy) {
|
- if (dialog_choice_ == kUnknown) {
|
- // Start out assuming we are going to use dialogs from the toolkit.
|
- dialog_choice_ = kToolkit;
|
-
|
- // Check to see if the portal is available.
|
- if (SelectFileDialogLinuxPortal::IsPortalAvailable()) {
|
- dialog_choice_ = kPortal;
|
- } else {
|
- // Make sure to kill the portal connection.
|
- SelectFileDialogLinuxPortal::DestroyPortalConnection();
|
-
|
- // Check to see if KDE is the desktop environment.
|
- std::unique_ptr<base::Environment> env(base::Environment::Create());
|
- base::nix::DesktopEnvironment desktop =
|
- base::nix::GetDesktopEnvironment(env.get());
|
- if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 ||
|
- desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
|
- desktop == base::nix::DESKTOP_ENVIRONMENT_KDE5) {
|
- // Check to see if the user dislikes the KDE file dialog.
|
- if (!env->HasVar("NO_CHROME_KDE_FILE_DIALOG")) {
|
- // Check to see if the KDE dialog works.
|
- if (SelectFileDialogLinux::CheckKDEDialogWorksOnUIThread(
|
- KDialogVersion())) {
|
- dialog_choice_ = kKde;
|
- }
|
- }
|
- }
|
- }
|
- }
|
+ if (dialog_choice_ == kUnknown)
|
+ dialog_choice_ = GetFileDialogChoice();
|
|
- const ui::ShellDialogLinux* shell_dialogs = ui::ShellDialogLinux::instance();
|
+ const ShellDialogLinux* shell_dialogs = ShellDialogLinux::instance();
|
switch (dialog_choice_) {
|
case kToolkit:
|
if (!shell_dialogs)
|
break;
|
return shell_dialogs->CreateSelectFileDialog(listener, std::move(policy));
|
+#if defined(USE_DBUS)
|
case kPortal:
|
return new SelectFileDialogLinuxPortal(listener, std::move(policy));
|
+#endif
|
case kKde: {
|
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
base::nix::DesktopEnvironment desktop =
|
--
|
2.20.1
|