From fb70b81ee6842b737d1c1dda18d542d7f18eeb2f Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 10:37:35 -0600 Subject: [PATCH] fix: broken OOP `window.print()` on macOS/Linux (#45259) fix: broken OOP printing on macOS/Linux Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- .../electron_content_utility_client.cc | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/shell/utility/electron_content_utility_client.cc b/shell/utility/electron_content_utility_client.cc index 5c5226cfea70..45baca4f0b08 100644 --- a/shell/utility/electron_content_utility_client.cc +++ b/shell/utility/electron_content_utility_client.cc @@ -31,6 +31,11 @@ #include "components/services/print_compositor/public/mojom/print_compositor.mojom.h" // nogncheck #endif // BUILDFLAG(ENABLE_PRINTING) +#if BUILDFLAG(ENABLE_OOP_PRINTING) +#include "chrome/services/printing/print_backend_service_impl.h" +#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h" +#endif // BUILDFLAG(ENABLE_OOP_PRINTING) + #if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(IS_WIN) #include "chrome/services/printing/pdf_to_emf_converter_factory.h" #endif @@ -72,6 +77,21 @@ auto RunPrintCompositor( } #endif +#if BUILDFLAG(ENABLE_OOP_PRINTING) +auto RunPrintingSandboxedPrintBackendHost( + mojo::PendingReceiver + receiver) { + return std::make_unique( + std::move(receiver)); +} +auto RunPrintingUnsandboxedPrintBackendHost( + mojo::PendingReceiver + receiver) { + return std::make_unique( + std::move(receiver)); +} +#endif // BUILDFLAG(ENABLE_OOP_PRINTING) + auto RunProxyResolver( mojo::PendingReceiver receiver) { @@ -122,6 +142,11 @@ void ElectronContentUtilityClient::RegisterMainThreadServices( services.Add(RunPrintCompositor); #endif +#if BUILDFLAG(ENABLE_OOP_PRINTING) + services.Add(RunPrintingSandboxedPrintBackendHost); + services.Add(RunPrintingUnsandboxedPrintBackendHost); +#endif + #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ (BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(IS_WIN)) services.Add(RunPrintingService);