mas_avoid_private_macos_api_usage.patch.patch 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Samuel Attard <[email protected]>
  3. Date: Thu, 20 Sep 2018 17:48:49 -0700
  4. Subject: mas: avoid private macOS API usage
  5. * Use the stub killring file when building blink
  6. * Remove usage of the following private APIs
  7. * abort_report_np
  8. * pthread_fchdir_np
  9. * pthread_chdir_np
  10. * SetApplicationIsDaemon
  11. * _LSSetApplicationLaunchServicesServerConnectionStatus
  12. * AreDeviceAndUserJoinedToDomain
  13. * _CFIsObjC
  14. * AudioDeviceDuck
  15. * NSNextStepFrame
  16. * NSThemeFrame
  17. * NSTextInputReplacementRangeAttributeName
  18. * NSAccessibilityRemoteUIElement is unnecessary for Electron's use-case. We use it
  19. for progressive web apps (where the AXTree is in the browser process, but macOS
  20. needs to think it's coming from the PWA process). I think it can just be chopped
  21. out -- if there are any side-effects, we should be able to work around them.
  22. * CAContext removal
  23. * For apps that spend a lot of time watching video (especially fullscreen video),
  24. the power/battery usage will likely increase 1.5x to 2x. For something that is,
  25. e.g, scrolling, it'll be smaller, more like 1.15x or 1.25x.
  26. In terms of performance, the impact will likely be fairly small -- any app that
  27. could hit 60fps before will likely still be able to hit 60fps. There may even be
  28. cases where performance improves when disabling remote CoreAnimation (remote
  29. CoreAnimation is really only about battery usage).
  30. * CTFontDescriptorIsSystemUIFont is a private API, we're using an
  31. _interesting_ technique in the MAS build to determine if the font is a
  32. system font by checking if it's kCTFontPriorityAttribute is set to
  33. system priority.
  34. diff --git a/base/BUILD.gn b/base/BUILD.gn
  35. index 39f6bfe3cab60ea9576e7760bfc6693408d1a4b9..24ef8a380ca12f36fade75c51e4849d0915a2a3d 100644
  36. --- a/base/BUILD.gn
  37. +++ b/base/BUILD.gn
  38. @@ -1041,6 +1041,7 @@ component("base") {
  39. "//build:ios_buildflags",
  40. "//build/config/compiler:compiler_buildflags",
  41. "//third_party/modp_b64",
  42. + "//electron/build/config:generate_mas_config",
  43. ]
  44. if (!is_nacl) {
  45. # Used by metrics/crc32, except on NaCl builds.
  46. diff --git a/base/enterprise_util_mac.mm b/base/enterprise_util_mac.mm
  47. index 4bf9a3c27e05c6635b2beb8e880b5b43dbed61b5..f328fbb49c45991f44a9c75325491d0873746b61 100644
  48. --- a/base/enterprise_util_mac.mm
  49. +++ b/base/enterprise_util_mac.mm
  50. @@ -16,6 +16,7 @@
  51. #include "base/strings/string_split.h"
  52. #include "base/strings/string_util.h"
  53. #include "base/strings/sys_string_conversions.h"
  54. +#include "electron/mas.h"
  55. namespace base {
  56. @@ -116,6 +117,14 @@ DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain() {
  57. DeviceUserDomainJoinState state{.device_joined = false,
  58. .user_joined = false};
  59. +#if IS_MAS_BUILD()
  60. + return state;
  61. + }();
  62. +
  63. + return state;
  64. +}
  65. +#else
  66. +
  67. @autoreleasepool {
  68. ODSession* session = [ODSession defaultSession];
  69. if (session == nil) {
  70. @@ -219,5 +228,6 @@ DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain() {
  71. return state;
  72. }
  73. +#endif
  74. } // namespace base
  75. diff --git a/base/process/launch_mac.cc b/base/process/launch_mac.cc
  76. index 569c1c83d82517d9cb65282f766368ce3d9d0572..8114bf8e9a9d002824b3804bff599591eacaba37 100644
  77. --- a/base/process/launch_mac.cc
  78. +++ b/base/process/launch_mac.cc
  79. @@ -21,13 +21,19 @@
  80. #include "base/threading/scoped_blocking_call.h"
  81. #include "base/threading/thread_restrictions.h"
  82. #include "base/trace_event/base_tracing.h"
  83. +#include "electron/mas.h"
  84. +#if IS_MAS_BUILD()
  85. +#include <sys/syscall.h>
  86. +#endif
  87. extern "C" {
  88. // Changes the current thread's directory to a path or directory file
  89. // descriptor.
  90. +#if !IS_MAS_BUILD()
  91. int pthread_chdir_np(const char* dir);
  92. int pthread_fchdir_np(int fd);
  93. +#endif
  94. int responsibility_spawnattrs_setdisclaim(posix_spawnattr_t attrs,
  95. int disclaim);
  96. @@ -104,13 +110,27 @@ class PosixSpawnFileActions {
  97. #if !BUILDFLAG(IS_MAC)
  98. int ChangeCurrentThreadDirectory(const char* path) {
  99. +#if IS_MAS_BUILD()
  100. + #pragma clang diagnostic push
  101. + #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  102. + return syscall(SYS___pthread_chdir, path);
  103. + #pragma clang diagnostic pop
  104. +#else
  105. return pthread_chdir_np(path);
  106. +#endif
  107. }
  108. // The recommended way to unset a per-thread cwd is to set a new value to an
  109. // invalid file descriptor, per libpthread-218.1.3/private/private.h.
  110. int ResetCurrentThreadDirectory() {
  111. +#if IS_MAS_BUILD()
  112. + #pragma clang diagnostic push
  113. + #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  114. + return syscall(SYS___pthread_fchdir, -1);
  115. + #pragma clang diagnostic pop
  116. +#else
  117. return pthread_fchdir_np(-1);
  118. +#endif
  119. }
  120. #endif
  121. @@ -234,7 +254,7 @@ Process LaunchProcess(const std::vector<std::string>& argv,
  122. file_actions.Inherit(STDERR_FILENO);
  123. }
  124. -#if BUILDFLAG(IS_MAC)
  125. +#if 0
  126. if (options.disclaim_responsibility) {
  127. DPSXCHECK(responsibility_spawnattrs_setdisclaim(attr.get(), 1));
  128. }
  129. diff --git a/base/process/process_info_mac.cc b/base/process/process_info_mac.cc
  130. index 94a028be3c315edc0056408ab9ab41b6b001a1c1..abf9003bc71506d389ff77dc708c897113bba412 100644
  131. --- a/base/process/process_info_mac.cc
  132. +++ b/base/process/process_info_mac.cc
  133. @@ -4,19 +4,27 @@
  134. #include "base/process/process_info.h"
  135. +#include "electron/mas.h"
  136. +
  137. #include <stdio.h>
  138. #include <stdlib.h>
  139. #include <unistd.h>
  140. +#if !IS_MAS_BUILD()
  141. extern "C" {
  142. pid_t responsibility_get_pid_responsible_for_pid(pid_t);
  143. }
  144. +#endif
  145. namespace base {
  146. bool IsProcessSelfResponsible() {
  147. +#if !IS_MAS_BUILD()
  148. const pid_t pid = getpid();
  149. return responsibility_get_pid_responsible_for_pid(pid) == pid;
  150. +#else
  151. + return true;
  152. +#endif
  153. }
  154. } // namespace base
  155. diff --git a/components/os_crypt/sync/BUILD.gn b/components/os_crypt/sync/BUILD.gn
  156. index 3b81e00e1535ec729a521b83fe2471985d177e5c..094f52fd80bd91be4e705a457d12ea89271dc037 100644
  157. --- a/components/os_crypt/sync/BUILD.gn
  158. +++ b/components/os_crypt/sync/BUILD.gn
  159. @@ -46,6 +46,7 @@ component("os_crypt") {
  160. "os_crypt_mac.mm",
  161. ]
  162. deps += [ "//crypto:mock_apple_keychain" ]
  163. + deps += ["//electron/build/config:generate_mas_config"]
  164. }
  165. if (is_win) {
  166. diff --git a/components/os_crypt/sync/keychain_password_mac.mm b/components/os_crypt/sync/keychain_password_mac.mm
  167. index e7a65e97b51d93bff864889813317fb7c6ffc846..bb1fc0c99164ae4bdaaaa78e87c30e88932a928c 100644
  168. --- a/components/os_crypt/sync/keychain_password_mac.mm
  169. +++ b/components/os_crypt/sync/keychain_password_mac.mm
  170. @@ -13,6 +13,7 @@
  171. #include "base/rand_util.h"
  172. #include "build/branding_buildflags.h"
  173. #include "crypto/apple_keychain.h"
  174. +#include "electron/mas.h"
  175. using crypto::AppleKeychain;
  176. diff --git a/components/remote_cocoa/app_shim/BUILD.gn b/components/remote_cocoa/app_shim/BUILD.gn
  177. index b7a2dede5c5e9a797d10627b7d804064bf13b3f4..df0a36405396372aad2affe602e41b5923b80322 100644
  178. --- a/components/remote_cocoa/app_shim/BUILD.gn
  179. +++ b/components/remote_cocoa/app_shim/BUILD.gn
  180. @@ -87,6 +87,7 @@ component("app_shim") {
  181. "//ui/gfx",
  182. "//ui/gfx/geometry",
  183. "//ui/strings:ui_strings_grit",
  184. + "//electron/build/config:generate_mas_config",
  185. ]
  186. frameworks = [
  187. "Cocoa.framework",
  188. diff --git a/components/remote_cocoa/app_shim/application_bridge.mm b/components/remote_cocoa/app_shim/application_bridge.mm
  189. index e9f4e5131238b9fb5f1b4b3e90a0cb84a7fc15b4..8b5f4cae3123ac5480ad73f0c873fca0d62f7c9f 100644
  190. --- a/components/remote_cocoa/app_shim/application_bridge.mm
  191. +++ b/components/remote_cocoa/app_shim/application_bridge.mm
  192. @@ -12,6 +12,7 @@
  193. #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
  194. #include "components/remote_cocoa/app_shim/native_widget_ns_window_host_helper.h"
  195. #include "components/system_media_controls/mac/remote_cocoa/system_media_controls_bridge.h"
  196. +#include "electron/mas.h"
  197. #include "mojo/public/cpp/bindings/associated_remote.h"
  198. #include "mojo/public/cpp/bindings/self_owned_receiver.h"
  199. #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
  200. @@ -51,6 +52,7 @@
  201. // NativeWidgetNSWindowHostHelper:
  202. id GetNativeViewAccessible() override {
  203. +#if !IS_MAS_BUILD()
  204. if (!remote_accessibility_element_) {
  205. base::ProcessId browser_pid = base::kNullProcessId;
  206. std::vector<uint8_t> element_token;
  207. @@ -61,6 +63,9 @@ id GetNativeViewAccessible() override {
  208. ui::RemoteAccessibility::GetRemoteElementFromToken(element_token);
  209. }
  210. return remote_accessibility_element_;
  211. +#else
  212. + return nil;
  213. +#endif
  214. }
  215. void DispatchKeyEvent(ui::KeyEvent* event) override {
  216. bool event_handled = false;
  217. @@ -99,7 +104,9 @@ void GetWordAt(const gfx::Point& location_in_content,
  218. mojo::AssociatedRemote<mojom::TextInputHost> text_input_host_remote_;
  219. std::unique_ptr<NativeWidgetNSWindowBridge> bridge_;
  220. +#if !IS_MAS_BUILD()
  221. NSAccessibilityRemoteUIElement* __strong remote_accessibility_element_;
  222. +#endif
  223. };
  224. } // namespace
  225. 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
  226. index 53553a707a646012c50b0bd2d0ffd8d4dbd67e11..e306511e15fd2a522748c3f90c78aab8dde4238e 100644
  227. --- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  228. +++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  229. @@ -8,7 +8,9 @@
  230. #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
  231. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  232. +#include "electron/mas.h"
  233. +#if !IS_MAS_BUILD()
  234. @interface NSWindow (PrivateBrowserNativeWidgetAPI)
  235. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  236. @end
  237. @@ -65,10 +67,13 @@ - (BOOL)_shouldCenterTrafficLights {
  238. @end
  239. +#endif // MAS_BUILD
  240. +
  241. @implementation BrowserNativeWidgetWindow
  242. // NSWindow (PrivateAPI) overrides.
  243. +#if !IS_MAS_BUILD()
  244. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  245. // - NSThemeFrame and its subclasses will be nil if it's missing at runtime.
  246. if ([BrowserWindowFrame class])
  247. @@ -115,6 +120,8 @@ - (BOOL)_usesCustomDrawing {
  248. return NO;
  249. }
  250. +#endif // MAS_BUILD
  251. +
  252. // Handle "Move focus to the window toolbar" configured in System Preferences ->
  253. // Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|)
  254. // tends to just be nil.
  255. 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
  256. index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..149de0175c2ec0e41e3ba40caad7019ca87386d6 100644
  257. --- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  258. +++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  259. @@ -4,6 +4,10 @@
  260. #import "components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.h"
  261. +#include "electron/mas.h"
  262. +
  263. +#if !IS_MAS_BUILD()
  264. +
  265. @interface NSWindow (PrivateAPI)
  266. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  267. @end
  268. @@ -18,8 +22,12 @@ - (CGFloat)_titlebarHeight {
  269. }
  270. @end
  271. +#endif // MAS_BUILD
  272. +
  273. @implementation NativeWidgetMacFramelessNSWindow
  274. +#if !IS_MAS_BUILD()
  275. +
  276. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  277. if ([NativeWidgetMacFramelessNSWindowFrame class]) {
  278. return [NativeWidgetMacFramelessNSWindowFrame class];
  279. @@ -27,4 +35,6 @@ + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  280. return [super frameViewClassForStyleMask:windowStyle];
  281. }
  282. +#endif // MAS_BUILD
  283. +
  284. @end
  285. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  286. index 945b01f2132547fa0f6a97ee4895994c500d1410..864f93f7c4159abc63e1535195fbf9d112558b91 100644
  287. --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  288. +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  289. @@ -9,6 +9,7 @@
  290. #include "base/apple/foundation_util.h"
  291. #include "components/remote_cocoa/app_shim/remote_cocoa_app_shim_export.h"
  292. +#include "electron/mas.h"
  293. #import "ui/base/cocoa/command_dispatcher.h"
  294. namespace remote_cocoa {
  295. @@ -17,6 +18,7 @@ class NativeWidgetNSWindowBridge;
  296. @protocol WindowTouchBarDelegate;
  297. +#if !IS_MAS_BUILD()
  298. // Weak lets Chrome launch even if a future macOS doesn't have the below classes
  299. WEAK_IMPORT_ATTRIBUTE
  300. @interface NSNextStepFrame : NSView
  301. @@ -33,6 +35,7 @@ REMOTE_COCOA_APP_SHIM_EXPORT
  302. REMOTE_COCOA_APP_SHIM_EXPORT
  303. @interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame
  304. @end
  305. +#endif
  306. // The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that
  307. // can only be accomplished by overriding methods.
  308. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  309. index 2aa2bd8d68c08359461254875f02fc37f8693058..5d5584d22ead9730876fae2fc3971982ae7f61bb 100644
  310. --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  311. +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  312. @@ -26,6 +26,7 @@
  313. #import "components/remote_cocoa/app_shim/views_nswindow_delegate.h"
  314. #import "components/remote_cocoa/app_shim/window_touch_bar_delegate.h"
  315. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  316. +#include "electron/mas.h"
  317. #import "ui/base/cocoa/user_interface_item_command_handler.h"
  318. #import "ui/base/cocoa/window_size_constants.h"
  319. @@ -111,14 +112,18 @@ void OrderChildWindow(NSWindow* child_window,
  320. } // namespace
  321. +#if !IS_MAS_BUILD()
  322. @interface NSNextStepFrame (Private)
  323. - (instancetype)initWithFrame:(NSRect)frame
  324. styleMask:(NSUInteger)styleMask
  325. owner:(id)owner;
  326. @end
  327. +#endif
  328. @interface NSWindow (Private)
  329. +#if !IS_MAS_BUILD()
  330. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
  331. +#endif
  332. - (BOOL)hasKeyAppearance;
  333. - (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
  334. - (BOOL)_isConsideredOpenForPersistentState;
  335. @@ -157,6 +162,8 @@ - (void)cr_mouseDownOnFrameView:(NSEvent*)event {
  336. }
  337. @end
  338. +#if !IS_MAS_BUILD()
  339. +
  340. @implementation NativeWidgetMacNSWindowTitledFrame
  341. - (void)mouseDown:(NSEvent*)event {
  342. if (self.window.isMovable)
  343. @@ -184,6 +191,8 @@ - (BOOL)usesCustomDrawing {
  344. }
  345. @end
  346. +#endif // MAS_BUILD
  347. +
  348. @implementation NativeWidgetMacNSWindow {
  349. @private
  350. CommandDispatcher* __strong _commandDispatcher;
  351. @@ -374,6 +383,8 @@ - (NSAccessibilityRole)accessibilityRole {
  352. // NSWindow overrides.
  353. +#if !IS_MAS_BUILD()
  354. +
  355. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
  356. if (windowStyle & NSWindowStyleMaskTitled) {
  357. if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
  358. @@ -385,6 +396,8 @@ + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
  359. return [super frameViewClassForStyleMask:windowStyle];
  360. }
  361. +#endif
  362. +
  363. - (BOOL)_isTitleHidden {
  364. bool shouldShowWindowTitle = YES;
  365. if (_bridge)
  366. 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
  367. index 285a406e8cec06bf3beeca81b32e6561528279f9..a82a3653253b8a362d6ae3be41cbaaa017f757ca 100644
  368. --- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
  369. +++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
  370. @@ -41,6 +41,7 @@
  371. #import "components/remote_cocoa/app_shim/views_nswindow_delegate.h"
  372. #import "components/remote_cocoa/app_shim/window_move_loop.h"
  373. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  374. +#include "electron/mas.h"
  375. #include "mojo/public/cpp/bindings/self_owned_receiver.h"
  376. #include "net/cert/x509_util_apple.h"
  377. #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
  378. @@ -643,10 +644,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
  379. // this should be treated as an error and caught early.
  380. CHECK(bridged_view_);
  381. +#if !IS_MAS_BUILD()
  382. // Send the accessibility tokens for the NSView now that it exists.
  383. host_->SetRemoteAccessibilityTokens(
  384. ui::RemoteAccessibility::GetTokenForLocalElement(window_),
  385. ui::RemoteAccessibility::GetTokenForLocalElement(bridged_view_));
  386. +#endif
  387. // Beware: This view was briefly removed (in favor of a bare CALayer) in
  388. // https://crrev.com/c/1236675. The ordering of unassociated layers relative
  389. diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn
  390. index 853a95c65674b1011898c64445024bdc30c9709b..2f36496cf77258fe7e7b5eb7c93c6c53ff55abd0 100644
  391. --- a/components/viz/service/BUILD.gn
  392. +++ b/components/viz/service/BUILD.gn
  393. @@ -371,6 +371,7 @@ viz_component("service") {
  394. "frame_sinks/external_begin_frame_source_mac.h",
  395. ]
  396. }
  397. + deps += ["//electron/build/config:generate_mas_config"]
  398. }
  399. if (is_android || use_ozone) {
  400. @@ -645,6 +646,7 @@ viz_source_set("unit_tests") {
  401. "display_embedder/software_output_device_mac_unittest.mm",
  402. ]
  403. frameworks = [ "IOSurface.framework" ]
  404. + deps += ["//electron/build/config:generate_mas_config"]
  405. }
  406. if (is_win) {
  407. 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
  408. index dbf334caa3a6d10017b69ad76802e389a011436b..da828823e8195cc9e497866363c9af93dcd4ec3f 100644
  409. --- a/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
  410. +++ b/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
  411. @@ -15,6 +15,7 @@
  412. #include "content/common/web_contents_ns_view_bridge.mojom.h"
  413. #include "content/public/browser/remote_cocoa.h"
  414. #include "content/public/browser/render_widget_host_view_mac_delegate.h"
  415. +#include "electron/mas.h"
  416. #include "mojo/public/cpp/bindings/associated_receiver.h"
  417. #include "mojo/public/cpp/bindings/associated_remote.h"
  418. #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
  419. @@ -63,7 +64,9 @@ explicit RenderWidgetHostNSViewBridgeOwner(
  420. const RenderWidgetHostNSViewBridgeOwner&) = delete;
  421. private:
  422. +#if !IS_MAS_BUILD()
  423. NSAccessibilityRemoteUIElement* __strong remote_accessibility_element_;
  424. +#endif
  425. void OnMojoDisconnect() { delete this; }
  426. std::unique_ptr<blink::WebCoalescedInputEvent> TranslateEvent(
  427. @@ -75,6 +78,7 @@ explicit RenderWidgetHostNSViewBridgeOwner(
  428. }
  429. id GetAccessibilityElement() override {
  430. +#if !IS_MAS_BUILD()
  431. if (!remote_accessibility_element_) {
  432. base::ProcessId browser_pid = base::kNullProcessId;
  433. std::vector<uint8_t> element_token;
  434. @@ -85,6 +89,9 @@ id GetAccessibilityElement() override {
  435. ui::RemoteAccessibility::GetRemoteElementFromToken(element_token);
  436. }
  437. return remote_accessibility_element_;
  438. +#else
  439. + return nil;
  440. +#endif
  441. }
  442. // RenderWidgetHostNSViewHostHelper implementation.
  443. @@ -103,8 +110,10 @@ id GetFocusedBrowserAccessibilityElement() override {
  444. return [bridgedContentView accessibilityFocusedUIElement];
  445. }
  446. void SetAccessibilityWindow(NSWindow* window) override {
  447. +#if !IS_MAS_BUILD()
  448. host_->SetRemoteAccessibilityWindowToken(
  449. ui::RemoteAccessibility::GetTokenForLocalElement(window));
  450. +#endif
  451. }
  452. void ForwardKeyboardEvent(const input::NativeWebKeyboardEvent& key_event,
  453. 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
  454. index 7b306925815201084a92db192d623b7d2f4d2691..348b538f286443b08bc979feaaa47a41c469cd4b 100644
  455. --- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
  456. +++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
  457. @@ -35,6 +35,7 @@
  458. #include "content/public/browser/browser_accessibility_state.h"
  459. #import "content/public/browser/render_widget_host_view_mac_delegate.h"
  460. #include "content/public/common/content_features.h"
  461. +#include "electron/mas.h"
  462. #include "skia/ext/skia_utils_mac.h"
  463. #include "third_party/blink/public/common/features.h"
  464. #include "third_party/blink/public/mojom/input/input_handler.mojom.h"
  465. @@ -2062,15 +2063,21 @@ - (NSAccessibilityRole)accessibilityRole {
  466. // Since this implementation doesn't have to wait any IPC calls, this doesn't
  467. // make any key-typing jank. --hbono 7/23/09
  468. //
  469. +#if !IS_MAS_BUILD()
  470. extern "C" {
  471. extern NSString* NSTextInputReplacementRangeAttributeName;
  472. }
  473. +#endif
  474. - (NSArray*)validAttributesForMarkedText {
  475. // This code is just copied from WebKit except renaming variables.
  476. static NSArray* const kAttributes = @[
  477. NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
  478. +#if !IS_MAS_BUILD()
  479. NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName
  480. +#else
  481. + NSMarkedClauseSegmentAttributeName
  482. +#endif
  483. ];
  484. return kAttributes;
  485. }
  486. diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
  487. index aa9fefa344107d0d088668dd2e004be1e9fc8df1..015bc46e90a0e14e33d4ea65c37767a7f8d5681c 100644
  488. --- a/content/browser/BUILD.gn
  489. +++ b/content/browser/BUILD.gn
  490. @@ -319,6 +319,7 @@ source_set("browser") {
  491. "//ui/strings:ax_strings",
  492. "//ui/touch_selection",
  493. "//v8:v8_version",
  494. + "//electron/build/config:generate_mas_config",
  495. ]
  496. public_deps = [
  497. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h
  498. index 2285564db47ef15eb9a83affd1e481b5671c3940..cf5e79a5540d8208c34579d7e8b5a5715abb1beb 100644
  499. --- a/content/browser/renderer_host/render_widget_host_view_mac.h
  500. +++ b/content/browser/renderer_host/render_widget_host_view_mac.h
  501. @@ -23,6 +23,7 @@
  502. #include "content/browser/renderer_host/text_input_manager.h"
  503. #include "content/common/content_export.h"
  504. #include "content/common/render_widget_host_ns_view.mojom.h"
  505. +#include "electron/mas.h"
  506. #include "mojo/public/cpp/bindings/associated_receiver.h"
  507. #include "mojo/public/cpp/bindings/associated_remote.h"
  508. #include "third_party/blink/public/mojom/webshare/webshare.mojom.h"
  509. @@ -53,7 +54,9 @@ class CursorManager;
  510. @protocol RenderWidgetHostViewMacDelegate;
  511. +#if !IS_MAS_BUILD()
  512. @class NSAccessibilityRemoteUIElement;
  513. +#endif
  514. @class RenderWidgetHostViewCocoa;
  515. namespace content {
  516. @@ -684,9 +687,11 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
  517. // EnsureSurfaceSynchronizedForWebTest().
  518. uint32_t latest_capture_sequence_number_ = 0u;
  519. +#if !IS_MAS_BUILD()
  520. // Remote accessibility objects corresponding to the NSWindow that this is
  521. // displayed to the user in.
  522. NSAccessibilityRemoteUIElement* __strong remote_window_accessible_;
  523. +#endif
  524. // Used to force the NSApplication's focused accessibility element to be the
  525. // content::BrowserAccessibilityCocoa accessibility tree when the NSView for
  526. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
  527. index 4a6a4da32e4effbad8bff85220edf0b34685f274..e3c4075e4aa4a2bf854f5308f25775bd10ce32dc 100644
  528. --- a/content/browser/renderer_host/render_widget_host_view_mac.mm
  529. +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
  530. @@ -48,6 +48,7 @@
  531. #include "content/public/browser/render_widget_host.h"
  532. #include "content/public/browser/web_contents.h"
  533. #include "content/public/common/page_visibility_state.h"
  534. +#include "electron/mas.h"
  535. #include "media/base/media_switches.h"
  536. #include "skia/ext/platform_canvas.h"
  537. #include "skia/ext/skia_utils_mac.h"
  538. @@ -273,8 +274,10 @@
  539. void RenderWidgetHostViewMac::MigrateNSViewBridge(
  540. remote_cocoa::mojom::Application* remote_cocoa_application,
  541. uint64_t parent_ns_view_id) {
  542. +#if !IS_MAS_BUILD()
  543. // Destroy the previous remote accessibility element.
  544. remote_window_accessible_ = nil;
  545. +#endif
  546. // Reset `ns_view_` before resetting `remote_ns_view_` to avoid dangling
  547. // pointers. `ns_view_` gets reinitialized later in this method.
  548. @@ -1639,8 +1642,10 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
  549. gfx::NativeViewAccessible
  550. RenderWidgetHostViewMac::AccessibilityGetNativeViewAccessibleForWindow() {
  551. +#if !IS_MAS_BUILD()
  552. if (remote_window_accessible_)
  553. return remote_window_accessible_;
  554. +#endif
  555. return [GetInProcessNSView() window];
  556. }
  557. @@ -1689,9 +1694,11 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
  558. }
  559. void RenderWidgetHostViewMac::SetAccessibilityWindow(NSWindow* window) {
  560. +#if !IS_MAS_BUILD()
  561. // When running in-process, just use the NSView's NSWindow as its own
  562. // accessibility element.
  563. remote_window_accessible_ = nil;
  564. +#endif
  565. }
  566. bool RenderWidgetHostViewMac::SyncIsWidgetForMainFrame(
  567. @@ -2215,20 +2222,26 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
  568. void RenderWidgetHostViewMac::GetRenderWidgetAccessibilityToken(
  569. GetRenderWidgetAccessibilityTokenCallback callback) {
  570. base::ProcessId pid = getpid();
  571. +#if !IS_MAS_BUILD()
  572. id element_id = GetNativeViewAccessible();
  573. std::vector<uint8_t> token =
  574. ui::RemoteAccessibility::GetTokenForLocalElement(element_id);
  575. std::move(callback).Run(pid, token);
  576. +#else
  577. + std::move(callback).Run(pid, std::vector<uint8_t>());
  578. +#endif
  579. }
  580. void RenderWidgetHostViewMac::SetRemoteAccessibilityWindowToken(
  581. const std::vector<uint8_t>& window_token) {
  582. +#if !IS_MAS_BUILD()
  583. if (window_token.empty()) {
  584. remote_window_accessible_ = nil;
  585. } else {
  586. remote_window_accessible_ =
  587. ui::RemoteAccessibility::GetRemoteElementFromToken(window_token);
  588. }
  589. +#endif
  590. }
  591. ///////////////////////////////////////////////////////////////////////////////
  592. diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn
  593. index 9f48c905f4abbb0f2e184299a915232cf6a0f6b0..83e1af29e9b035e54b447941d55b95eb960219f1 100644
  594. --- a/content/common/BUILD.gn
  595. +++ b/content/common/BUILD.gn
  596. @@ -287,6 +287,7 @@ source_set("common") {
  597. "//ui/shell_dialogs",
  598. "//url",
  599. "//url/ipc:url_ipc",
  600. + "//electron/build/config:generate_mas_config",
  601. ]
  602. defines = []
  603. diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn
  604. index 2ac766d0149f0405b3fcad0ec1b6e0685ed3658c..2fc827605b134a3bf24438b42405f70a819dbd9b 100644
  605. --- a/content/renderer/BUILD.gn
  606. +++ b/content/renderer/BUILD.gn
  607. @@ -336,6 +336,7 @@ target(link_target_type, "renderer") {
  608. "//ui/surface",
  609. "//url",
  610. "//v8",
  611. + "//electron/build/config:generate_mas_config",
  612. ]
  613. allow_circular_includes_from = []
  614. diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm
  615. index d4db3b179725cb96bcbd0f73db7d52ef8b7522db..703b0f56a61abac51961bfd918b7349b943900de 100644
  616. --- a/content/renderer/renderer_main_platform_delegate_mac.mm
  617. +++ b/content/renderer/renderer_main_platform_delegate_mac.mm
  618. @@ -7,12 +7,15 @@
  619. #import <Cocoa/Cocoa.h>
  620. #include "base/check_op.h"
  621. +#include "electron/mas.h"
  622. #include "sandbox/mac/seatbelt.h"
  623. #include "sandbox/mac/system_services.h"
  624. +#if !IS_MAS_BUILD()
  625. extern "C" {
  626. CGError CGSSetDenyWindowServerConnections(bool);
  627. }
  628. +#endif
  629. namespace content {
  630. @@ -22,6 +25,7 @@
  631. // verifies there are no existing open connections), and then indicates that
  632. // Chrome should continue execution without access to launchservicesd.
  633. void DisableSystemServices() {
  634. +#if !IS_MAS_BUILD()
  635. // Tell the WindowServer that we don't want to make any future connections.
  636. // This will return Success as long as there are no open connections, which
  637. // is what we want.
  638. @@ -30,6 +34,7 @@ void DisableSystemServices() {
  639. sandbox::DisableLaunchServices();
  640. sandbox::DisableCoreServicesCheckFix();
  641. +#endif
  642. }
  643. } // namespace
  644. diff --git a/content/renderer/theme_helper_mac.mm b/content/renderer/theme_helper_mac.mm
  645. index a1068589ad844518038ee7bc15a3de9bc5cba525..1ff781c49f086ec8015c7d3c44567dbec3d00ff8 100644
  646. --- a/content/renderer/theme_helper_mac.mm
  647. +++ b/content/renderer/theme_helper_mac.mm
  648. @@ -7,16 +7,28 @@
  649. #include <Cocoa/Cocoa.h>
  650. #include "base/strings/sys_string_conversions.h"
  651. +#include "electron/mas.h"
  652. +#if !IS_MAS_BUILD()
  653. extern "C" {
  654. bool CGFontRenderingGetFontSmoothingDisabled(void);
  655. }
  656. -
  657. +#endif
  658. namespace content {
  659. bool IsSubpixelAntialiasingAvailable() {
  660. +#if !IS_MAS_BUILD()
  661. // See https://trac.webkit.org/changeset/239306/webkit for more info.
  662. return !CGFontRenderingGetFontSmoothingDisabled();
  663. +#else
  664. + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
  665. + NSString *default_key = @"CGFontRenderingGetFontSmoothingDisabled";
  666. + // Check that key exists since boolForKey defaults to NO when the
  667. + // key is missing and this key in fact defaults to YES;
  668. + if ([defaults objectForKey:default_key] == nil)
  669. + return false;
  670. + return ![defaults boolForKey:default_key];
  671. +#endif
  672. }
  673. } // namespace content
  674. diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
  675. index 075b7804d631a2107de59f310169353e6da5fffe..6a40b5bd8dae7af5ef231757fd384e4be0508669 100644
  676. --- a/content/test/BUILD.gn
  677. +++ b/content/test/BUILD.gn
  678. @@ -638,6 +638,7 @@ static_library("test_support") {
  679. "//url",
  680. "//url/mojom:url_mojom_gurl",
  681. "//v8",
  682. + "//electron/build/config:generate_mas_config"
  683. ]
  684. data_deps = [
  685. @@ -1107,6 +1108,7 @@ static_library("browsertest_support") {
  686. }
  687. configs += [ "//v8:external_startup_data" ]
  688. + deps += ["//electron/build/config:generate_mas_config"]
  689. }
  690. mojom("content_test_mojo_bindings") {
  691. @@ -1931,6 +1933,7 @@ test("content_browsertests") {
  692. "//ui/shell_dialogs",
  693. "//ui/snapshot",
  694. "//ui/webui:test_support",
  695. + "//electron/build/config:generate_mas_config"
  696. ]
  697. if (!(is_chromeos_ash && target_cpu == "arm64" && current_cpu == "arm")) {
  698. @@ -3209,6 +3212,7 @@ test("content_unittests") {
  699. "//ui/latency:test_support",
  700. "//ui/shell_dialogs:shell_dialogs",
  701. "//ui/webui:test_support",
  702. + "//electron/build/config:generate_mas_config"
  703. ]
  704. if (enable_nocompile_tests) {
  705. diff --git a/content/web_test/BUILD.gn b/content/web_test/BUILD.gn
  706. index 99e612f705c5dff041454802033564085718260a..aa37555d9a9c0fda19d0096d035c245eca5ca0c6 100644
  707. --- a/content/web_test/BUILD.gn
  708. +++ b/content/web_test/BUILD.gn
  709. @@ -228,6 +228,7 @@ static_library("web_test_browser") {
  710. "//ui/gl",
  711. "//ui/shell_dialogs:shell_dialogs",
  712. "//url",
  713. + "//electron/build/config:generate_mas_config"
  714. ]
  715. # TODO(crbug.com/40139469): Blink test plugin must be migrated from PPAPI.
  716. diff --git a/device/bluetooth/BUILD.gn b/device/bluetooth/BUILD.gn
  717. index 82d4f2bf563f6bf489b1f257efb249ba4ec9a7f3..7ae5132961a01175d0d28004e5fc2e9cfb924bdd 100644
  718. --- a/device/bluetooth/BUILD.gn
  719. +++ b/device/bluetooth/BUILD.gn
  720. @@ -258,6 +258,7 @@ component("bluetooth") {
  721. "IOKit.framework",
  722. "Foundation.framework",
  723. ]
  724. + deps += ["//electron/build/config:generate_mas_config"]
  725. }
  726. if (is_mac) {
  727. diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
  728. index fa86583a2d82c4076cfcf64cdc3f6bbb533b95d7..3e4bda0bc31431cb2cc0893d246be6bb54cfab83 100644
  729. --- a/device/bluetooth/bluetooth_adapter_mac.mm
  730. +++ b/device/bluetooth/bluetooth_adapter_mac.mm
  731. @@ -38,7 +38,9 @@
  732. #include "device/bluetooth/bluetooth_discovery_session_outcome.h"
  733. #include "device/bluetooth/bluetooth_socket_mac.h"
  734. #include "device/bluetooth/public/cpp/bluetooth_address.h"
  735. +#include "electron/mas.h"
  736. +#if !IS_MAS_BUILD()
  737. extern "C" {
  738. // Undocumented IOBluetooth Preference API [1]. Used by `blueutil` [2] and
  739. // `Karabiner` [3] to programmatically control the Bluetooth state. Calling the
  740. @@ -52,6 +54,7 @@
  741. // [4] https://support.apple.com/kb/PH25091
  742. void IOBluetoothPreferenceSetControllerPowerState(int state);
  743. }
  744. +#endif
  745. // A simple helper class that forwards any Bluetooth device connect notification
  746. // to its wrapped |_adapter|.
  747. @@ -161,8 +164,10 @@ bool IsDeviceSystemPaired(const std::string& device_address) {
  748. : controller_state_function_(
  749. base::BindRepeating(&BluetoothAdapterMac::GetHostControllerState,
  750. base::Unretained(this))),
  751. +#if !IS_MAS_BUILD()
  752. power_state_function_(
  753. base::BindRepeating(IOBluetoothPreferenceSetControllerPowerState)),
  754. +#endif
  755. device_paired_status_callback_(
  756. base::BindRepeating(&IsDeviceSystemPaired)) {
  757. }
  758. @@ -313,8 +318,12 @@ bool IsDeviceSystemPaired(const std::string& device_address) {
  759. }
  760. bool BluetoothAdapterMac::SetPoweredImpl(bool powered) {
  761. +#if !IS_MAS_BUILD()
  762. power_state_function_.Run(base::strict_cast<int>(powered));
  763. return true;
  764. +#else
  765. + return false;
  766. +#endif
  767. }
  768. base::WeakPtr<BluetoothLowEnergyAdapterApple>
  769. diff --git a/gpu/ipc/service/BUILD.gn b/gpu/ipc/service/BUILD.gn
  770. index 973cd337f2781271b4ca3e29db07939ec6917327..90658a336138e4e50f93c38f1c1f465c1c2bd4dc 100644
  771. --- a/gpu/ipc/service/BUILD.gn
  772. +++ b/gpu/ipc/service/BUILD.gn
  773. @@ -135,6 +135,7 @@ component("service") {
  774. "QuartzCore.framework",
  775. ]
  776. defines += [ "GL_SILENCE_DEPRECATION" ]
  777. + deps += ["//electron/build/config:generate_mas_config"]
  778. }
  779. if (is_ios) {
  780. sources += [ "image_transport_surface_ios.mm" ]
  781. diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h
  782. index 36322ddd3047f96569f35807541a37d3c6672b09..0121a780cf3b79fc1120c1b85cd5cd30c14968ef 100644
  783. --- a/gpu/ipc/service/image_transport_surface_overlay_mac.h
  784. +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h
  785. @@ -8,6 +8,7 @@
  786. #include <vector>
  787. #include "base/memory/weak_ptr.h"
  788. +#include "electron/mas.h"
  789. #include "gpu/ipc/service/command_buffer_stub.h"
  790. #include "gpu/ipc/service/image_transport_surface.h"
  791. #include "ui/gfx/ca_layer_result.h"
  792. @@ -23,7 +24,9 @@
  793. #include "ui/display/types/display_constants.h"
  794. #endif
  795. +#if !IS_MAS_BUILD()
  796. @class CAContext;
  797. +#endif
  798. @class CALayer;
  799. namespace ui {
  800. diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn
  801. index 6f3b368103b05f07ae67da4c0307efe039b8dfce..c8b18509dc508fbb928b97830536d210b378bf73 100644
  802. --- a/media/audio/BUILD.gn
  803. +++ b/media/audio/BUILD.gn
  804. @@ -197,6 +197,7 @@ source_set("audio") {
  805. "CoreMedia.framework",
  806. ]
  807. weak_frameworks = [ "ScreenCaptureKit.framework" ] # macOS 13.0
  808. + deps += ["//electron/build/config:generate_mas_config"]
  809. }
  810. if (is_ios) {
  811. diff --git a/media/audio/apple/audio_low_latency_input.cc b/media/audio/apple/audio_low_latency_input.cc
  812. index 9b78f60304a0e487904fdb22c9e6d85a237ca96e..e639558d34edab3ba3b1bb4f502bd91405e58637 100644
  813. --- a/media/audio/apple/audio_low_latency_input.cc
  814. +++ b/media/audio/apple/audio_low_latency_input.cc
  815. @@ -28,6 +28,7 @@
  816. #include "base/strings/sys_string_conversions.h"
  817. #include "base/time/time.h"
  818. #include "base/trace_event/trace_event.h"
  819. +#include "electron/mas.h"
  820. #include "media/audio/apple/audio_manager_apple.h"
  821. #include "media/audio/apple/scoped_audio_unit.h"
  822. #include "media/base/audio_bus.h"
  823. @@ -39,19 +40,23 @@
  824. namespace {
  825. extern "C" {
  826. +#if !IS_MAS_BUILD()
  827. // See:
  828. // https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/PAL/pal/spi/cf/CoreAudioSPI.h?rev=228264
  829. OSStatus AudioDeviceDuck(AudioDeviceID inDevice,
  830. Float32 inDuckedLevel,
  831. const AudioTimeStamp* __nullable inStartTime,
  832. Float32 inRampDuration) __attribute__((weak_import));
  833. +#endif
  834. }
  835. void UndoDucking(AudioDeviceID output_device_id) {
  836. +#if !IS_MAS_BUILD()
  837. if (AudioDeviceDuck != nullptr) {
  838. // Ramp the volume back up over half a second.
  839. AudioDeviceDuck(output_device_id, 1.0, nullptr, 0.5);
  840. }
  841. +#endif
  842. }
  843. } // namespace
  844. #endif
  845. diff --git a/net/dns/BUILD.gn b/net/dns/BUILD.gn
  846. index 5f4ff9ff8172d4ad282cc9c781f85118b8ba7d1a..cc85f488884f48df94198b7e4d4823946e750716 100644
  847. --- a/net/dns/BUILD.gn
  848. +++ b/net/dns/BUILD.gn
  849. @@ -187,6 +187,8 @@ source_set("dns") {
  850. ":host_resolver_manager",
  851. ":mdns_client",
  852. ]
  853. +
  854. + deps += ["//electron/build/config:generate_mas_config"]
  855. }
  856. # The standard API of net/dns.
  857. diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
  858. index 70d5665ad7b9ef62370497636af919ede2508ad4..f4dc3e2b8053cdb3e8c439ab1a1d6369a8e6a7dc 100644
  859. --- a/net/dns/dns_config_service_posix.cc
  860. +++ b/net/dns/dns_config_service_posix.cc
  861. @@ -28,6 +28,7 @@
  862. #include "base/threading/scoped_blocking_call.h"
  863. #include "base/time/time.h"
  864. #include "build/build_config.h"
  865. +#include "electron/mas.h"
  866. #include "net/base/ip_endpoint.h"
  867. #include "net/dns/dns_config.h"
  868. #include "net/dns/dns_hosts.h"
  869. @@ -135,8 +136,8 @@ class DnsConfigServicePosix::Watcher : public DnsConfigService::Watcher {
  870. bool Watch() override {
  871. CheckOnCorrectSequence();
  872. -
  873. bool success = true;
  874. +#if !IS_MAS_BUILD()
  875. if (!config_watcher_.Watch(base::BindRepeating(&Watcher::OnConfigChanged,
  876. base::Unretained(this)))) {
  877. LOG(ERROR) << "DNS config watch failed to start.";
  878. @@ -153,6 +154,7 @@ class DnsConfigServicePosix::Watcher : public DnsConfigService::Watcher {
  879. success = false;
  880. }
  881. #endif // !BUILDFLAG(IS_IOS)
  882. +#endif
  883. return success;
  884. }
  885. diff --git a/sandbox/mac/BUILD.gn b/sandbox/mac/BUILD.gn
  886. index 299a028f23314f479d2da8f914a5bdf34698d854..67a56a3b4c8fc524f1ec8cfec856f24d30402134 100644
  887. --- a/sandbox/mac/BUILD.gn
  888. +++ b/sandbox/mac/BUILD.gn
  889. @@ -39,6 +39,7 @@ component("seatbelt") {
  890. ]
  891. public_deps = [ "//third_party/protobuf:protobuf_lite" ]
  892. defines = [ "SEATBELT_IMPLEMENTATION" ]
  893. + deps += ["//electron/build/config:generate_mas_config"]
  894. }
  895. component("seatbelt_extension") {
  896. @@ -52,6 +53,7 @@ component("seatbelt_extension") {
  897. libs = [ "sandbox" ]
  898. public_deps = [ "//base" ]
  899. defines = [ "SEATBELT_IMPLEMENTATION" ]
  900. + deps += ["//electron/build/config:generate_mas_config"]
  901. }
  902. component("system_services") {
  903. @@ -66,6 +68,7 @@ component("system_services") {
  904. deps = [ ":seatbelt_export" ]
  905. public_deps = [ "//base" ]
  906. defines = [ "SEATBELT_IMPLEMENTATION" ]
  907. + deps += ["//electron/build/config:generate_mas_config"]
  908. }
  909. source_set("sandbox_unittests") {
  910. diff --git a/sandbox/mac/sandbox_compiler.cc b/sandbox/mac/sandbox_compiler.cc
  911. index f35d9ef2a2df3db8ecbf1d7b909c7b1cf33f3cd9..5d52330d1bd70cd7b97ee3360721f10c8447c717 100644
  912. --- a/sandbox/mac/sandbox_compiler.cc
  913. +++ b/sandbox/mac/sandbox_compiler.cc
  914. @@ -7,6 +7,7 @@
  915. #include <string>
  916. #include <vector>
  917. +#include "electron/mas.h"
  918. #include "sandbox/mac/seatbelt.h"
  919. namespace sandbox {
  920. @@ -47,6 +48,7 @@ bool SandboxCompiler::SetParameter(const std::string& key,
  921. }
  922. bool SandboxCompiler::CompileAndApplyProfile(std::string& error) {
  923. +#if !IS_MAS_BUILD()
  924. if (mode_ == Target::kSource) {
  925. std::vector<const char*> params;
  926. @@ -67,6 +69,9 @@ bool SandboxCompiler::CompileAndApplyProfile(std::string& error) {
  927. }
  928. }
  929. return false;
  930. +#else
  931. + return true;
  932. +#endif
  933. }
  934. bool SandboxCompiler::CompilePolicyToProto(mac::SandboxPolicy& policy,
  935. diff --git a/sandbox/mac/sandbox_logging.cc b/sandbox/mac/sandbox_logging.cc
  936. index 095c639b9893e885d8937e29ed7d47a7c28bc6b6..7e0cf9b9f94b16741358bdb45122f8b2bd68c0f9 100644
  937. --- a/sandbox/mac/sandbox_logging.cc
  938. +++ b/sandbox/mac/sandbox_logging.cc
  939. @@ -16,6 +16,7 @@
  940. #include <string>
  941. #include "build/build_config.h"
  942. +#include "electron/mas.h"
  943. #include "sandbox/mac/sandbox_crash_message.h"
  944. #if defined(ARCH_CPU_X86_64)
  945. @@ -33,9 +34,11 @@
  946. }
  947. #endif
  948. +#if !IS_MAS_BUILD()
  949. extern "C" {
  950. void abort_report_np(const char*, ...);
  951. }
  952. +#endif
  953. namespace sandbox::logging {
  954. @@ -76,9 +79,11 @@ void SendOsLog(Level level, const char* message) {
  955. sandbox::crash_message::SetCrashMessage(message);
  956. }
  957. +#if !IS_MAS_BUILD()
  958. if (level == Level::FATAL) {
  959. abort_report_np(message);
  960. }
  961. +#endif
  962. }
  963. // |error| is strerror(errno) when a P* logging function is called. Pass
  964. diff --git a/sandbox/mac/seatbelt.cc b/sandbox/mac/seatbelt.cc
  965. index 15c835e118456394c0a00ac98c11241c14ca75bd..a16faabe2bd63a5e0fbe9082a3b4b7c8aa0ea064 100644
  966. --- a/sandbox/mac/seatbelt.cc
  967. +++ b/sandbox/mac/seatbelt.cc
  968. @@ -4,12 +4,14 @@
  969. #include "sandbox/mac/seatbelt.h"
  970. +#include "electron/mas.h"
  971. +
  972. #include <errno.h>
  973. #include <unistd.h>
  974. extern "C" {
  975. #include <sandbox.h>
  976. -
  977. +#if !IS_MAS_BUILD()
  978. int sandbox_init_with_parameters(const char* profile,
  979. uint64_t flags,
  980. const char* const parameters[],
  981. @@ -40,13 +42,13 @@ sandbox_profile_t* sandbox_compile_string(const char* data,
  982. char** error);
  983. int sandbox_apply(sandbox_profile_t*);
  984. void sandbox_free_profile(sandbox_profile_t*);
  985. -
  986. +#endif
  987. } // extern "C"
  988. namespace sandbox {
  989. namespace {
  990. -
  991. +#if !IS_MAS_BUILD()
  992. bool HandleSandboxResult(int rv, char* errorbuf, std::string* error) {
  993. if (rv == 0) {
  994. if (error)
  995. @@ -74,36 +76,48 @@ bool HandleSandboxErrno(int rv, const char* message, std::string* error) {
  996. }
  997. return false;
  998. }
  999. -
  1000. +#endif
  1001. } // namespace
  1002. // static
  1003. Seatbelt::Parameters Seatbelt::Parameters::Create() {
  1004. Parameters params;
  1005. +#if !IS_MAS_BUILD()
  1006. params.params_ = ::sandbox_create_params();
  1007. +#endif
  1008. return params;
  1009. }
  1010. Seatbelt::Parameters::Parameters() = default;
  1011. Seatbelt::Parameters::Parameters(Seatbelt::Parameters&& other) {
  1012. +#if !IS_MAS_BUILD()
  1013. params_ = std::exchange(other.params_, nullptr);
  1014. +#endif
  1015. }
  1016. Seatbelt::Parameters& Seatbelt::Parameters::operator=(
  1017. Seatbelt::Parameters&& other) {
  1018. +#if !IS_MAS_BUILD()
  1019. params_ = std::exchange(other.params_, nullptr);
  1020. +#endif
  1021. return *this;
  1022. }
  1023. bool Seatbelt::Parameters::Set(const char* key, const char* value) {
  1024. +#if !IS_MAS_BUILD()
  1025. return ::sandbox_set_param(params_, key, value) == 0;
  1026. +#else
  1027. + return true;
  1028. +#endif
  1029. }
  1030. Seatbelt::Parameters::~Parameters() {
  1031. +#if !IS_MAS_BUILD()
  1032. if (params_) {
  1033. ::sandbox_free_params(params_);
  1034. }
  1035. +#endif
  1036. }
  1037. // Initialize the static member variables.
  1038. @@ -114,6 +128,7 @@ const char* Seatbelt::kProfilePureComputation = kSBXProfilePureComputation;
  1039. // static
  1040. bool Seatbelt::Init(const char* profile, uint64_t flags, std::string* error) {
  1041. +#if !IS_MAS_BUILD()
  1042. // OS X deprecated these functions, but did not provide a suitable replacement,
  1043. // so ignore the deprecation warning.
  1044. #pragma clang diagnostic push
  1045. @@ -122,6 +137,9 @@ bool Seatbelt::Init(const char* profile, uint64_t flags, std::string* error) {
  1046. int rv = ::sandbox_init(profile, flags, &errorbuf);
  1047. return HandleSandboxResult(rv, errorbuf, error);
  1048. #pragma clang diagnostic pop
  1049. +#else
  1050. + return true;
  1051. +#endif
  1052. }
  1053. // static
  1054. @@ -129,10 +147,14 @@ bool Seatbelt::InitWithParams(const char* profile,
  1055. uint64_t flags,
  1056. const char* const parameters[],
  1057. std::string* error) {
  1058. +#if !IS_MAS_BUILD()
  1059. char* errorbuf = nullptr;
  1060. int rv =
  1061. ::sandbox_init_with_parameters(profile, flags, parameters, &errorbuf);
  1062. return HandleSandboxResult(rv, errorbuf, error);
  1063. +#else
  1064. + return true;
  1065. +#endif
  1066. }
  1067. // static
  1068. @@ -140,6 +162,7 @@ bool Seatbelt::Compile(const char* profile,
  1069. const Seatbelt::Parameters& params,
  1070. std::string& compiled_profile,
  1071. std::string* error) {
  1072. +#if !IS_MAS_BUILD()
  1073. char* errorbuf = nullptr;
  1074. sandbox_profile_t* sandbox_profile =
  1075. ::sandbox_compile_string(profile, params.params(), &errorbuf);
  1076. @@ -149,33 +172,44 @@ bool Seatbelt::Compile(const char* profile,
  1077. compiled_profile.assign(reinterpret_cast<const char*>(sandbox_profile->data),
  1078. sandbox_profile->size);
  1079. ::sandbox_free_profile(sandbox_profile);
  1080. +#endif
  1081. return true;
  1082. }
  1083. // static
  1084. bool Seatbelt::ApplyCompiledProfile(const std::string& profile,
  1085. std::string* error) {
  1086. +#if !IS_MAS_BUILD()
  1087. sandbox_profile_t sbox_profile = {
  1088. .builtin = nullptr,
  1089. .data = reinterpret_cast<const uint8_t*>(profile.data()),
  1090. .size = profile.size()};
  1091. return HandleSandboxErrno(::sandbox_apply(&sbox_profile),
  1092. "sandbox_apply: ", error);
  1093. +#else
  1094. + return true;
  1095. +#endif
  1096. }
  1097. // static
  1098. void Seatbelt::FreeError(char* errorbuf) {
  1099. +#if !IS_MAS_BUILD()
  1100. // OS X deprecated these functions, but did not provide a suitable replacement,
  1101. // so ignore the deprecation warning.
  1102. #pragma clang diagnostic push
  1103. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  1104. return ::sandbox_free_error(errorbuf);
  1105. #pragma clang diagnostic pop
  1106. +#endif
  1107. }
  1108. // static
  1109. bool Seatbelt::IsSandboxed() {
  1110. +#if !IS_MAS_BUILD()
  1111. return ::sandbox_check(getpid(), NULL, 0);
  1112. +#else
  1113. + return true;
  1114. +#endif
  1115. }
  1116. } // namespace sandbox
  1117. diff --git a/sandbox/mac/seatbelt_extension.cc b/sandbox/mac/seatbelt_extension.cc
  1118. index b3f017a8be25209a78ed6a1221abcdeeb7904752..64aacf0542cbb899b04a9f957b8d094e9c8669ff 100644
  1119. --- a/sandbox/mac/seatbelt_extension.cc
  1120. +++ b/sandbox/mac/seatbelt_extension.cc
  1121. @@ -9,8 +9,10 @@
  1122. #include "base/check.h"
  1123. #include "base/memory/ptr_util.h"
  1124. #include "base/notreached.h"
  1125. +#include "electron/mas.h"
  1126. #include "sandbox/mac/seatbelt_extension_token.h"
  1127. +#if !IS_MAS_BUILD()
  1128. // libsandbox private API.
  1129. extern "C" {
  1130. extern const char* APP_SANDBOX_READ;
  1131. @@ -22,6 +24,7 @@ char* sandbox_extension_issue_file(const char* type,
  1132. const char* path,
  1133. uint32_t flags);
  1134. }
  1135. +#endif
  1136. namespace sandbox {
  1137. @@ -50,7 +53,11 @@ std::unique_ptr<SeatbeltExtension> SeatbeltExtension::FromToken(
  1138. bool SeatbeltExtension::Consume() {
  1139. DCHECK(!token_.empty());
  1140. +#if !IS_MAS_BUILD()
  1141. handle_ = sandbox_extension_consume(token_.c_str());
  1142. +#else
  1143. + handle_ = -1;
  1144. +#endif
  1145. return handle_ > 0;
  1146. }
  1147. @@ -62,7 +69,11 @@ bool SeatbeltExtension::ConsumePermanently() {
  1148. }
  1149. bool SeatbeltExtension::Revoke() {
  1150. +#if !IS_MAS_BUILD()
  1151. int rv = sandbox_extension_release(handle_);
  1152. +#else
  1153. + int rv = -1;
  1154. +#endif
  1155. handle_ = 0;
  1156. token_.clear();
  1157. return rv == 0;
  1158. @@ -80,12 +91,14 @@ SeatbeltExtension::SeatbeltExtension(const std::string& token)
  1159. char* SeatbeltExtension::IssueToken(SeatbeltExtension::Type type,
  1160. const std::string& resource) {
  1161. switch (type) {
  1162. +#if !IS_MAS_BUILD()
  1163. case FILE_READ:
  1164. return sandbox_extension_issue_file(APP_SANDBOX_READ, resource.c_str(),
  1165. 0);
  1166. case FILE_READ_WRITE:
  1167. return sandbox_extension_issue_file(APP_SANDBOX_READ_WRITE,
  1168. resource.c_str(), 0);
  1169. +#endif
  1170. default:
  1171. NOTREACHED_IN_MIGRATION();
  1172. return nullptr;
  1173. diff --git a/sandbox/mac/system_services.cc b/sandbox/mac/system_services.cc
  1174. index eb81a70e4d5d5cd3e6ae9b45f8cd1c795ea76c51..9921ccb10d3455600eddd85f77f10228016389af 100644
  1175. --- a/sandbox/mac/system_services.cc
  1176. +++ b/sandbox/mac/system_services.cc
  1177. @@ -8,7 +8,9 @@
  1178. #include <CoreFoundation/CoreFoundation.h>
  1179. #include "base/apple/osstatus_logging.h"
  1180. +#include "electron/mas.h"
  1181. +#if !IS_MAS_BUILD()
  1182. extern "C" {
  1183. OSStatus SetApplicationIsDaemon(Boolean isDaemon);
  1184. void _LSSetApplicationLaunchServicesServerConnectionStatus(
  1185. @@ -19,10 +21,12 @@ void _LSSetApplicationLaunchServicesServerConnectionStatus(
  1186. // https://github.com/WebKit/WebKit/blob/24aaedc770d192d03a07ba4a71727274aaa8fc07/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm#L840
  1187. void _CSCheckFixDisable();
  1188. } // extern "C"
  1189. +#endif
  1190. namespace sandbox {
  1191. void DisableLaunchServices() {
  1192. + #if !IS_MAS_BUILD()
  1193. // Allow the process to continue without a LaunchServices ASN. The
  1194. // INIT_Process function in HIServices will abort if it cannot connect to
  1195. // launchservicesd to get an ASN. By setting this flag, HIServices skips
  1196. @@ -36,10 +40,13 @@ void DisableLaunchServices() {
  1197. 0, ^bool(CFDictionaryRef options) {
  1198. return false;
  1199. });
  1200. + #endif
  1201. }
  1202. void DisableCoreServicesCheckFix() {
  1203. +#if !IS_MAS_BUILD()
  1204. _CSCheckFixDisable();
  1205. +#endif
  1206. }
  1207. } // namespace sandbox
  1208. diff --git a/third_party/blink/renderer/core/BUILD.gn b/third_party/blink/renderer/core/BUILD.gn
  1209. index d6bdf90cc367cfd2dd8a6bea596593384bcde9d9..1e9a25c205fb3f4c9241623b2ba0f8af443fe010 100644
  1210. --- a/third_party/blink/renderer/core/BUILD.gn
  1211. +++ b/third_party/blink/renderer/core/BUILD.gn
  1212. @@ -403,6 +403,7 @@ component("core") {
  1213. "//ui/gfx/geometry",
  1214. "//ui/gfx/geometry:geometry_skia",
  1215. "//ui/strings",
  1216. + "//electron/build/config:generate_mas_config",
  1217. ]
  1218. if (is_mac) {
  1219. diff --git a/third_party/blink/renderer/core/editing/build.gni b/third_party/blink/renderer/core/editing/build.gni
  1220. index 7f16c41fc7a4ee73b6a720ca195d3bf148bbe730..b0f76b9f709bacc6cd9f74948a556848451b7dc5 100644
  1221. --- a/third_party/blink/renderer/core/editing/build.gni
  1222. +++ b/third_party/blink/renderer/core/editing/build.gni
  1223. @@ -356,10 +356,14 @@ blink_core_sources_editing = [
  1224. if (is_mac) {
  1225. blink_core_sources_editing += [
  1226. "commands/smart_replace_cf.cc",
  1227. - "kill_ring_mac.mm",
  1228. "substring_util.h",
  1229. "substring_util.mm",
  1230. ]
  1231. + if (is_mas_build) {
  1232. + blink_core_sources_editing += [ "kill_ring_mac.mm" ]
  1233. + } else {
  1234. + blink_core_sources_editing += [ "kill_ring_none.cc" ]
  1235. + }
  1236. } else {
  1237. blink_core_sources_editing += [ "kill_ring_none.cc" ]
  1238. }
  1239. diff --git a/ui/accelerated_widget_mac/BUILD.gn b/ui/accelerated_widget_mac/BUILD.gn
  1240. index 3ead42e14ad9d41a30c5637678a3ac49296ce2a6..07665bbefd34737bf6a8c3e79d70b066920788c9 100644
  1241. --- a/ui/accelerated_widget_mac/BUILD.gn
  1242. +++ b/ui/accelerated_widget_mac/BUILD.gn
  1243. @@ -64,6 +64,7 @@ component("accelerated_widget_mac") {
  1244. "//ui/gfx",
  1245. "//ui/gfx/geometry",
  1246. "//ui/gl",
  1247. + "//electron/build/config:generate_mas_config",
  1248. ]
  1249. }
  1250. diff --git a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h
  1251. index b11c365f42dd1ddc363de0d94c387b13ac65bef3..5da42beb20b514396287cc6dc5cba608e1660b2e 100644
  1252. --- a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h
  1253. +++ b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.h
  1254. @@ -7,6 +7,7 @@
  1255. #include <queue>
  1256. +#include "electron/mas.h"
  1257. #include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h"
  1258. #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h"
  1259. #include "ui/gfx/ca_layer_result.h"
  1260. @@ -14,7 +15,9 @@
  1261. #include "ui/gl/gl_surface.h"
  1262. #include "ui/gl/presenter.h"
  1263. +#if !IS_MAS_BUILD()
  1264. @class CAContext;
  1265. +#endif
  1266. @class CALayer;
  1267. namespace ui {
  1268. @@ -110,7 +113,9 @@ class ACCELERATED_WIDGET_MAC_EXPORT CALayerTreeCoordinator {
  1269. // both the current tree and the pending trees.
  1270. size_t presented_ca_layer_trees_max_length_ = 2;
  1271. +#if !IS_MAS_BUILD()
  1272. CAContext* __strong ca_context_;
  1273. +#endif
  1274. // The root CALayer to display the current frame. This does not change
  1275. // over the lifetime of the object.
  1276. diff --git a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
  1277. index b99461d52e3a62b58330691e65f9956748cfbf02..f0c3bb1b809a29eee3d990b0a8bbffddb7500895 100644
  1278. --- a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
  1279. +++ b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
  1280. @@ -10,6 +10,7 @@
  1281. #include "base/mac/mac_util.h"
  1282. #include "base/task/single_thread_task_runner.h"
  1283. #include "base/trace_event/trace_event.h"
  1284. +#include "electron/mas.h"
  1285. #include "ui/base/cocoa/animation_utils.h"
  1286. #include "ui/base/cocoa/remote_layer_api.h"
  1287. #include "ui/gfx/ca_layer_params.h"
  1288. @@ -33,6 +34,7 @@
  1289. new_presentation_feedback_timestamps_(
  1290. new_presentation_feedback_timestamps),
  1291. buffer_presented_callback_(buffer_presented_callback) {
  1292. +#if !IS_MAS_BUILD()
  1293. if (allow_remote_layers_) {
  1294. root_ca_layer_ = [[CALayer alloc] init];
  1295. #if BUILDFLAG(IS_MAC)
  1296. @@ -61,6 +63,7 @@
  1297. #endif
  1298. ca_context_.layer = root_ca_layer_;
  1299. }
  1300. +#endif
  1301. }
  1302. CALayerTreeCoordinator::~CALayerTreeCoordinator() = default;
  1303. @@ -164,9 +167,13 @@
  1304. TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", TRACE_EVENT_SCOPE_THREAD,
  1305. "GLImpl", static_cast<int>(gl::GetGLImplementation()),
  1306. "width", pixel_size_.width());
  1307. +#if !IS_MAS_BUILD()
  1308. if (allow_remote_layers_) {
  1309. params.ca_context_id = [ca_context_ contextId];
  1310. } else {
  1311. +#else
  1312. + if (true) {
  1313. +#endif
  1314. IOSurfaceRef io_surface = frame->layer_tree->GetContentIOSurface();
  1315. if (io_surface) {
  1316. DCHECK(!allow_remote_layers_);
  1317. diff --git a/ui/accelerated_widget_mac/display_ca_layer_tree.mm b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
  1318. index dcf493d62990018040a3f84b6f875af737bd2214..3d1c4dcc9ee0bbfdac15f40d9c74e9f342a59e39 100644
  1319. --- a/ui/accelerated_widget_mac/display_ca_layer_tree.mm
  1320. +++ b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
  1321. @@ -12,6 +12,7 @@
  1322. #include "base/mac/mac_util.h"
  1323. #include "base/trace_event/trace_event.h"
  1324. #include "build/build_config.h"
  1325. +#include "electron/mas.h"
  1326. #include "ui/base/cocoa/animation_utils.h"
  1327. #include "ui/base/cocoa/remote_layer_api.h"
  1328. #include "ui/gfx/geometry/dip_util.h"
  1329. @@ -121,6 +122,7 @@ - (void)setContentsChanged;
  1330. }
  1331. void DisplayCALayerTree::GotCALayerFrame(uint32_t ca_context_id) {
  1332. +#if !IS_MAS_BUILD()
  1333. // Early-out if the remote layer has not changed.
  1334. if (remote_layer_.contextId == ca_context_id) {
  1335. return;
  1336. @@ -150,6 +152,9 @@ - (void)setContentsChanged;
  1337. [io_surface_layer_ removeFromSuperlayer];
  1338. io_surface_layer_ = nil;
  1339. }
  1340. +#else
  1341. + NOTREACHED() << "Remote layer is being used in MAS build";
  1342. +#endif
  1343. }
  1344. void DisplayCALayerTree::GotIOSurfaceFrame(
  1345. diff --git a/ui/accessibility/platform/BUILD.gn b/ui/accessibility/platform/BUILD.gn
  1346. index 2e24201fcdc1ec65688e2b08d28a74a218792af2..6085a8cde3df9a763e0eb63a9620f9971a3f57c8 100644
  1347. --- a/ui/accessibility/platform/BUILD.gn
  1348. +++ b/ui/accessibility/platform/BUILD.gn
  1349. @@ -282,6 +282,7 @@ component("platform") {
  1350. "AppKit.framework",
  1351. "Foundation.framework",
  1352. ]
  1353. + deps += ["//electron/build/config:generate_mas_config"]
  1354. }
  1355. if (is_ios) {
  1356. diff --git a/ui/accessibility/platform/browser_accessibility_manager_mac.mm b/ui/accessibility/platform/browser_accessibility_manager_mac.mm
  1357. index f9bd6478bea53f2b005c2d57b5f1db5313f77595..be1581eaf1dd1b6a7d1b44c7df3b16c04b6d19bc 100644
  1358. --- a/ui/accessibility/platform/browser_accessibility_manager_mac.mm
  1359. +++ b/ui/accessibility/platform/browser_accessibility_manager_mac.mm
  1360. @@ -13,13 +13,16 @@
  1361. #include "base/task/single_thread_task_runner.h"
  1362. #include "base/task/task_traits.h"
  1363. #include "base/time/time.h"
  1364. +#include "electron/mas.h"
  1365. #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
  1366. #include "ui/accessibility/ax_role_properties.h"
  1367. #include "ui/accessibility/platform/ax_platform_tree_manager_delegate.h"
  1368. #include "ui/accessibility/platform/ax_private_webkit_constants_mac.h"
  1369. #import "ui/accessibility/platform/browser_accessibility_cocoa.h"
  1370. #import "ui/accessibility/platform/browser_accessibility_mac.h"
  1371. +#if !IS_MAS_BUILD()
  1372. #include "ui/base/cocoa/remote_accessibility_api.h"
  1373. +#endif
  1374. namespace {
  1375. @@ -227,6 +230,7 @@ void PostAnnouncementNotification(NSString* announcement,
  1376. return;
  1377. }
  1378. +#if !IS_MAS_BUILD()
  1379. BrowserAccessibilityManager* root_manager = GetManagerForRootFrame();
  1380. if (root_manager) {
  1381. BrowserAccessibilityManagerMac* root_manager_mac =
  1382. @@ -249,6 +253,7 @@ void PostAnnouncementNotification(NSString* announcement,
  1383. return;
  1384. }
  1385. }
  1386. +#endif
  1387. // Use native VoiceOver support for live regions.
  1388. BrowserAccessibilityCocoa* retained_node = native_node;
  1389. @@ -645,6 +650,7 @@ void PostAnnouncementNotification(NSString* announcement,
  1390. return window == [NSApp accessibilityFocusedWindow];
  1391. }
  1392. +#if !IS_MAS_BUILD()
  1393. // TODO(accessibility): We need a solution to the problem described below.
  1394. // If the window is NSAccessibilityRemoteUIElement, there are some challenges:
  1395. // 1. NSApp is the browser which spawned the PWA, and what it considers the
  1396. @@ -673,6 +679,7 @@ void PostAnnouncementNotification(NSString* announcement,
  1397. if ([window isKindOfClass:[NSAccessibilityRemoteUIElement class]]) {
  1398. return true;
  1399. }
  1400. +#endif
  1401. return false;
  1402. }
  1403. diff --git a/ui/accessibility/platform/inspect/ax_transform_mac.mm b/ui/accessibility/platform/inspect/ax_transform_mac.mm
  1404. index c8171f0527fe5194f0ea73b57c4444d4c630fbc4..c2ac4da580e3e7f749a0a4de1e859af62de11672 100644
  1405. --- a/ui/accessibility/platform/inspect/ax_transform_mac.mm
  1406. +++ b/ui/accessibility/platform/inspect/ax_transform_mac.mm
  1407. @@ -11,6 +11,7 @@
  1408. #include "base/apple/foundation_util.h"
  1409. #include "base/strings/sys_string_conversions.h"
  1410. +#include "electron/mas.h"
  1411. #include "ui/accessibility/ax_range.h"
  1412. #include "ui/accessibility/platform/ax_platform_node.h"
  1413. #include "ui/accessibility/platform/ax_platform_node_cocoa.h"
  1414. @@ -111,6 +112,7 @@
  1415. }
  1416. }
  1417. +#if !IS_MAS_BUILD()
  1418. // AXTextMarker
  1419. if (IsAXTextMarker(value)) {
  1420. return AXTextMarkerToBaseValue(value, indexer);
  1421. @@ -120,6 +122,7 @@
  1422. if (IsAXTextMarkerRange(value)) {
  1423. return AXTextMarkerRangeToBaseValue(value, indexer);
  1424. }
  1425. +#endif
  1426. // Accessible object
  1427. if (AXElementWrapper::IsValidElement(value)) {
  1428. diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
  1429. index 79937bebda1b3405a8acbf1559ebd994a3f7bf0b..a64ff04007701c0a1304a7d766f8b2aa034b1ee3 100644
  1430. --- a/ui/base/BUILD.gn
  1431. +++ b/ui/base/BUILD.gn
  1432. @@ -384,6 +384,13 @@ component("base") {
  1433. sources += [ "resource/resource_bundle_lacros.cc" ]
  1434. }
  1435. + if (is_mas_build) {
  1436. + sources -= [
  1437. + "cocoa/remote_accessibility_api.h",
  1438. + "cocoa/remote_accessibility_api.mm",
  1439. + ]
  1440. + }
  1441. +
  1442. if (is_ios) {
  1443. sources += [
  1444. "device_form_factor_ios.mm",
  1445. @@ -535,6 +542,12 @@ component("base") {
  1446. "//url",
  1447. ]
  1448. + if (is_mac) {
  1449. + deps += [
  1450. + "//electron/build/config:generate_mas_config"
  1451. + ]
  1452. + }
  1453. +
  1454. if (is_debug || dcheck_always_on) {
  1455. deps += [ "//third_party/re2" ]
  1456. }
  1457. diff --git a/ui/base/cocoa/remote_accessibility_api.h b/ui/base/cocoa/remote_accessibility_api.h
  1458. index 3182458838aa96d34911280ab4c6c3aa4aa22d6d..6dc85c366b7e61c8bd0302e501c3223a19223313 100644
  1459. --- a/ui/base/cocoa/remote_accessibility_api.h
  1460. +++ b/ui/base/cocoa/remote_accessibility_api.h
  1461. @@ -10,9 +10,12 @@
  1462. #include <vector>
  1463. #include "base/component_export.h"
  1464. +#include "electron/mas.h"
  1465. // NSAccessibilityRemoteUIElement is a private class in AppKit.
  1466. +#if !IS_MAS_BUILD()
  1467. +
  1468. @interface NSAccessibilityRemoteUIElement : NSObject
  1469. + (void)setRemoteUIApp:(BOOL)flag;
  1470. + (BOOL)isRemoteUIApp;
  1471. @@ -38,4 +41,6 @@ class COMPONENT_EXPORT(UI_BASE) RemoteAccessibility {
  1472. } // namespace ui
  1473. +#endif // MAS_BUILD
  1474. +
  1475. #endif // UI_BASE_COCOA_REMOTE_ACCESSIBILITY_API_H_
  1476. diff --git a/ui/base/cocoa/remote_layer_api.h b/ui/base/cocoa/remote_layer_api.h
  1477. index 59dc2f82214cfd883b6ebef3b0fb25af6387a9cd..912c5252d1b30d943a1552739b9eef9a8eae2d7a 100644
  1478. --- a/ui/base/cocoa/remote_layer_api.h
  1479. +++ b/ui/base/cocoa/remote_layer_api.h
  1480. @@ -9,6 +9,7 @@
  1481. #include "base/component_export.h"
  1482. #include "build/build_config.h"
  1483. +#include "electron/mas.h"
  1484. #if defined(__OBJC__)
  1485. #import <Foundation/Foundation.h>
  1486. @@ -17,6 +18,7 @@
  1487. #if BUILDFLAG(IS_MAC)
  1488. +#if !IS_MAS_BUILD()
  1489. // The CGSConnectionID is used to create the CAContext in the process that is
  1490. // going to share the CALayers that it is rendering to another process to
  1491. // display.
  1492. @@ -68,6 +70,8 @@ extern NSString* const kCAContextIgnoresHitTest;
  1493. #endif // __OBJC__
  1494. +#endif // MAS_BUILD
  1495. +
  1496. namespace ui {
  1497. // This function will check if all of the interfaces listed above are supported
  1498. diff --git a/ui/base/cocoa/remote_layer_api.mm b/ui/base/cocoa/remote_layer_api.mm
  1499. index fc25ba79d2b0e1acdb7ba54b89e7d6e16f94771b..de771ef414b9a69e331261524f08e9a12145ec60 100644
  1500. --- a/ui/base/cocoa/remote_layer_api.mm
  1501. +++ b/ui/base/cocoa/remote_layer_api.mm
  1502. @@ -5,11 +5,13 @@
  1503. #include "ui/base/cocoa/remote_layer_api.h"
  1504. #include "base/feature_list.h"
  1505. +#include "electron/mas.h"
  1506. #include <objc/runtime.h>
  1507. namespace ui {
  1508. +#if !IS_MAS_BUILD()
  1509. namespace {
  1510. // Control use of cross-process CALayers to display content directly from the
  1511. // GPU process on Mac.
  1512. @@ -17,8 +19,10 @@
  1513. "RemoteCoreAnimationAPI",
  1514. base::FEATURE_ENABLED_BY_DEFAULT);
  1515. } // namespace
  1516. +#endif
  1517. bool RemoteLayerAPISupported() {
  1518. +#if !IS_MAS_BUILD()
  1519. if (!base::FeatureList::IsEnabled(kRemoteCoreAnimationAPI))
  1520. return false;
  1521. @@ -55,6 +59,9 @@ bool RemoteLayerAPISupported() {
  1522. // If everything is there, we should be able to use the API.
  1523. return true;
  1524. +#else
  1525. + return false;
  1526. +#endif // MAS_BUILD
  1527. }
  1528. } // namespace
  1529. diff --git a/ui/display/BUILD.gn b/ui/display/BUILD.gn
  1530. index 84afacf999c4905fdbaba332e19058a6471c3436..bbab402c8c11e62dad7fa946d9550efa3637dbda 100644
  1531. --- a/ui/display/BUILD.gn
  1532. +++ b/ui/display/BUILD.gn
  1533. @@ -130,6 +130,12 @@ component("display") {
  1534. "//ui/gfx/geometry",
  1535. ]
  1536. + if (is_mac) {
  1537. + deps += [
  1538. + "//electron/build/config:generate_mas_config"
  1539. + ]
  1540. + }
  1541. +
  1542. if (is_ios) {
  1543. deps += [ "//build:ios_buildflags" ]
  1544. }
  1545. diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm
  1546. index 35b71abc95f83bb01dba3f69e2d69a026840b7a2..6a2ff6768f16e503657cdb7ff6be7587c45842ec 100644
  1547. --- a/ui/display/mac/screen_mac.mm
  1548. +++ b/ui/display/mac/screen_mac.mm
  1549. @@ -30,6 +30,7 @@
  1550. #include "base/trace_event/trace_event.h"
  1551. #include "build/build_config.h"
  1552. #include "components/device_event_log/device_event_log.h"
  1553. +#include "electron/mas.h"
  1554. #include "ui/display/display.h"
  1555. #include "ui/display/display_change_notifier.h"
  1556. #include "ui/display/util/display_util.h"
  1557. @@ -176,7 +177,17 @@ DisplayMac BuildDisplayForScreen(NSScreen* screen) {
  1558. display.set_color_depth(Display::kDefaultBitsPerPixel);
  1559. display.set_depth_per_component(Display::kDefaultBitsPerComponent);
  1560. }
  1561. +#if IS_MAS_BUILD()
  1562. + // This is equivalent to the CGDisplayUsesForceToGray() API as at 2018-08-06,
  1563. + // but avoids usage of the private API.
  1564. + CFStringRef app = CFSTR("com.apple.CoreGraphics");
  1565. + CFStringRef key = CFSTR("DisplayUseForcedGray");
  1566. + Boolean key_valid = false;
  1567. + display.set_is_monochrome(
  1568. + CFPreferencesGetAppBooleanValue(key, app, &key_valid));
  1569. +#else
  1570. display.set_is_monochrome(CGDisplayUsesForceToGray());
  1571. +#endif
  1572. // Query the display's refresh rate.
  1573. if (@available(macos 12.0, *)) {
  1574. diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn
  1575. index c0a85b2cfc69a4f358ae03c65e774cdc45085bf6..27d77dfed33c69ede2b5a0326e763cb6c87200ef 100644
  1576. --- a/ui/gfx/BUILD.gn
  1577. +++ b/ui/gfx/BUILD.gn
  1578. @@ -333,6 +333,12 @@ component("gfx") {
  1579. "//ui/base:ui_data_pack",
  1580. ]
  1581. + if (is_mac) {
  1582. + deps += [
  1583. + "//electron/build/config:generate_mas_config"
  1584. + ]
  1585. + }
  1586. +
  1587. if (!is_apple) {
  1588. sources += [
  1589. "platform_font_skia.cc",
  1590. diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm
  1591. index fe3f85073e31de487a08e57d7f9b07aa4eccf8f3..cf5b07203c8bd559a404600cc98cc8eccdefd4d7 100644
  1592. --- a/ui/gfx/platform_font_mac.mm
  1593. +++ b/ui/gfx/platform_font_mac.mm
  1594. @@ -19,6 +19,7 @@
  1595. #include "base/numerics/safe_conversions.h"
  1596. #include "base/strings/sys_string_conversions.h"
  1597. #include "base/strings/utf_string_conversions.h"
  1598. +#include "electron/mas.h"
  1599. #include "third_party/skia/include/ports/SkTypeface_mac.h"
  1600. #include "ui/gfx/canvas.h"
  1601. #include "ui/gfx/font.h"
  1602. @@ -28,9 +29,11 @@
  1603. using Weight = Font::Weight;
  1604. +#if !IS_MAS_BUILD()
  1605. extern "C" {
  1606. bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
  1607. }
  1608. +#endif
  1609. namespace {
  1610. @@ -250,7 +253,13 @@ CTFontRef SystemFontForConstructorOfType(
  1611. // TODO(avi, etienneb): Figure out this font stuff.
  1612. base::apple::ScopedCFTypeRef<CTFontDescriptorRef> descriptor(
  1613. CTFontCopyFontDescriptor(font));
  1614. +#if IS_MAS_BUILD()
  1615. + CFNumberRef priority = (CFNumberRef)CTFontDescriptorCopyAttribute(descriptor.get(), (CFStringRef)kCTFontPriorityAttribute);
  1616. + SInt64 v;
  1617. + if (CFNumberGetValue(priority, kCFNumberSInt64Type, &v) && v == kCTFontPrioritySystem) {
  1618. +#else
  1619. if (CTFontDescriptorIsSystemUIFont(descriptor.get())) {
  1620. +#endif
  1621. // Assume it's the standard system font. The fact that this much is known is
  1622. // enough.
  1623. return PlatformFontMac::SystemFontType::kGeneral;
  1624. diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn
  1625. index 4ba2f9a9ed0aa26cc54f0fbaa70eb280b1dd3a69..f7cf6cdb3038d962d7a2ce2be02c75a502ff7766 100644
  1626. --- a/ui/views/BUILD.gn
  1627. +++ b/ui/views/BUILD.gn
  1628. @@ -722,6 +722,8 @@ component("views") {
  1629. "IOSurface.framework",
  1630. "QuartzCore.framework",
  1631. ]
  1632. +
  1633. + deps += ["//electron/build/config:generate_mas_config"]
  1634. }
  1635. if (is_win) {
  1636. @@ -1155,6 +1157,8 @@ source_set("test_support") {
  1637. "//ui/base/mojom:ui_base_types",
  1638. ]
  1639. + deps += ["//electron/build/config:generate_mas_config"]
  1640. +
  1641. if (is_win) {
  1642. sources += [
  1643. "test/desktop_window_tree_host_win_test_api.cc",
  1644. diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.h b/ui/views/cocoa/native_widget_mac_ns_window_host.h
  1645. index 81979cdb6c5dbad84ea67ef9014ce4027bcdc161..daeda64747dcbcd05f34e77079be701c5b281e7d 100644
  1646. --- a/ui/views/cocoa/native_widget_mac_ns_window_host.h
  1647. +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.h
  1648. @@ -18,6 +18,7 @@
  1649. #include "components/remote_cocoa/browser/scoped_cg_window_id.h"
  1650. #include "components/remote_cocoa/common/native_widget_ns_window.mojom.h"
  1651. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  1652. +#include "electron/mas.h"
  1653. #include "mojo/public/cpp/bindings/associated_receiver.h"
  1654. #include "mojo/public/cpp/bindings/associated_remote.h"
  1655. #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
  1656. @@ -32,7 +33,9 @@
  1657. #include "ui/views/window/dialog_observer.h"
  1658. @class NativeWidgetMacNSWindow;
  1659. +#if !IS_MAS_BUILD()
  1660. @class NSAccessibilityRemoteUIElement;
  1661. +#endif
  1662. @class NSView;
  1663. namespace remote_cocoa {
  1664. @@ -483,10 +486,12 @@ class VIEWS_EXPORT NativeWidgetMacNSWindowHost
  1665. mojo::AssociatedRemote<remote_cocoa::mojom::NativeWidgetNSWindow>
  1666. remote_ns_window_remote_;
  1667. +#if !IS_MAS_BUILD()
  1668. // Remote accessibility objects corresponding to the NSWindow and its root
  1669. // NSView.
  1670. NSAccessibilityRemoteUIElement* __strong remote_window_accessible_;
  1671. NSAccessibilityRemoteUIElement* __strong remote_view_accessible_;
  1672. +#endif
  1673. // Used to force the NSApplication's focused accessibility element to be the
  1674. // views::Views accessibility tree when the NSView for this is focused.
  1675. diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.mm b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
  1676. index 9a915cb0c36b224b8b95fa84bc1909de4283776f..e402df17b4e7273c850d0bd822019ee9d0f669a9 100644
  1677. --- a/ui/views/cocoa/native_widget_mac_ns_window_host.mm
  1678. +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
  1679. @@ -21,6 +21,7 @@
  1680. #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
  1681. #include "components/remote_cocoa/browser/ns_view_ids.h"
  1682. #include "components/remote_cocoa/browser/window.h"
  1683. +#include "electron/mas.h"
  1684. #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
  1685. #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
  1686. #include "ui/accessibility/accessibility_features.h"
  1687. @@ -349,7 +350,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1688. NativeWidgetMacNSWindowHost::GetNativeViewAccessibleForNSView() const {
  1689. if (in_process_ns_window_bridge_)
  1690. return in_process_ns_window_bridge_->ns_view();
  1691. +#if !IS_MAS_BUILD()
  1692. return remote_view_accessible_;
  1693. +#else
  1694. + return nullptr;
  1695. +#endif
  1696. }
  1697. gfx::NativeViewAccessible
  1698. @@ -364,7 +369,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1699. return [in_process_ns_window_bridge_->ns_view() window];
  1700. }
  1701. +#if !IS_MAS_BUILD()
  1702. return remote_window_accessible_;
  1703. +#else
  1704. + return nullptr;
  1705. +#endif
  1706. }
  1707. remote_cocoa::mojom::NativeWidgetNSWindow*
  1708. @@ -1333,9 +1342,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1709. // for PWAs. However this breaks accessibility on in-process windows,
  1710. // so set it back to NO when a local window gains focus. See
  1711. // https://crbug.com/41485830.
  1712. +#if !IS_MAS_BUILD()
  1713. if (is_key && features::IsAccessibilityRemoteUIAppEnabled()) {
  1714. [NSAccessibilityRemoteUIElement setRemoteUIApp:!!application_host_];
  1715. }
  1716. +#endif
  1717. // Explicitly set the keyboard accessibility state on regaining key
  1718. // window status.
  1719. if (is_key && is_content_first_responder)
  1720. @@ -1474,17 +1485,20 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1721. void NativeWidgetMacNSWindowHost::SetRemoteAccessibilityTokens(
  1722. const std::vector<uint8_t>& window_token,
  1723. const std::vector<uint8_t>& view_token) {
  1724. +#if !IS_MAS_BUILD()
  1725. remote_window_accessible_ =
  1726. ui::RemoteAccessibility::GetRemoteElementFromToken(window_token);
  1727. remote_view_accessible_ =
  1728. ui::RemoteAccessibility::GetRemoteElementFromToken(view_token);
  1729. [remote_view_accessible_ setWindowUIElement:remote_window_accessible_];
  1730. [remote_view_accessible_ setTopLevelUIElement:remote_window_accessible_];
  1731. +#endif
  1732. }
  1733. bool NativeWidgetMacNSWindowHost::GetRootViewAccessibilityToken(
  1734. base::ProcessId* pid,
  1735. std::vector<uint8_t>* token) {
  1736. +#if !IS_MAS_BUILD()
  1737. *pid = getpid();
  1738. id element_id = GetNativeViewAccessible();
  1739. @@ -1497,6 +1511,7 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1740. }
  1741. *token = ui::RemoteAccessibility::GetTokenForLocalElement(element_id);
  1742. +#endif
  1743. return true;
  1744. }
  1745. diff --git a/ui/views/controls/webview/BUILD.gn b/ui/views/controls/webview/BUILD.gn
  1746. index 111d6432586f47833dde50678b908c76ad88d37a..429ca4402652a2d89ead228d92971f0cb3b6222c 100644
  1747. --- a/ui/views/controls/webview/BUILD.gn
  1748. +++ b/ui/views/controls/webview/BUILD.gn
  1749. @@ -46,6 +46,12 @@ component("webview") {
  1750. "//url",
  1751. ]
  1752. + if (is_mac) {
  1753. + deps += [
  1754. + "//electron/build/config:generate_mas_config",
  1755. + ]
  1756. + }
  1757. +
  1758. public_deps = [
  1759. "//base",
  1760. "//content/public/browser",