2022-07-21 19:26:10 +02:00
|
|
|
diff --git printing/printing_context_linux.cc printing/printing_context_linux.cc
|
2023-01-30 18:43:54 +01:00
|
|
|
index 5520e15c232c8..2648037fcf37e 100644
|
2022-07-21 19:26:10 +02:00
|
|
|
--- printing/printing_context_linux.cc
|
|
|
|
+++ printing/printing_context_linux.cc
|
2023-01-12 17:49:21 +01:00
|
|
|
@@ -69,11 +69,11 @@ mojom::ResultCode PrintingContextLinux::UseDefaultSettings() {
|
2022-07-25 19:49:32 +02:00
|
|
|
ResetSettings();
|
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-07-25 19:49:32 +02:00
|
|
|
- if (!ui::LinuxUi::instance())
|
2023-01-12 17:49:21 +01:00
|
|
|
+ if (!ui::PrintingContextLinuxDelegate::instance())
|
2022-07-25 19:49:32 +02:00
|
|
|
return mojom::ResultCode::kSuccess;
|
|
|
|
|
|
|
|
if (!print_dialog_)
|
|
|
|
- print_dialog_ = ui::LinuxUi::instance()->CreatePrintDialog(this);
|
2023-01-12 17:49:21 +01:00
|
|
|
+ print_dialog_ = ui::PrintingContextLinuxDelegate::instance()->CreatePrintDialog(this);
|
2022-07-25 19:49:32 +02:00
|
|
|
print_dialog_->UseDefaultSettings();
|
2023-01-12 17:49:21 +01:00
|
|
|
#endif
|
2022-07-25 19:49:32 +02:00
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
@@ -82,8 +82,8 @@ mojom::ResultCode PrintingContextLinux::UseDefaultSettings() {
|
2022-07-21 19:26:10 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
gfx::Size PrintingContextLinux::GetPdfPaperSizeDeviceUnits() {
|
2023-01-12 17:49:21 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-07-25 19:49:32 +02:00
|
|
|
- if (ui::LinuxUi::instance())
|
|
|
|
- return ui::LinuxUi::instance()->GetPdfPaperSize(this);
|
2023-01-12 17:49:21 +01:00
|
|
|
+ if (ui::PrintingContextLinuxDelegate::instance())
|
|
|
|
+ return ui::PrintingContextLinuxDelegate::instance()->GetPdfPaperSize(this);
|
|
|
|
#endif
|
2022-07-25 19:49:32 +02:00
|
|
|
|
|
|
|
return gfx::Size();
|
2023-01-12 17:49:21 +01:00
|
|
|
@@ -95,11 +95,11 @@ mojom::ResultCode PrintingContextLinux::UpdatePrinterSettings(
|
2022-07-25 19:49:32 +02:00
|
|
|
DCHECK(!in_print_job_);
|
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-07-25 19:49:32 +02:00
|
|
|
- if (!ui::LinuxUi::instance())
|
2023-01-12 17:49:21 +01:00
|
|
|
+ if (!ui::PrintingContextLinuxDelegate::instance())
|
2022-07-25 19:49:32 +02:00
|
|
|
return mojom::ResultCode::kSuccess;
|
|
|
|
|
|
|
|
if (!print_dialog_)
|
|
|
|
- print_dialog_ = ui::LinuxUi::instance()->CreatePrintDialog(this);
|
2023-01-12 17:49:21 +01:00
|
|
|
+ print_dialog_ = ui::PrintingContextLinuxDelegate::instance()->CreatePrintDialog(this);
|
2022-07-25 19:49:32 +02:00
|
|
|
|
|
|
|
// PrintDialogGtk::UpdateSettings() calls InitWithSettings() so settings_ will
|
|
|
|
// remain non-null after this line.
|
|
|
|
diff --git ui/linux/linux_ui.cc ui/linux/linux_ui.cc
|
2023-01-12 17:49:21 +01:00
|
|
|
index 29db798e8b171..f8b9546b90321 100644
|
2022-07-25 19:49:32 +02:00
|
|
|
--- ui/linux/linux_ui.cc
|
|
|
|
+++ ui/linux/linux_ui.cc
|
2023-01-12 17:49:21 +01:00
|
|
|
@@ -18,11 +18,29 @@ namespace ui {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
LinuxUi* g_linux_ui = nullptr;
|
|
|
|
+static PrintingContextLinuxDelegate* g_delegate = nullptr;
|
2022-09-26 21:30:45 +02:00
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
+// static
|
|
|
|
+PrintingContextLinuxDelegate* PrintingContextLinuxDelegate::SetInstance(
|
|
|
|
+ PrintingContextLinuxDelegate* delegate) {
|
|
|
|
+ auto old_delegate = g_delegate;
|
|
|
|
+ g_delegate = delegate;
|
|
|
|
+ return old_delegate;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// static
|
|
|
|
+PrintingContextLinuxDelegate* PrintingContextLinuxDelegate::instance() {
|
|
|
|
+ return g_delegate;
|
|
|
|
+}
|
|
|
|
+
|
2022-08-23 03:37:40 +02:00
|
|
|
// static
|
2022-09-26 21:30:45 +02:00
|
|
|
LinuxUi* LinuxUi::SetInstance(LinuxUi* instance) {
|
2022-07-25 19:49:32 +02:00
|
|
|
+#if BUILDFLAG(IS_LINUX) && BUILDFLAG(ENABLE_PRINTING)
|
2023-01-12 17:49:21 +01:00
|
|
|
+ PrintingContextLinuxDelegate::SetInstance(instance);
|
2022-07-25 19:49:32 +02:00
|
|
|
+#endif
|
2022-08-23 03:37:40 +02:00
|
|
|
+
|
2022-09-26 21:30:45 +02:00
|
|
|
return std::exchange(g_linux_ui, instance);
|
2022-07-25 19:49:32 +02:00
|
|
|
}
|
2022-08-23 03:37:40 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
diff --git ui/linux/linux_ui.h ui/linux/linux_ui.h
|
2023-01-12 17:49:21 +01:00
|
|
|
index b5fd57741d2f4..eaab5f1bd2b0b 100644
|
2022-07-25 19:49:32 +02:00
|
|
|
--- ui/linux/linux_ui.h
|
|
|
|
+++ ui/linux/linux_ui.h
|
2022-11-15 18:50:53 +01:00
|
|
|
@@ -18,6 +18,10 @@
|
2022-08-23 03:37:40 +02:00
|
|
|
#include "build/chromecast_buildflags.h"
|
|
|
|
#include "printing/buildflags/buildflags.h"
|
2022-07-25 19:49:32 +02:00
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_PRINTING)
|
|
|
|
+#include "printing/printing_context_linux.h" // nogncheck
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
// The main entrypoint into Linux toolkit specific code. GTK/QT code should only
|
|
|
|
// be executed behind this interface.
|
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
@@ -60,9 +64,27 @@ class TextEditCommandAuraLinux;
|
|
|
|
class WindowButtonOrderObserver;
|
|
|
|
class WindowFrameProvider;
|
2022-08-23 03:37:40 +02:00
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
+class COMPONENT_EXPORT(LINUX_UI) PrintingContextLinuxDelegate {
|
|
|
|
+ public:
|
|
|
|
+ virtual ~PrintingContextLinuxDelegate() = default;
|
|
|
|
+
|
|
|
|
+ virtual printing::PrintDialogLinuxInterface* CreatePrintDialog(
|
|
|
|
+ printing::PrintingContextLinux* context) = 0;
|
|
|
|
+
|
|
|
|
+ virtual gfx::Size GetPdfPaperSize(printing::PrintingContextLinux* context) = 0;
|
|
|
|
+
|
|
|
|
+ static PrintingContextLinuxDelegate* SetInstance(
|
|
|
|
+ PrintingContextLinuxDelegate* delegate);
|
|
|
|
+ static PrintingContextLinuxDelegate* instance();
|
|
|
|
+};
|
|
|
|
+
|
2022-07-25 19:49:32 +02:00
|
|
|
// Adapter class with targets to render like different toolkits. Set by any
|
|
|
|
// project that wants to do linux desktop native rendering.
|
2022-08-23 03:37:40 +02:00
|
|
|
-class COMPONENT_EXPORT(LINUX_UI) LinuxUi {
|
|
|
|
+class COMPONENT_EXPORT(LINUX_UI) LinuxUi
|
2022-07-25 19:49:32 +02:00
|
|
|
+#if BUILDFLAG(ENABLE_PRINTING)
|
2023-01-12 17:49:21 +01:00
|
|
|
+ : public PrintingContextLinuxDelegate
|
2022-07-25 19:49:32 +02:00
|
|
|
+#endif
|
2022-08-23 03:37:40 +02:00
|
|
|
+ {
|
2022-07-25 19:49:32 +02:00
|
|
|
public:
|
2022-11-15 18:50:53 +01:00
|
|
|
// Describes the window management actions that could be taken in response to
|
|
|
|
// a middle click in the non client area.
|
2023-01-12 17:49:21 +01:00
|
|
|
@@ -129,14 +151,6 @@ class COMPONENT_EXPORT(LINUX_UI) LinuxUi {
|
2022-07-25 19:49:32 +02:00
|
|
|
// Returns a map of KeyboardEvent code to KeyboardEvent key values.
|
|
|
|
virtual base::flat_map<std::string, std::string> GetKeyboardLayoutMap() = 0;
|
|
|
|
|
|
|
|
-#if BUILDFLAG(ENABLE_PRINTING)
|
|
|
|
- virtual printing::PrintDialogLinuxInterface* CreatePrintDialog(
|
|
|
|
- printing::PrintingContextLinux* context) = 0;
|
|
|
|
-
|
|
|
|
- virtual gfx::Size GetPdfPaperSize(
|
|
|
|
- printing::PrintingContextLinux* context) = 0;
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
// Returns a native file selection dialog. `listener` is of type
|
|
|
|
// SelectFileDialog::Listener. TODO(thomasanderson): Move
|
|
|
|
// SelectFileDialog::Listener to SelectFileDialogListener so that it can be
|