mas_avoid_private_macos_api_usage.patch.patch 69 KB

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