mirror of
https://github.com/electron/electron.git
synced 2026-10-28 11:44:46 +08:00
* chore: bump chromium in DEPS to 158.0.8116.0 * 8527713: [Linux] Persist offered GlobalShortcuts portal shortcuts Upstream BindShortcuts() now looks commands up with find() and falls back to persisted offered shortcuts whose owner isn't loaded. Moved the pending bind group tracking into the found branch so unloaded shortcuts don't resolve a registration. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8527713 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * 8618876: Add compromised eMudhra intermediates to blocklist. Upstream now ships the same eight SPKI hashes in cert_verify_proc_blocklist.inc, so the Electron patch carrying them is no longer needed. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8618876 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * chore: update patches * 8615507: Use ChildProcessId in ContentBrowserClient::SelectClientCertificate() Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8615507 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * 8617940: Roll hunspell_dictionaries and update dictionary versions Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8617940 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * 8581764: DynamicPatching: Decouple //content from ChildModule Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8581764 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: electron-claude[bot] <279139701+electron-claude[bot]@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2621 lines
92 KiB
Diff
2621 lines
92 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samuel Attard <samuel.r.attard@gmail.com>
|
|
Date: Thu, 20 Sep 2018 17:48:49 -0700
|
|
Subject: mas: avoid private macOS API usage
|
|
|
|
* Use the stub killring file when building blink
|
|
* Remove usage of the following private APIs
|
|
* abort_report_np
|
|
* pthread_fchdir_np
|
|
* pthread_chdir_np
|
|
* SetApplicationIsDaemon
|
|
* _LSSetApplicationLaunchServicesServerConnectionStatus
|
|
* AreDeviceAndUserJoinedToDomain
|
|
* _CFIsObjC
|
|
* CGSSetWindowCaptureExcludeShape
|
|
* CGRegionCreateWithRect
|
|
* CGSGetEventPort
|
|
* CGEventCreateNextEvent
|
|
* CTFontCopyVariationAxesInternal
|
|
* AudioDeviceDuck
|
|
* NSNextStepFrame
|
|
* NSThemeFrame
|
|
* NSTextInputReplacementRangeAttributeName
|
|
* _toolbarView
|
|
* _menuImpl
|
|
* _removeFromGroups:
|
|
* _isConsideredOpenForPersistentState
|
|
* _boundsIfOpen
|
|
* _resizeDirectionForMouseLocation:
|
|
* NSAppendToKillRing
|
|
* kCFBundleNumericVersionKey
|
|
* __NSNewKillRingSequence
|
|
* __NSInitializeKillRing
|
|
* NSYankFromKillRing
|
|
* NSSetKillRingToYankedState
|
|
* NSAccessibilityRemoteUIElement is unnecessary for Electron's use-case. We use it
|
|
for progressive web apps (where the AXTree is in the browser process, but macOS
|
|
needs to think it's coming from the PWA process). I think it can just be chopped
|
|
out -- if there are any side-effects, we should be able to work around them.
|
|
* CAContext removal
|
|
* For apps that spend a lot of time watching video (especially fullscreen video),
|
|
the power/battery usage will likely increase 1.5x to 2x. For something that is,
|
|
e.g, scrolling, it'll be smaller, more like 1.15x or 1.25x.
|
|
|
|
In terms of performance, the impact will likely be fairly small -- any app that
|
|
could hit 60fps before will likely still be able to hit 60fps. There may even be
|
|
cases where performance improves when disabling remote CoreAnimation (remote
|
|
CoreAnimation is really only about battery usage).
|
|
* WindowServerEventPumpThread is a no-op in the MAS build because draining
|
|
the WindowServer event queue needs CGSMainConnectionID, CGSGetEventPort
|
|
and CGEventCreateNextEvent. The pump is treated as failed up front so that
|
|
CADisplayLink is never created in the GPU process and every root frame
|
|
sink falls back to a timer-based VSync source, matching upstream's own
|
|
behavior when the pump cannot be started.
|
|
* CTFontDescriptorIsSystemUIFont is a private API, we're using an
|
|
_interesting_ technique in the MAS build to determine if the font is a
|
|
system font by checking if it's kCTFontPriorityAttribute is set to
|
|
system priority.
|
|
|
|
diff --git a/base/BUILD.gn b/base/BUILD.gn
|
|
index ce307f24f31e740e4afc05fe531a1fe9e2463a92..7f5ef6fc7f4f8f42d6d259310684ec535ae85e72 100644
|
|
--- a/base/BUILD.gn
|
|
+++ b/base/BUILD.gn
|
|
@@ -1154,6 +1154,7 @@ component("base") {
|
|
"//build:ios_buildflags",
|
|
"//build/config/compiler:compiler_buildflags",
|
|
"//third_party/modp_b64",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
|
|
# Used by metrics/crc32
|
|
diff --git a/base/allocator/BUILD.gn b/base/allocator/BUILD.gn
|
|
index f2e33bd815cb93747e20d6591068dc7d1e1789a8..51a4eb83881d83122408787a4f002a4c114ccaec 100644
|
|
--- a/base/allocator/BUILD.gn
|
|
+++ b/base/allocator/BUILD.gn
|
|
@@ -29,6 +29,7 @@ if (is_apple) {
|
|
deps = [
|
|
":buildflags",
|
|
"//base/allocator/partition_allocator:buildflags",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
}
|
|
}
|
|
diff --git a/base/allocator/early_zone_registration_apple.cc b/base/allocator/early_zone_registration_apple.cc
|
|
index 416e541436d201aabca26cdbf7e8477103bd014c..8c5f92b03d67e5f0587b0e94209690611e3b082a 100644
|
|
--- a/base/allocator/early_zone_registration_apple.cc
|
|
+++ b/base/allocator/early_zone_registration_apple.cc
|
|
@@ -197,15 +197,33 @@ void EarlyMallocZoneRegistration() {
|
|
// a duplicate even when a binary copy of this code exists.
|
|
if (allocator_shim::IsZoneAlreadyRegistered(
|
|
allocator_shim::kDelegatingZoneName)) {
|
|
+#if !IS_MAS_BUILD()
|
|
abort_report_np(
|
|
"The delegating default zone has unexpectedly already been "
|
|
"registered.");
|
|
+#else
|
|
+#pragma clang diagnostic push
|
|
+#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
+ os_log_fault(OS_LOG_DEFAULT, "The delegating default zone "
|
|
+ "has unexpectedly already been registered.");
|
|
+#pragma clang diagnostic pop
|
|
+ abort();
|
|
+#endif
|
|
}
|
|
if (allocator_shim::IsZoneAlreadyRegistered(
|
|
allocator_shim::kPartitionAllocZoneName)) {
|
|
+#if !IS_MAS_BUILD()
|
|
abort_report_np(
|
|
"The PartitionAlloc default zone has unexpectedly already been "
|
|
"registered.");
|
|
+#else
|
|
+#pragma clang diagnostic push
|
|
+#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
+ os_log_fault(OS_LOG_DEFAULT, "The PartitionAlloc default zone "
|
|
+ "has unexpectedly already been registered.");
|
|
+#pragma clang diagnostic pop
|
|
+ abort();
|
|
+#endif
|
|
}
|
|
|
|
// Register puts the new zone at the end, unregister swaps the new zone with
|
|
@@ -229,7 +247,16 @@ void EarlyMallocZoneRegistration() {
|
|
|
|
// Sanity check.
|
|
if (allocator_shim::GetDefaultMallocZoneOrDie() != &g_delegating_zone) {
|
|
+#if !IS_MAS_BUILD()
|
|
abort_report_np("Failed to install the delegating zone as default.");
|
|
+#else
|
|
+#pragma clang diagnostic push
|
|
+#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
+ os_log_fault(OS_LOG_DEFAULT, "Failed to install the delegating zone "
|
|
+ "as default.");
|
|
+#pragma clang diagnostic pop
|
|
+ abort();
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
diff --git a/base/allocator/partition_allocator/src/partition_alloc/BUILD.gn b/base/allocator/partition_allocator/src/partition_alloc/BUILD.gn
|
|
index 9e9f063efe6f16f2f960e520badd025d0dea0a87..67aabbd6a143d9a6b0e6f2de7dd22cf03984908c 100644
|
|
--- a/base/allocator/partition_allocator/src/partition_alloc/BUILD.gn
|
|
+++ b/base/allocator/partition_allocator/src/partition_alloc/BUILD.gn
|
|
@@ -1029,6 +1029,7 @@ if (is_clang_or_gcc) {
|
|
":allocator_base",
|
|
":allocator_core",
|
|
":buildflags",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
}
|
|
} # if (is_clang_or_gcc)
|
|
diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/early_zone_registration_utils_apple.h b/base/allocator/partition_allocator/src/partition_alloc/shim/early_zone_registration_utils_apple.h
|
|
index 725b3d78c27d9621500d8193b0b4e45c6103cff0..cd3580fb4b7261b5d8e6ff691214e432c0170dc4 100644
|
|
--- a/base/allocator/partition_allocator/src/partition_alloc/shim/early_zone_registration_utils_apple.h
|
|
+++ b/base/allocator/partition_allocator/src/partition_alloc/shim/early_zone_registration_utils_apple.h
|
|
@@ -12,16 +12,21 @@
|
|
|
|
#include <mach/mach.h>
|
|
#include <malloc/malloc.h>
|
|
+#include <os/log.h>
|
|
|
|
#include <span>
|
|
#include <string_view>
|
|
|
|
+#include "electron/mas.h"
|
|
+
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
// abort_report_np() records the message in a special section that both the
|
|
// system CrashReporter and Crashpad collect in crash reports. See also in
|
|
// chrome_exe_main_mac.cc.
|
|
void abort_report_np(const char* fmt, ...);
|
|
} // extern "C"
|
|
+#endif
|
|
|
|
namespace allocator_shim {
|
|
|
|
@@ -34,7 +39,15 @@ inline std::span<malloc_zone_t*> GetMallocZonesOrDie() {
|
|
kern_return_t result = malloc_get_all_zones(
|
|
mach_task_self(), /*reader=*/nullptr, &zones, &zone_count);
|
|
if (result != KERN_SUCCESS) [[unlikely]] {
|
|
+#if !IS_MAS_BUILD()
|
|
abort_report_np("Cannot enumerate malloc zones.");
|
|
+#else
|
|
+#pragma clang diagnostic push
|
|
+#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
+ os_log_fault(OS_LOG_DEFAULT, "Cannot enumerate malloc zones.");
|
|
+#pragma clang diagnostic pop
|
|
+ abort();
|
|
+#endif
|
|
}
|
|
// This is not guaranteed by the C++ standard, but commonly satisfied.
|
|
// It must be safe to assume the same memory layout for arrays of two
|
|
diff --git a/base/enterprise_util_mac.mm b/base/enterprise_util_mac.mm
|
|
index 4bf9a3c27e05c6635b2beb8e880b5b43dbed61b5..f328fbb49c45991f44a9c75325491d0873746b61 100644
|
|
--- a/base/enterprise_util_mac.mm
|
|
+++ b/base/enterprise_util_mac.mm
|
|
@@ -16,6 +16,7 @@
|
|
#include "base/strings/string_split.h"
|
|
#include "base/strings/string_util.h"
|
|
#include "base/strings/sys_string_conversions.h"
|
|
+#include "electron/mas.h"
|
|
|
|
namespace base {
|
|
|
|
@@ -116,6 +117,14 @@ DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain() {
|
|
DeviceUserDomainJoinState state{.device_joined = false,
|
|
.user_joined = false};
|
|
|
|
+#if IS_MAS_BUILD()
|
|
+ return state;
|
|
+ }();
|
|
+
|
|
+ return state;
|
|
+}
|
|
+#else
|
|
+
|
|
@autoreleasepool {
|
|
ODSession* session = [ODSession defaultSession];
|
|
if (session == nil) {
|
|
@@ -219,5 +228,6 @@ DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain() {
|
|
|
|
return state;
|
|
}
|
|
+#endif
|
|
|
|
} // namespace base
|
|
diff --git a/base/mac/info_plist_data.mm b/base/mac/info_plist_data.mm
|
|
index 419a051968c58ae5a761708e4d942e8975c70852..a77032dd43f5fcbe29c54b622b34607fba09d350 100644
|
|
--- a/base/mac/info_plist_data.mm
|
|
+++ b/base/mac/info_plist_data.mm
|
|
@@ -11,15 +11,19 @@
|
|
#include "base/apple/bundle_locations.h"
|
|
#include "base/apple/foundation_util.h"
|
|
#include "base/containers/span.h"
|
|
+#include "electron/mas.h"
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
// Key used within CoreFoundation for loaded Info plists
|
|
extern const CFStringRef _kCFBundleNumericVersionKey;
|
|
}
|
|
+#endif
|
|
|
|
namespace base::mac {
|
|
|
|
std::vector<uint8_t> OuterBundleCachedInfoPlistData() {
|
|
+#if !IS_MAS_BUILD()
|
|
// NSBundle's info dictionary is used to ensure that any changes to Info.plist
|
|
// on disk due to pending updates do not result in a version of the data being
|
|
// used that doesn't match the code signature of the running app.
|
|
@@ -43,6 +47,9 @@
|
|
error:nullptr];
|
|
base::span<const uint8_t> span = apple::NSDataToSpan(data);
|
|
return {span.begin(), span.end()};
|
|
+#else
|
|
+ return {};
|
|
+#endif
|
|
}
|
|
|
|
} // namespace base::mac
|
|
diff --git a/base/process/launch_mac.cc b/base/process/launch_mac.cc
|
|
index 7e09a9d4a676c7a91b3a68ef6e173c590c384b5a..2f86e619a4441c0d290834da431931216426bf3e 100644
|
|
--- a/base/process/launch_mac.cc
|
|
+++ b/base/process/launch_mac.cc
|
|
@@ -85,6 +85,10 @@ int posix_spawnattr_set_csm_np(const posix_spawnattr_t*, uint32_t)
|
|
#include "base/threading/scoped_blocking_call.h"
|
|
#include "base/threading/thread_restrictions.h"
|
|
#include "base/trace_event/trace_event.h"
|
|
+#include "electron/mas.h"
|
|
+#if IS_MAS_BUILD()
|
|
+#include <sys/syscall.h>
|
|
+#endif
|
|
|
|
#if BUILDFLAG(IS_MAC)
|
|
#include "base/apple/mach_port_rendezvous_mac.h"
|
|
@@ -93,9 +97,11 @@ int posix_spawnattr_set_csm_np(const posix_spawnattr_t*, uint32_t)
|
|
extern "C" {
|
|
// Changes the current thread's directory to a path or directory file
|
|
// descriptor.
|
|
+#if !IS_MAS_BUILD()
|
|
int pthread_chdir_np(const char* dir);
|
|
|
|
int pthread_fchdir_np(int fd);
|
|
+#endif
|
|
|
|
int responsibility_spawnattrs_setdisclaim(posix_spawnattr_t attrs,
|
|
int disclaim);
|
|
@@ -176,13 +182,27 @@ class PosixSpawnFileActions {
|
|
|
|
#if !BUILDFLAG(IS_MAC)
|
|
int ChangeCurrentThreadDirectory(const char* path) {
|
|
+#if IS_MAS_BUILD()
|
|
+ #pragma clang diagnostic push
|
|
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
+ return syscall(SYS___pthread_chdir, path);
|
|
+ #pragma clang diagnostic pop
|
|
+#else
|
|
return pthread_chdir_np(path);
|
|
+#endif
|
|
}
|
|
|
|
// The recommended way to unset a per-thread cwd is to set a new value to an
|
|
// invalid file descriptor, per libpthread-218.1.3/private/private.h.
|
|
int ResetCurrentThreadDirectory() {
|
|
+#if IS_MAS_BUILD()
|
|
+ #pragma clang diagnostic push
|
|
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
+ return syscall(SYS___pthread_fchdir, -1);
|
|
+ #pragma clang diagnostic pop
|
|
+#else
|
|
return pthread_fchdir_np(-1);
|
|
+#endif
|
|
}
|
|
#endif
|
|
|
|
@@ -306,16 +326,16 @@ Process LaunchProcess(const std::vector<std::string>& argv,
|
|
file_actions.Inherit(STDERR_FILENO);
|
|
}
|
|
|
|
-#if BUILDFLAG(IS_MAC)
|
|
+#if !IS_MAS_BUILD()
|
|
if (options.disclaim_responsibility) {
|
|
DPSXCHECK(responsibility_spawnattrs_setdisclaim(attr.get(), 1));
|
|
}
|
|
+#endif
|
|
|
|
EnvironmentMap new_environment_map = options.environment;
|
|
+#if !IS_MAS_BUILD()
|
|
MachPortRendezvousServerMac::AddFeatureStateToEnvironment(
|
|
new_environment_map);
|
|
-#else
|
|
- const EnvironmentMap& new_environment_map = options.environment;
|
|
#endif
|
|
|
|
std::vector<char*> argv_cstr;
|
|
diff --git a/base/process/process_info_mac.mm b/base/process/process_info_mac.mm
|
|
index f038c8ae1a2d80dc788e315963f883b5445cbad3..54f2b2c1bb3458f0df677b69e9d2d4a95fd89d1d 100644
|
|
--- a/base/process/process_info_mac.mm
|
|
+++ b/base/process/process_info_mac.mm
|
|
@@ -4,6 +4,8 @@
|
|
|
|
#include "base/process/process_info.h"
|
|
|
|
+#include "electron/mas.h"
|
|
+
|
|
#import <AppKit/AppKit.h>
|
|
#include <unistd.h>
|
|
|
|
@@ -11,12 +13,15 @@
|
|
|
|
#include "base/check.h"
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
pid_t responsibility_get_pid_responsible_for_pid(pid_t);
|
|
}
|
|
+#endif
|
|
|
|
namespace {
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
bool AppContainsBluetoothUsageDescription(NSRunningApplication* app) {
|
|
NSURL* bundle_url = app.bundleURL;
|
|
if (!bundle_url) {
|
|
@@ -35,16 +40,22 @@ bool AppContainsBluetoothUsageDescription(NSRunningApplication* app) {
|
|
PCHECK(responsible_pid != -1);
|
|
return pid != responsible_pid ? std::optional(responsible_pid) : std::nullopt;
|
|
}
|
|
+#endif
|
|
|
|
} // namespace
|
|
|
|
namespace base {
|
|
|
|
bool IsCurrentProcessSelfResponsible() {
|
|
+#if !IS_MAS_BUILD()
|
|
return ResponsiblePidIfNotSelf() == std::nullopt;
|
|
+#else
|
|
+ return true;
|
|
+#endif
|
|
}
|
|
|
|
bool DoesResponsibleProcessHaveBluetoothMetadata() {
|
|
+#if !IS_MAS_BUILD()
|
|
const std::optional<pid_t> responsible_pid = ResponsiblePidIfNotSelf();
|
|
|
|
// Returns true directly if this is a self-responsible app (e.g., Chrome opens
|
|
@@ -61,6 +72,9 @@ bool DoesResponsibleProcessHaveBluetoothMetadata() {
|
|
return AppContainsBluetoothUsageDescription(app);
|
|
}
|
|
return false;
|
|
+#else
|
|
+ return true;
|
|
+#endif
|
|
}
|
|
|
|
} // namespace base
|
|
diff --git a/components/os_crypt/common/BUILD.gn b/components/os_crypt/common/BUILD.gn
|
|
index 10db0687101b69542f9dd33592d0655c7343e3c8..a5ad767ff8e1854ee6840f8eb4e83a9e6b9f16c5 100644
|
|
--- a/components/os_crypt/common/BUILD.gn
|
|
+++ b/components/os_crypt/common/BUILD.gn
|
|
@@ -26,6 +26,7 @@ if (is_apple) {
|
|
"//base",
|
|
"//build:branding_buildflags",
|
|
"//crypto",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
}
|
|
}
|
|
diff --git a/components/os_crypt/common/keychain_password_mac.mm b/components/os_crypt/common/keychain_password_mac.mm
|
|
index 212b93095214422112afd346e36cd2838891725b..80b417c1a022c287acae948b51d6f7c863f93721 100644
|
|
--- a/components/os_crypt/common/keychain_password_mac.mm
|
|
+++ b/components/os_crypt/common/keychain_password_mac.mm
|
|
@@ -16,6 +16,7 @@
|
|
#include "base/strings/string_view_util.h"
|
|
#include "build/branding_buildflags.h"
|
|
#include "crypto/apple/keychain_v2.h"
|
|
+#include "electron/mas.h"
|
|
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
|
|
|
|
using crypto::apple::KeychainV2;
|
|
diff --git a/components/remote_cocoa/app_shim/BUILD.gn b/components/remote_cocoa/app_shim/BUILD.gn
|
|
index 8e61a19d40c2f2bfa01f0d434685b2c0c7ae1504..d5096225ce552147af1a273897364367c5e68e63 100644
|
|
--- a/components/remote_cocoa/app_shim/BUILD.gn
|
|
+++ b/components/remote_cocoa/app_shim/BUILD.gn
|
|
@@ -81,6 +81,7 @@ component("app_shim") {
|
|
"//components/crash/core/common",
|
|
"//components/remote_cocoa/common:mojo",
|
|
"//components/system_media_controls",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
"//mojo/public/cpp/bindings",
|
|
"//net",
|
|
"//ui/accelerated_widget_mac",
|
|
diff --git a/components/remote_cocoa/app_shim/NSToolbar+Private.mm b/components/remote_cocoa/app_shim/NSToolbar+Private.mm
|
|
index 5c6f4c37205de6d7cfb91c837ad4586473cf2fdb..551dc7a0e71711eee9d5176a33b345b8b8b276fb 100644
|
|
--- a/components/remote_cocoa/app_shim/NSToolbar+Private.mm
|
|
+++ b/components/remote_cocoa/app_shim/NSToolbar+Private.mm
|
|
@@ -4,6 +4,9 @@
|
|
|
|
#import "components/remote_cocoa/app_shim/NSToolbar+Private.h"
|
|
|
|
+#include "electron/mas.h"
|
|
+
|
|
+#if !IS_MAS_BUILD()
|
|
// Access the private view that backs the toolbar.
|
|
// TODO(http://crbug.com/40261565): Remove when FB12010731 is fixed in AppKit.
|
|
@interface NSToolbar (ToolbarView)
|
|
@@ -18,3 +21,4 @@ - (NSView *)privateToolbarView {
|
|
: nil;
|
|
}
|
|
@end
|
|
+#endif
|
|
diff --git a/components/remote_cocoa/app_shim/application_bridge.mm b/components/remote_cocoa/app_shim/application_bridge.mm
|
|
index af1a8021dd83eab66047d622323f2308aac39b8b..8ecf7a4c0ef2163ce7fb19aa3f68c619109c9f2d 100644
|
|
--- a/components/remote_cocoa/app_shim/application_bridge.mm
|
|
+++ b/components/remote_cocoa/app_shim/application_bridge.mm
|
|
@@ -13,6 +13,7 @@
|
|
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
|
|
#include "components/remote_cocoa/app_shim/native_widget_ns_window_host_helper.h"
|
|
#include "components/system_media_controls/mac/remote_cocoa/system_media_controls_bridge.h"
|
|
+#include "electron/mas.h"
|
|
#include "mojo/public/cpp/bindings/associated_remote.h"
|
|
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
|
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
|
|
@@ -54,6 +55,7 @@
|
|
|
|
// NativeWidgetNSWindowHostHelper:
|
|
id GetNativeViewAccessible() override {
|
|
+#if !IS_MAS_BUILD()
|
|
if (!remote_accessibility_element_) {
|
|
base::ProcessId browser_pid = base::kNullProcessId;
|
|
std::vector<uint8_t> element_token;
|
|
@@ -64,6 +66,9 @@ id GetNativeViewAccessible() override {
|
|
ui::RemoteAccessibility::GetRemoteElementFromToken(element_token);
|
|
}
|
|
return remote_accessibility_element_;
|
|
+#else
|
|
+ return nil;
|
|
+#endif
|
|
}
|
|
void DispatchKeyEvent(ui::KeyEvent* event) override {
|
|
bool event_handled = false;
|
|
@@ -101,7 +106,9 @@ void GetWordAt(const gfx::Point& location_in_content,
|
|
mojo::AssociatedRemote<mojom::TextInputHost> text_input_host_remote_;
|
|
|
|
std::unique_ptr<NativeWidgetNSWindowBridge> bridge_;
|
|
+#if !IS_MAS_BUILD()
|
|
NSAccessibilityRemoteUIElement* __strong remote_accessibility_element_;
|
|
+#endif
|
|
};
|
|
|
|
bool g_is_out_of_process_app_shim = false;
|
|
diff --git a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
|
|
index ae93fe9bd90c4d63983cf824cf2c23ef39b36eed..7287359129278df032868a2a056714b2eda5d882 100644
|
|
--- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
|
|
+++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
|
|
@@ -9,7 +9,9 @@
|
|
#include "base/mac/mac_util.h"
|
|
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
|
|
#include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
|
|
+#include "electron/mas.h"
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
namespace {
|
|
// Workaround for https://crbug.com/1369643
|
|
const double kThinControllerHeight = 0.5;
|
|
@@ -144,12 +146,15 @@ - (void)maybeShowTrafficLights {
|
|
|
|
@end
|
|
|
|
+#endif // MAS_BUILD
|
|
+
|
|
@implementation BrowserNativeWidgetWindow
|
|
|
|
@synthesize thinTitlebarViewController = _thinTitlebarViewController;
|
|
|
|
// NSWindow (PrivateAPI) overrides.
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
|
|
// - NSThemeFrame and its subclasses will be nil if it's missing at runtime.
|
|
if ([BrowserWindowFrame class])
|
|
@@ -206,6 +211,8 @@ - (BOOL)_usesCustomDrawing {
|
|
return NO;
|
|
}
|
|
|
|
+#endif // MAS_BUILD
|
|
+
|
|
// Handle "Move focus to the window toolbar" configured in System Preferences ->
|
|
// Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|)
|
|
// tends to just be nil.
|
|
@@ -216,8 +223,10 @@ - (void)_handleFocusToolbarHotKey:(id)unknown {
|
|
}
|
|
|
|
- (void)setAlwaysShowTrafficLights:(BOOL)alwaysShow {
|
|
+#if !IS_MAS_BUILD()
|
|
[base::apple::ObjCCastStrict<BrowserWindowFrame>(self.contentView.superview)
|
|
setAlwaysShowTrafficLights:alwaysShow];
|
|
+#endif
|
|
}
|
|
|
|
@end
|
|
diff --git a/components/remote_cocoa/app_shim/menu_controller_cocoa_delegate_impl.mm b/components/remote_cocoa/app_shim/menu_controller_cocoa_delegate_impl.mm
|
|
index 5dd3ae5dff160834524c013594f76f59ad7e2fdd..356d677b9e6addeeb60af6b4e2d63125bc4f51c4 100644
|
|
--- a/components/remote_cocoa/app_shim/menu_controller_cocoa_delegate_impl.mm
|
|
+++ b/components/remote_cocoa/app_shim/menu_controller_cocoa_delegate_impl.mm
|
|
@@ -8,6 +8,7 @@
|
|
#include "base/apple/foundation_util.h"
|
|
#include "base/logging.h"
|
|
#import "base/message_loop/message_pump_apple.h"
|
|
+#import "electron/mas.h"
|
|
#import "skia/ext/skia_utils_mac.h"
|
|
#import "ui/base/cocoa/cocoa_base_utils.h"
|
|
#include "ui/base/interaction/element_tracker_mac.h"
|
|
@@ -111,6 +112,7 @@ - (void)highlightItemAtIndex:(NSInteger)index;
|
|
|
|
@interface NSMenu (Impl)
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// Returns the impl. (If called on macOS 14 this would return a subclass of
|
|
// NSCocoaMenuImpl, but private API use is not needed on macOS 14.)
|
|
- (id<CrNSCarbonMenuImpl>)_menuImpl;
|
|
@@ -119,6 +121,7 @@ @interface NSMenu (Impl)
|
|
// on both Carbon and Cocoa impls, but always (incorrectly) returns a zero
|
|
// origin with the Cocoa impl. Therefore, do not use with macOS 14 or later.
|
|
- (CGRect)_boundsIfOpen;
|
|
+#endif
|
|
|
|
@end
|
|
|
|
@@ -239,6 +242,7 @@ - (void)controllerWillAddMenu:(NSMenu*)menu fromModel:(ui::MenuModel*)model {
|
|
}
|
|
menuShown = true;
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
if (alertedIndex.has_value()) {
|
|
const auto index = base::checked_cast<NSInteger>(alertedIndex.value());
|
|
if (@available(macOS 14.0, *)) {
|
|
@@ -247,6 +251,7 @@ - (void)controllerWillAddMenu:(NSMenu*)menu fromModel:(ui::MenuModel*)model {
|
|
[strongMenu._menuImpl highlightItemAtIndex:index];
|
|
}
|
|
}
|
|
+#endif
|
|
|
|
if (@available(macOS 14.0, *)) {
|
|
for (auto [elementId, index] : elementIds) {
|
|
@@ -267,7 +272,11 @@ - (void)controllerWillAddMenu:(NSMenu*)menu fromModel:(ui::MenuModel*)model {
|
|
dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_MSEC),
|
|
dispatch_get_main_queue(), ^{
|
|
gfx::Rect bounds =
|
|
+#if !IS_MAS_BUILD()
|
|
gfx::ScreenRectFromNSRect(strongMenu._boundsIfOpen);
|
|
+#else
|
|
+ gfx::ScreenRectFromNSRect(NSMakeRect(0, 0, 0, 0));
|
|
+#endif
|
|
for (auto [elementId, index] : elementIds) {
|
|
ui::ElementTrackerMac::GetInstance()->NotifyMenuItemShown(
|
|
strongMenu, elementId, bounds);
|
|
diff --git a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
|
|
index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..149de0175c2ec0e41e3ba40caad7019ca87386d6 100644
|
|
--- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
|
|
@@ -4,6 +4,10 @@
|
|
|
|
#import "components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.h"
|
|
|
|
+#include "electron/mas.h"
|
|
+
|
|
+#if !IS_MAS_BUILD()
|
|
+
|
|
@interface NSWindow (PrivateAPI)
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
|
|
@end
|
|
@@ -18,8 +22,12 @@ - (CGFloat)_titlebarHeight {
|
|
}
|
|
@end
|
|
|
|
+#endif // MAS_BUILD
|
|
+
|
|
@implementation NativeWidgetMacFramelessNSWindow
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
+
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
|
|
if ([NativeWidgetMacFramelessNSWindowFrame class]) {
|
|
return [NativeWidgetMacFramelessNSWindowFrame class];
|
|
@@ -27,4 +35,6 @@ + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
|
|
return [super frameViewClassForStyleMask:windowStyle];
|
|
}
|
|
|
|
+#endif // MAS_BUILD
|
|
+
|
|
@end
|
|
diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
|
|
index 48f47bf3eeb8464d1c3925f0f73f62c790cac2f0..b7b2b7c1b7e99927012ce1676cc753b2bcdd887b 100644
|
|
--- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
|
|
@@ -10,6 +10,7 @@
|
|
#include "base/apple/foundation_util.h"
|
|
#import "components/remote_cocoa/app_shim/native_widget_mac_nswindow_headless.h"
|
|
#include "components/remote_cocoa/app_shim/remote_cocoa_app_shim_export.h"
|
|
+#include "electron/mas.h"
|
|
#import "ui/base/cocoa/command_dispatcher.h"
|
|
|
|
namespace remote_cocoa {
|
|
@@ -18,6 +19,7 @@ class NativeWidgetNSWindowBridge;
|
|
|
|
@protocol WindowTouchBarDelegate;
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// Weak lets Chrome launch even if a future macOS doesn't have the below classes
|
|
WEAK_IMPORT_ATTRIBUTE
|
|
@interface NSNextStepFrame : NSView
|
|
@@ -34,6 +36,7 @@ REMOTE_COCOA_APP_SHIM_EXPORT
|
|
REMOTE_COCOA_APP_SHIM_EXPORT
|
|
@interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame
|
|
@end
|
|
+#endif
|
|
|
|
// The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that
|
|
// can only be accomplished by overriding methods.
|
|
diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
|
|
index c5c652c6c67da33e9a2127cbbc35ec5fc535df6c..e58bb7368359e6ba13c249b8677a91e509313ce3 100644
|
|
--- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
|
|
@@ -23,6 +23,7 @@
|
|
#import "components/remote_cocoa/app_shim/views_nswindow_delegate.h"
|
|
#import "components/remote_cocoa/app_shim/window_touch_bar_delegate.h"
|
|
#include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
|
|
+#include "electron/mas.h"
|
|
#include "ui/accessibility/platform/ax_platform_node.h"
|
|
#import "ui/base/cocoa/default_command_dispatcher_delegate.h"
|
|
#import "ui/base/cocoa/user_interface_item_command_handler.h"
|
|
@@ -112,15 +113,17 @@ void OrderChildWindow(NSWindow* child_window,
|
|
|
|
} // namespace
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
@interface NSNextStepFrame (Private)
|
|
- (instancetype)initWithFrame:(NSRect)frame
|
|
styleMask:(NSUInteger)styleMask
|
|
owner:(id)owner;
|
|
@end
|
|
+#endif
|
|
|
|
@interface NSWindow (Private)
|
|
+#if !IS_MAS_BUILD()
|
|
+ (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
|
|
-- (BOOL)hasKeyAppearance;
|
|
- (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
|
|
- (BOOL)_isConsideredOpenForPersistentState;
|
|
- (void)_zoomToScreenEdge:(NSUInteger)edge;
|
|
@@ -131,6 +134,8 @@ - (void)_setFrame:(NSRect)frameRect
|
|
animate:(BOOL)animate;
|
|
- (void)_setFrameAfterMove:(NSRect)frameRect;
|
|
- (BOOL)_isNonactivatingPanel;
|
|
+#endif
|
|
+- (BOOL)hasKeyAppearance;
|
|
@end
|
|
|
|
struct NSEdgeAndCornerThicknesses {
|
|
@@ -175,13 +180,30 @@ - (void)cr_mouseDownOnFrameView:(NSEvent*)event;
|
|
@implementation NSView (CRFrameViewAdditions)
|
|
// If a mouseDown: falls through to the frame view, turn it into a window drag.
|
|
- (void)cr_mouseDownOnFrameView:(NSEvent*)event {
|
|
+#if !IS_MAS_BUILD()
|
|
if ([self.window _resizeDirectionForMouseLocation:event.locationInWindow] !=
|
|
-1)
|
|
return;
|
|
+#else
|
|
+ // For MAS builds, approximate the resize direction check.
|
|
+ if (self.window.styleMask & NSWindowStyleMaskResizable) {
|
|
+ constexpr CGFloat kResizeThreshold = 5.0;
|
|
+ NSPoint location = event.locationInWindow;
|
|
+ NSRect frame = self.window.frame;
|
|
+ CGFloat width = NSWidth(frame);
|
|
+ CGFloat height = NSHeight(frame);
|
|
+ if (location.x < kResizeThreshold || location.x > width - kResizeThreshold ||
|
|
+ location.y < kResizeThreshold || location.y > height - kResizeThreshold) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+#endif
|
|
[self.window performWindowDragWithEvent:event];
|
|
}
|
|
@end
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
+
|
|
@implementation NativeWidgetMacNSWindowTitledFrame
|
|
- (void)mouseDown:(NSEvent*)event {
|
|
if (self.window.movable) {
|
|
@@ -210,6 +232,8 @@ - (BOOL)usesCustomDrawing {
|
|
}
|
|
@end
|
|
|
|
+#endif // MAS_BUILD
|
|
+
|
|
@implementation NativeWidgetMacNSWindow {
|
|
@private
|
|
CommandDispatcher* __strong _commandDispatcher;
|
|
@@ -290,6 +314,7 @@ - (BOOL)invokeOriginalIsVisibleForTesting {
|
|
// bubbles and the find bar, but these should not be movable.
|
|
// Instead, let's push this up to the parent window which should be
|
|
// the browser.
|
|
+#if !IS_MAS_BUILD()
|
|
- (void)_zoomToScreenEdge:(NSUInteger)edge {
|
|
if (self.parentWindow) {
|
|
[self.parentWindow _zoomToScreenEdge:edge];
|
|
@@ -297,6 +322,7 @@ - (void)_zoomToScreenEdge:(NSUInteger)edge {
|
|
[super _zoomToScreenEdge:edge];
|
|
}
|
|
}
|
|
+#endif
|
|
|
|
// This override helps diagnose lifetime issues in crash stacktraces by
|
|
// inserting a symbol on NativeWidgetMacNSWindow and should be kept even if it
|
|
@@ -429,6 +455,8 @@ - (NSAccessibilityRole)accessibilityRole {
|
|
|
|
// NSWindow overrides.
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
+
|
|
+ (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
|
|
if (windowStyle & NSWindowStyleMaskTitled) {
|
|
if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
|
|
@@ -440,6 +468,8 @@ + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
|
|
return [super frameViewClassForStyleMask:windowStyle];
|
|
}
|
|
|
|
+#endif
|
|
+
|
|
// Constrains the frame rect during an active window move loop so that the top
|
|
// of the window does not exceed the menu bar / visible top of the display,
|
|
// while allowing smooth unrestricted dragging across display boundaries without
|
|
@@ -537,6 +567,8 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {
|
|
return [super constrainFrameRect:frameRect toScreen:screen];
|
|
}
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
+
|
|
// AppKit's internal screen layout manager invokes
|
|
// _setFrame:fromAdjustmentToScreen: and _setFrameAfterMove: asynchronously
|
|
// during screen layout changes or display boundary transitions to adjust the
|
|
@@ -585,6 +617,8 @@ - (void)_setFrameAfterMove:(NSRect)frameRect {
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
+
|
|
- (NSWindow*)topmostVisibleChildModalWindow {
|
|
if (!_bridge) {
|
|
return nil;
|
|
@@ -628,12 +662,14 @@ - (BOOL)_usesCustomDrawing {
|
|
// if it were valid to set that style for windows, setting the window style
|
|
// recalculates and re-caches a bunch of stuff, so a surgical override is the
|
|
// cleanest approach.
|
|
+#if !IS_MAS_BUILD()
|
|
- (BOOL)_isNonactivatingPanel {
|
|
if (_activationIndependence) {
|
|
return YES;
|
|
}
|
|
return [super _isNonactivatingPanel];
|
|
}
|
|
+#endif
|
|
|
|
+ (void)_getExteriorResizeEdgeThicknesses:
|
|
(NSEdgeAndCornerThicknesses*)outThicknesses
|
|
@@ -947,9 +983,11 @@ - (id)archiver:(NSKeyedArchiver*)archiver willEncodeObject:(id)object {
|
|
}
|
|
|
|
- (void)saveRestorableState {
|
|
+#if !IS_MAS_BUILD()
|
|
if (!_bridge || ![self _isConsideredOpenForPersistentState]) {
|
|
return;
|
|
}
|
|
+#endif
|
|
|
|
// Certain conditions, such as in the Speedometer 3 benchmark, can trigger a
|
|
// rapid succession of calls to saveRestorableState. If there's no pending
|
|
@@ -1016,6 +1054,7 @@ - (void)reallySaveRestorableState {
|
|
// affects its restorable state changes.
|
|
- (void)invalidateRestorableState {
|
|
[super invalidateRestorableState];
|
|
+#if !IS_MAS_BUILD()
|
|
if ([self _isConsideredOpenForPersistentState]) {
|
|
if (_willUpdateRestorableState)
|
|
return;
|
|
@@ -1028,6 +1067,7 @@ - (void)invalidateRestorableState {
|
|
_willUpdateRestorableState = NO;
|
|
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
}
|
|
+#endif
|
|
}
|
|
|
|
// On newer SDKs, _canMiniaturize respects NSWindowStyleMaskMiniaturizable in
|
|
@@ -1206,6 +1246,7 @@ - (void)maybeRemoveTreeFromOrderingGroups {
|
|
// Since _removeFromGroups: is not documented it could go away in newer
|
|
// versions of macOS. If the selector does not exist, DumpWithoutCrashing() so
|
|
// we hear about the change.
|
|
+#if !IS_MAS_BUILD()
|
|
if (![NSWindow instancesRespondToSelector:@selector(_removeFromGroups:)]) {
|
|
base::debug::DumpWithoutCrashing();
|
|
return;
|
|
@@ -1223,6 +1264,7 @@ - (void)maybeRemoveTreeFromOrderingGroups {
|
|
[currentWindow _removeFromGroups:child];
|
|
}
|
|
}
|
|
+#endif
|
|
}
|
|
|
|
- (NSWindow*)rootWindow {
|
|
diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
|
index 5abdca1cb441d306b5dbea7d7bf7e1400ce3a14d..d2235a096f5ea7b5c3ecdc84af9b10a839615347 100644
|
|
--- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
|
@@ -42,6 +42,7 @@
|
|
#import "components/remote_cocoa/app_shim/views_nswindow_delegate.h"
|
|
#import "components/remote_cocoa/app_shim/window_move_loop.h"
|
|
#include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
|
|
+#include "electron/mas.h"
|
|
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
|
#include "net/cert/x509_util_apple.h"
|
|
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
|
|
@@ -78,10 +79,13 @@
|
|
using CGRegionRef = CFTypeRef;
|
|
|
|
CG_EXTERN CGSConnectionID CGSMainConnectionID(void);
|
|
+
|
|
+#if !IS_MAS_BUILD()
|
|
CG_EXTERN CGError CGSSetWindowCaptureExcludeShape(CGSConnectionID cid,
|
|
CGSWindowID wid,
|
|
CGRegionRef region);
|
|
CG_EXTERN CGRegionRef CGRegionCreateWithRect(CGRect rect);
|
|
+#endif
|
|
|
|
namespace remote_cocoa {
|
|
|
|
@@ -94,6 +98,7 @@ CG_EXTERN CGError CGSSetWindowCaptureExcludeShape(CGSConnectionID cid,
|
|
constexpr auto kUIPaintTimeout = base::Milliseconds(500);
|
|
|
|
void ApplyCaptureExclusion(NSWindow* window, bool allow) {
|
|
+#if !IS_MAS_BUILD()
|
|
CGSConnectionID connection_id = CGSMainConnectionID();
|
|
CGSWindowID window_id = window.windowNumber;
|
|
CGRect frame = window.frame;
|
|
@@ -103,6 +108,9 @@ void ApplyCaptureExclusion(NSWindow* window, bool allow) {
|
|
region.reset(CGRegionCreateWithRect(frame));
|
|
}
|
|
CGSSetWindowCaptureExcludeShape(connection_id, window_id, region.get());
|
|
+#else
|
|
+ [window setSharingType:allow ? NSWindowSharingReadOnly : NSWindowSharingNone];
|
|
+#endif
|
|
}
|
|
|
|
// Returns the display that the specified window is on.
|
|
@@ -822,10 +830,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
|
|
// this should be treated as an error and caught early.
|
|
CHECK(bridged_view_);
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// Send the accessibility tokens for the NSView now that it exists.
|
|
host_->SetRemoteAccessibilityTokens(
|
|
ui::RemoteAccessibility::GetTokenForLocalElement(window_),
|
|
ui::RemoteAccessibility::GetTokenForLocalElement(bridged_view_));
|
|
+#endif
|
|
|
|
// Beware: This view was briefly removed (in favor of a bare CALayer) in
|
|
// https://crrev.com/c/1236675. The ordering of unassociated layers relative
|
|
diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn
|
|
index f26d694210e94f500c8dab69eb362f52336baf07..80c201e6f239f713491bf51303455909a93de3f5 100644
|
|
--- a/components/viz/service/BUILD.gn
|
|
+++ b/components/viz/service/BUILD.gn
|
|
@@ -388,6 +388,7 @@ viz_component("service") {
|
|
"frame_sinks/external_begin_frame_source_mojo_mac.h",
|
|
]
|
|
}
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
if (is_ios) {
|
|
@@ -748,6 +749,7 @@ viz_source_set("unit_tests") {
|
|
"frame_sinks/external_begin_frame_source_mac_unittest.cc",
|
|
]
|
|
frameworks = [ "IOSurface.framework" ]
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
if (is_win) {
|
|
diff --git a/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm b/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
|
|
index 010c713090e5038dc90db131c8f621422d30c03b..20c35e887a0496ee609c077e3b0494bdded41dba 100644
|
|
--- a/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
|
|
+++ b/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
|
|
@@ -15,6 +15,7 @@
|
|
#include "content/common/web_contents_ns_view_bridge.mojom.h"
|
|
#include "content/public/browser/remote_cocoa.h"
|
|
#include "content/public/browser/render_widget_host_view_mac_delegate.h"
|
|
+#include "electron/mas.h"
|
|
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
|
#include "mojo/public/cpp/bindings/associated_remote.h"
|
|
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
|
|
@@ -63,7 +64,9 @@ explicit RenderWidgetHostNSViewBridgeOwner(
|
|
const RenderWidgetHostNSViewBridgeOwner&) = delete;
|
|
|
|
private:
|
|
+#if !IS_MAS_BUILD()
|
|
NSAccessibilityRemoteUIElement* __strong remote_accessibility_element_;
|
|
+#endif
|
|
void OnMojoDisconnect() { delete this; }
|
|
|
|
std::unique_ptr<blink::WebCoalescedInputEvent> TranslateEvent(
|
|
@@ -75,6 +78,7 @@ explicit RenderWidgetHostNSViewBridgeOwner(
|
|
}
|
|
|
|
id GetAccessibilityElement() override {
|
|
+#if !IS_MAS_BUILD()
|
|
if (!remote_accessibility_element_) {
|
|
base::ProcessId browser_pid = base::kNullProcessId;
|
|
std::vector<uint8_t> element_token;
|
|
@@ -85,6 +89,9 @@ id GetAccessibilityElement() override {
|
|
ui::RemoteAccessibility::GetRemoteElementFromToken(element_token);
|
|
}
|
|
return remote_accessibility_element_;
|
|
+#else
|
|
+ return nil;
|
|
+#endif
|
|
}
|
|
|
|
// RenderWidgetHostNSViewHostHelper implementation.
|
|
@@ -103,8 +110,10 @@ id GetFocusedBrowserAccessibilityElement() override {
|
|
return [bridgedContentView accessibilityFocusedUIElement];
|
|
}
|
|
void SetAccessibilityWindow(NSWindow* window) override {
|
|
+#if !IS_MAS_BUILD()
|
|
host_->SetRemoteAccessibilityWindowToken(
|
|
ui::RemoteAccessibility::GetTokenForLocalElement(window));
|
|
+#endif
|
|
}
|
|
|
|
void ForwardKeyboardEvent(const input::NativeWebKeyboardEvent& key_event,
|
|
diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
|
|
index 45e8631ea6e5497edb90b91223d962abe3071849..dbd8cbc192931ee7821f7e76923c6cb260bddb61 100644
|
|
--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
|
|
+++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
|
|
@@ -35,6 +35,7 @@
|
|
#import "content/public/browser/render_widget_host_view_mac_delegate.h"
|
|
#include "content/public/browser/scoped_accessibility_mode.h"
|
|
#include "content/public/common/content_features.h"
|
|
+#include "electron/mas.h"
|
|
#include "skia/ext/skia_utils_mac.h"
|
|
#include "third_party/blink/public/common/features.h"
|
|
#include "third_party/blink/public/mojom/input/input_handler.mojom.h"
|
|
@@ -2501,15 +2502,21 @@ - (NSAccessibilityRole)accessibilityRole {
|
|
// Since this implementation doesn't have to wait any IPC calls, this doesn't
|
|
// make any key-typing jank. --hbono 7/23/09
|
|
//
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
extern NSString* NSTextInputReplacementRangeAttributeName;
|
|
}
|
|
+#endif
|
|
|
|
- (NSArray*)validAttributesForMarkedText {
|
|
// This code is just copied from WebKit except renaming variables.
|
|
static NSArray* const kAttributes = @[
|
|
NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
|
|
+#if !IS_MAS_BUILD()
|
|
NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName
|
|
+#else
|
|
+ NSMarkedClauseSegmentAttributeName
|
|
+#endif
|
|
];
|
|
return kAttributes;
|
|
}
|
|
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
|
|
index 4e929a8d7ce90f7bc4aa9205fd676e27b4d659c9..2402a6091de68d5e37c5ec1039eeb2b4055c6976 100644
|
|
--- a/content/browser/BUILD.gn
|
|
+++ b/content/browser/BUILD.gn
|
|
@@ -384,6 +384,7 @@ source_set("browser") {
|
|
"//ui/webui/resources",
|
|
"//v8",
|
|
"//v8:v8_version",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
|
|
public_deps = [
|
|
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h
|
|
index 4fcbaac7dc34f51a6f3d8754d5a5f84042649451..3fcb1eedfa9ba7d5063972f11807bbf18552ab48 100644
|
|
--- a/content/browser/renderer_host/render_widget_host_view_mac.h
|
|
+++ b/content/browser/renderer_host/render_widget_host_view_mac.h
|
|
@@ -26,6 +26,7 @@
|
|
#include "content/browser/renderer_host/text_input_manager.h"
|
|
#include "content/common/content_export.h"
|
|
#include "content/common/render_widget_host_ns_view.mojom.h"
|
|
+#include "electron/mas.h"
|
|
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
|
#include "mojo/public/cpp/bindings/associated_remote.h"
|
|
#include "third_party/blink/public/common/page/content_to_visible_time_request.h"
|
|
@@ -58,7 +59,9 @@ class CursorManager;
|
|
|
|
@protocol RenderWidgetHostViewMacDelegate;
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
@class NSAccessibilityRemoteUIElement;
|
|
+#endif
|
|
@class RenderWidgetHostViewCocoa;
|
|
|
|
namespace content {
|
|
@@ -728,9 +731,11 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
|
|
bool pointer_lock_unadjusted_movement_ = false;
|
|
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// Remote accessibility objects corresponding to the NSWindow that this is
|
|
// displayed to the user in.
|
|
NSAccessibilityRemoteUIElement* __strong remote_window_accessible_;
|
|
+#endif
|
|
|
|
ui::AXTreeID parent_ax_tree_id_ = ui::AXTreeIDUnknown();
|
|
|
|
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
|
|
index 10d8a0e16d6bd7e603eddabfd3f053f44d43d7a1..23b8154e7695d2fb4efbd777de6e84f2ad5d614e 100644
|
|
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
|
|
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
|
|
@@ -58,6 +58,7 @@
|
|
#include "content/public/browser/render_widget_host.h"
|
|
#include "content/public/browser/web_contents.h"
|
|
#include "content/public/common/page_visibility_state.h"
|
|
+#include "electron/mas.h"
|
|
#include "media/base/media_switches.h"
|
|
#include "skia/ext/platform_canvas.h"
|
|
#include "skia/ext/skia_utils_mac.h"
|
|
@@ -317,8 +318,10 @@ void SendVisibleTimeRequestToDelegatedFrameHost(
|
|
void RenderWidgetHostViewMac::MigrateNSViewBridge(
|
|
remote_cocoa::mojom::Application* remote_cocoa_application,
|
|
uint64_t parent_ns_view_id) {
|
|
+#if !IS_MAS_BUILD()
|
|
// Destroy the previous remote accessibility element.
|
|
remote_window_accessible_ = nil;
|
|
+#endif
|
|
|
|
// Reset `ns_view_` before resetting `remote_ns_view_` to avoid dangling
|
|
// pointers. `ns_view_` gets reinitialized later in this method.
|
|
@@ -1897,10 +1900,12 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
|
|
|
|
gfx::NativeViewAccessible
|
|
RenderWidgetHostViewMac::AccessibilityGetNativeViewAccessibleForWindow() {
|
|
+#if !IS_MAS_BUILD()
|
|
if (remote_window_accessible_) {
|
|
return gfx::NativeViewAccessible(
|
|
(id<NSAccessibility>)remote_window_accessible_);
|
|
}
|
|
+#endif
|
|
return gfx::NativeViewAccessible([GetInProcessNSView() window]);
|
|
}
|
|
|
|
@@ -1975,9 +1980,11 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
|
|
}
|
|
|
|
void RenderWidgetHostViewMac::SetAccessibilityWindow(NSWindow* window) {
|
|
+#if !IS_MAS_BUILD()
|
|
// When running in-process, just use the NSView's NSWindow as its own
|
|
// accessibility element.
|
|
remote_window_accessible_ = nil;
|
|
+#endif
|
|
}
|
|
|
|
bool RenderWidgetHostViewMac::SyncIsWidgetForMainFrame(
|
|
@@ -2550,20 +2557,26 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
|
|
void RenderWidgetHostViewMac::GetRenderWidgetAccessibilityToken(
|
|
GetRenderWidgetAccessibilityTokenCallback callback) {
|
|
base::ProcessId pid = getpid();
|
|
+#if !IS_MAS_BUILD()
|
|
id element_id = GetNativeViewAccessible().Get();
|
|
std::vector<uint8_t> token =
|
|
ui::RemoteAccessibility::GetTokenForLocalElement(element_id);
|
|
std::move(callback).Run(pid, token);
|
|
+#else
|
|
+ std::move(callback).Run(pid, std::vector<uint8_t>());
|
|
+#endif
|
|
}
|
|
|
|
void RenderWidgetHostViewMac::SetRemoteAccessibilityWindowToken(
|
|
const std::vector<uint8_t>& window_token) {
|
|
+#if !IS_MAS_BUILD()
|
|
if (window_token.empty()) {
|
|
remote_window_accessible_ = nil;
|
|
} else {
|
|
remote_window_accessible_ =
|
|
ui::RemoteAccessibility::GetRemoteElementFromToken(window_token);
|
|
}
|
|
+#endif
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn
|
|
index e41489d4c98fbf96f9bfadfb78c5b0b0f5a5d841..1a6298d187d6245370d7c29c419617a8c401c5d0 100644
|
|
--- a/content/common/BUILD.gn
|
|
+++ b/content/common/BUILD.gn
|
|
@@ -279,6 +279,7 @@ source_set("common") {
|
|
"//ui/shell_dialogs",
|
|
"//url",
|
|
"//url/ipc:url_ipc",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
|
|
defines = []
|
|
diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn
|
|
index cf78814644054c5557ba7d4192384531c56143d3..e91c3a6f5109349cf9c26a3da1d06dbbdfb8402b 100644
|
|
--- a/content/renderer/BUILD.gn
|
|
+++ b/content/renderer/BUILD.gn
|
|
@@ -321,6 +321,7 @@ target(link_target_type, "renderer") {
|
|
"//ui/strings:auto_image_annotation_strings_grit",
|
|
"//url",
|
|
"//v8",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
|
|
if (is_android) {
|
|
diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm
|
|
index d4db3b179725cb96bcbd0f73db7d52ef8b7522db..703b0f56a61abac51961bfd918b7349b943900de 100644
|
|
--- a/content/renderer/renderer_main_platform_delegate_mac.mm
|
|
+++ b/content/renderer/renderer_main_platform_delegate_mac.mm
|
|
@@ -7,12 +7,15 @@
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#include "base/check_op.h"
|
|
+#include "electron/mas.h"
|
|
#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 +25,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 +34,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 a1068589ad844518038ee7bc15a3de9bc5cba525..1ff781c49f086ec8015c7d3c44567dbec3d00ff8 100644
|
|
--- a/content/renderer/theme_helper_mac.mm
|
|
+++ b/content/renderer/theme_helper_mac.mm
|
|
@@ -7,16 +7,28 @@
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
#include "base/strings/sys_string_conversions.h"
|
|
+#include "electron/mas.h"
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
bool CGFontRenderingGetFontSmoothingDisabled(void);
|
|
}
|
|
-
|
|
+#endif
|
|
namespace content {
|
|
|
|
bool IsSubpixelAntialiasingAvailable() {
|
|
+#if !IS_MAS_BUILD()
|
|
// See https://trac.webkit.org/changeset/239306/webkit for more info.
|
|
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
|
|
}
|
|
|
|
} // namespace content
|
|
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
|
|
index 55748f1d95405ecdb2fd730791cd063621f12872..0ac18717077395f3698f1d4b0a2bca4c2554874d 100644
|
|
--- a/content/test/BUILD.gn
|
|
+++ b/content/test/BUILD.gn
|
|
@@ -649,6 +649,7 @@ static_library("test_support") {
|
|
"//url",
|
|
"//url/mojom:url_mojom_gurl",
|
|
"//v8",
|
|
+ "//electron/build/config:generate_mas_config"
|
|
]
|
|
|
|
data_deps = [
|
|
@@ -1133,6 +1134,8 @@ static_library("browsertest_support") {
|
|
}
|
|
|
|
configs += [ "//v8:external_startup_data" ]
|
|
+
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
mojom("content_test_mojo_bindings") {
|
|
@@ -2058,6 +2061,7 @@ test("content_browsertests") {
|
|
"//ui/shell_dialogs",
|
|
"//ui/snapshot",
|
|
"//ui/webui:test_support",
|
|
+ "//electron/build/config:generate_mas_config"
|
|
]
|
|
|
|
if (!(is_chromeos && target_cpu == "arm64" && current_cpu == "arm")) {
|
|
@@ -3446,6 +3450,7 @@ test("content_unittests") {
|
|
"//ui/shell_dialogs",
|
|
"//ui/webui:test_support",
|
|
"//url",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
|
|
if (is_chromeos) {
|
|
diff --git a/content/web_test/BUILD.gn b/content/web_test/BUILD.gn
|
|
index 3899c88b9b44a0a81b018d183bc2cebd89c9b63c..134ec2948f521414fa5cd78f35c5d4a8ac4bf5a4 100644
|
|
--- a/content/web_test/BUILD.gn
|
|
+++ b/content/web_test/BUILD.gn
|
|
@@ -219,6 +219,7 @@ static_library("web_test_browser") {
|
|
"//ui/gl",
|
|
"//ui/shell_dialogs",
|
|
"//url",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
|
|
if (is_mac) {
|
|
diff --git a/device/bluetooth/BUILD.gn b/device/bluetooth/BUILD.gn
|
|
index 9e1af8c4ed42041d88a94277691cab2dd20f149f..8e8e00b960fd1359f63479edde6d64890e25bfd7 100644
|
|
--- a/device/bluetooth/BUILD.gn
|
|
+++ b/device/bluetooth/BUILD.gn
|
|
@@ -255,6 +255,7 @@ component("bluetooth") {
|
|
"CoreBluetooth.framework",
|
|
"Foundation.framework",
|
|
]
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
if (is_mac) {
|
|
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
|
|
index 8940cda1ea6211df84da098078a1f90c66666013..335e42c54e5d6a9f591065519443e99c8bc49b91 100644
|
|
--- a/device/bluetooth/bluetooth_adapter_mac.mm
|
|
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
|
|
@@ -40,7 +40,9 @@
|
|
#include "device/bluetooth/bluetooth_discovery_session_outcome.h"
|
|
#include "device/bluetooth/bluetooth_socket_mac.h"
|
|
#include "device/bluetooth/public/cpp/bluetooth_address.h"
|
|
+#include "electron/mas.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
|
|
@@ -54,6 +56,7 @@
|
|
// [4] https://support.apple.com/kb/PH25091
|
|
void IOBluetoothPreferenceSetControllerPowerState(int state);
|
|
}
|
|
+#endif
|
|
|
|
namespace device {
|
|
class BluetoothDevicesConnectListenerBridge;
|
|
@@ -237,8 +240,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
|
|
device_paired_status_callback_(
|
|
base::BindRepeating(&IsDeviceSystemPaired)) {
|
|
}
|
|
@@ -399,8 +404,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
|
|
}
|
|
|
|
base::WeakPtr<BluetoothLowEnergyAdapterApple>
|
|
diff --git a/gpu/ipc/service/BUILD.gn b/gpu/ipc/service/BUILD.gn
|
|
index 86a6d2345caae8300b7494bc02e226d4bd6dbd0b..661c23091fb8e7cc554072f80d4815e9628ac1e7 100644
|
|
--- a/gpu/ipc/service/BUILD.gn
|
|
+++ b/gpu/ipc/service/BUILD.gn
|
|
@@ -136,6 +136,7 @@ component("service") {
|
|
"QuartzCore.framework",
|
|
]
|
|
defines += [ "GL_SILENCE_DEPRECATION" ]
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
if (is_ios) {
|
|
sources += [ "image_transport_surface_ios.mm" ]
|
|
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
|
index 6ea6c1130663f04ee766750dde257f3cc701a5b0..355930d10267b8c2c95c320c6d154080bb15079f 100644
|
|
--- a/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
|
+++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
|
@@ -8,6 +8,7 @@
|
|
#include <vector>
|
|
|
|
#include "base/memory/weak_ptr.h"
|
|
+#include "electron/mas.h"
|
|
#include "gpu/ipc/service/command_buffer_stub.h"
|
|
#include "gpu/ipc/service/image_transport_surface.h"
|
|
#include "ui/gfx/ca_layer_result.h"
|
|
@@ -27,7 +28,9 @@
|
|
#include <BrowserEngineKit/BrowserEngineKit.h>
|
|
#endif
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
@class CAContext;
|
|
+#endif
|
|
@class CALayer;
|
|
|
|
namespace ui {
|
|
diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn
|
|
index 8667a1ba4f71a57f61915bb2588a338e5960a952..099a65446d90b10b021ac47d1c4e26b179e8e40b 100644
|
|
--- a/media/audio/BUILD.gn
|
|
+++ b/media/audio/BUILD.gn
|
|
@@ -198,6 +198,7 @@ source_set("audio") {
|
|
"CoreMedia.framework",
|
|
"ScreenCaptureKit.framework",
|
|
]
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
if (is_ios) {
|
|
diff --git a/media/audio/apple/audio_low_latency_input.cc b/media/audio/apple/audio_low_latency_input.cc
|
|
index d9014423b00c31677765e5eede59b79576451fdc..239fbc68ac6ada16dce7c7b1bac74df40f3a15e9 100644
|
|
--- a/media/audio/apple/audio_low_latency_input.cc
|
|
+++ b/media/audio/apple/audio_low_latency_input.cc
|
|
@@ -28,6 +28,7 @@
|
|
#include "base/strings/sys_string_conversions.h"
|
|
#include "base/time/time.h"
|
|
#include "base/trace_event/trace_event.h"
|
|
+#include "electron/mas.h"
|
|
#include "media/audio/apple/audio_manager_apple.h"
|
|
#include "media/audio/apple/scoped_audio_unit.h"
|
|
#include "media/base/audio_bus.h"
|
|
@@ -41,19 +42,23 @@
|
|
|
|
namespace {
|
|
extern "C" {
|
|
+#if !IS_MAS_BUILD()
|
|
// See:
|
|
// https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/PAL/pal/spi/cf/CoreAudioSPI.h?rev=228264
|
|
OSStatus AudioDeviceDuck(AudioDeviceID inDevice,
|
|
Float32 inDuckedLevel,
|
|
const AudioTimeStamp* __nullable inStartTime,
|
|
Float32 inRampDuration) __attribute__((weak_import));
|
|
+#endif
|
|
}
|
|
|
|
void UndoDucking(AudioDeviceID output_device_id) {
|
|
+#if !IS_MAS_BUILD()
|
|
if (AudioDeviceDuck != nullptr) {
|
|
// Ramp the volume back up over half a second.
|
|
AudioDeviceDuck(output_device_id, 1.0, nullptr, 0.5);
|
|
}
|
|
+#endif
|
|
}
|
|
} // namespace
|
|
#endif
|
|
diff --git a/net/dns/BUILD.gn b/net/dns/BUILD.gn
|
|
index 5f416202e142225d8a4361ac47cb2288ee4c537f..8221b0c60770c878a8ce9975ef0e89bb4242307e 100644
|
|
--- a/net/dns/BUILD.gn
|
|
+++ b/net/dns/BUILD.gn
|
|
@@ -224,6 +224,8 @@ source_set("dns") {
|
|
":host_resolver_manager",
|
|
":mdns_client",
|
|
]
|
|
+
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
# The standard API of net/dns.
|
|
diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
|
|
index a62aab2e51a66ce3f12d7755ddb6c4fd95274ffa..48534345166ebe5fd53b5eba4aeef132191e76c4 100644
|
|
--- a/net/dns/dns_config_service_posix.cc
|
|
+++ b/net/dns/dns_config_service_posix.cc
|
|
@@ -25,6 +25,7 @@
|
|
#include "base/threading/scoped_blocking_call.h"
|
|
#include "base/time/time.h"
|
|
#include "build/build_config.h"
|
|
+#include "electron/mas.h"
|
|
#include "net/base/ip_endpoint.h"
|
|
#include "net/dns/dns_config.h"
|
|
#include "net/dns/dns_hosts.h"
|
|
@@ -132,8 +133,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.";
|
|
@@ -150,6 +151,7 @@ class DnsConfigServicePosix::Watcher : public DnsConfigService::Watcher {
|
|
success = false;
|
|
}
|
|
#endif // !BUILDFLAG(IS_IOS)
|
|
+#endif
|
|
return success;
|
|
}
|
|
|
|
diff --git a/sandbox/mac/BUILD.gn b/sandbox/mac/BUILD.gn
|
|
index df81a017297f8c5a9e2f9a29c272af7e3936bc84..99c1b632c8a9d93d56f307e437a47c18eaea434d 100644
|
|
--- a/sandbox/mac/BUILD.gn
|
|
+++ b/sandbox/mac/BUILD.gn
|
|
@@ -28,6 +28,7 @@ component("seatbelt") {
|
|
"//base:compiler_specific",
|
|
]
|
|
defines = [ "SEATBELT_IMPLEMENTATION" ]
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
component("seatbelt_extension") {
|
|
@@ -41,6 +42,7 @@ component("seatbelt_extension") {
|
|
libs = [ "sandbox" ]
|
|
public_deps = [ "//base" ]
|
|
defines = [ "SEATBELT_IMPLEMENTATION" ]
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
component("system_services") {
|
|
@@ -55,6 +57,7 @@ component("system_services") {
|
|
deps = [ ":seatbelt_export" ]
|
|
public_deps = [ "//base" ]
|
|
defines = [ "SEATBELT_IMPLEMENTATION" ]
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
source_set("sandbox_unittests") {
|
|
diff --git a/sandbox/mac/sandbox_logging.cc b/sandbox/mac/sandbox_logging.cc
|
|
index a243eba4fead115a34165cff3a1ebf37e2248f19..8e4c119d5551747605272681b68968adbcabfeec 100644
|
|
--- a/sandbox/mac/sandbox_logging.cc
|
|
+++ b/sandbox/mac/sandbox_logging.cc
|
|
@@ -17,6 +17,7 @@
|
|
|
|
#include "base/compiler_specific.h"
|
|
#include "build/build_config.h"
|
|
+#include "electron/mas.h"
|
|
#include "sandbox/mac/sandbox_crash_message.h"
|
|
|
|
#if defined(ARCH_CPU_X86_64)
|
|
@@ -34,9 +35,11 @@
|
|
}
|
|
#endif
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
void abort_report_np(const char*, ...);
|
|
}
|
|
+#endif
|
|
|
|
namespace sandbox::logging {
|
|
|
|
@@ -78,7 +81,12 @@ void SendOsLog(Level level, const char* message) {
|
|
}
|
|
|
|
if (level == Level::FATAL) {
|
|
+#if !IS_MAS_BUILD()
|
|
abort_report_np(message);
|
|
+#else
|
|
+ UNSAFE_TODO(os_log_fault(OS_LOG_DEFAULT, "%s", message));
|
|
+ abort();
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
diff --git a/sandbox/mac/sandbox_serializer.cc b/sandbox/mac/sandbox_serializer.cc
|
|
index 0e6e650f88e6aadd46bec96a8b41768c37d7cc6a..a6830e3f886e408c254ccd1c2b1d5c15cd3bcb92 100644
|
|
--- a/sandbox/mac/sandbox_serializer.cc
|
|
+++ b/sandbox/mac/sandbox_serializer.cc
|
|
@@ -8,6 +8,7 @@
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
+#include "electron/mas.h"
|
|
#include "sandbox/mac/sandbox_logging.h"
|
|
#include "sandbox/mac/seatbelt.h"
|
|
|
|
@@ -193,6 +194,7 @@ SandboxSerializer::DeserializePolicy(const std::string& serialized_policy,
|
|
// static
|
|
bool SandboxSerializer::ApplySerializedPolicy(
|
|
const std::string& serialized_policy) {
|
|
+#if !IS_MAS_BUILD()
|
|
std::string error;
|
|
std::optional<DeserializedPolicy> deserialized_policy =
|
|
DeserializePolicy(serialized_policy, error);
|
|
@@ -223,6 +225,9 @@ bool SandboxSerializer::ApplySerializedPolicy(
|
|
break;
|
|
}
|
|
return true;
|
|
+#else
|
|
+ return true;
|
|
+#endif
|
|
}
|
|
|
|
} // namespace sandbox
|
|
diff --git a/sandbox/mac/seatbelt.cc b/sandbox/mac/seatbelt.cc
|
|
index 0ecb609e920cfd819e9ecd7a1ae6ddfcea060b1e..1d83c1db5f582993f51107de823c8958bf6e6c4d 100644
|
|
--- a/sandbox/mac/seatbelt.cc
|
|
+++ b/sandbox/mac/seatbelt.cc
|
|
@@ -4,6 +4,8 @@
|
|
|
|
#include "sandbox/mac/seatbelt.h"
|
|
|
|
+#include "electron/mas.h"
|
|
+
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
|
|
@@ -12,7 +14,7 @@
|
|
|
|
extern "C" {
|
|
#include <sandbox.h>
|
|
-
|
|
+#if !IS_MAS_BUILD()
|
|
int sandbox_init_with_parameters(const char* profile,
|
|
uint64_t flags,
|
|
const char* const parameters[],
|
|
@@ -58,13 +60,14 @@ sandbox_profile_t* sandbox_compile_string(const char* data,
|
|
char** error);
|
|
int sandbox_apply(sandbox_profile_t*);
|
|
void sandbox_free_profile(sandbox_profile_t*);
|
|
-
|
|
+#endif
|
|
} // extern "C"
|
|
|
|
namespace sandbox {
|
|
|
|
namespace {
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// `managed_errorbuf` uses a unique_ptr with a deleter to ensure that memory is
|
|
// freed using the sandbox library's deallocation function to prevent unexpected
|
|
// behavior.
|
|
@@ -107,40 +110,53 @@ bool HandleSandboxErrno(int rv, const char* message, std::string* error) {
|
|
}
|
|
return false;
|
|
}
|
|
-
|
|
+#endif
|
|
} // namespace
|
|
|
|
// static
|
|
Seatbelt::Parameters Seatbelt::Parameters::Create() {
|
|
Parameters params;
|
|
+#if !IS_MAS_BUILD()
|
|
params.params_ = ::sandbox_create_params();
|
|
+#endif
|
|
return params;
|
|
}
|
|
|
|
Seatbelt::Parameters::Parameters() = default;
|
|
|
|
Seatbelt::Parameters::Parameters(Seatbelt::Parameters&& other) {
|
|
+#if !IS_MAS_BUILD()
|
|
params_ = std::exchange(other.params_, nullptr);
|
|
+#endif
|
|
}
|
|
|
|
Seatbelt::Parameters& Seatbelt::Parameters::operator=(
|
|
Seatbelt::Parameters&& other) {
|
|
+#if !IS_MAS_BUILD()
|
|
params_ = std::exchange(other.params_, nullptr);
|
|
+#endif
|
|
return *this;
|
|
}
|
|
|
|
bool Seatbelt::Parameters::Set(const char* key, const char* value) {
|
|
+#if !IS_MAS_BUILD()
|
|
return ::sandbox_set_param(params_, key, value) == 0;
|
|
+#else
|
|
+ return true;
|
|
+#endif
|
|
}
|
|
|
|
Seatbelt::Parameters::~Parameters() {
|
|
+#if !IS_MAS_BUILD()
|
|
if (params_) {
|
|
::sandbox_free_params(params_);
|
|
}
|
|
+#endif
|
|
}
|
|
|
|
// static
|
|
bool Seatbelt::Init(const char* profile, uint64_t flags, std::string* error) {
|
|
+#if !IS_MAS_BUILD()
|
|
// OS X deprecated these functions, but did not provide a suitable replacement,
|
|
// so ignore the deprecation warning.
|
|
#pragma clang diagnostic push
|
|
@@ -150,6 +166,9 @@ bool Seatbelt::Init(const char* profile, uint64_t flags, std::string* error) {
|
|
return HandleSandboxResult(
|
|
rv, std::unique_ptr<char, sandbox_error_deleter>(errorbuf), error);
|
|
#pragma clang diagnostic pop
|
|
+#else
|
|
+ return true;
|
|
+#endif
|
|
}
|
|
|
|
// static
|
|
@@ -157,17 +176,22 @@ bool Seatbelt::InitWithParams(const std::string& profile,
|
|
uint64_t flags,
|
|
const std::vector<std::string>& parameters,
|
|
std::string* error) {
|
|
+#if !IS_MAS_BUILD()
|
|
std::vector<const char*> weak_params;
|
|
for (const std::string& param : parameters) {
|
|
weak_params.push_back(param.c_str());
|
|
}
|
|
// The parameters array must be null terminated.
|
|
weak_params.push_back(nullptr);
|
|
+
|
|
char* errorbuf = nullptr;
|
|
int rv = ::sandbox_init_with_parameters(profile.c_str(), flags,
|
|
weak_params.data(), &errorbuf);
|
|
return HandleSandboxResult(
|
|
rv, std::unique_ptr<char, sandbox_error_deleter>(errorbuf), error);
|
|
+#else
|
|
+ return true;
|
|
+#endif
|
|
}
|
|
|
|
// static
|
|
@@ -175,6 +199,7 @@ bool Seatbelt::Compile(const char* profile,
|
|
const Seatbelt::Parameters& params,
|
|
std::string& compiled_profile,
|
|
std::string* error) {
|
|
+#if !IS_MAS_BUILD()
|
|
char* errorbuf = nullptr;
|
|
sandbox_profile_t* sandbox_profile =
|
|
::sandbox_compile_string(profile, params.params(), &errorbuf);
|
|
@@ -186,23 +211,32 @@ bool Seatbelt::Compile(const char* profile,
|
|
compiled_profile.assign(reinterpret_cast<const char*>(sandbox_profile->data),
|
|
sandbox_profile->size);
|
|
::sandbox_free_profile(sandbox_profile);
|
|
+#endif
|
|
return true;
|
|
}
|
|
|
|
// static
|
|
bool Seatbelt::ApplyCompiledProfile(const std::string& profile,
|
|
std::string* error) {
|
|
+#if !IS_MAS_BUILD()
|
|
sandbox_profile_t sbox_profile = {
|
|
.builtin = nullptr,
|
|
.data = reinterpret_cast<const uint8_t*>(profile.data()),
|
|
.size = profile.size()};
|
|
return HandleSandboxErrno(::sandbox_apply(&sbox_profile),
|
|
"sandbox_apply: ", error);
|
|
+#else
|
|
+ return true;
|
|
+#endif
|
|
}
|
|
|
|
// 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 79edca9ca521d1bc2ff343967348eb98039b292a..23f9410ee66024e2c6b0b6b2b356a67b0ae2eba7 100644
|
|
--- a/sandbox/mac/seatbelt_extension.cc
|
|
+++ b/sandbox/mac/seatbelt_extension.cc
|
|
@@ -9,8 +9,10 @@
|
|
#include "base/check.h"
|
|
#include "base/memory/ptr_util.h"
|
|
#include "base/notreached.h"
|
|
+#include "electron/mas.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 +24,7 @@ char* sandbox_extension_issue_file(const char* type,
|
|
const char* path,
|
|
uint32_t flags);
|
|
}
|
|
+#endif
|
|
|
|
namespace sandbox {
|
|
|
|
@@ -50,7 +53,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 +69,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 +91,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();
|
|
}
|
|
diff --git a/sandbox/mac/system_services.cc b/sandbox/mac/system_services.cc
|
|
index eb81a70e4d5d5cd3e6ae9b45f8cd1c795ea76c51..9921ccb10d3455600eddd85f77f10228016389af 100644
|
|
--- a/sandbox/mac/system_services.cc
|
|
+++ b/sandbox/mac/system_services.cc
|
|
@@ -8,7 +8,9 @@
|
|
#include <CoreFoundation/CoreFoundation.h>
|
|
|
|
#include "base/apple/osstatus_logging.h"
|
|
+#include "electron/mas.h"
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
OSStatus SetApplicationIsDaemon(Boolean isDaemon);
|
|
void _LSSetApplicationLaunchServicesServerConnectionStatus(
|
|
@@ -19,10 +21,12 @@ void _LSSetApplicationLaunchServicesServerConnectionStatus(
|
|
// https://github.com/WebKit/WebKit/blob/24aaedc770d192d03a07ba4a71727274aaa8fc07/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm#L840
|
|
void _CSCheckFixDisable();
|
|
} // extern "C"
|
|
+#endif
|
|
|
|
namespace sandbox {
|
|
|
|
void DisableLaunchServices() {
|
|
+ #if !IS_MAS_BUILD()
|
|
// Allow the process to continue without a LaunchServices ASN. The
|
|
// INIT_Process function in HIServices will abort if it cannot connect to
|
|
// launchservicesd to get an ASN. By setting this flag, HIServices skips
|
|
@@ -36,10 +40,13 @@ void DisableLaunchServices() {
|
|
0, ^bool(CFDictionaryRef options) {
|
|
return false;
|
|
});
|
|
+ #endif
|
|
}
|
|
|
|
void DisableCoreServicesCheckFix() {
|
|
+#if !IS_MAS_BUILD()
|
|
_CSCheckFixDisable();
|
|
+#endif
|
|
}
|
|
|
|
} // namespace sandbox
|
|
diff --git a/third_party/blink/renderer/core/BUILD.gn b/third_party/blink/renderer/core/BUILD.gn
|
|
index a96e9c9df209abba41bccf9d348eee89058b5f83..12942929d97d2bfff86fc43c506253934fd8e68e 100644
|
|
--- a/third_party/blink/renderer/core/BUILD.gn
|
|
+++ b/third_party/blink/renderer/core/BUILD.gn
|
|
@@ -446,6 +446,7 @@ component("core") {
|
|
"//ui/gfx/geometry",
|
|
"//ui/gfx/geometry:geometry_skia",
|
|
"//ui/strings",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
|
|
if (is_mac) {
|
|
diff --git a/third_party/blink/renderer/core/editing/kill_ring_mac.mm b/third_party/blink/renderer/core/editing/kill_ring_mac.mm
|
|
index 94afefcee81b87c05bf9b1199d90d3d4b5ea84a6..3e3aaea0ec6c8fad0d90a931d269af3af01ab73a 100644
|
|
--- a/third_party/blink/renderer/core/editing/kill_ring_mac.mm
|
|
+++ b/third_party/blink/renderer/core/editing/kill_ring_mac.mm
|
|
@@ -25,8 +25,11 @@
|
|
|
|
#import "third_party/blink/renderer/core/editing/kill_ring.h"
|
|
|
|
+#include "electron/mas.h"
|
|
+
|
|
namespace blink {
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
|
|
// Kill ring calls. Would be better to use NSKillRing.h, but that's not
|
|
@@ -39,7 +42,9 @@
|
|
void _NSNewKillRingSequence();
|
|
void _NSSetKillRingToYankedState();
|
|
}
|
|
+#endif // !IS_MAS_BUILD()
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
static void InitializeKillRingIfNeeded() {
|
|
static bool initialized_kill_ring = false;
|
|
if (!initialized_kill_ring) {
|
|
@@ -47,30 +52,43 @@ static void InitializeKillRingIfNeeded() {
|
|
_NSInitializeKillRing();
|
|
}
|
|
}
|
|
+#endif // !IS_MAS_BUILD()
|
|
|
|
void KillRing::Append(const String& string) {
|
|
+#if !IS_MAS_BUILD()
|
|
InitializeKillRingIfNeeded();
|
|
_NSAppendToKillRing(string);
|
|
+#endif // !IS_MAS_BUILD()
|
|
}
|
|
|
|
void KillRing::Prepend(const String& string) {
|
|
+#if !IS_MAS_BUILD()
|
|
InitializeKillRingIfNeeded();
|
|
_NSPrependToKillRing(string);
|
|
+#endif // !IS_MAS_BUILD()
|
|
}
|
|
|
|
String KillRing::Yank() {
|
|
+#if !IS_MAS_BUILD()
|
|
InitializeKillRingIfNeeded();
|
|
return _NSYankFromKillRing();
|
|
+#else
|
|
+ return String();
|
|
+#endif // !IS_MAS_BUILD()
|
|
}
|
|
|
|
void KillRing::StartNewSequence() {
|
|
+#if !IS_MAS_BUILD()
|
|
InitializeKillRingIfNeeded();
|
|
_NSNewKillRingSequence();
|
|
+#endif // !IS_MAS_BUILD()
|
|
}
|
|
|
|
void KillRing::SetToYankedState() {
|
|
+#if !IS_MAS_BUILD()
|
|
InitializeKillRingIfNeeded();
|
|
_NSSetKillRingToYankedState();
|
|
+#endif // !IS_MAS_BUILD()
|
|
}
|
|
|
|
} // namespace blink
|
|
diff --git a/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm b/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm
|
|
index b3fd5abd10fae78c0bb62da6966e516400d1a452..9af448405391822f851b70e76725ec6c8b0adee1 100644
|
|
--- a/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm
|
|
+++ b/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm
|
|
@@ -41,6 +41,7 @@
|
|
#include "base/apple/foundation_util.h"
|
|
#include "base/apple/scoped_cftyperef.h"
|
|
#include "base/numerics/byte_conversions.h"
|
|
+#include "electron/mas.h"
|
|
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
|
|
#include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
|
|
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
|
|
@@ -64,8 +65,10 @@
|
|
// We don't need localized variation axis name, so we can use
|
|
// `CTFontCopyVariationAxesInternal()` instead.
|
|
// Request for public API: FB13788219.
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" CFArrayRef CTFontCopyVariationAxesInternal(CTFontRef)
|
|
CT_AVAILABLE(macos(12.1));
|
|
+#endif
|
|
|
|
namespace blink {
|
|
|
|
@@ -591,12 +594,16 @@ void ClampVariationValuesToFontAcceptableRange(
|
|
// we are enabling it only on MacOS 13+ because these are our benchmarking
|
|
// platforms.
|
|
NSArray* all_axes;
|
|
+#if !IS_MAS_BUILD()
|
|
if (@available(macOS 13.0, *)) {
|
|
all_axes =
|
|
CFToNSOwnershipCast(CTFontCopyVariationAxesInternal(ct_font.get()));
|
|
} else {
|
|
all_axes = CFToNSOwnershipCast(CTFontCopyVariationAxes(ct_font.get()));
|
|
}
|
|
+#else
|
|
+ all_axes = CFToNSOwnershipCast(CTFontCopyVariationAxes(ct_font.get()));
|
|
+#endif
|
|
if (!all_axes) {
|
|
return;
|
|
}
|
|
diff --git a/ui/accelerated_widget_mac/BUILD.gn b/ui/accelerated_widget_mac/BUILD.gn
|
|
index eb90cda4852ca7dc0932cc77801f6b4d62c5624d..2b2dedabfc75548cb46227905035cdc6a4ed681e 100644
|
|
--- a/ui/accelerated_widget_mac/BUILD.gn
|
|
+++ b/ui/accelerated_widget_mac/BUILD.gn
|
|
@@ -84,6 +84,7 @@ component("accelerated_widget_mac") {
|
|
"//ui/gfx",
|
|
"//ui/gfx/geometry",
|
|
"//ui/gl",
|
|
+ "//electron/build/config:generate_mas_config",
|
|
]
|
|
}
|
|
|
|
diff --git a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h
|
|
index 0cd9d96de17609451543c2ecec0d4e59c63c60f9..cf87c704194b246a801f55d9e231c4d4ddb8c774 100644
|
|
--- a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h
|
|
+++ b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h
|
|
@@ -8,13 +8,16 @@
|
|
#include <queue>
|
|
|
|
#include "base/containers/queue.h"
|
|
+#include "electron/mas.h"
|
|
#include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h"
|
|
#include "ui/gfx/ca_layer_result.h"
|
|
#include "ui/gfx/presentation_feedback.h"
|
|
#include "ui/gl/gl_context.h"
|
|
#include "ui/gl/presenter.h"
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
@class CAContext;
|
|
+#endif
|
|
@class CALayer;
|
|
@protocol MTLDevice;
|
|
|
|
@@ -128,7 +131,9 @@ class ACCELERATED_WIDGET_MAC_EXPORT CALayerTreeCoordinator {
|
|
// both the current tree and the pending trees.
|
|
size_t presented_ca_layer_trees_max_length_ = 2;
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
CAContext* __strong ca_context_;
|
|
+#endif
|
|
|
|
// The root CALayer to display the current frame. This does not change
|
|
// over the lifetime of the object.
|
|
diff --git a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
|
|
index 93cc4151a829a0f6e001731a24cb5a87569121ac..b7e13096b37151de48ee5703e2aac76de6513839 100644
|
|
--- a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
|
|
+++ b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
|
|
@@ -11,6 +11,7 @@
|
|
#include "base/task/single_thread_task_runner.h"
|
|
#include "base/trace_event/trace_event.h"
|
|
#include "build/ios_buildflags.h"
|
|
+#include "electron/mas.h"
|
|
#include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h"
|
|
#include "ui/base/cocoa/animation_utils.h"
|
|
#include "ui/base/cocoa/remote_layer_api.h"
|
|
@@ -158,6 +159,7 @@
|
|
}
|
|
|
|
void CALayerTreeCoordinator::EnsureCAContextAndRootLayer() {
|
|
+#if !IS_MAS_BUILD()
|
|
if (!allow_remote_layers_) {
|
|
return;
|
|
}
|
|
@@ -192,6 +194,7 @@
|
|
ca_context_.layer = root_ca_layer_;
|
|
#endif // !BUILDFLAG(IS_IOS) || BUILDFLAG(IS_IOS_TVOS)
|
|
}
|
|
+#endif // !IS_MAS_BUILD()
|
|
}
|
|
|
|
void CALayerTreeCoordinator::CommitPresentedFrameToCA(
|
|
@@ -222,11 +225,13 @@
|
|
if (has_resized_since_last_swap_) {
|
|
// Create a new CAContext for the new size. This allows new frame update at
|
|
// the new size to be atomic with things like resizing the NSWindow.
|
|
+#if !IS_MAS_BUILD()
|
|
if (base::FeatureList::IsEnabled(features::kCAContextFenceOnResize) &&
|
|
allow_remote_layers_) {
|
|
params.ca_context_fence_mach_port.reset([ca_context_ createFencePort]);
|
|
[ca_context_ setFencePort:params.ca_context_fence_mach_port.get()];
|
|
}
|
|
+#endif // !IS_MAS_BUILD()
|
|
has_resized_since_last_swap_ = false;
|
|
}
|
|
#endif
|
|
@@ -249,10 +254,13 @@
|
|
TRACE_EVENT_INSTANT("test_gpu", "SwapBuffers", "GLImpl",
|
|
static_cast<int>(gl::GetGLImplementation()), "width",
|
|
pixel_size_.width());
|
|
-
|
|
+#if !IS_MAS_BUILD()
|
|
if (allow_remote_layers_) {
|
|
params.ca_context_id = [ca_context_ contextId];
|
|
} else {
|
|
+#else
|
|
+ if (true) {
|
|
+#endif
|
|
IOSurfaceRef io_surface = frame.layer_tree->GetContentIOSurface();
|
|
if (io_surface) {
|
|
DCHECK(!allow_remote_layers_);
|
|
diff --git a/ui/accelerated_widget_mac/display_ca_layer_tree.mm b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
|
index b20c2d410c6848a5041d14322e834818e3f175e7..2575c23d4909651bf568480c2173d1b213dcd31f 100644
|
|
--- a/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
|
+++ b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
|
@@ -12,6 +12,7 @@
|
|
#include "base/mac/mac_util.h"
|
|
#include "base/trace_event/trace_event.h"
|
|
#include "build/build_config.h"
|
|
+#include "electron/mas.h"
|
|
#include "ui/base/cocoa/animation_utils.h"
|
|
#include "ui/base/cocoa/remote_layer_api.h"
|
|
#include "ui/base/ui_base_features.h"
|
|
@@ -122,6 +123,7 @@ - (void)setContentsChanged;
|
|
}
|
|
|
|
void DisplayCALayerTree::GotCALayerFrame(uint32_t ca_context_id) {
|
|
+#if !IS_MAS_BUILD()
|
|
// Early-out if the remote layer has not changed.
|
|
if (remote_layer_.contextId == ca_context_id) {
|
|
return;
|
|
@@ -151,6 +153,9 @@ - (void)setContentsChanged;
|
|
[io_surface_layer_ removeFromSuperlayer];
|
|
io_surface_layer_ = nil;
|
|
}
|
|
+#else
|
|
+ NOTREACHED() << "Remote layer is being used in MAS build";
|
|
+#endif
|
|
}
|
|
|
|
void DisplayCALayerTree::GotIOSurfaceFrame(
|
|
diff --git a/ui/accessibility/platform/BUILD.gn b/ui/accessibility/platform/BUILD.gn
|
|
index f0850f8dd184571bf1c3f7a5e26c6b719c6c1925..a74ebc91c325addedec9209cc3729949d061d518 100644
|
|
--- a/ui/accessibility/platform/BUILD.gn
|
|
+++ b/ui/accessibility/platform/BUILD.gn
|
|
@@ -300,6 +300,7 @@ component("platform") {
|
|
"AppKit.framework",
|
|
"Foundation.framework",
|
|
]
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
if (is_ios) {
|
|
diff --git a/ui/accessibility/platform/browser_accessibility_manager_mac.mm b/ui/accessibility/platform/browser_accessibility_manager_mac.mm
|
|
index 798a207f331d8e436398b979ff5ac6eaf3d40eb0..f30ff033b9d0d1ba1312569104eeccfdce5bcfe3 100644
|
|
--- a/ui/accessibility/platform/browser_accessibility_manager_mac.mm
|
|
+++ b/ui/accessibility/platform/browser_accessibility_manager_mac.mm
|
|
@@ -17,6 +17,7 @@
|
|
#include "base/task/single_thread_task_runner.h"
|
|
#include "base/task/task_traits.h"
|
|
#include "base/time/time.h"
|
|
+#include "electron/mas.h"
|
|
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
|
|
#include "ui/accessibility/accessibility_features.h"
|
|
#include "ui/accessibility/ax_role_properties.h"
|
|
@@ -25,7 +26,9 @@
|
|
#include "ui/accessibility/platform/ax_private_webkit_constants_mac.h"
|
|
#import "ui/accessibility/platform/browser_accessibility_cocoa.h"
|
|
#import "ui/accessibility/platform/browser_accessibility_mac.h"
|
|
+#if !IS_MAS_BUILD()
|
|
#include "ui/base/cocoa/remote_accessibility_api.h"
|
|
+#endif
|
|
|
|
using base::apple::CFToNSPtrCast;
|
|
using base::apple::ObjCCast;
|
|
@@ -243,6 +246,7 @@ void PostAnnouncementNotification(NSString* announcement,
|
|
return;
|
|
}
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
BrowserAccessibilityManager* root_manager = GetManagerForRootFrame();
|
|
if (root_manager) {
|
|
BrowserAccessibilityManagerMac* root_manager_mac =
|
|
@@ -265,6 +269,7 @@ void PostAnnouncementNotification(NSString* announcement,
|
|
return;
|
|
}
|
|
}
|
|
+#endif
|
|
|
|
// Use native VoiceOver support for live regions.
|
|
BrowserAccessibilityCocoa* retained_node = native_node;
|
|
@@ -762,6 +767,7 @@ void PostAnnouncementNotification(NSString* announcement,
|
|
return window == [NSApp accessibilityFocusedWindow];
|
|
}
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// TODO(accessibility): We need a solution to the problem described below.
|
|
// If the window is NSAccessibilityRemoteUIElement, there are some challenges:
|
|
// 1. NSApp is the browser which spawned the PWA, and what it considers the
|
|
@@ -790,6 +796,7 @@ void PostAnnouncementNotification(NSString* announcement,
|
|
if ([window isKindOfClass:[NSAccessibilityRemoteUIElement class]]) {
|
|
return true;
|
|
}
|
|
+#endif
|
|
|
|
return false;
|
|
}
|
|
diff --git a/ui/accessibility/platform/inspect/ax_transform_mac.mm b/ui/accessibility/platform/inspect/ax_transform_mac.mm
|
|
index 9423a2891552e8df3ea5b05c720ab11795c4b92d..610c479ef03759d3082b42d7a402cbeadac66e81 100644
|
|
--- a/ui/accessibility/platform/inspect/ax_transform_mac.mm
|
|
+++ b/ui/accessibility/platform/inspect/ax_transform_mac.mm
|
|
@@ -8,6 +8,7 @@
|
|
|
|
#include "base/apple/foundation_util.h"
|
|
#include "base/strings/sys_string_conversions.h"
|
|
+#include "electron/mas.h"
|
|
#include "ui/accessibility/ax_range.h"
|
|
#include "ui/accessibility/platform/ax_platform_node.h"
|
|
#include "ui/accessibility/platform/ax_platform_node_cocoa.h"
|
|
@@ -108,6 +109,7 @@
|
|
}
|
|
}
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// AXTextMarker
|
|
if (IsAXTextMarker(value)) {
|
|
return AXTextMarkerToBaseValue(value, indexer);
|
|
@@ -117,6 +119,7 @@
|
|
if (IsAXTextMarkerRange(value)) {
|
|
return AXTextMarkerRangeToBaseValue(value, indexer);
|
|
}
|
|
+#endif
|
|
|
|
// Accessible object
|
|
if (AXElementWrapper::IsValidElement(value)) {
|
|
diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
|
|
index bf24872b5002f61820bae1a496d3332814f30dbf..8f1401184c874df7a1a258f2a60882dbdc76c057 100644
|
|
--- a/ui/base/BUILD.gn
|
|
+++ b/ui/base/BUILD.gn
|
|
@@ -367,6 +367,13 @@ component("base") {
|
|
]
|
|
}
|
|
|
|
+ if (is_mas_build) {
|
|
+ sources -= [
|
|
+ "cocoa/remote_accessibility_api.h",
|
|
+ "cocoa/remote_accessibility_api.mm",
|
|
+ ]
|
|
+ }
|
|
+
|
|
if (is_ios) {
|
|
sources += [
|
|
"device_form_factor_ios.mm",
|
|
@@ -520,6 +527,12 @@ component("base") {
|
|
"//url",
|
|
]
|
|
|
|
+ if (is_mac) {
|
|
+ deps += [
|
|
+ "//electron/build/config:generate_mas_config"
|
|
+ ]
|
|
+ }
|
|
+
|
|
if (is_debug || dcheck_always_on) {
|
|
deps += [ "//third_party/re2" ]
|
|
}
|
|
diff --git a/ui/base/cocoa/remote_accessibility_api.h b/ui/base/cocoa/remote_accessibility_api.h
|
|
index 3182458838aa96d34911280ab4c6c3aa4aa22d6d..6dc85c366b7e61c8bd0302e501c3223a19223313 100644
|
|
--- a/ui/base/cocoa/remote_accessibility_api.h
|
|
+++ b/ui/base/cocoa/remote_accessibility_api.h
|
|
@@ -10,9 +10,12 @@
|
|
#include <vector>
|
|
|
|
#include "base/component_export.h"
|
|
+#include "electron/mas.h"
|
|
|
|
// NSAccessibilityRemoteUIElement is a private class in AppKit.
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
+
|
|
@interface NSAccessibilityRemoteUIElement : NSObject
|
|
+ (void)setRemoteUIApp:(BOOL)flag;
|
|
+ (BOOL)isRemoteUIApp;
|
|
@@ -38,4 +41,6 @@ class COMPONENT_EXPORT(UI_BASE) RemoteAccessibility {
|
|
|
|
} // namespace ui
|
|
|
|
+#endif // MAS_BUILD
|
|
+
|
|
#endif // UI_BASE_COCOA_REMOTE_ACCESSIBILITY_API_H_
|
|
diff --git a/ui/base/cocoa/remote_layer_api.h b/ui/base/cocoa/remote_layer_api.h
|
|
index 8a11a77f1a502b601015793738ec690b74932b11..aaaf4dd5632a57f5a68424ec36e2ff6be418f6a3 100644
|
|
--- a/ui/base/cocoa/remote_layer_api.h
|
|
+++ b/ui/base/cocoa/remote_layer_api.h
|
|
@@ -9,6 +9,7 @@
|
|
|
|
#include "base/component_export.h"
|
|
#include "build/build_config.h"
|
|
+#include "electron/mas.h"
|
|
|
|
#if defined(__OBJC__)
|
|
#import <Foundation/Foundation.h>
|
|
@@ -17,6 +18,7 @@
|
|
|
|
#if BUILDFLAG(IS_MAC)
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// The CGSConnectionID is used to create the CAContext in the process that is
|
|
// going to share the CALayers that it is rendering to another process to
|
|
// display.
|
|
@@ -71,6 +73,8 @@ extern NSString* const kCAContextIgnoresHitTest;
|
|
|
|
#endif // __OBJC__
|
|
|
|
+#endif // MAS_BUILD
|
|
+
|
|
namespace ui {
|
|
|
|
// This function will check if all of the interfaces listed above are supported
|
|
diff --git a/ui/base/cocoa/remote_layer_api.mm b/ui/base/cocoa/remote_layer_api.mm
|
|
index 93e90c4eba9bc9b93d68e834eb6baabeb2d0ecf0..1b90f41d05f847a94adf2f4da827b1d0143b7bcf 100644
|
|
--- a/ui/base/cocoa/remote_layer_api.mm
|
|
+++ b/ui/base/cocoa/remote_layer_api.mm
|
|
@@ -5,18 +5,22 @@
|
|
#include "ui/base/cocoa/remote_layer_api.h"
|
|
|
|
#include "base/feature_list.h"
|
|
+#include "electron/mas.h"
|
|
|
|
#include <objc/runtime.h>
|
|
|
|
namespace ui {
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
namespace {
|
|
// Control use of cross-process CALayers to display content directly from the
|
|
// GPU process on Mac.
|
|
BASE_FEATURE(kRemoteCoreAnimationAPI, base::FEATURE_ENABLED_BY_DEFAULT);
|
|
} // namespace
|
|
+#endif
|
|
|
|
bool RemoteLayerAPISupported() {
|
|
+#if !IS_MAS_BUILD()
|
|
if (!base::FeatureList::IsEnabled(kRemoteCoreAnimationAPI))
|
|
return false;
|
|
|
|
@@ -53,6 +57,9 @@ bool RemoteLayerAPISupported() {
|
|
|
|
// If everything is there, we should be able to use the API.
|
|
return true;
|
|
+#else
|
|
+ return false;
|
|
+#endif // MAS_BUILD
|
|
}
|
|
|
|
} // namespace
|
|
diff --git a/ui/display/BUILD.gn b/ui/display/BUILD.gn
|
|
index 6f419c1255ad8e10e50a0de3bc9599a07e8d917e..8f93adfc525f98fb569f3dd63ff9788329e387a0 100644
|
|
--- a/ui/display/BUILD.gn
|
|
+++ b/ui/display/BUILD.gn
|
|
@@ -139,6 +139,12 @@ component("display") {
|
|
"//ui/gfx/geometry",
|
|
]
|
|
|
|
+ if (is_mac) {
|
|
+ deps += [
|
|
+ "//electron/build/config:generate_mas_config"
|
|
+ ]
|
|
+ }
|
|
+
|
|
if (is_ios) {
|
|
deps += [ "//build:ios_buildflags" ]
|
|
}
|
|
diff --git a/ui/display/mac/ca_display_link_mac.mm b/ui/display/mac/ca_display_link_mac.mm
|
|
index 6e1add2ad1ccd151b98f9926d8cde3268f56de05..94a44aa0b97fb1dd2365c135c35e74769115bc51 100644
|
|
--- a/ui/display/mac/ca_display_link_mac.mm
|
|
+++ b/ui/display/mac/ca_display_link_mac.mm
|
|
@@ -20,15 +20,18 @@
|
|
#include "base/metrics/histogram_macros.h"
|
|
#include "base/no_destructor.h"
|
|
#include "base/trace_event/trace_event.h"
|
|
+#include "electron/mas.h"
|
|
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
|
|
#include "ui/display/mac/screen_utils_mac.h"
|
|
|
|
extern "C" {
|
|
+#if !IS_MAS_BUILD()
|
|
// Undocumented CoreGraphics framework functions.
|
|
using CGSConnectionID = uint32_t;
|
|
CGSConnectionID CGSMainConnectionID();
|
|
CGError CGSGetEventPort(CGSConnectionID connection_id, mach_port_t* port);
|
|
CGEventRef CGEventCreateNextEvent(CGSConnectionID connection_id);
|
|
+#endif
|
|
|
|
// Undocumented SkyLight framework functions.
|
|
// SLSGetDisplayLink() is a private function (SPI) that creates a CADisplayLink
|
|
@@ -299,6 +302,15 @@ void RecordWindowServerEventPumpResult(
|
|
viz_task_runner_(base::SingleThreadTaskRunner::GetCurrentDefault()) {
|
|
weak_ptr_ = weak_factory_.GetWeakPtr();
|
|
|
|
+#if IS_MAS_BUILD()
|
|
+ // Draining the WindowServer event queue needs the private CGS* functions
|
|
+ // declared above, which the Mac App Store build cannot use. Without the
|
|
+ // pump, CADisplayLink may stop firing after display reconfiguration or power
|
|
+ // resume, so treat the pump as failed up front and let every root frame sink
|
|
+ // fall back to a timer-based VSync source.
|
|
+ shutdown_ = true;
|
|
+ CADisplayLinkGlobals::Get().SetWindowServerEventPumpFailed();
|
|
+#else
|
|
base::Thread::Options thread_options;
|
|
thread_options.message_pump_type = base::MessagePumpType::NS_RUNLOOP;
|
|
thread_options.thread_type = base::ThreadType::kPresentation;
|
|
@@ -308,6 +320,7 @@ void RecordWindowServerEventPumpResult(
|
|
FROM_HERE,
|
|
base::BindOnce(&WindowServerEventPumpThread::PumpWindowServerEvents,
|
|
base::Unretained(this)));
|
|
+#endif
|
|
}
|
|
|
|
// In a standard out-of-process GPU scenario,
|
|
@@ -325,6 +338,7 @@ void RecordWindowServerEventPumpResult(
|
|
|
|
shutdown_ = true;
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// Send an empty message to wake up the thread and quit the while loop.
|
|
// See WindowServerEventPumpThread::PumpWindowServerEvents() for details.
|
|
CGSConnectionID connection_id = CGSMainConnectionID();
|
|
@@ -348,10 +362,12 @@ void RecordWindowServerEventPumpResult(
|
|
<< "CGSGetEventPort() in ~WindowServerEventPumpThread failed. Error: "
|
|
<< err;
|
|
}
|
|
+#endif
|
|
|
|
Stop();
|
|
}
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
void WindowServerEventPumpThread::PumpWindowServerEvents() {
|
|
CGSConnectionID connection_id = CGSMainConnectionID();
|
|
// We haven't seen this happen in practice, but WebKit's implementation
|
|
@@ -499,6 +515,7 @@ void RecordWindowServerEventPumpResult(
|
|
}
|
|
}
|
|
}
|
|
+#endif
|
|
|
|
void WindowServerEventPumpThread::DisableDisplayLink(Result failure) {
|
|
// This may be called from the pump thread. Hop to the Viz thread, which owns
|
|
diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm
|
|
index 618217772a2fa38077ca0913dc017ecc6a702142..f06c9cf5bd3d841935d4e7353e7040272d51abb4 100644
|
|
--- a/ui/display/mac/screen_mac.mm
|
|
+++ b/ui/display/mac/screen_mac.mm
|
|
@@ -29,6 +29,7 @@
|
|
#include "build/build_config.h"
|
|
#include "components/device_event_log/device_event_log.h"
|
|
#include "components/viz/common/resources/shared_image_format.h"
|
|
+#include "electron/mas.h"
|
|
#include "ui/display/display.h"
|
|
#include "ui/display/display_change_notifier.h"
|
|
#include "ui/display/mac/screen_mac_headless.h"
|
|
@@ -181,7 +182,17 @@ DisplayMac BuildDisplayForScreen(NSScreen* screen) {
|
|
display.set_color_depth(Display::kDefaultBitsPerPixel);
|
|
display.set_depth_per_component(Display::kDefaultBitsPerComponent);
|
|
}
|
|
+#if IS_MAS_BUILD()
|
|
+ // This is equivalent to the CGDisplayUsesForceToGray() API as at 2018-08-06,
|
|
+ // but avoids usage of the private API.
|
|
+ CFStringRef app = CFSTR("com.apple.CoreGraphics");
|
|
+ CFStringRef key = CFSTR("DisplayUseForcedGray");
|
|
+ Boolean key_valid = false;
|
|
+ display.set_is_monochrome(
|
|
+ CFPreferencesGetAppBooleanValue(key, app, &key_valid));
|
|
+#else
|
|
display.set_is_monochrome(CGDisplayUsesForceToGray());
|
|
+#endif
|
|
|
|
// Query the display's refresh rate. To get a float number such as 59.95Hz,
|
|
// use 1.0/screen.minimumRefreshInterval instead of
|
|
diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn
|
|
index c50d748fb83207ff46e5d46a8979ebea1d5c30f7..e4c4a8cdb71bc872e8dbf998b6bfa7a0ff053d25 100644
|
|
--- a/ui/gfx/BUILD.gn
|
|
+++ b/ui/gfx/BUILD.gn
|
|
@@ -284,6 +284,8 @@ component("gfx") {
|
|
"CoreGraphics.framework",
|
|
"CoreText.framework",
|
|
]
|
|
+
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
if (is_ios) {
|
|
sources += [
|
|
diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm
|
|
index 65ae8170664d15c7884261812400d0ed638a681d..86c937f1e6d03b88803a2ca80abff19c5acc6408 100644
|
|
--- a/ui/gfx/platform_font_mac.mm
|
|
+++ b/ui/gfx/platform_font_mac.mm
|
|
@@ -19,6 +19,7 @@
|
|
#include "base/numerics/safe_conversions.h"
|
|
#include "base/strings/sys_string_conversions.h"
|
|
#include "base/strings/utf_string_conversions.h"
|
|
+#include "electron/mas.h"
|
|
#include "third_party/skia/include/ports/SkTypeface_mac.h"
|
|
#include "ui/gfx/canvas.h"
|
|
#include "ui/gfx/font.h"
|
|
@@ -28,9 +29,11 @@
|
|
|
|
using Weight = Font::Weight;
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
extern "C" {
|
|
bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
|
|
}
|
|
+#endif
|
|
|
|
namespace {
|
|
|
|
@@ -250,7 +253,13 @@ CTFontRef SystemFontForConstructorOfType(
|
|
// TODO(avi, etienneb): Figure out this font stuff.
|
|
base::apple::ScopedCFTypeRef<CTFontDescriptorRef> descriptor(
|
|
CTFontCopyFontDescriptor(font));
|
|
+#if IS_MAS_BUILD()
|
|
+ CFNumberRef priority = (CFNumberRef)CTFontDescriptorCopyAttribute(descriptor.get(), (CFStringRef)kCTFontPriorityAttribute);
|
|
+ SInt64 v;
|
|
+ if (CFNumberGetValue(priority, kCFNumberSInt64Type, &v) && v == kCTFontPrioritySystem) {
|
|
+#else
|
|
if (CTFontDescriptorIsSystemUIFont(descriptor.get())) {
|
|
+#endif
|
|
// Assume it's the standard system font. The fact that this much is known is
|
|
// enough.
|
|
return PlatformFontMac::SystemFontType::kGeneral;
|
|
diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn
|
|
index 86668cf470ff935533b03342b0afdc4c24f976d8..5223189e074ff1871fd0b916a24b7753101d433e 100644
|
|
--- a/ui/views/BUILD.gn
|
|
+++ b/ui/views/BUILD.gn
|
|
@@ -791,6 +791,8 @@ component("views") {
|
|
"IOSurface.framework",
|
|
"QuartzCore.framework",
|
|
]
|
|
+
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
}
|
|
|
|
if (is_win) {
|
|
@@ -1212,6 +1214,8 @@ source_set("test_support") {
|
|
"//ui/base/mojom:ui_base_types",
|
|
]
|
|
|
|
+ deps += ["//electron/build/config:generate_mas_config"]
|
|
+
|
|
if (is_win) {
|
|
sources += [
|
|
"test/desktop_window_tree_host_win_test_api.cc",
|
|
diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.h b/ui/views/cocoa/native_widget_mac_ns_window_host.h
|
|
index a66a1f0ffaae89ab3f338fe2c80d907c34da6f91..37cdddfb2f8309aa1bb331d2052eeff02fc5584b 100644
|
|
--- a/ui/views/cocoa/native_widget_mac_ns_window_host.h
|
|
+++ b/ui/views/cocoa/native_widget_mac_ns_window_host.h
|
|
@@ -20,6 +20,7 @@
|
|
#include "components/remote_cocoa/browser/scoped_cg_window_id.h"
|
|
#include "components/remote_cocoa/common/native_widget_ns_window.mojom.h"
|
|
#include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
|
|
+#include "electron/mas.h"
|
|
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
|
#include "mojo/public/cpp/bindings/associated_remote.h"
|
|
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
|
|
@@ -36,7 +37,9 @@
|
|
#include "ui/views/window/dialog_observer.h"
|
|
|
|
@class NativeWidgetMacNSWindow;
|
|
+#if !IS_MAS_BUILD()
|
|
@class NSAccessibilityRemoteUIElement;
|
|
+#endif
|
|
@class NSView;
|
|
|
|
namespace remote_cocoa {
|
|
@@ -530,10 +533,12 @@ class VIEWS_EXPORT NativeWidgetMacNSWindowHost
|
|
mojo::AssociatedRemote<remote_cocoa::mojom::NativeWidgetNSWindow>
|
|
remote_ns_window_remote_;
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
// Remote accessibility objects corresponding to the NSWindow and its root
|
|
// NSView.
|
|
NSAccessibilityRemoteUIElement* __strong remote_window_accessible_;
|
|
NSAccessibilityRemoteUIElement* __strong remote_view_accessible_;
|
|
+#endif
|
|
|
|
// Used to force the NSApplication's focused accessibility element to be the
|
|
// views::Views accessibility tree when the NSView for this is focused.
|
|
diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.mm b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
|
|
index 352ef08958711c421ef89c48125c7505ed024afe..dcdfee94a5959f49422b4c37a0fbac9c7a378760 100644
|
|
--- a/ui/views/cocoa/native_widget_mac_ns_window_host.mm
|
|
+++ b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
|
|
@@ -24,6 +24,7 @@
|
|
#include "components/remote_cocoa/browser/ns_view_ids.h"
|
|
#include "components/remote_cocoa/browser/window.h"
|
|
#include "components/remote_cocoa/common/native_widget_ns_window.mojom.h"
|
|
+#include "electron/mas.h"
|
|
#include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
|
|
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
|
|
#include "ui/accessibility/accessibility_features.h"
|
|
@@ -374,8 +375,12 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
|
|
if (in_process_ns_window_bridge_) {
|
|
return gfx::NativeViewAccessible(in_process_ns_window_bridge_->ns_view());
|
|
}
|
|
+#if !IS_MAS_BUILD()
|
|
return gfx::NativeViewAccessible(
|
|
(id<NSAccessibility>)remote_view_accessible_);
|
|
+#else
|
|
+ return {};
|
|
+#endif
|
|
}
|
|
|
|
gfx::NativeViewAccessible
|
|
@@ -391,8 +396,12 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
|
|
[in_process_ns_window_bridge_->ns_view() window]);
|
|
}
|
|
|
|
+#if !IS_MAS_BUILD()
|
|
return gfx::NativeViewAccessible(
|
|
(id<NSAccessibility>)remote_window_accessible_);
|
|
+#else
|
|
+ return {};
|
|
+#endif
|
|
}
|
|
|
|
remote_cocoa::mojom::NativeWidgetNSWindow*
|
|
@@ -1650,9 +1659,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
|
|
// for PWAs. However this breaks accessibility on in-process windows,
|
|
// so set it back to NO when a local window gains focus. See
|
|
// https://crbug.com/41485830.
|
|
+#if !IS_MAS_BUILD()
|
|
if (is_key && ::features::IsAccessibilityRemoteUIAppEnabled()) {
|
|
[NSAccessibilityRemoteUIElement setRemoteUIApp:!!application_host_];
|
|
}
|
|
+#endif
|
|
// Explicitly set the keyboard accessibility state on regaining key
|
|
// window status.
|
|
if (is_key && is_content_first_responder) {
|
|
@@ -1805,17 +1816,20 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
|
|
void NativeWidgetMacNSWindowHost::SetRemoteAccessibilityTokens(
|
|
const std::vector<uint8_t>& window_token,
|
|
const std::vector<uint8_t>& view_token) {
|
|
+#if !IS_MAS_BUILD()
|
|
remote_window_accessible_ =
|
|
ui::RemoteAccessibility::GetRemoteElementFromToken(window_token);
|
|
remote_view_accessible_ =
|
|
ui::RemoteAccessibility::GetRemoteElementFromToken(view_token);
|
|
[remote_view_accessible_ setWindowUIElement:remote_window_accessible_];
|
|
[remote_view_accessible_ setTopLevelUIElement:remote_window_accessible_];
|
|
+#endif
|
|
}
|
|
|
|
bool NativeWidgetMacNSWindowHost::GetRootViewAccessibilityToken(
|
|
base::ProcessId* pid,
|
|
std::vector<uint8_t>* token) {
|
|
+#if !IS_MAS_BUILD()
|
|
*pid = getpid();
|
|
id element_id = GetNativeViewAccessible();
|
|
|
|
@@ -1828,6 +1842,7 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
|
|
}
|
|
|
|
*token = ui::RemoteAccessibility::GetTokenForLocalElement(element_id);
|
|
+#endif
|
|
return true;
|
|
}
|
|
|
|
diff --git a/ui/views/controls/webview/BUILD.gn b/ui/views/controls/webview/BUILD.gn
|
|
index f9d0756f8031155c15df2e861c11de9343d6d938..ca00e8523a1b82e86fc74421ff90b566c58687cc 100644
|
|
--- a/ui/views/controls/webview/BUILD.gn
|
|
+++ b/ui/views/controls/webview/BUILD.gn
|
|
@@ -51,6 +51,12 @@ component("webview") {
|
|
"//url",
|
|
]
|
|
|
|
+ if (is_mac) {
|
|
+ deps += [
|
|
+ "//electron/build/config:generate_mas_config",
|
|
+ ]
|
|
+ }
|
|
+
|
|
public_deps = [
|
|
"//base",
|
|
"//content/public/browser",
|