mas_avoid_private_macos_api_usage.patch.patch 69 KB

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