1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Samuel Attard <[email protected]>
- 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
- * AudioDeviceDuck
- * NSNextStepFrame
- * NSThemeFrame
- * NSTextInputReplacementRangeAttributeName
- * 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).
- * 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 998d8906b6bd33f48199dc5a67bbd149742eb561..90015e0be79e850a9225263e90b662fa3fbe005f 100644
- --- a/base/BUILD.gn
- +++ b/base/BUILD.gn
- @@ -1031,6 +1031,7 @@ component("base") {
- "//build:ios_buildflags",
- "//build/config/compiler:compiler_buildflags",
- "//third_party/modp_b64",
- + "//electron/build/config:generate_mas_config",
- ]
- if (!is_nacl) {
- # Used by metrics/crc32, except on NaCl builds.
- 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/process/launch_mac.cc b/base/process/launch_mac.cc
- index 1baeaec5125bbdc19dccbd18c8702f291ccc71ba..613c644eda45c7e4bf1a7a06dad6d8b4b85daa11 100644
- --- a/base/process/launch_mac.cc
- +++ b/base/process/launch_mac.cc
- @@ -21,13 +21,19 @@
- #include "base/threading/scoped_blocking_call.h"
- #include "base/threading/thread_restrictions.h"
- #include "base/trace_event/base_tracing.h"
- +#include "electron/mas.h"
- +#if IS_MAS_BUILD()
- +#include <sys/syscall.h>
- +#endif
-
- 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);
- @@ -104,13 +110,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
-
- @@ -234,7 +254,7 @@ Process LaunchProcess(const std::vector<std::string>& argv,
- file_actions.Inherit(STDERR_FILENO);
- }
-
- -#if BUILDFLAG(IS_MAC)
- +#if 0
- if (options.disclaim_responsibility) {
- DPSXCHECK(responsibility_spawnattrs_setdisclaim(attr.get(), 1));
- }
- diff --git a/base/process/process_info_mac.mm b/base/process/process_info_mac.mm
- index e12c1d078147d956a1d9b1bc498c1b1d6fe7b974..233362259dc4e728ed37435e650417647b45a6af 100644
- --- a/base/process/process_info_mac.mm
- +++ b/base/process/process_info_mac.mm
- @@ -4,15 +4,20 @@
-
- #include "base/process/process_info.h"
-
- +#include "electron/mas.h"
- +
- #import <AppKit/AppKit.h>
- #include <unistd.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) {
- @@ -24,12 +29,14 @@ bool AppContainsBluetoothUsageDescription(NSRunningApplication* app) {
- [bundle objectForInfoDictionaryKey:@"NSBluetoothAlwaysUsageDescription"];
- return bluetooth_entry != nil;
- }
- +#endif
-
- } // namespace
-
- namespace base {
-
- bool DoesResponsibleProcessHaveBluetoothMetadata() {
- +#if !IS_MAS_BUILD()
- const pid_t pid = getpid();
- const pid_t responsible_pid = responsibility_get_pid_responsible_for_pid(pid);
- // Returns true directly if this is a self-responsible app(e.g. Chrome opens
- @@ -46,6 +53,9 @@ bool DoesResponsibleProcessHaveBluetoothMetadata() {
- return AppContainsBluetoothUsageDescription(app);
- }
- return false;
- +#else
- + return true;
- +#endif
- }
-
- } // namespace base
- diff --git a/components/os_crypt/sync/BUILD.gn b/components/os_crypt/sync/BUILD.gn
- index ff1e356ff696d3830d02644969c36a71fdf32ff6..b39c716c52524b95f2d3417a98e60c0c41147c93 100644
- --- a/components/os_crypt/sync/BUILD.gn
- +++ b/components/os_crypt/sync/BUILD.gn
- @@ -38,6 +38,8 @@ component("sync") {
- "os_crypt_mac.mm",
- ]
- deps += [ "//crypto:mock_apple_keychain" ]
- + deps += ["//electron/build/config:generate_mas_config"]
- +
- } else if (is_win) {
- sources += [ "os_crypt_win.cc" ]
- deps += [ "//components/version_info" ]
- diff --git a/components/os_crypt/sync/keychain_password_mac.mm b/components/os_crypt/sync/keychain_password_mac.mm
- index d87682447b850e4cf9065f0d26d14077acbe467d..a179c9bc02158130f4b15bf8022721f4b53a8303 100644
- --- a/components/os_crypt/sync/keychain_password_mac.mm
- +++ b/components/os_crypt/sync/keychain_password_mac.mm
- @@ -14,6 +14,7 @@
- #include "base/rand_util.h"
- #include "build/branding_buildflags.h"
- #include "crypto/apple_keychain.h"
- +#include "electron/mas.h"
-
- using crypto::AppleKeychain;
-
- diff --git a/components/remote_cocoa/app_shim/BUILD.gn b/components/remote_cocoa/app_shim/BUILD.gn
- index ad40ddbbcb0fcfa070833ea6c0d01432bbb67768..df632da340c132f469f4f35738514763437e67fc 100644
- --- a/components/remote_cocoa/app_shim/BUILD.gn
- +++ b/components/remote_cocoa/app_shim/BUILD.gn
- @@ -75,6 +75,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/application_bridge.mm b/components/remote_cocoa/app_shim/application_bridge.mm
- index e9f4e5131238b9fb5f1b4b3e90a0cb84a7fc15b4..8b5f4cae3123ac5480ad73f0c873fca0d62f7c9f 100644
- --- a/components/remote_cocoa/app_shim/application_bridge.mm
- +++ b/components/remote_cocoa/app_shim/application_bridge.mm
- @@ -12,6 +12,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"
- @@ -51,6 +52,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;
- @@ -61,6 +63,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;
- @@ -99,7 +104,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
- };
-
- } // namespace
- 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 19fff43c3daaef5451b6b60b84a610a21311448e..240b954661d34fcc4329d39490be33c485fa8b6e 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 "components/remote_cocoa/app_shim/features.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;
- @@ -100,12 +102,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])
- @@ -165,6 +170,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.
- @@ -175,8 +182,8 @@ - (void)_handleFocusToolbarHotKey:(id)unknown {
- }
-
- - (void)setAlwaysShowTrafficLights:(BOOL)alwaysShow {
- - [base::apple::ObjCCastStrict<BrowserWindowFrame>(self.contentView.superview)
- - setAlwaysShowTrafficLights:alwaysShow];
- + // [base::apple::ObjCCastStrict<BrowserWindowFrame>(self.contentView.superview)
- + // setAlwaysShowTrafficLights:alwaysShow];
- }
-
- @end
- 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 127a2829fafa04bfbab0b883304dfb815d7e1c22..61d7946e52862f3586b1e098d7d44a125656de81 100644
- --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
- +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
- @@ -9,6 +9,7 @@
-
- #include "base/apple/foundation_util.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 {
- @@ -17,6 +18,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
- @@ -33,6 +35,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 2b50e3c3750c9ac6dd84a514663062a5d754b43e..49ced9aa87d3bcb00cd3d76ac32d4eec89873549 100644
- --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
- +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
- @@ -26,6 +26,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/user_interface_item_command_handler.h"
- #import "ui/base/cocoa/window_size_constants.h"
- @@ -112,14 +113,18 @@ 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;
- +#endif
- - (BOOL)hasKeyAppearance;
- - (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
- - (BOOL)_isConsideredOpenForPersistentState;
- @@ -159,6 +164,8 @@ - (void)cr_mouseDownOnFrameView:(NSEvent*)event {
- }
- @end
-
- +#if !IS_MAS_BUILD()
- +
- @implementation NativeWidgetMacNSWindowTitledFrame
- - (void)mouseDown:(NSEvent*)event {
- if (self.window.isMovable)
- @@ -186,6 +193,8 @@ - (BOOL)usesCustomDrawing {
- }
- @end
-
- +#endif // MAS_BUILD
- +
- @implementation NativeWidgetMacNSWindow {
- @private
- CommandDispatcher* __strong _commandDispatcher;
- @@ -383,6 +392,8 @@ - (NSAccessibilityRole)accessibilityRole {
-
- // NSWindow overrides.
-
- +#if !IS_MAS_BUILD()
- +
- + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
- if (windowStyle & NSWindowStyleMaskTitled) {
- if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
- @@ -394,6 +405,8 @@ + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
- return [super frameViewClassForStyleMask:windowStyle];
- }
-
- +#endif
- +
- - (BOOL)_isTitleHidden {
- bool shouldShowWindowTitle = YES;
- if (_bridge)
- 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 bcd3ea598687c5a85cddc862cdb16eab2d8dbd5d..2ed210685453409a2aa330bf718694f70a3d862d 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
- @@ -41,6 +41,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"
- @@ -676,10 +677,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 64c24ac24ace18bece4e4e5e870ff2bc5fc3058d..f99f39d7629682e90cd8b49e6bbf5480cd7de67e 100644
- --- a/components/viz/service/BUILD.gn
- +++ b/components/viz/service/BUILD.gn
- @@ -386,6 +386,7 @@ viz_component("service") {
- "frame_sinks/external_begin_frame_source_mac.h",
- ]
- }
- + deps += ["//electron/build/config:generate_mas_config"]
- }
-
- if (is_android || use_ozone) {
- @@ -686,6 +687,7 @@ viz_source_set("unit_tests") {
- "display_embedder/software_output_device_mac_unittest.mm",
- ]
- 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 dbf334caa3a6d10017b69ad76802e389a011436b..da828823e8195cc9e497866363c9af93dcd4ec3f 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 b712b8af0e770aa3acbeb1167b1a20bc1547c98a..fdb476a7e470c4b32649d4b3b7e4e44559b5b1c1 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 @@
- #include "content/public/browser/browser_accessibility_state.h"
- #import "content/public/browser/render_widget_host_view_mac_delegate.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"
- @@ -2142,15 +2143,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 23906303cc6470d5bc6b83f79e04ec45781ceea0..40f16697ec17c34bb89b1e160164c228f38c1168 100644
- --- a/content/browser/BUILD.gn
- +++ b/content/browser/BUILD.gn
- @@ -339,6 +339,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 d73737088c819274c854db491a7d4d26f9367eb2..b72427517b88e5cb4179dbc551f3f4f321fd8b4e 100644
- --- a/content/browser/renderer_host/render_widget_host_view_mac.h
- +++ b/content/browser/renderer_host/render_widget_host_view_mac.h
- @@ -24,6 +24,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/mojom/webshare/webshare.mojom.h"
- @@ -54,7 +55,9 @@ class CursorManager;
-
- @protocol RenderWidgetHostViewMacDelegate;
-
- +#if !IS_MAS_BUILD()
- @class NSAccessibilityRemoteUIElement;
- +#endif
- @class RenderWidgetHostViewCocoa;
-
- namespace content {
- @@ -691,9 +694,11 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
- // EnsureSurfaceSynchronizedForWebTest().
- uint32_t latest_capture_sequence_number_ = 0u;
-
- +#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
-
- // Used to force the NSApplication's focused accessibility element to be the
- // content::BrowserAccessibilityCocoa accessibility tree when the NSView for
- 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 e8c48002df717501128b9a135d5662dfca044e9c..71db145609652dbbe733dbc96d2630b686f6c8c9 100644
- --- a/content/browser/renderer_host/render_widget_host_view_mac.mm
- +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
- @@ -49,6 +49,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"
- @@ -274,8 +275,10 @@
- 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.
- @@ -1626,8 +1629,10 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
-
- gfx::NativeViewAccessible
- RenderWidgetHostViewMac::AccessibilityGetNativeViewAccessibleForWindow() {
- +#if !IS_MAS_BUILD()
- if (remote_window_accessible_)
- return remote_window_accessible_;
- +#endif
- return [GetInProcessNSView() window];
- }
-
- @@ -1676,9 +1681,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(
- @@ -2205,20 +2212,26 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
- void RenderWidgetHostViewMac::GetRenderWidgetAccessibilityToken(
- GetRenderWidgetAccessibilityTokenCallback callback) {
- base::ProcessId pid = getpid();
- +#if !IS_MAS_BUILD()
- id element_id = GetNativeViewAccessible();
- 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 fb23dfd8f90ad3eeb55e4db373ca67f75d8e5ce1..df902b0b01ed4d092070a92fdf77cf69fde475e7 100644
- --- a/content/common/BUILD.gn
- +++ b/content/common/BUILD.gn
- @@ -283,6 +283,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 dcb22228bcc86d081c9d0a0a7bdeab896ed07ca7..3e863d861c22e044099e227346845bb6422e21fd 100644
- --- a/content/renderer/BUILD.gn
- +++ b/content/renderer/BUILD.gn
- @@ -331,6 +331,7 @@ target(link_target_type, "renderer") {
- "//ui/surface",
- "//url",
- "//v8",
- + "//electron/build/config:generate_mas_config",
- ]
- allow_circular_includes_from = []
-
- 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 2c5c9ae4e2ba0d20c432d5cf3ec1b816cda0117b..ddcbfff7dffa23bd09843df90b7bdb8e8d9e0f10 100644
- --- a/content/test/BUILD.gn
- +++ b/content/test/BUILD.gn
- @@ -658,6 +658,7 @@ static_library("test_support") {
- "//url",
- "//url/mojom:url_mojom_gurl",
- "//v8",
- + "//electron/build/config:generate_mas_config"
- ]
-
- data_deps = [
- @@ -1111,6 +1112,7 @@ static_library("browsertest_support") {
- }
-
- configs += [ "//v8:external_startup_data" ]
- + deps += ["//electron/build/config:generate_mas_config"]
- }
-
- mojom("content_test_mojo_bindings") {
- @@ -1946,6 +1948,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")) {
- @@ -3262,6 +3265,7 @@ test("content_unittests") {
- "//ui/shell_dialogs:shell_dialogs",
- "//ui/webui:test_support",
- "//url",
- + "//electron/build/config:generate_mas_config"
- ]
-
- if (enable_nocompile_tests) {
- diff --git a/content/web_test/BUILD.gn b/content/web_test/BUILD.gn
- index 8779cf7cbbe2a583fda51867eaebc627f00bd4cd..98da1587fdc8cc8358a69db2b51d39820a0b15f3 100644
- --- a/content/web_test/BUILD.gn
- +++ b/content/web_test/BUILD.gn
- @@ -227,6 +227,7 @@ static_library("web_test_browser") {
- "//ui/gl",
- "//ui/shell_dialogs:shell_dialogs",
- "//url",
- + "//electron/build/config:generate_mas_config"
- ]
-
- # TODO(crbug.com/40139469): Blink test plugin must be migrated from PPAPI.
- diff --git a/device/bluetooth/BUILD.gn b/device/bluetooth/BUILD.gn
- index d27d7140cc55a35e6ffb65028265bcb2ae5932d1..1ea92b29c730aba1c667de83bb98ca85f2046470 100644
- --- a/device/bluetooth/BUILD.gn
- +++ b/device/bluetooth/BUILD.gn
- @@ -253,6 +253,7 @@ component("bluetooth") {
- "IOKit.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 6431af67ab634cf23729b9102c189b2181cfd2cf..22040e1bfb96d810a2d8e62e44e4afbc684c8c06 100644
- --- a/device/bluetooth/bluetooth_adapter_mac.mm
- +++ b/device/bluetooth/bluetooth_adapter_mac.mm
- @@ -38,7 +38,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
- @@ -52,6 +54,7 @@
- // [4] https://support.apple.com/kb/PH25091
- void IOBluetoothPreferenceSetControllerPowerState(int state);
- }
- +#endif
-
- // A simple helper class that forwards any Bluetooth device connect notification
- // to its wrapped |_adapter|.
- @@ -161,8 +164,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)) {
- }
- @@ -313,8 +318,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 973cd337f2781271b4ca3e29db07939ec6917327..90658a336138e4e50f93c38f1c1f465c1c2bd4dc 100644
- --- a/gpu/ipc/service/BUILD.gn
- +++ b/gpu/ipc/service/BUILD.gn
- @@ -135,6 +135,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 93665e7ec19efa8d94fe0bb4f195642f43432c24..23c25ce53e4e630e173777943770a09ee736cc3d 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 87126a36725849cbaf478e2dc24dc3a628a30846..a3a88b07af91b86191d9e5727a1d021ebbbb22ce 100644
- --- a/media/audio/BUILD.gn
- +++ b/media/audio/BUILD.gn
- @@ -196,6 +196,7 @@ source_set("audio") {
- "CoreMedia.framework",
- ]
- weak_frameworks = [ "ScreenCaptureKit.framework" ] # macOS 13.0
- + 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 da17e30384033a795e35d9cd27f16aa1a2b1ad24..f98dc86b19569290d81e7d2a172c1f217a72d00e 100644
- --- a/media/audio/apple/audio_low_latency_input.cc
- +++ b/media/audio/apple/audio_low_latency_input.cc
- @@ -29,6 +29,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 543b8ae16c1ddc33b3602adc7216a1756681f5fe..21b2898f8b1f40a85d60145bfdff3aa1d7e9b154 100644
- --- a/net/dns/BUILD.gn
- +++ b/net/dns/BUILD.gn
- @@ -189,6 +189,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 70d5665ad7b9ef62370497636af919ede2508ad4..f4dc3e2b8053cdb3e8c439ab1a1d6369a8e6a7dc 100644
- --- a/net/dns/dns_config_service_posix.cc
- +++ b/net/dns/dns_config_service_posix.cc
- @@ -28,6 +28,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"
- @@ -135,8 +136,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.";
- @@ -153,6 +154,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 453e2185fc85fcb29fa7af3f94cce5bda8118b0c..1c383675bb9113b5b1df9280b8ee994123794dfc 100644
- --- a/sandbox/mac/BUILD.gn
- +++ b/sandbox/mac/BUILD.gn
- @@ -25,6 +25,7 @@ component("seatbelt") {
- libs = [ "sandbox" ]
- deps = [ ":seatbelt_export" ]
- defines = [ "SEATBELT_IMPLEMENTATION" ]
- + deps += ["//electron/build/config:generate_mas_config"]
- }
-
- component("seatbelt_extension") {
- @@ -38,6 +39,7 @@ component("seatbelt_extension") {
- libs = [ "sandbox" ]
- public_deps = [ "//base" ]
- defines = [ "SEATBELT_IMPLEMENTATION" ]
- + deps += ["//electron/build/config:generate_mas_config"]
- }
-
- component("system_services") {
- @@ -52,6 +54,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 095c639b9893e885d8937e29ed7d47a7c28bc6b6..7e0cf9b9f94b16741358bdb45122f8b2bd68c0f9 100644
- --- a/sandbox/mac/sandbox_logging.cc
- +++ b/sandbox/mac/sandbox_logging.cc
- @@ -16,6 +16,7 @@
- #include <string>
-
- #include "build/build_config.h"
- +#include "electron/mas.h"
- #include "sandbox/mac/sandbox_crash_message.h"
-
- #if defined(ARCH_CPU_X86_64)
- @@ -33,9 +34,11 @@
- }
- #endif
-
- +#if !IS_MAS_BUILD()
- extern "C" {
- void abort_report_np(const char*, ...);
- }
- +#endif
-
- namespace sandbox::logging {
-
- @@ -76,9 +79,11 @@ void SendOsLog(Level level, const char* message) {
- sandbox::crash_message::SetCrashMessage(message);
- }
-
- +#if !IS_MAS_BUILD()
- if (level == Level::FATAL) {
- abort_report_np(message);
- }
- +#endif
- }
-
- // |error| is strerror(errno) when a P* logging function is called. Pass
- diff --git a/sandbox/mac/sandbox_serializer.cc b/sandbox/mac/sandbox_serializer.cc
- index 899f231e9bc8e1c76682972dd3f41d4cc38f4868..1da42104cc82cbabfd0c14fdd7025d6963aa50d6 100644
- --- a/sandbox/mac/sandbox_serializer.cc
- +++ b/sandbox/mac/sandbox_serializer.cc
- @@ -7,6 +7,7 @@
- #include <string>
- #include <vector>
-
- +#include "electron/mas.h"
- #include "sandbox/mac/sandbox_logging.h"
- #include "sandbox/mac/seatbelt.h"
-
- @@ -31,6 +32,7 @@ void EncodeVarInt(uint64_t from, std::string* into) {
- } while (from);
- }
-
- +#if !IS_MAS_BUILD()
- bool DecodeVarInt(std::string_view* from, uint64_t* into) {
- std::string_view::const_iterator it = from->begin();
- int shift = 0;
- @@ -49,12 +51,12 @@ bool DecodeVarInt(std::string_view* from, uint64_t* into) {
- from->remove_prefix(it - from->begin());
- return true;
- }
- -
- +#endif
- void EncodeString(const std::string& value, std::string* into) {
- EncodeVarInt(value.length(), into);
- into->append(value);
- }
- -
- +#if !IS_MAS_BUILD()
- bool DecodeString(std::string_view* slice, std::string* value) {
- uint64_t length;
- if (!DecodeVarInt(slice, &length) || length < 0) {
- @@ -69,7 +71,7 @@ bool DecodeString(std::string_view* slice, std::string* value) {
- slice->remove_prefix(size);
- return true;
- }
- -
- +#endif
- } // namespace
-
- SandboxSerializer::SandboxSerializer(Target mode) : mode_(mode) {
- @@ -140,6 +142,7 @@ bool SandboxSerializer::SerializePolicy(std::string& serialized_policy,
- // static
- bool SandboxSerializer::ApplySerializedPolicy(
- const std::string& serialized_policy) {
- +#if !IS_MAS_BUILD()
- std::string_view policy = serialized_policy;
- uint64_t mode;
- if (!DecodeVarInt(&policy, &mode)) {
- @@ -201,6 +204,9 @@ bool SandboxSerializer::ApplySerializedPolicy(
- }
-
- return true;
- +#else
- + return true;
- +#endif
- }
-
- } // namespace sandbox
- diff --git a/sandbox/mac/seatbelt.cc b/sandbox/mac/seatbelt.cc
- index 1960e1c8771fad615a098af09ff1f9a191f67764..29b97b352d08cd1fe73b17fd80cb41cc7e58dcaa 100644
- --- a/sandbox/mac/seatbelt.cc
- +++ b/sandbox/mac/seatbelt.cc
- @@ -4,12 +4,14 @@
-
- #include "sandbox/mac/seatbelt.h"
-
- +#include "electron/mas.h"
- +
- #include <errno.h>
- #include <unistd.h>
-
- extern "C" {
- #include <sandbox.h>
- -
- +#if !IS_MAS_BUILD()
- int sandbox_init_with_parameters(const char* profile,
- uint64_t flags,
- const char* const parameters[],
- @@ -40,13 +42,13 @@ 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()
- bool HandleSandboxResult(int rv, char* errorbuf, std::string* error) {
- if (rv == 0) {
- if (error)
- @@ -74,36 +76,48 @@ 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
- }
-
- // Initialize the static member variables.
- @@ -114,6 +128,7 @@ const char* Seatbelt::kProfilePureComputation = kSBXProfilePureComputation;
-
- // 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
- @@ -122,6 +137,9 @@ bool Seatbelt::Init(const char* profile, uint64_t flags, std::string* error) {
- int rv = ::sandbox_init(profile, flags, &errorbuf);
- return HandleSandboxResult(rv, errorbuf, error);
- #pragma clang diagnostic pop
- +#else
- + return true;
- +#endif
- }
-
- // static
- @@ -129,16 +147,21 @@ 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, errorbuf, error);
- +#else
- + return true;
- +#endif
- }
-
- // static
- @@ -146,6 +169,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);
- @@ -155,33 +179,44 @@ 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
- void Seatbelt::FreeError(char* errorbuf) {
- +#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
- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
- return ::sandbox_free_error(errorbuf);
- #pragma clang diagnostic pop
- +#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 3ff395b3ff3b646a64c43503d2c172776bf68c84..e40030307e8d9df7e00a402e241e00664b236c7d 100644
- --- a/third_party/blink/renderer/core/BUILD.gn
- +++ b/third_party/blink/renderer/core/BUILD.gn
- @@ -414,6 +414,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/build.gni b/third_party/blink/renderer/core/editing/build.gni
- index d38e951cdbf1ab9b367273ad0fb8f962155a7f3b..e39ee0414cb54004096dbfffc4f768e805f3310a 100644
- --- a/third_party/blink/renderer/core/editing/build.gni
- +++ b/third_party/blink/renderer/core/editing/build.gni
- @@ -358,10 +358,14 @@ blink_core_sources_editing = [
- if (is_mac) {
- blink_core_sources_editing += [
- "commands/smart_replace_cf.cc",
- - "kill_ring_mac.mm",
- "substring_util.h",
- "substring_util.mm",
- ]
- + if (is_mas_build) {
- + blink_core_sources_editing += [ "kill_ring_mac.mm" ]
- + } else {
- + blink_core_sources_editing += [ "kill_ring_none.cc" ]
- + }
- } else {
- blink_core_sources_editing += [ "kill_ring_none.cc" ]
- }
- diff --git a/ui/accelerated_widget_mac/BUILD.gn b/ui/accelerated_widget_mac/BUILD.gn
- index 47e88da13d22b60e27b458f2fd33f10829b31fc0..b32ad8cd5af69c835ecfdbf50329347fb700f9b3 100644
- --- a/ui/accelerated_widget_mac/BUILD.gn
- +++ b/ui/accelerated_widget_mac/BUILD.gn
- @@ -68,6 +68,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 a615405dac100a08234b43f5ec354fb829bb5222..3cf40179700a4d5b69e18993b923f8f14919f9fa 100644
- --- a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h
- +++ b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h
- @@ -7,6 +7,7 @@
-
- #include <queue>
-
- +#include "electron/mas.h"
- #include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h"
- #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h"
- #include "ui/gfx/ca_layer_result.h"
- @@ -14,7 +15,9 @@
- #include "ui/gl/gl_surface.h"
- #include "ui/gl/presenter.h"
-
- +#if !IS_MAS_BUILD()
- @class CAContext;
- +#endif
- @class CALayer;
-
- namespace ui {
- @@ -110,7 +113,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 cfb80b21ada7f04ff615b0437403ac1c6c95bb14..34341007de140aba2e6eeb9d8e8de0ea492c2466 100644
- --- a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
- +++ b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
- @@ -10,6 +10,7 @@
- #include "base/mac/mac_util.h"
- #include "base/task/single_thread_task_runner.h"
- #include "base/trace_event/trace_event.h"
- +#include "electron/mas.h"
- #include "ui/base/cocoa/animation_utils.h"
- #include "ui/base/cocoa/remote_layer_api.h"
- #include "ui/gfx/ca_layer_params.h"
- @@ -30,6 +31,7 @@
- allow_av_sample_buffer_display_layer_(
- allow_av_sample_buffer_display_layer),
- buffer_presented_callback_(buffer_presented_callback) {
- +#if !IS_MAS_BUILD()
- if (allow_remote_layers_) {
- root_ca_layer_ = [[CALayer alloc] init];
- #if BUILDFLAG(IS_MAC)
- @@ -58,6 +60,7 @@
- #endif
- ca_context_.layer = root_ca_layer_;
- }
- +#endif
- }
-
- CALayerTreeCoordinator::~CALayerTreeCoordinator() = default;
- @@ -161,9 +164,13 @@
- TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", TRACE_EVENT_SCOPE_THREAD,
- "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 dcf493d62990018040a3f84b6f875af737bd2214..3d1c4dcc9ee0bbfdac15f40d9c74e9f342a59e39 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/gfx/geometry/dip_util.h"
- @@ -121,6 +122,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;
- @@ -150,6 +152,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 8b25953be73da43fa2e0b5957569ae481dc6a082..7f9175e7eb67ef27fe110ee72f5e9c885018c2ac 100644
- --- a/ui/accessibility/platform/BUILD.gn
- +++ b/ui/accessibility/platform/BUILD.gn
- @@ -288,6 +288,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 444f315852deabbac971165a7de9751a1bb367e3..7aba9f251f869c64d7722558084f209bd5d27075 100644
- --- a/ui/accessibility/platform/browser_accessibility_manager_mac.mm
- +++ b/ui/accessibility/platform/browser_accessibility_manager_mac.mm
- @@ -13,6 +13,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"
- @@ -20,7 +21,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
-
- namespace {
-
- @@ -228,6 +231,7 @@ void PostAnnouncementNotification(NSString* announcement,
- return;
- }
-
- +#if !IS_MAS_BUILD()
- BrowserAccessibilityManager* root_manager = GetManagerForRootFrame();
- if (root_manager) {
- BrowserAccessibilityManagerMac* root_manager_mac =
- @@ -250,6 +254,7 @@ void PostAnnouncementNotification(NSString* announcement,
- return;
- }
- }
- +#endif
-
- // Use native VoiceOver support for live regions.
- BrowserAccessibilityCocoa* retained_node = native_node;
- @@ -662,6 +667,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
- @@ -690,6 +696,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 c8171f0527fe5194f0ea73b57c4444d4c630fbc4..c2ac4da580e3e7f749a0a4de1e859af62de11672 100644
- --- a/ui/accessibility/platform/inspect/ax_transform_mac.mm
- +++ b/ui/accessibility/platform/inspect/ax_transform_mac.mm
- @@ -11,6 +11,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"
- @@ -111,6 +112,7 @@
- }
- }
-
- +#if !IS_MAS_BUILD()
- // AXTextMarker
- if (IsAXTextMarker(value)) {
- return AXTextMarkerToBaseValue(value, indexer);
- @@ -120,6 +122,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 4b91bad93384b435bed2e8da5e185603fb0a66a3..d68202e3fe92d01b148bf494a3599e2a8d8ced91 100644
- --- a/ui/base/BUILD.gn
- +++ b/ui/base/BUILD.gn
- @@ -363,6 +363,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",
- @@ -516,6 +523,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 59dc2f82214cfd883b6ebef3b0fb25af6387a9cd..912c5252d1b30d943a1552739b9eef9a8eae2d7a 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.
- @@ -68,6 +70,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 fc25ba79d2b0e1acdb7ba54b89e7d6e16f94771b..de771ef414b9a69e331261524f08e9a12145ec60 100644
- --- a/ui/base/cocoa/remote_layer_api.mm
- +++ b/ui/base/cocoa/remote_layer_api.mm
- @@ -5,11 +5,13 @@
- #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.
- @@ -17,8 +19,10 @@
- "RemoteCoreAnimationAPI",
- base::FEATURE_ENABLED_BY_DEFAULT);
- } // namespace
- +#endif
-
- bool RemoteLayerAPISupported() {
- +#if !IS_MAS_BUILD()
- if (!base::FeatureList::IsEnabled(kRemoteCoreAnimationAPI))
- return false;
-
- @@ -55,6 +59,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 eea9eb92fadfcb72adfffffb0e43082a79bcf3a7..dd2110c1e9393f7ad33a0e64c09ef732b3292a54 100644
- --- a/ui/display/BUILD.gn
- +++ b/ui/display/BUILD.gn
- @@ -125,6 +125,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/screen_mac.mm b/ui/display/mac/screen_mac.mm
- index 29ae2da6a8a2c2a612dfb92f7f9c03ca5fa306b1..440c139a32a0c205e77b657d4aab64684661a01d 100644
- --- a/ui/display/mac/screen_mac.mm
- +++ b/ui/display/mac/screen_mac.mm
- @@ -30,6 +30,7 @@
- #include "base/trace_event/trace_event.h"
- #include "build/build_config.h"
- #include "components/device_event_log/device_event_log.h"
- +#include "electron/mas.h"
- #include "ui/display/display.h"
- #include "ui/display/display_change_notifier.h"
- #include "ui/display/util/display_util.h"
- @@ -176,7 +177,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.
- if (@available(macos 12.0, *)) {
- diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn
- index cb507971bef962e91cd8fca696692194696d1142..d2aee3962e3377980940e6d3538487a566a609b4 100644
- --- a/ui/gfx/BUILD.gn
- +++ b/ui/gfx/BUILD.gn
- @@ -334,6 +334,12 @@ component("gfx") {
- "//ui/base:ui_data_pack",
- ]
-
- + if (is_mac) {
- + deps += [
- + "//electron/build/config:generate_mas_config"
- + ]
- + }
- +
- if (!is_apple) {
- sources += [
- "platform_font_skia.cc",
- diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm
- index fe3f85073e31de487a08e57d7f9b07aa4eccf8f3..cf5b07203c8bd559a404600cc98cc8eccdefd4d7 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 0f9f25edf65eaee5191ac1f6b70bd43a25091578..e6cce5c607e437c8a9d0fe43eb472a125fdae0eb 100644
- --- a/ui/views/BUILD.gn
- +++ b/ui/views/BUILD.gn
- @@ -720,6 +720,8 @@ component("views") {
- "IOSurface.framework",
- "QuartzCore.framework",
- ]
- +
- + deps += ["//electron/build/config:generate_mas_config"]
- }
-
- if (is_win) {
- @@ -1142,6 +1144,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 6a18c94e8c9d531ab3a59faf6027848caed8de57..63aa6b3ba824a3fa71c5a3db94b9ac5e8d0ea7c0 100644
- --- a/ui/views/cocoa/native_widget_mac_ns_window_host.h
- +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.h
- @@ -18,6 +18,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"
- @@ -33,7 +34,9 @@
- #include "ui/views/window/dialog_observer.h"
-
- @class NativeWidgetMacNSWindow;
- +#if !IS_MAS_BUILD()
- @class NSAccessibilityRemoteUIElement;
- +#endif
- @class NSView;
-
- namespace remote_cocoa {
- @@ -487,10 +490,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 7e5047fabe59fb2773f13836145cfce64bc1a135..fed3d6a70139443d76ce6181df69bb490c46a081 100644
- --- a/ui/views/cocoa/native_widget_mac_ns_window_host.mm
- +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
- @@ -21,6 +21,7 @@
- #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
- #include "components/remote_cocoa/browser/ns_view_ids.h"
- #include "components/remote_cocoa/browser/window.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"
- @@ -352,7 +353,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
- if (in_process_ns_window_bridge_) {
- return in_process_ns_window_bridge_->ns_view();
- }
- +#if !IS_MAS_BUILD()
- return remote_view_accessible_;
- +#else
- + return nullptr;
- +#endif
- }
-
- gfx::NativeViewAccessible
- @@ -367,7 +372,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
- return [in_process_ns_window_bridge_->ns_view() window];
- }
-
- +#if !IS_MAS_BUILD()
- return remote_window_accessible_;
- +#else
- + return nullptr;
- +#endif
- }
-
- remote_cocoa::mojom::NativeWidgetNSWindow*
- @@ -1371,9 +1380,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) {
- @@ -1514,17 +1525,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();
-
- @@ -1537,6 +1551,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 111d6432586f47833dde50678b908c76ad88d37a..429ca4402652a2d89ead228d92971f0cb3b6222c 100644
- --- a/ui/views/controls/webview/BUILD.gn
- +++ b/ui/views/controls/webview/BUILD.gn
- @@ -46,6 +46,12 @@ component("webview") {
- "//url",
- ]
-
- + if (is_mac) {
- + deps += [
- + "//electron/build/config:generate_mas_config",
- + ]
- + }
- +
- public_deps = [
- "//base",
- "//content/public/browser",
|