electron/patches/chromium/mas_no_private_api.patch
electron-roller[bot] d02c9f8bc6
chore: bump chromium to 111.0.5544.3 (main) (#36820)
* chore: bump chromium in DEPS to 111.0.5522.0

* chore: bump chromium in DEPS to 111.0.5524.0

* chore: bump chromium in DEPS to 111.0.5526.0

* chore: bump chromium in DEPS to 111.0.5528.0

* chore: update patches/chromium/mas_avoid_usage_of_private_macos_apis.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4132807

Fix simple code shear

* chore: update patches/chromium/unsandboxed_ppapi_processes_skip_zygote.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4130675

Fix simple code shear

* chore: update patches/chromium/hack_plugin_response_interceptor_to_point_to_electron.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4144281

Fix simple code shear; applied cleanly w/patch-fuzz

* chore: update patches/chromium/disable_unload_metrics.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4126173

Fix simple code shear; applied cleanly w/patch-fuzz

* chore: update patches/chromium/feat_add_data_parameter_to_processsingleton.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4144281

Fix simple code shear; applied cleanly w/patch-fuzz

* chore: update patches/chromium/preconnect_manager.patch

https://chromium-review.googlesource.com/c/chromium/src/+/4144281

Fix simple code shear; applied cleanly w/patch-fuzz

* chore: update patches/v8/force_cppheapcreateparams_to_be_noncopyable.patch

https://chromium-review.googlesource.com/c/v8/v8/+/3533019

Fix simple code shear; applied cleanly w/patch-fuzz

* chore: update patches

* chore: update patches/chromium/add_maximized_parameter_to_linuxui_getwindowframeprovider.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4128765

Upstream added a new call to HeaderContext(), whose signature we have patched

* chore: bump chromium in DEPS to 111.0.5530.0

* chore: update patches

* Move ChildProcessHost* from content/common to content/browser

Xref: Move ChildProcessHost* from content/common to content/browser

* Remove RenderViewHostChanged

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4134103
[upstream removal of RenderViewHostChanged]

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4092763
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4093234
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4133892
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4134103
[examples of upstream code adjusting to the change]

Upstream handles this change in roughly two approaches:

1. Move the code over to RenderFrameHostChanged(old_host, new_host)
   but test for new_host->IsInPrimaryMainFrame() before acting

2. Migrate to the PrimaryPageChanged(page) API and use
   page.GetMainDocument() to get the RenderFrameHost.

I've chosen 1. because electron_api_web_contents needed that pointer
to old_host to call RemoveInputEventListener(), but I may be missing
some context & would appreciate review on this commit.

* Make electron/shell/browser/relauncher_win.cc use <winternl.h>

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4129135

Many internal Windows types are now available in winternl.h
so upstrem no longer defines the types themselves.

* Move ChildProcessHost* from content/common to content/browser

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4134795

* fixup! Make electron/shell/browser/relauncher_win.cc use <winternl.h>

winternl.h does not define the field we need, so clone the struct Chromium was using into unnamed namespace

* fixup! Move ChildProcessHost* from content/common to content/browser

chore: update #includes too

* chore: bump chromium in DEPS to 111.0.5532.0

* chore: sync patches/chromium/pepper_plugin_support.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4133323

manually reync patch; no code changes

* chore: sync patches/chromium/mas_no_private_api.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4143865

the content/common/pseudonymization_salt.cc patch is no longer needed

* chore: sync patches/chromium/mas_disable_remote_accessibility.patch

patch-fuzz update; no manual changes

* chore: sync patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4111725

manually reync patch; no code changes

* chore: sync patches/chromium/create_browser_v8_snapshot_file_name_fuse.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4133323

manually reync patch; no code changes

* chore: sync patches/v8/fix_build_deprecated_attribute_for_older_msvc_versions.patch

Xref: https://chromium-review.googlesource.com/c/v8/v8/+/4127230

patch-fuzz update; no manual changes

* chore: rebuild patches

* fixup! Remove RenderViewHostChanged

Use PrimaryPageChanged()

* chore: remove unused method TabsUpdateFunction::OnExecuteCodeFinished()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4133991

This private, already-unused function showed up as a FTBFS because it
took a base::ListValue parameter and ListValue was removed upstream.

* task posting v3: remove includes of runner handles and IWYU task runners

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4133323

* chore: lint

* chore: more lint

* fixup! task posting v3: remove includes of runner handles and IWYU task runners

macOS, too

* fixup! task posting v3: remove includes of runner handles and IWYU task runners

* chore: bump chromium in DEPS to 111.0.5534.0

* chore: sync patches/chromium/allow_new_privileges_in_unsandboxed_child_processes.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4141862

patch-fuzz update; no manual changes

* chore: sync patches/chromium/logging_win32_only_create_a_console_if_logging_to_stderr.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4153110

Sync to minor upstream changes. Add const correctness.

* chore: sync electron/patches/chromium/feat_configure_launch_options_for_service_process.patch

https://chromium-review.googlesource.com/c/chromium/src/+/4141862

patch-fuzz update; no manual changes

* chore: patches/v8/fix_build_deprecated_attribute_for_older_msvc_versions.patch

sync https://chromium-review.googlesource.com/c/v8/v8/+/4147787

patch-fuzz update; no manual changes

* chore: update patches

* chore: bump chromium in DEPS to 111.0.5536.0

* chore: sync patches/chromium/allow_new_privileges_in_unsandboxed_child_processes.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4141863

Sync with upstream code changes. Minor code golf for readability.

Note: upstream is laying groundwork for being able to work off of env vars
instead of switches. Doesn't affect us yet but worth being aware of.

> + // Environment variables could be supported in the future, but are not
> + // currently supported when launching with the zygote.

* chore: update patches/chromium/feat_expose_raw_response_headers_from_urlloader.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4126836

patch-fuzz update; no manual changes

* chore: sync electron/patches/chromium/feat_configure_launch_options_for_service_process.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4141863

manual sync

* chore: sync electron/patches/v8/fix_build_deprecated_attribute_for_older_msvc_versions.patch

https://chromium-review.googlesource.com/c/v8/v8/+/4147788

fuzz-patch

* chore: rebuild patches

* chore: bump chromium in DEPS to 111.0.5538.0

* chore: bump chromium in DEPS to 111.0.5540.0

* chore: update patches

* Remove sdk_forward_declarations

https://chromium-review.googlesource.com/c/chromium/src/+/4166680

* task posting v3: Remove task runner handles from codebase entirely

Refs https://chromium-review.googlesource.com/c/chromium/src/+/4150928

* Cleanup child_process_launcher_helper*

Refs https://chromium-review.googlesource.com/c/chromium/src/+/4141863

* fix: utilityprocess spec on macOS

* fix: build on windows

Refs https://chromium-review.googlesource.com/c/chromium/src/+/4141863

* chore: fix lint

* chore: bump chromium 111.0.5544.3

* chore: gen filenames.libcxx.gni

* Add check for Executable+Writable handles in renderer processes.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/3774416

* fixup! Add check for Executable+Writable handles in renderer processes.

* 4143761: [110] Disable SwiftShader for WebGL on M1 Macs.

https://chromium-review.googlesource.com/c/chromium/src/+/4143761
(cherry picked from commit 2f74db3c2139424c416f92d9169aeaa8a2f9c1ec)

* chore: bump chromium to 111.0.5555.0

* 56085: Remove hmac.h include from ssl.h.

https://boringssl-review.googlesource.com/c/boringssl/+/56085

* 4167020: Remove forwarding headers

https://chromium-review.googlesource.com/c/chromium/src/+/4167020

* chore: bump chromium to 111.0.5559.0

* 4181044: Restrict WebCursor usage to RenderWidgetHostViewAura

https://chromium-review.googlesource.com/c/chromium/src/+/4181044

* 4189437: views: rename ink_drop_host_view to ink_drop_host

https://chromium-review.googlesource.com/c/chromium/src/+/4189437

* chore: bump chromium to 111.0.5560.0

* 4167016: win7dep: remove non aeroglass code

https://chromium-review.googlesource.com/c/chromium/src/+/4167016

* fixup after rebase: Remove forwarding header

s https://chromium-review.googlesource.com/c/chromium/src/+/4167020

* 4125755: Reland "Reject getDisplayMedia calls without user activation"

https://chromium-review.googlesource.com/c/chromium/src/+/4125755

* test: add workaround

* chore: update patches

* fix: alter coreModuleRegExp to prevent arm crash

* Revert "fix: alter coreModuleRegExp to prevent arm crash"

This reverts commit 7e50630c98137831a711c5abdbc8809e60cf1d73.

* 4218354: Disable the use of preserve_most on arm64 Windows

https://chromium-review.googlesource.com/c/v8/v8/+/4218354

* chore: review changes

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2023-02-03 12:43:42 +01:00

318 lines
11 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Tue, 9 Oct 2018 10:36:20 -0700
Subject: mas: avoid some private APIs
Guard usages in blink of private Mac APIs by MAS_BUILD, so they can be
excluded for people who want to submit their apps to the Mac App store.
diff --git a/base/process/process_info_mac.cc b/base/process/process_info_mac.cc
index 6840358c3187522c63dff66b5a85567aaadc5c12..72c57fbc5fbb267f96ff9e21915fb801ed5bf24e 100644
--- a/base/process/process_info_mac.cc
+++ b/base/process/process_info_mac.cc
@@ -9,18 +9,22 @@
#include <stdlib.h>
#include <unistd.h>
+#if !IS_MAS_BUILD()
extern "C" {
pid_t responsibility_get_pid_responsible_for_pid(pid_t)
API_AVAILABLE(macosx(10.12));
}
+#endif
namespace base {
bool IsProcessSelfResponsible() {
+#if !IS_MAS_BUILD()
if (__builtin_available(macOS 10.14, *)) {
const pid_t pid = getpid();
return responsibility_get_pid_responsible_for_pid(pid) == pid;
}
+#endif
return true;
}
diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm
index add9345fdd076698fc7ec654d7ef1701699639a4..ea5287cbe878014e4f0f6124a459bef225b0ca59 100644
--- a/content/renderer/renderer_main_platform_delegate_mac.mm
+++ b/content/renderer/renderer_main_platform_delegate_mac.mm
@@ -10,9 +10,11 @@
#include "sandbox/mac/seatbelt.h"
#include "sandbox/mac/system_services.h"
+#if !IS_MAS_BUILD()
extern "C" {
CGError CGSSetDenyWindowServerConnections(bool);
}
+#endif
namespace content {
@@ -22,6 +24,7 @@
// verifies there are no existing open connections), and then indicates that
// Chrome should continue execution without access to launchservicesd.
void DisableSystemServices() {
+#if !IS_MAS_BUILD()
// Tell the WindowServer that we don't want to make any future connections.
// This will return Success as long as there are no open connections, which
// is what we want.
@@ -30,6 +33,7 @@ void DisableSystemServices() {
sandbox::DisableLaunchServices();
sandbox::DisableCoreServicesCheckFix();
+#endif
}
} // namespace
diff --git a/content/renderer/theme_helper_mac.mm b/content/renderer/theme_helper_mac.mm
index f50448237c40710e25644c2f7d44e8d0bc0789c8..752b575cf341546bdcc46e6dfff28fe4c66325b3 100644
--- a/content/renderer/theme_helper_mac.mm
+++ b/content/renderer/theme_helper_mac.mm
@@ -7,11 +7,11 @@
#include <Cocoa/Cocoa.h>
#include "base/strings/sys_string_conversions.h"
-
+#if !IS_MAS_BUILD()
extern "C" {
bool CGFontRenderingGetFontSmoothingDisabled(void) API_AVAILABLE(macos(10.14));
}
-
+#endif
namespace content {
void SystemColorsDidChange(int aqua_color_variant,
@@ -59,8 +59,19 @@ void SystemColorsDidChange(int aqua_color_variant,
bool IsSubpixelAntialiasingAvailable() {
if (__builtin_available(macOS 10.14, *)) {
// See https://trac.webkit.org/changeset/239306/webkit for more info.
+#if !IS_MAS_BUILD()
return !CGFontRenderingGetFontSmoothingDisabled();
+#else
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ NSString *default_key = @"CGFontRenderingGetFontSmoothingDisabled";
+ // Check that key exists since boolForKey defaults to NO when the
+ // key is missing and this key in fact defaults to YES;
+ if ([defaults objectForKey:default_key] == nil)
+ return false;
+ return ![defaults boolForKey:default_key];
+#endif
}
+
return true;
}
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index 0c4121f178392864053f5511bf880d8e20845fdd..f472ecfc2ba6d3ce51fa14f989bfad77d21347fb 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -42,6 +42,7 @@
#include "device/bluetooth/bluetooth_socket_mac.h"
#include "device/bluetooth/public/cpp/bluetooth_address.h"
+#if !IS_MAS_BUILD()
extern "C" {
// Undocumented IOBluetooth Preference API [1]. Used by `blueutil` [2] and
// `Karabiner` [3] to programmatically control the Bluetooth state. Calling the
@@ -55,6 +56,7 @@
// [4] https://support.apple.com/kb/PH25091
void IOBluetoothPreferenceSetControllerPowerState(int state);
}
+#endif
namespace {
@@ -114,8 +116,10 @@ bool IsDeviceSystemPaired(const std::string& device_address) {
: controller_state_function_(
base::BindRepeating(&BluetoothAdapterMac::GetHostControllerState,
base::Unretained(this))),
+#if !IS_MAS_BUILD()
power_state_function_(
base::BindRepeating(IOBluetoothPreferenceSetControllerPowerState)),
+#endif
classic_discovery_manager_(
BluetoothDiscoveryManagerMac::CreateClassic(this)),
low_energy_discovery_manager_(
@@ -356,8 +360,12 @@ bool IsDeviceSystemPaired(const std::string& device_address) {
}
bool BluetoothAdapterMac::SetPoweredImpl(bool powered) {
+#if !IS_MAS_BUILD()
power_state_function_.Run(base::strict_cast<int>(powered));
return true;
+#else
+ return false;
+#endif
}
void BluetoothAdapterMac::RemovePairingDelegateInternal(
diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn
index 79021074867df91e3090bc6bbea6114364e6e78d..44635f13048890b20c74870d26c4e74bab363ddb 100644
--- a/media/audio/BUILD.gn
+++ b/media/audio/BUILD.gn
@@ -176,6 +176,12 @@ source_set("audio") {
"mac/scoped_audio_unit.cc",
"mac/scoped_audio_unit.h",
]
+ if (is_mas_build) {
+ sources -= [
+ "mac/coreaudio_dispatch_override.cc",
+ "mac/coreaudio_dispatch_override.h",
+ ]
+ }
frameworks = [
"AudioToolbox.framework",
"AudioUnit.framework",
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc
index 2cd163bf82f16a44456d0f98505514489ba8f751..636096ec3d6425b858bbcb9f732be44cbab077e7 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -975,7 +975,7 @@ AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters(
void AudioManagerMac::InitializeOnAudioThread() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
- InitializeCoreAudioDispatchOverride();
+ // InitializeCoreAudioDispatchOverride();
power_observer_ = std::make_unique<AudioPowerObserver>();
}
diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
index a93e7cd74d2a9d692304ecf10279fae8e96bb695..3506d6ca555701bad6623cc1c614e0081892e42b 100644
--- a/net/dns/dns_config_service_posix.cc
+++ b/net/dns/dns_config_service_posix.cc
@@ -130,8 +130,8 @@ class DnsConfigServicePosix::Watcher : public DnsConfigService::Watcher {
bool Watch() override {
CheckOnCorrectSequence();
-
bool success = true;
+#if !IS_MAS_BUILD()
if (!config_watcher_.Watch(base::BindRepeating(&Watcher::OnConfigChanged,
base::Unretained(this)))) {
LOG(ERROR) << "DNS config watch failed to start.";
@@ -148,6 +148,7 @@ class DnsConfigServicePosix::Watcher : public DnsConfigService::Watcher {
success = false;
}
#endif // !BUILDFLAG(IS_IOS)
+#endif
return success;
}
diff --git a/sandbox/mac/sandbox_compiler.cc b/sandbox/mac/sandbox_compiler.cc
index f35d9ef2a2df3db8ecbf1d7b909c7b1cf33f3cd9..a710b8b4f851666fd65bb37f69ec2fa70259697b 100644
--- a/sandbox/mac/sandbox_compiler.cc
+++ b/sandbox/mac/sandbox_compiler.cc
@@ -47,6 +47,7 @@ bool SandboxCompiler::SetParameter(const std::string& key,
}
bool SandboxCompiler::CompileAndApplyProfile(std::string& error) {
+#if !IS_MAS_BUILD()
if (mode_ == Target::kSource) {
std::vector<const char*> params;
@@ -67,6 +68,9 @@ bool SandboxCompiler::CompileAndApplyProfile(std::string& error) {
}
}
return false;
+#else
+ return true;
+#endif
}
bool SandboxCompiler::CompilePolicyToProto(mac::SandboxPolicy& policy,
diff --git a/sandbox/mac/seatbelt.cc b/sandbox/mac/seatbelt.cc
index 15c835e118456394c0a00ac98c11241c14ca75bd..49332a94219fc3e64ab05baa04681325edddfeb0 100644
--- a/sandbox/mac/seatbelt.cc
+++ b/sandbox/mac/seatbelt.cc
@@ -175,7 +175,11 @@ void Seatbelt::FreeError(char* errorbuf) {
// static
bool Seatbelt::IsSandboxed() {
+#if !IS_MAS_BUILD()
return ::sandbox_check(getpid(), NULL, 0);
+#else
+ return true;
+#endif
}
} // namespace sandbox
diff --git a/sandbox/mac/seatbelt_extension.cc b/sandbox/mac/seatbelt_extension.cc
index 18479382a277cb2b25626ec8d31442bfd1377ee6..7d80d7fa8337523c3a70f317f883f0cc26c6f40b 100644
--- a/sandbox/mac/seatbelt_extension.cc
+++ b/sandbox/mac/seatbelt_extension.cc
@@ -11,6 +11,7 @@
#include "base/notreached.h"
#include "sandbox/mac/seatbelt_extension_token.h"
+#if !IS_MAS_BUILD()
// libsandbox private API.
extern "C" {
extern const char* APP_SANDBOX_READ;
@@ -22,6 +23,7 @@ char* sandbox_extension_issue_file(const char* type,
const char* path,
uint32_t flags);
}
+#endif
namespace sandbox {
@@ -50,7 +52,11 @@ std::unique_ptr<SeatbeltExtension> SeatbeltExtension::FromToken(
bool SeatbeltExtension::Consume() {
DCHECK(!token_.empty());
+#if !IS_MAS_BUILD()
handle_ = sandbox_extension_consume(token_.c_str());
+#else
+ handle_ = -1;
+#endif
return handle_ > 0;
}
@@ -62,7 +68,11 @@ bool SeatbeltExtension::ConsumePermanently() {
}
bool SeatbeltExtension::Revoke() {
+#if !IS_MAS_BUILD()
int rv = sandbox_extension_release(handle_);
+#else
+ int rv = -1;
+#endif
handle_ = 0;
token_.clear();
return rv == 0;
@@ -80,12 +90,14 @@ SeatbeltExtension::SeatbeltExtension(const std::string& token)
char* SeatbeltExtension::IssueToken(SeatbeltExtension::Type type,
const std::string& resource) {
switch (type) {
+#if !IS_MAS_BUILD()
case FILE_READ:
return sandbox_extension_issue_file(APP_SANDBOX_READ, resource.c_str(),
0);
case FILE_READ_WRITE:
return sandbox_extension_issue_file(APP_SANDBOX_READ_WRITE,
resource.c_str(), 0);
+#endif
default:
NOTREACHED();
return nullptr;
diff --git a/ui/accessibility/platform/inspect/ax_transform_mac.mm b/ui/accessibility/platform/inspect/ax_transform_mac.mm
index fe043e6dc2203a9054ae367b70a3854b8560c9c7..6cc51d9df176512f6f296e0eb82bc31b5a9515fa 100644
--- a/ui/accessibility/platform/inspect/ax_transform_mac.mm
+++ b/ui/accessibility/platform/inspect/ax_transform_mac.mm
@@ -88,6 +88,7 @@
}
}
+#if !IS_MAS_BUILD()
// AXTextMarker
if (IsAXTextMarker(value)) {
return AXTextMarkerToBaseValue(value, indexer);
@@ -96,6 +97,7 @@
// AXTextMarkerRange
if (IsAXTextMarkerRange(value))
return AXTextMarkerRangeToBaseValue(value, indexer);
+#endif
// Accessible object
if (AXElementWrapper::IsValidElement(value)) {