Skip to content

Commit

Permalink
build: fix building with enable_plugins = false (#35260)
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Aug 8, 2022
1 parent db6c227 commit 3b683c1
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 0 deletions.
2 changes: 2 additions & 0 deletions patches/chromium/.patches
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch
disable_gpu_acceleration_on_vmware_on_linux.patch
add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
cherry-pick-94a8bdafc8c6.patch
fix_mac_build_with_enable_plugins_false.patch
fix_windows_build_with_enable_plugins_false.patch
119 changes: 119 additions & 0 deletions patches/chromium/fix_mac_build_with_enable_plugins_false.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig@chromium.org>
Date: Thu, 23 Jun 2022 17:54:12 +0000
Subject: Fix Mac build with enable_plugins=false.

Remove spurious includes of plugin headers, and add appropriate #ifs.

Bug: 1027360
Change-Id: I445252f5de14dff8e89ab371429a24ad3e57ca97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3719213
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Thomas Lukaszewicz <tluk@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1017248}

diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 480244fb50f636f519485693b8d1a4cf5033c3b0..f426e30ff371c35382512d7ec7846ca6cf58515e 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -108,7 +108,6 @@
#include "components/prefs/pref_service.h"
#include "components/sessions/core/tab_restore_service.h"
#include "content/public/browser/download_manager.h"
-#include "content/public/browser/plugin_service.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "net/base/filename_util.h"
diff --git a/content/browser/sandbox_mac_unittest.mm b/content/browser/sandbox_mac_unittest.mm
index 05e9b29d7a039094fb6fd63fb8b152439f089d41..b860c1e54f0ced814fb269087924d2f695f816f3 100644
--- a/content/browser/sandbox_mac_unittest.mm
+++ b/content/browser/sandbox_mac_unittest.mm
@@ -30,6 +30,7 @@
#include "content/browser/sandbox_parameters_mac.h"
#include "content/common/mac/font_loader.h"
#include "crypto/openssl_util.h"
+#include "ppapi/buildflags/buildflags.h"
#include "sandbox/mac/seatbelt.h"
#include "sandbox/mac/seatbelt_exec.h"
#include "sandbox/policy/mac/sandbox_mac.h"
@@ -93,7 +94,9 @@ void ExecuteInAllSandboxTypes(const std::string& multiprocess_main,
sandbox::mojom::Sandbox::kCdm,
sandbox::mojom::Sandbox::kGpu,
sandbox::mojom::Sandbox::kNaClLoader,
+#if BUILDFLAG(ENABLE_PLUGINS)
sandbox::mojom::Sandbox::kPpapi,
+#endif
sandbox::mojom::Sandbox::kPrintBackend,
sandbox::mojom::Sandbox::kPrintCompositor,
sandbox::mojom::Sandbox::kRenderer,
diff --git a/content/browser/sandbox_parameters_mac.mm b/content/browser/sandbox_parameters_mac.mm
index 76a22420f605994ebe0a7ffa9a7f2a0535c2440f..cf8b251180177c3ea4f8ddb2450f0483d201ba2b 100644
--- a/content/browser/sandbox_parameters_mac.mm
+++ b/content/browser/sandbox_parameters_mac.mm
@@ -20,7 +20,6 @@
#include "base/strings/sys_string_conversions.h"
#include "base/system/sys_info.h"
#include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/plugin_service.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
@@ -34,6 +33,7 @@
#include "third_party/abseil-cpp/absl/types/optional.h"

#if BUILDFLAG(ENABLE_PLUGINS)
+#include "content/public/browser/plugin_service.h"
#include "content/public/common/pepper_plugin_info.h"
#endif

@@ -229,11 +229,11 @@ void SetupSandboxParameters(sandbox::mojom::Sandbox sandbox_type,
case sandbox::mojom::Sandbox::kNetwork:
SetupNetworkSandboxParameters(client);
break;
- case sandbox::mojom::Sandbox::kPpapi:
#if BUILDFLAG(ENABLE_PLUGINS)
+ case sandbox::mojom::Sandbox::kPpapi:
SetupPPAPISandboxParameters(client);
-#endif
break;
+#endif
case sandbox::mojom::Sandbox::kNoSandbox:
CHECK(false) << "Unhandled parameters for sandbox_type "
<< static_cast<int>(sandbox_type);
diff --git a/sandbox/policy/mac/sandbox_mac.mm b/sandbox/policy/mac/sandbox_mac.mm
index 34f8b003c96b9fff00b666ae184b5076e5d6fd45..11392b99ecad98f2cf39e67d545fe1947ede1593 100644
--- a/sandbox/policy/mac/sandbox_mac.mm
+++ b/sandbox/policy/mac/sandbox_mac.mm
@@ -12,6 +12,7 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
+#include "ppapi/buildflags/buildflags.h"
#include "printing/buildflags/buildflags.h"
#include "sandbox/policy/mac/audio.sb.h"
#include "sandbox/policy/mac/cdm.sb.h"
@@ -69,9 +70,11 @@
case sandbox::mojom::Sandbox::kNetwork:
profile += kSeatbeltPolicyString_network;
break;
+#if BUILDFLAG(ENABLE_PLUGINS)
case sandbox::mojom::Sandbox::kPpapi:
profile += kSeatbeltPolicyString_ppapi;
break;
+#endif
#if BUILDFLAG(ENABLE_PRINTING)
case sandbox::mojom::Sandbox::kPrintBackend:
profile += kSeatbeltPolicyString_print_backend;
diff --git a/ui/views_content_client/views_content_client_main_parts_mac.mm b/ui/views_content_client/views_content_client_main_parts_mac.mm
index 044600ad464fc48a805bf3e47811808983d43fef..df23f797e4f0898d9dc7742e05d286f540bfdacb 100644
--- a/ui/views_content_client/views_content_client_main_parts_mac.mm
+++ b/ui/views_content_client/views_content_client_main_parts_mac.mm
@@ -12,7 +12,6 @@
#include "base/mac/scoped_nsobject.h"
#include "base/path_service.h"
#include "content/public/browser/context_factory.h"
-#include "content/public/browser/plugin_service.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/result_codes.h"
#include "content/shell/browser/shell_application_mac.h"
108 changes: 108 additions & 0 deletions patches/chromium/fix_windows_build_with_enable_plugins_false.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig@chromium.org>
Date: Thu, 23 Jun 2022 18:52:27 +0000
Subject: Fix Windows build with enable_plugins=false.

Add some #if checks to Windows-only code so plugins enums are only
referenced when plugins are enabled. Also only build
plugin_list_unittest.cc when plugins are enabled.

Bug: 1027360
Change-Id: I0d265ae711e5e3401076dc89d1d49329f423ca64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3719402
Reviewed-by: Alex Gough <ajgo@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1017281}

diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 939c28a029418bc353795aa1a007508680f42e57..2db6a0d23d72c3d77db6eec4de7c9d0f0500fbe2 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -3951,7 +3951,9 @@ std::wstring ChromeContentBrowserClient::GetAppContainerSidForSandboxType(
return std::wstring();
case sandbox::mojom::Sandbox::kGpu:
return std::wstring();
+#if BUILDFLAG(ENABLE_PLUGINS)
case sandbox::mojom::Sandbox::kPpapi:
+#endif
case sandbox::mojom::Sandbox::kNoSandbox:
case sandbox::mojom::Sandbox::kNoSandboxAndElevatedPrivileges:
case sandbox::mojom::Sandbox::kXrCompositing:
@@ -4023,7 +4025,9 @@ bool ChromeContentBrowserClient::PreSpawnChild(
break;
case sandbox::mojom::Sandbox::kUtility:
case sandbox::mojom::Sandbox::kGpu:
+#if BUILDFLAG(ENABLE_PLUGINS)
case sandbox::mojom::Sandbox::kPpapi:
+#endif
case sandbox::mojom::Sandbox::kNoSandbox:
case sandbox::mojom::Sandbox::kNoSandboxAndElevatedPrivileges:
case sandbox::mojom::Sandbox::kXrCompositing:
diff --git a/chrome/child/pdf_child_init.cc b/chrome/child/pdf_child_init.cc
index e53cfc60b41fe0d4eeb0362e9923f1e39e61a64d..8e0d72623bbb0c92c8fd8b97ab833c947806667b 100644
--- a/chrome/child/pdf_child_init.cc
+++ b/chrome/child/pdf_child_init.cc
@@ -14,6 +14,7 @@
#include "base/win/windows_version.h"
#include "content/public/child/child_thread.h"
#include "content/public/common/content_switches.h"
+#include "ppapi/buildflags/buildflags.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#include "sandbox/policy/sandbox_type.h"
#include "sandbox/policy/switches.h"
@@ -57,7 +58,9 @@ void MaybePatchGdiGetFontData() {
auto service_sandbox_type =
sandbox::policy::SandboxTypeFromCommandLine(command_line);
bool need_gdi =
+#if BUILDFLAG(ENABLE_PLUGINS)
service_sandbox_type == sandbox::mojom::Sandbox::kPpapi ||
+#endif
service_sandbox_type == sandbox::mojom::Sandbox::kPrintCompositor ||
service_sandbox_type == sandbox::mojom::Sandbox::kPdfConversion ||
(service_sandbox_type == sandbox::mojom::Sandbox::kRenderer &&
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
index dec80de25675467a07d3c213538d240507916254..1df3675fed1656094e808fa4477ffd2ea126b83d 100644
--- a/content/test/BUILD.gn
+++ b/content/test/BUILD.gn
@@ -2168,7 +2168,6 @@ test("content_unittests") {
"../browser/payments/payment_manager_unittest.cc",
"../browser/permissions/permission_controller_impl_unittest.cc",
"../browser/picture_in_picture/picture_in_picture_service_impl_unittest.cc",
- "../browser/plugin_list_unittest.cc",
"../browser/ppapi_plugin_sandboxed_process_launcher_delegate_unittest.cc",
"../browser/prerender/prerender_host_registry_unittest.cc",
"../browser/prerender/prerender_host_unittest.cc",
@@ -2870,8 +2869,8 @@ test("content_unittests") {
deps += [ "//ui/events:test_support" ]
}

- if (!is_win && !is_mac) {
- sources -= [ "../browser/plugin_list_unittest.cc" ]
+ if (enable_plugins && (is_win || is_mac)) {
+ sources += [ "../browser/plugin_list_unittest.cc" ]
}

if (use_ozone) {
diff --git a/sandbox/policy/win/sandbox_win.cc b/sandbox/policy/win/sandbox_win.cc
index e4e7cfe65b87ef3bc6b88073dc384a50fd8256ea..0f89e8b8e971fe77cc537cb2e92b54f1d988bc2a 100644
--- a/sandbox/policy/win/sandbox_win.cc
+++ b/sandbox/policy/win/sandbox_win.cc
@@ -38,6 +38,7 @@
#include "base/win/sid.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
+#include "ppapi/buildflags/buildflags.h"
#include "printing/buildflags/buildflags.h"
#include "sandbox/features.h"
#include "sandbox/policy/features.h"
@@ -1216,8 +1217,10 @@ std::string SandboxWin::GetSandboxTypeInEnglish(Sandbox sandbox_type) {
return "Utility";
case Sandbox::kGpu:
return "GPU";
+#if BUILDFLAG(ENABLE_PLUGINS)
case Sandbox::kPpapi:
return "PPAPI";
+#endif
case Sandbox::kNetwork:
return "Network";
case Sandbox::kCdm:

0 comments on commit 3b683c1

Please sign in to comment.