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 bc4673a6b121f256823a86d90684ae93d90ec0a5..c0451595f4c8e24ede35dacceb2192ebafba61f8 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -106,7 +106,6 @@
 #include "components/sessions/core/tab_restore_service.h"
 #include "components/sessions/core/tab_restore_service_observer.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 6bb0bce891d470aea7c5e83be734e2d581a55f4e..7d09c42806834c147ad481a5873e920b85b1c5b9 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 5cbb9e323da29ed4153ca1d028154bdd566f6554..c604abe1d6369076e41e97be1d7900058cc71bb9 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 35d1091e0c555d00ac1fc5ac878fa2a6e09e718b..2a1a5aaf18d43a68b13783d55279e481bd91c2e5 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"
@@ -70,9 +71,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 bc299671710a4517af3df61b3cc4d7b055aedc0e..6e16b917e3cf0de2919a0b501614ef91285b6d67 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"
