From eb40d2cbfafea4ae8dfac9090d099b368f4ed3eb Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 29 Sep 2024 17:10:34 -0500 Subject: [PATCH] fix: FTBFS when building with `enable_plugins = false` (#44003) * fix: do not build electron_plugin_info_host_impl.cc when plugins are disabled it fails to build from source with this error: ../../content/public/browser/plugin_service.h:17:2: error: "Plugins should be enabled" 17 | #error "Plugins should be enabled" * fix: FTBFS in printing_utils.cc when ENABLE_PDF is false * fixup! fix: do not build electron_plugin_info_host_impl.cc when plugins are disabled fix BUILD.gn linting --- BUILD.gn | 2 ++ filenames.gni | 2 -- shell/browser/electron_browser_client.cc | 2 ++ shell/browser/printing/printing_utils.cc | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index d0f301f1cb47..0b1f112e9e75 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -674,6 +674,8 @@ source_set("electron_lib") { if (enable_plugins) { sources += [ + "shell/browser/electron_plugin_info_host_impl.cc", + "shell/browser/electron_plugin_info_host_impl.h", "shell/common/plugin_info.cc", "shell/common/plugin_info.h", ] diff --git a/filenames.gni b/filenames.gni index aa1148d00a59..5bb446ae2d81 100644 --- a/filenames.gni +++ b/filenames.gni @@ -379,8 +379,6 @@ filenames = { "shell/browser/electron_navigation_throttle.h", "shell/browser/electron_permission_manager.cc", "shell/browser/electron_permission_manager.h", - "shell/browser/electron_plugin_info_host_impl.cc", - "shell/browser/electron_plugin_info_host_impl.h", "shell/browser/electron_speech_recognition_manager_delegate.cc", "shell/browser/electron_speech_recognition_manager_delegate.h", "shell/browser/electron_web_contents_utility_handler_impl.cc", diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index e657d0c8ff85..11fdc4e2f769 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -1458,6 +1458,7 @@ void ElectronBrowserClient:: render_frame_host); }, &render_frame_host)); +#if BUILDFLAG(ENABLE_PLUGINS) associated_registry.AddInterface( base::BindRepeating( [](content::RenderFrameHost* render_frame_host, @@ -1468,6 +1469,7 @@ void ElectronBrowserClient:: std::move(receiver)); }, &render_frame_host)); +#endif #if BUILDFLAG(ENABLE_PRINTING) associated_registry.AddInterface( base::BindRepeating( diff --git a/shell/browser/printing/printing_utils.cc b/shell/browser/printing/printing_utils.cc index 14dc82a3245a..52534ee31fdb 100644 --- a/shell/browser/printing/printing_utils.cc +++ b/shell/browser/printing/printing_utils.cc @@ -15,11 +15,14 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "electron/buildflags/buildflags.h" -#include "pdf/pdf_features.h" #include "printing/backend/print_backend.h" // nogncheck #include "printing/units.h" #include "shell/common/thread_restrictions.h" +#if BUILDFLAG(ENABLE_PDF_VIEWER) +#include "pdf/pdf_features.h" +#endif + #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h" #endif