mas_avoid_private_macos_api_usage.patch.patch 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  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 854457658bbdc09f21f61eb76928dfd423e1eedd..e9443d83d35786b09bc1ff70a0360f6f7e66a42e 100644
  36. --- a/base/BUILD.gn
  37. +++ b/base/BUILD.gn
  38. @@ -1028,6 +1028,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.mm b/base/process/process_info_mac.mm
  130. index e12c1d078147d956a1d9b1bc498c1b1d6fe7b974..233362259dc4e728ed37435e650417647b45a6af 100644
  131. --- a/base/process/process_info_mac.mm
  132. +++ b/base/process/process_info_mac.mm
  133. @@ -4,15 +4,20 @@
  134. #include "base/process/process_info.h"
  135. +#include "electron/mas.h"
  136. +
  137. #import <AppKit/AppKit.h>
  138. #include <unistd.h>
  139. +#if !IS_MAS_BUILD()
  140. extern "C" {
  141. pid_t responsibility_get_pid_responsible_for_pid(pid_t);
  142. }
  143. +#endif
  144. namespace {
  145. +#if !IS_MAS_BUILD()
  146. bool AppContainsBluetoothUsageDescription(NSRunningApplication* app) {
  147. NSURL* bundle_url = app.bundleURL;
  148. if (!bundle_url) {
  149. @@ -24,12 +29,14 @@ bool AppContainsBluetoothUsageDescription(NSRunningApplication* app) {
  150. [bundle objectForInfoDictionaryKey:@"NSBluetoothAlwaysUsageDescription"];
  151. return bluetooth_entry != nil;
  152. }
  153. +#endif
  154. } // namespace
  155. namespace base {
  156. bool DoesResponsibleProcessHaveBluetoothMetadata() {
  157. +#if !IS_MAS_BUILD()
  158. const pid_t pid = getpid();
  159. const pid_t responsible_pid = responsibility_get_pid_responsible_for_pid(pid);
  160. // Returns true directly if this is a self-responsible app(e.g. Chrome opens
  161. @@ -46,6 +53,9 @@ bool DoesResponsibleProcessHaveBluetoothMetadata() {
  162. return AppContainsBluetoothUsageDescription(app);
  163. }
  164. return false;
  165. +#else
  166. + return true;
  167. +#endif
  168. }
  169. } // namespace base
  170. diff --git a/components/os_crypt/sync/BUILD.gn b/components/os_crypt/sync/BUILD.gn
  171. index ff1e356ff696d3830d02644969c36a71fdf32ff6..b39c716c52524b95f2d3417a98e60c0c41147c93 100644
  172. --- a/components/os_crypt/sync/BUILD.gn
  173. +++ b/components/os_crypt/sync/BUILD.gn
  174. @@ -38,6 +38,8 @@ component("sync") {
  175. "os_crypt_mac.mm",
  176. ]
  177. deps += [ "//crypto:mock_apple_keychain" ]
  178. + deps += ["//electron/build/config:generate_mas_config"]
  179. +
  180. } else if (is_win) {
  181. sources += [ "os_crypt_win.cc" ]
  182. deps += [ "//components/version_info" ]
  183. diff --git a/components/os_crypt/sync/keychain_password_mac.mm b/components/os_crypt/sync/keychain_password_mac.mm
  184. index d87682447b850e4cf9065f0d26d14077acbe467d..a179c9bc02158130f4b15bf8022721f4b53a8303 100644
  185. --- a/components/os_crypt/sync/keychain_password_mac.mm
  186. +++ b/components/os_crypt/sync/keychain_password_mac.mm
  187. @@ -14,6 +14,7 @@
  188. #include "base/rand_util.h"
  189. #include "build/branding_buildflags.h"
  190. #include "crypto/apple_keychain.h"
  191. +#include "electron/mas.h"
  192. using crypto::AppleKeychain;
  193. diff --git a/components/remote_cocoa/app_shim/BUILD.gn b/components/remote_cocoa/app_shim/BUILD.gn
  194. index ad40ddbbcb0fcfa070833ea6c0d01432bbb67768..df632da340c132f469f4f35738514763437e67fc 100644
  195. --- a/components/remote_cocoa/app_shim/BUILD.gn
  196. +++ b/components/remote_cocoa/app_shim/BUILD.gn
  197. @@ -75,6 +75,7 @@ component("app_shim") {
  198. "//components/crash/core/common",
  199. "//components/remote_cocoa/common:mojo",
  200. "//components/system_media_controls",
  201. + "//electron/build/config:generate_mas_config",
  202. "//mojo/public/cpp/bindings",
  203. "//net",
  204. "//ui/accelerated_widget_mac",
  205. diff --git a/components/remote_cocoa/app_shim/application_bridge.mm b/components/remote_cocoa/app_shim/application_bridge.mm
  206. index e9f4e5131238b9fb5f1b4b3e90a0cb84a7fc15b4..8b5f4cae3123ac5480ad73f0c873fca0d62f7c9f 100644
  207. --- a/components/remote_cocoa/app_shim/application_bridge.mm
  208. +++ b/components/remote_cocoa/app_shim/application_bridge.mm
  209. @@ -12,6 +12,7 @@
  210. #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
  211. #include "components/remote_cocoa/app_shim/native_widget_ns_window_host_helper.h"
  212. #include "components/system_media_controls/mac/remote_cocoa/system_media_controls_bridge.h"
  213. +#include "electron/mas.h"
  214. #include "mojo/public/cpp/bindings/associated_remote.h"
  215. #include "mojo/public/cpp/bindings/self_owned_receiver.h"
  216. #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
  217. @@ -51,6 +52,7 @@
  218. // NativeWidgetNSWindowHostHelper:
  219. id GetNativeViewAccessible() override {
  220. +#if !IS_MAS_BUILD()
  221. if (!remote_accessibility_element_) {
  222. base::ProcessId browser_pid = base::kNullProcessId;
  223. std::vector<uint8_t> element_token;
  224. @@ -61,6 +63,9 @@ id GetNativeViewAccessible() override {
  225. ui::RemoteAccessibility::GetRemoteElementFromToken(element_token);
  226. }
  227. return remote_accessibility_element_;
  228. +#else
  229. + return nil;
  230. +#endif
  231. }
  232. void DispatchKeyEvent(ui::KeyEvent* event) override {
  233. bool event_handled = false;
  234. @@ -99,7 +104,9 @@ void GetWordAt(const gfx::Point& location_in_content,
  235. mojo::AssociatedRemote<mojom::TextInputHost> text_input_host_remote_;
  236. std::unique_ptr<NativeWidgetNSWindowBridge> bridge_;
  237. +#if !IS_MAS_BUILD()
  238. NSAccessibilityRemoteUIElement* __strong remote_accessibility_element_;
  239. +#endif
  240. };
  241. } // namespace
  242. 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
  243. index 19fff43c3daaef5451b6b60b84a610a21311448e..240b954661d34fcc4329d39490be33c485fa8b6e 100644
  244. --- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  245. +++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  246. @@ -9,7 +9,9 @@
  247. #include "components/remote_cocoa/app_shim/features.h"
  248. #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
  249. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  250. +#include "electron/mas.h"
  251. +#if !IS_MAS_BUILD()
  252. namespace {
  253. // Workaround for https://crbug.com/1369643
  254. const double kThinControllerHeight = 0.5;
  255. @@ -100,12 +102,15 @@ - (void)maybeShowTrafficLights {
  256. @end
  257. +#endif // MAS_BUILD
  258. +
  259. @implementation BrowserNativeWidgetWindow
  260. @synthesize thinTitlebarViewController = _thinTitlebarViewController;
  261. // NSWindow (PrivateAPI) overrides.
  262. +#if !IS_MAS_BUILD()
  263. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  264. // - NSThemeFrame and its subclasses will be nil if it's missing at runtime.
  265. if ([BrowserWindowFrame class])
  266. @@ -165,6 +170,8 @@ - (BOOL)_usesCustomDrawing {
  267. return NO;
  268. }
  269. +#endif // MAS_BUILD
  270. +
  271. // Handle "Move focus to the window toolbar" configured in System Preferences ->
  272. // Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|)
  273. // tends to just be nil.
  274. @@ -175,8 +182,8 @@ - (void)_handleFocusToolbarHotKey:(id)unknown {
  275. }
  276. - (void)setAlwaysShowTrafficLights:(BOOL)alwaysShow {
  277. - [base::apple::ObjCCastStrict<BrowserWindowFrame>(self.contentView.superview)
  278. - setAlwaysShowTrafficLights:alwaysShow];
  279. + // [base::apple::ObjCCastStrict<BrowserWindowFrame>(self.contentView.superview)
  280. + // setAlwaysShowTrafficLights:alwaysShow];
  281. }
  282. @end
  283. 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
  284. index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..149de0175c2ec0e41e3ba40caad7019ca87386d6 100644
  285. --- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  286. +++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  287. @@ -4,6 +4,10 @@
  288. #import "components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.h"
  289. +#include "electron/mas.h"
  290. +
  291. +#if !IS_MAS_BUILD()
  292. +
  293. @interface NSWindow (PrivateAPI)
  294. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  295. @end
  296. @@ -18,8 +22,12 @@ - (CGFloat)_titlebarHeight {
  297. }
  298. @end
  299. +#endif // MAS_BUILD
  300. +
  301. @implementation NativeWidgetMacFramelessNSWindow
  302. +#if !IS_MAS_BUILD()
  303. +
  304. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  305. if ([NativeWidgetMacFramelessNSWindowFrame class]) {
  306. return [NativeWidgetMacFramelessNSWindowFrame class];
  307. @@ -27,4 +35,6 @@ + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  308. return [super frameViewClassForStyleMask:windowStyle];
  309. }
  310. +#endif // MAS_BUILD
  311. +
  312. @end
  313. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  314. index 127a2829fafa04bfbab0b883304dfb815d7e1c22..61d7946e52862f3586b1e098d7d44a125656de81 100644
  315. --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  316. +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  317. @@ -9,6 +9,7 @@
  318. #include "base/apple/foundation_util.h"
  319. #include "components/remote_cocoa/app_shim/remote_cocoa_app_shim_export.h"
  320. +#include "electron/mas.h"
  321. #import "ui/base/cocoa/command_dispatcher.h"
  322. namespace remote_cocoa {
  323. @@ -17,6 +18,7 @@ class NativeWidgetNSWindowBridge;
  324. @protocol WindowTouchBarDelegate;
  325. +#if !IS_MAS_BUILD()
  326. // Weak lets Chrome launch even if a future macOS doesn't have the below classes
  327. WEAK_IMPORT_ATTRIBUTE
  328. @interface NSNextStepFrame : NSView
  329. @@ -33,6 +35,7 @@ REMOTE_COCOA_APP_SHIM_EXPORT
  330. REMOTE_COCOA_APP_SHIM_EXPORT
  331. @interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame
  332. @end
  333. +#endif
  334. // The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that
  335. // can only be accomplished by overriding methods.
  336. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  337. index 2b50e3c3750c9ac6dd84a514663062a5d754b43e..49ced9aa87d3bcb00cd3d76ac32d4eec89873549 100644
  338. --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  339. +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  340. @@ -26,6 +26,7 @@
  341. #import "components/remote_cocoa/app_shim/views_nswindow_delegate.h"
  342. #import "components/remote_cocoa/app_shim/window_touch_bar_delegate.h"
  343. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  344. +#include "electron/mas.h"
  345. #include "ui/accessibility/platform/ax_platform_node.h"
  346. #import "ui/base/cocoa/user_interface_item_command_handler.h"
  347. #import "ui/base/cocoa/window_size_constants.h"
  348. @@ -112,14 +113,18 @@ void OrderChildWindow(NSWindow* child_window,
  349. } // namespace
  350. +#if !IS_MAS_BUILD()
  351. @interface NSNextStepFrame (Private)
  352. - (instancetype)initWithFrame:(NSRect)frame
  353. styleMask:(NSUInteger)styleMask
  354. owner:(id)owner;
  355. @end
  356. +#endif
  357. @interface NSWindow (Private)
  358. +#if !IS_MAS_BUILD()
  359. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
  360. +#endif
  361. - (BOOL)hasKeyAppearance;
  362. - (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
  363. - (BOOL)_isConsideredOpenForPersistentState;
  364. @@ -159,6 +164,8 @@ - (void)cr_mouseDownOnFrameView:(NSEvent*)event {
  365. }
  366. @end
  367. +#if !IS_MAS_BUILD()
  368. +
  369. @implementation NativeWidgetMacNSWindowTitledFrame
  370. - (void)mouseDown:(NSEvent*)event {
  371. if (self.window.isMovable)
  372. @@ -186,6 +193,8 @@ - (BOOL)usesCustomDrawing {
  373. }
  374. @end
  375. +#endif // MAS_BUILD
  376. +
  377. @implementation NativeWidgetMacNSWindow {
  378. @private
  379. CommandDispatcher* __strong _commandDispatcher;
  380. @@ -383,6 +392,8 @@ - (NSAccessibilityRole)accessibilityRole {
  381. // NSWindow overrides.
  382. +#if !IS_MAS_BUILD()
  383. +
  384. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
  385. if (windowStyle & NSWindowStyleMaskTitled) {
  386. if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
  387. @@ -394,6 +405,8 @@ + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
  388. return [super frameViewClassForStyleMask:windowStyle];
  389. }
  390. +#endif
  391. +
  392. - (BOOL)_isTitleHidden {
  393. bool shouldShowWindowTitle = YES;
  394. if (_bridge)
  395. 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
  396. index 36c522793dc37f7c72f7cccde50895927b5560cb..689351b5a6e6e6013b808c1b4924b8848dcc0fa2 100644
  397. --- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
  398. +++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
  399. @@ -41,6 +41,7 @@
  400. #import "components/remote_cocoa/app_shim/views_nswindow_delegate.h"
  401. #import "components/remote_cocoa/app_shim/window_move_loop.h"
  402. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  403. +#include "electron/mas.h"
  404. #include "mojo/public/cpp/bindings/self_owned_receiver.h"
  405. #include "net/cert/x509_util_apple.h"
  406. #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
  407. @@ -665,10 +666,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
  408. // this should be treated as an error and caught early.
  409. CHECK(bridged_view_);
  410. +#if !IS_MAS_BUILD()
  411. // Send the accessibility tokens for the NSView now that it exists.
  412. host_->SetRemoteAccessibilityTokens(
  413. ui::RemoteAccessibility::GetTokenForLocalElement(window_),
  414. ui::RemoteAccessibility::GetTokenForLocalElement(bridged_view_));
  415. +#endif
  416. // Beware: This view was briefly removed (in favor of a bare CALayer) in
  417. // https://crrev.com/c/1236675. The ordering of unassociated layers relative
  418. diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn
  419. index 3f1b98692d11116f965fe0eb7e4b6cae308a4f19..6ac941799bda10ce7f93612691a438018160a9dd 100644
  420. --- a/components/viz/service/BUILD.gn
  421. +++ b/components/viz/service/BUILD.gn
  422. @@ -378,6 +378,7 @@ viz_component("service") {
  423. "frame_sinks/external_begin_frame_source_mac.h",
  424. ]
  425. }
  426. + deps += ["//electron/build/config:generate_mas_config"]
  427. }
  428. if (is_android || use_ozone) {
  429. @@ -678,6 +679,7 @@ viz_source_set("unit_tests") {
  430. "display_embedder/software_output_device_mac_unittest.mm",
  431. ]
  432. frameworks = [ "IOSurface.framework" ]
  433. + deps += ["//electron/build/config:generate_mas_config"]
  434. }
  435. if (is_win) {
  436. 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
  437. index dbf334caa3a6d10017b69ad76802e389a011436b..da828823e8195cc9e497866363c9af93dcd4ec3f 100644
  438. --- a/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
  439. +++ b/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
  440. @@ -15,6 +15,7 @@
  441. #include "content/common/web_contents_ns_view_bridge.mojom.h"
  442. #include "content/public/browser/remote_cocoa.h"
  443. #include "content/public/browser/render_widget_host_view_mac_delegate.h"
  444. +#include "electron/mas.h"
  445. #include "mojo/public/cpp/bindings/associated_receiver.h"
  446. #include "mojo/public/cpp/bindings/associated_remote.h"
  447. #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
  448. @@ -63,7 +64,9 @@ explicit RenderWidgetHostNSViewBridgeOwner(
  449. const RenderWidgetHostNSViewBridgeOwner&) = delete;
  450. private:
  451. +#if !IS_MAS_BUILD()
  452. NSAccessibilityRemoteUIElement* __strong remote_accessibility_element_;
  453. +#endif
  454. void OnMojoDisconnect() { delete this; }
  455. std::unique_ptr<blink::WebCoalescedInputEvent> TranslateEvent(
  456. @@ -75,6 +78,7 @@ explicit RenderWidgetHostNSViewBridgeOwner(
  457. }
  458. id GetAccessibilityElement() override {
  459. +#if !IS_MAS_BUILD()
  460. if (!remote_accessibility_element_) {
  461. base::ProcessId browser_pid = base::kNullProcessId;
  462. std::vector<uint8_t> element_token;
  463. @@ -85,6 +89,9 @@ id GetAccessibilityElement() override {
  464. ui::RemoteAccessibility::GetRemoteElementFromToken(element_token);
  465. }
  466. return remote_accessibility_element_;
  467. +#else
  468. + return nil;
  469. +#endif
  470. }
  471. // RenderWidgetHostNSViewHostHelper implementation.
  472. @@ -103,8 +110,10 @@ id GetFocusedBrowserAccessibilityElement() override {
  473. return [bridgedContentView accessibilityFocusedUIElement];
  474. }
  475. void SetAccessibilityWindow(NSWindow* window) override {
  476. +#if !IS_MAS_BUILD()
  477. host_->SetRemoteAccessibilityWindowToken(
  478. ui::RemoteAccessibility::GetTokenForLocalElement(window));
  479. +#endif
  480. }
  481. void ForwardKeyboardEvent(const input::NativeWebKeyboardEvent& key_event,
  482. 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
  483. index a76028eed0249244d0559de102a756e3b2771b63..cb65efb56849d57e2e656f90d5b1d737ba2d952d 100644
  484. --- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
  485. +++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
  486. @@ -35,6 +35,7 @@
  487. #include "content/public/browser/browser_accessibility_state.h"
  488. #import "content/public/browser/render_widget_host_view_mac_delegate.h"
  489. #include "content/public/common/content_features.h"
  490. +#include "electron/mas.h"
  491. #include "skia/ext/skia_utils_mac.h"
  492. #include "third_party/blink/public/common/features.h"
  493. #include "third_party/blink/public/mojom/input/input_handler.mojom.h"
  494. @@ -2151,15 +2152,21 @@ - (NSAccessibilityRole)accessibilityRole {
  495. // Since this implementation doesn't have to wait any IPC calls, this doesn't
  496. // make any key-typing jank. --hbono 7/23/09
  497. //
  498. +#if !IS_MAS_BUILD()
  499. extern "C" {
  500. extern NSString* NSTextInputReplacementRangeAttributeName;
  501. }
  502. +#endif
  503. - (NSArray*)validAttributesForMarkedText {
  504. // This code is just copied from WebKit except renaming variables.
  505. static NSArray* const kAttributes = @[
  506. NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
  507. +#if !IS_MAS_BUILD()
  508. NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName
  509. +#else
  510. + NSMarkedClauseSegmentAttributeName
  511. +#endif
  512. ];
  513. return kAttributes;
  514. }
  515. diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
  516. index fec51f705d1a8424fdbff13d33aa6a2b16a650e5..42f5feab06cf2ebb20f851a78111aa952e8bff55 100644
  517. --- a/content/browser/BUILD.gn
  518. +++ b/content/browser/BUILD.gn
  519. @@ -329,6 +329,7 @@ source_set("browser") {
  520. "//ui/touch_selection",
  521. "//ui/webui/resources",
  522. "//v8:v8_version",
  523. + "//electron/build/config:generate_mas_config",
  524. ]
  525. public_deps = [
  526. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h
  527. index bea4e26ef8577e8e8bc60287cf1b94c7dfcc9478..eed42b0cbc3422b7fd59ae1b2550c53d6c92c9e3 100644
  528. --- a/content/browser/renderer_host/render_widget_host_view_mac.h
  529. +++ b/content/browser/renderer_host/render_widget_host_view_mac.h
  530. @@ -23,6 +23,7 @@
  531. #include "content/browser/renderer_host/text_input_manager.h"
  532. #include "content/common/content_export.h"
  533. #include "content/common/render_widget_host_ns_view.mojom.h"
  534. +#include "electron/mas.h"
  535. #include "mojo/public/cpp/bindings/associated_receiver.h"
  536. #include "mojo/public/cpp/bindings/associated_remote.h"
  537. #include "third_party/blink/public/mojom/webshare/webshare.mojom.h"
  538. @@ -53,7 +54,9 @@ class CursorManager;
  539. @protocol RenderWidgetHostViewMacDelegate;
  540. +#if !IS_MAS_BUILD()
  541. @class NSAccessibilityRemoteUIElement;
  542. +#endif
  543. @class RenderWidgetHostViewCocoa;
  544. namespace content {
  545. @@ -691,9 +694,11 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
  546. // EnsureSurfaceSynchronizedForWebTest().
  547. uint32_t latest_capture_sequence_number_ = 0u;
  548. +#if !IS_MAS_BUILD()
  549. // Remote accessibility objects corresponding to the NSWindow that this is
  550. // displayed to the user in.
  551. NSAccessibilityRemoteUIElement* __strong remote_window_accessible_;
  552. +#endif
  553. // Used to force the NSApplication's focused accessibility element to be the
  554. // content::BrowserAccessibilityCocoa accessibility tree when the NSView for
  555. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
  556. index 9185fd223c9611faee546570c0df36bc94cdb28c..86886e94e9e2c52e297a82175f6071852e792148 100644
  557. --- a/content/browser/renderer_host/render_widget_host_view_mac.mm
  558. +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
  559. @@ -48,6 +48,7 @@
  560. #include "content/public/browser/render_widget_host.h"
  561. #include "content/public/browser/web_contents.h"
  562. #include "content/public/common/page_visibility_state.h"
  563. +#include "electron/mas.h"
  564. #include "media/base/media_switches.h"
  565. #include "skia/ext/platform_canvas.h"
  566. #include "skia/ext/skia_utils_mac.h"
  567. @@ -273,8 +274,10 @@
  568. void RenderWidgetHostViewMac::MigrateNSViewBridge(
  569. remote_cocoa::mojom::Application* remote_cocoa_application,
  570. uint64_t parent_ns_view_id) {
  571. +#if !IS_MAS_BUILD()
  572. // Destroy the previous remote accessibility element.
  573. remote_window_accessible_ = nil;
  574. +#endif
  575. // Reset `ns_view_` before resetting `remote_ns_view_` to avoid dangling
  576. // pointers. `ns_view_` gets reinitialized later in this method.
  577. @@ -1616,8 +1619,10 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
  578. gfx::NativeViewAccessible
  579. RenderWidgetHostViewMac::AccessibilityGetNativeViewAccessibleForWindow() {
  580. +#if !IS_MAS_BUILD()
  581. if (remote_window_accessible_)
  582. return remote_window_accessible_;
  583. +#endif
  584. return [GetInProcessNSView() window];
  585. }
  586. @@ -1666,9 +1671,11 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
  587. }
  588. void RenderWidgetHostViewMac::SetAccessibilityWindow(NSWindow* window) {
  589. +#if !IS_MAS_BUILD()
  590. // When running in-process, just use the NSView's NSWindow as its own
  591. // accessibility element.
  592. remote_window_accessible_ = nil;
  593. +#endif
  594. }
  595. bool RenderWidgetHostViewMac::SyncIsWidgetForMainFrame(
  596. @@ -2195,20 +2202,26 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback,
  597. void RenderWidgetHostViewMac::GetRenderWidgetAccessibilityToken(
  598. GetRenderWidgetAccessibilityTokenCallback callback) {
  599. base::ProcessId pid = getpid();
  600. +#if !IS_MAS_BUILD()
  601. id element_id = GetNativeViewAccessible();
  602. std::vector<uint8_t> token =
  603. ui::RemoteAccessibility::GetTokenForLocalElement(element_id);
  604. std::move(callback).Run(pid, token);
  605. +#else
  606. + std::move(callback).Run(pid, std::vector<uint8_t>());
  607. +#endif
  608. }
  609. void RenderWidgetHostViewMac::SetRemoteAccessibilityWindowToken(
  610. const std::vector<uint8_t>& window_token) {
  611. +#if !IS_MAS_BUILD()
  612. if (window_token.empty()) {
  613. remote_window_accessible_ = nil;
  614. } else {
  615. remote_window_accessible_ =
  616. ui::RemoteAccessibility::GetRemoteElementFromToken(window_token);
  617. }
  618. +#endif
  619. }
  620. ///////////////////////////////////////////////////////////////////////////////
  621. diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn
  622. index 804e0934004a465b610fb9b83692adea15808d87..486dffeffc1637af3a4eba4d037e71628573c6ac 100644
  623. --- a/content/common/BUILD.gn
  624. +++ b/content/common/BUILD.gn
  625. @@ -285,6 +285,7 @@ source_set("common") {
  626. "//ui/shell_dialogs",
  627. "//url",
  628. "//url/ipc:url_ipc",
  629. + "//electron/build/config:generate_mas_config",
  630. ]
  631. defines = []
  632. diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn
  633. index 9c312682be17f1add7e9aa56772c3e1a2e22f98b..5f4362d3c717f24f787ab9298d4f5103442f3073 100644
  634. --- a/content/renderer/BUILD.gn
  635. +++ b/content/renderer/BUILD.gn
  636. @@ -329,6 +329,7 @@ target(link_target_type, "renderer") {
  637. "//ui/surface",
  638. "//url",
  639. "//v8",
  640. + "//electron/build/config:generate_mas_config",
  641. ]
  642. allow_circular_includes_from = []
  643. diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm
  644. index d4db3b179725cb96bcbd0f73db7d52ef8b7522db..703b0f56a61abac51961bfd918b7349b943900de 100644
  645. --- a/content/renderer/renderer_main_platform_delegate_mac.mm
  646. +++ b/content/renderer/renderer_main_platform_delegate_mac.mm
  647. @@ -7,12 +7,15 @@
  648. #import <Cocoa/Cocoa.h>
  649. #include "base/check_op.h"
  650. +#include "electron/mas.h"
  651. #include "sandbox/mac/seatbelt.h"
  652. #include "sandbox/mac/system_services.h"
  653. +#if !IS_MAS_BUILD()
  654. extern "C" {
  655. CGError CGSSetDenyWindowServerConnections(bool);
  656. }
  657. +#endif
  658. namespace content {
  659. @@ -22,6 +25,7 @@
  660. // verifies there are no existing open connections), and then indicates that
  661. // Chrome should continue execution without access to launchservicesd.
  662. void DisableSystemServices() {
  663. +#if !IS_MAS_BUILD()
  664. // Tell the WindowServer that we don't want to make any future connections.
  665. // This will return Success as long as there are no open connections, which
  666. // is what we want.
  667. @@ -30,6 +34,7 @@ void DisableSystemServices() {
  668. sandbox::DisableLaunchServices();
  669. sandbox::DisableCoreServicesCheckFix();
  670. +#endif
  671. }
  672. } // namespace
  673. diff --git a/content/renderer/theme_helper_mac.mm b/content/renderer/theme_helper_mac.mm
  674. index a1068589ad844518038ee7bc15a3de9bc5cba525..1ff781c49f086ec8015c7d3c44567dbec3d00ff8 100644
  675. --- a/content/renderer/theme_helper_mac.mm
  676. +++ b/content/renderer/theme_helper_mac.mm
  677. @@ -7,16 +7,28 @@
  678. #include <Cocoa/Cocoa.h>
  679. #include "base/strings/sys_string_conversions.h"
  680. +#include "electron/mas.h"
  681. +#if !IS_MAS_BUILD()
  682. extern "C" {
  683. bool CGFontRenderingGetFontSmoothingDisabled(void);
  684. }
  685. -
  686. +#endif
  687. namespace content {
  688. bool IsSubpixelAntialiasingAvailable() {
  689. +#if !IS_MAS_BUILD()
  690. // See https://trac.webkit.org/changeset/239306/webkit for more info.
  691. return !CGFontRenderingGetFontSmoothingDisabled();
  692. +#else
  693. + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
  694. + NSString *default_key = @"CGFontRenderingGetFontSmoothingDisabled";
  695. + // Check that key exists since boolForKey defaults to NO when the
  696. + // key is missing and this key in fact defaults to YES;
  697. + if ([defaults objectForKey:default_key] == nil)
  698. + return false;
  699. + return ![defaults boolForKey:default_key];
  700. +#endif
  701. }
  702. } // namespace content
  703. diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
  704. index bb9096575a4e362f084d6d612319595f109f27a1..c0eaa67da879637e3adfd948d400ee6487512c00 100644
  705. --- a/content/test/BUILD.gn
  706. +++ b/content/test/BUILD.gn
  707. @@ -652,6 +652,7 @@ static_library("test_support") {
  708. "//url",
  709. "//url/mojom:url_mojom_gurl",
  710. "//v8",
  711. + "//electron/build/config:generate_mas_config"
  712. ]
  713. data_deps = [
  714. @@ -1107,6 +1108,7 @@ static_library("browsertest_support") {
  715. }
  716. configs += [ "//v8:external_startup_data" ]
  717. + deps += ["//electron/build/config:generate_mas_config"]
  718. }
  719. mojom("content_test_mojo_bindings") {
  720. @@ -1934,6 +1936,7 @@ test("content_browsertests") {
  721. "//ui/shell_dialogs",
  722. "//ui/snapshot",
  723. "//ui/webui:test_support",
  724. + "//electron/build/config:generate_mas_config"
  725. ]
  726. if (!(is_chromeos && target_cpu == "arm64" && current_cpu == "arm")) {
  727. @@ -3222,6 +3225,7 @@ test("content_unittests") {
  728. "//ui/latency:test_support",
  729. "//ui/shell_dialogs:shell_dialogs",
  730. "//ui/webui:test_support",
  731. + "//electron/build/config:generate_mas_config"
  732. ]
  733. if (enable_nocompile_tests) {
  734. diff --git a/content/web_test/BUILD.gn b/content/web_test/BUILD.gn
  735. index 8779cf7cbbe2a583fda51867eaebc627f00bd4cd..98da1587fdc8cc8358a69db2b51d39820a0b15f3 100644
  736. --- a/content/web_test/BUILD.gn
  737. +++ b/content/web_test/BUILD.gn
  738. @@ -227,6 +227,7 @@ static_library("web_test_browser") {
  739. "//ui/gl",
  740. "//ui/shell_dialogs:shell_dialogs",
  741. "//url",
  742. + "//electron/build/config:generate_mas_config"
  743. ]
  744. # TODO(crbug.com/40139469): Blink test plugin must be migrated from PPAPI.
  745. diff --git a/device/bluetooth/BUILD.gn b/device/bluetooth/BUILD.gn
  746. index af32815b302dff9750a1dcd83b6e03df7d5f2dc9..7f20a6affe68057eb51d3176d7a901c85cacf2e0 100644
  747. --- a/device/bluetooth/BUILD.gn
  748. +++ b/device/bluetooth/BUILD.gn
  749. @@ -258,6 +258,7 @@ component("bluetooth") {
  750. "IOKit.framework",
  751. "Foundation.framework",
  752. ]
  753. + deps += ["//electron/build/config:generate_mas_config"]
  754. }
  755. if (is_mac) {
  756. diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
  757. index 6431af67ab634cf23729b9102c189b2181cfd2cf..22040e1bfb96d810a2d8e62e44e4afbc684c8c06 100644
  758. --- a/device/bluetooth/bluetooth_adapter_mac.mm
  759. +++ b/device/bluetooth/bluetooth_adapter_mac.mm
  760. @@ -38,7 +38,9 @@
  761. #include "device/bluetooth/bluetooth_discovery_session_outcome.h"
  762. #include "device/bluetooth/bluetooth_socket_mac.h"
  763. #include "device/bluetooth/public/cpp/bluetooth_address.h"
  764. +#include "electron/mas.h"
  765. +#if !IS_MAS_BUILD()
  766. extern "C" {
  767. // Undocumented IOBluetooth Preference API [1]. Used by `blueutil` [2] and
  768. // `Karabiner` [3] to programmatically control the Bluetooth state. Calling the
  769. @@ -52,6 +54,7 @@
  770. // [4] https://support.apple.com/kb/PH25091
  771. void IOBluetoothPreferenceSetControllerPowerState(int state);
  772. }
  773. +#endif
  774. // A simple helper class that forwards any Bluetooth device connect notification
  775. // to its wrapped |_adapter|.
  776. @@ -161,8 +164,10 @@ bool IsDeviceSystemPaired(const std::string& device_address) {
  777. : controller_state_function_(
  778. base::BindRepeating(&BluetoothAdapterMac::GetHostControllerState,
  779. base::Unretained(this))),
  780. +#if !IS_MAS_BUILD()
  781. power_state_function_(
  782. base::BindRepeating(IOBluetoothPreferenceSetControllerPowerState)),
  783. +#endif
  784. device_paired_status_callback_(
  785. base::BindRepeating(&IsDeviceSystemPaired)) {
  786. }
  787. @@ -313,8 +318,12 @@ bool IsDeviceSystemPaired(const std::string& device_address) {
  788. }
  789. bool BluetoothAdapterMac::SetPoweredImpl(bool powered) {
  790. +#if !IS_MAS_BUILD()
  791. power_state_function_.Run(base::strict_cast<int>(powered));
  792. return true;
  793. +#else
  794. + return false;
  795. +#endif
  796. }
  797. base::WeakPtr<BluetoothLowEnergyAdapterApple>
  798. diff --git a/gpu/ipc/service/BUILD.gn b/gpu/ipc/service/BUILD.gn
  799. index 973cd337f2781271b4ca3e29db07939ec6917327..90658a336138e4e50f93c38f1c1f465c1c2bd4dc 100644
  800. --- a/gpu/ipc/service/BUILD.gn
  801. +++ b/gpu/ipc/service/BUILD.gn
  802. @@ -135,6 +135,7 @@ component("service") {
  803. "QuartzCore.framework",
  804. ]
  805. defines += [ "GL_SILENCE_DEPRECATION" ]
  806. + deps += ["//electron/build/config:generate_mas_config"]
  807. }
  808. if (is_ios) {
  809. sources += [ "image_transport_surface_ios.mm" ]
  810. diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h
  811. index 36322ddd3047f96569f35807541a37d3c6672b09..0121a780cf3b79fc1120c1b85cd5cd30c14968ef 100644
  812. --- a/gpu/ipc/service/image_transport_surface_overlay_mac.h
  813. +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h
  814. @@ -8,6 +8,7 @@
  815. #include <vector>
  816. #include "base/memory/weak_ptr.h"
  817. +#include "electron/mas.h"
  818. #include "gpu/ipc/service/command_buffer_stub.h"
  819. #include "gpu/ipc/service/image_transport_surface.h"
  820. #include "ui/gfx/ca_layer_result.h"
  821. @@ -23,7 +24,9 @@
  822. #include "ui/display/types/display_constants.h"
  823. #endif
  824. +#if !IS_MAS_BUILD()
  825. @class CAContext;
  826. +#endif
  827. @class CALayer;
  828. namespace ui {
  829. diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn
  830. index 977aa5b452c882ee69690ba034ec00c9e7ff7e24..3ae3e2ead48ea1af9307dcd12647ca2a24b3a6f4 100644
  831. --- a/media/audio/BUILD.gn
  832. +++ b/media/audio/BUILD.gn
  833. @@ -198,6 +198,7 @@ source_set("audio") {
  834. "CoreMedia.framework",
  835. ]
  836. weak_frameworks = [ "ScreenCaptureKit.framework" ] # macOS 13.0
  837. + deps += ["//electron/build/config:generate_mas_config"]
  838. }
  839. if (is_ios) {
  840. diff --git a/media/audio/apple/audio_low_latency_input.cc b/media/audio/apple/audio_low_latency_input.cc
  841. index da17e30384033a795e35d9cd27f16aa1a2b1ad24..f98dc86b19569290d81e7d2a172c1f217a72d00e 100644
  842. --- a/media/audio/apple/audio_low_latency_input.cc
  843. +++ b/media/audio/apple/audio_low_latency_input.cc
  844. @@ -29,6 +29,7 @@
  845. #include "base/strings/sys_string_conversions.h"
  846. #include "base/time/time.h"
  847. #include "base/trace_event/trace_event.h"
  848. +#include "electron/mas.h"
  849. #include "media/audio/apple/audio_manager_apple.h"
  850. #include "media/audio/apple/scoped_audio_unit.h"
  851. #include "media/base/audio_bus.h"
  852. @@ -41,19 +42,23 @@
  853. namespace {
  854. extern "C" {
  855. +#if !IS_MAS_BUILD()
  856. // See:
  857. // https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/PAL/pal/spi/cf/CoreAudioSPI.h?rev=228264
  858. OSStatus AudioDeviceDuck(AudioDeviceID inDevice,
  859. Float32 inDuckedLevel,
  860. const AudioTimeStamp* __nullable inStartTime,
  861. Float32 inRampDuration) __attribute__((weak_import));
  862. +#endif
  863. }
  864. void UndoDucking(AudioDeviceID output_device_id) {
  865. +#if !IS_MAS_BUILD()
  866. if (AudioDeviceDuck != nullptr) {
  867. // Ramp the volume back up over half a second.
  868. AudioDeviceDuck(output_device_id, 1.0, nullptr, 0.5);
  869. }
  870. +#endif
  871. }
  872. } // namespace
  873. #endif
  874. diff --git a/net/dns/BUILD.gn b/net/dns/BUILD.gn
  875. index 543b8ae16c1ddc33b3602adc7216a1756681f5fe..21b2898f8b1f40a85d60145bfdff3aa1d7e9b154 100644
  876. --- a/net/dns/BUILD.gn
  877. +++ b/net/dns/BUILD.gn
  878. @@ -189,6 +189,8 @@ source_set("dns") {
  879. ":host_resolver_manager",
  880. ":mdns_client",
  881. ]
  882. +
  883. + deps += ["//electron/build/config:generate_mas_config"]
  884. }
  885. # The standard API of net/dns.
  886. diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
  887. index 70d5665ad7b9ef62370497636af919ede2508ad4..f4dc3e2b8053cdb3e8c439ab1a1d6369a8e6a7dc 100644
  888. --- a/net/dns/dns_config_service_posix.cc
  889. +++ b/net/dns/dns_config_service_posix.cc
  890. @@ -28,6 +28,7 @@
  891. #include "base/threading/scoped_blocking_call.h"
  892. #include "base/time/time.h"
  893. #include "build/build_config.h"
  894. +#include "electron/mas.h"
  895. #include "net/base/ip_endpoint.h"
  896. #include "net/dns/dns_config.h"
  897. #include "net/dns/dns_hosts.h"
  898. @@ -135,8 +136,8 @@ class DnsConfigServicePosix::Watcher : public DnsConfigService::Watcher {
  899. bool Watch() override {
  900. CheckOnCorrectSequence();
  901. -
  902. bool success = true;
  903. +#if !IS_MAS_BUILD()
  904. if (!config_watcher_.Watch(base::BindRepeating(&Watcher::OnConfigChanged,
  905. base::Unretained(this)))) {
  906. LOG(ERROR) << "DNS config watch failed to start.";
  907. @@ -153,6 +154,7 @@ class DnsConfigServicePosix::Watcher : public DnsConfigService::Watcher {
  908. success = false;
  909. }
  910. #endif // !BUILDFLAG(IS_IOS)
  911. +#endif
  912. return success;
  913. }
  914. diff --git a/sandbox/mac/BUILD.gn b/sandbox/mac/BUILD.gn
  915. index 453e2185fc85fcb29fa7af3f94cce5bda8118b0c..1c383675bb9113b5b1df9280b8ee994123794dfc 100644
  916. --- a/sandbox/mac/BUILD.gn
  917. +++ b/sandbox/mac/BUILD.gn
  918. @@ -25,6 +25,7 @@ component("seatbelt") {
  919. libs = [ "sandbox" ]
  920. deps = [ ":seatbelt_export" ]
  921. defines = [ "SEATBELT_IMPLEMENTATION" ]
  922. + deps += ["//electron/build/config:generate_mas_config"]
  923. }
  924. component("seatbelt_extension") {
  925. @@ -38,6 +39,7 @@ component("seatbelt_extension") {
  926. libs = [ "sandbox" ]
  927. public_deps = [ "//base" ]
  928. defines = [ "SEATBELT_IMPLEMENTATION" ]
  929. + deps += ["//electron/build/config:generate_mas_config"]
  930. }
  931. component("system_services") {
  932. @@ -52,6 +54,7 @@ component("system_services") {
  933. deps = [ ":seatbelt_export" ]
  934. public_deps = [ "//base" ]
  935. defines = [ "SEATBELT_IMPLEMENTATION" ]
  936. + deps += ["//electron/build/config:generate_mas_config"]
  937. }
  938. source_set("sandbox_unittests") {
  939. diff --git a/sandbox/mac/sandbox_logging.cc b/sandbox/mac/sandbox_logging.cc
  940. index 095c639b9893e885d8937e29ed7d47a7c28bc6b6..7e0cf9b9f94b16741358bdb45122f8b2bd68c0f9 100644
  941. --- a/sandbox/mac/sandbox_logging.cc
  942. +++ b/sandbox/mac/sandbox_logging.cc
  943. @@ -16,6 +16,7 @@
  944. #include <string>
  945. #include "build/build_config.h"
  946. +#include "electron/mas.h"
  947. #include "sandbox/mac/sandbox_crash_message.h"
  948. #if defined(ARCH_CPU_X86_64)
  949. @@ -33,9 +34,11 @@
  950. }
  951. #endif
  952. +#if !IS_MAS_BUILD()
  953. extern "C" {
  954. void abort_report_np(const char*, ...);
  955. }
  956. +#endif
  957. namespace sandbox::logging {
  958. @@ -76,9 +79,11 @@ void SendOsLog(Level level, const char* message) {
  959. sandbox::crash_message::SetCrashMessage(message);
  960. }
  961. +#if !IS_MAS_BUILD()
  962. if (level == Level::FATAL) {
  963. abort_report_np(message);
  964. }
  965. +#endif
  966. }
  967. // |error| is strerror(errno) when a P* logging function is called. Pass
  968. diff --git a/sandbox/mac/seatbelt.cc b/sandbox/mac/seatbelt.cc
  969. index 1960e1c8771fad615a098af09ff1f9a191f67764..29b97b352d08cd1fe73b17fd80cb41cc7e58dcaa 100644
  970. --- a/sandbox/mac/seatbelt.cc
  971. +++ b/sandbox/mac/seatbelt.cc
  972. @@ -4,12 +4,14 @@
  973. #include "sandbox/mac/seatbelt.h"
  974. +#include "electron/mas.h"
  975. +
  976. #include <errno.h>
  977. #include <unistd.h>
  978. extern "C" {
  979. #include <sandbox.h>
  980. -
  981. +#if !IS_MAS_BUILD()
  982. int sandbox_init_with_parameters(const char* profile,
  983. uint64_t flags,
  984. const char* const parameters[],
  985. @@ -40,13 +42,13 @@ sandbox_profile_t* sandbox_compile_string(const char* data,
  986. char** error);
  987. int sandbox_apply(sandbox_profile_t*);
  988. void sandbox_free_profile(sandbox_profile_t*);
  989. -
  990. +#endif
  991. } // extern "C"
  992. namespace sandbox {
  993. namespace {
  994. -
  995. +#if !IS_MAS_BUILD()
  996. bool HandleSandboxResult(int rv, char* errorbuf, std::string* error) {
  997. if (rv == 0) {
  998. if (error)
  999. @@ -74,36 +76,48 @@ bool HandleSandboxErrno(int rv, const char* message, std::string* error) {
  1000. }
  1001. return false;
  1002. }
  1003. -
  1004. +#endif
  1005. } // namespace
  1006. // static
  1007. Seatbelt::Parameters Seatbelt::Parameters::Create() {
  1008. Parameters params;
  1009. +#if !IS_MAS_BUILD()
  1010. params.params_ = ::sandbox_create_params();
  1011. +#endif
  1012. return params;
  1013. }
  1014. Seatbelt::Parameters::Parameters() = default;
  1015. Seatbelt::Parameters::Parameters(Seatbelt::Parameters&& other) {
  1016. +#if !IS_MAS_BUILD()
  1017. params_ = std::exchange(other.params_, nullptr);
  1018. +#endif
  1019. }
  1020. Seatbelt::Parameters& Seatbelt::Parameters::operator=(
  1021. Seatbelt::Parameters&& other) {
  1022. +#if !IS_MAS_BUILD()
  1023. params_ = std::exchange(other.params_, nullptr);
  1024. +#endif
  1025. return *this;
  1026. }
  1027. bool Seatbelt::Parameters::Set(const char* key, const char* value) {
  1028. +#if !IS_MAS_BUILD()
  1029. return ::sandbox_set_param(params_, key, value) == 0;
  1030. +#else
  1031. + return true;
  1032. +#endif
  1033. }
  1034. Seatbelt::Parameters::~Parameters() {
  1035. +#if !IS_MAS_BUILD()
  1036. if (params_) {
  1037. ::sandbox_free_params(params_);
  1038. }
  1039. +#endif
  1040. }
  1041. // Initialize the static member variables.
  1042. @@ -114,6 +128,7 @@ const char* Seatbelt::kProfilePureComputation = kSBXProfilePureComputation;
  1043. // static
  1044. bool Seatbelt::Init(const char* profile, uint64_t flags, std::string* error) {
  1045. +#if !IS_MAS_BUILD()
  1046. // OS X deprecated these functions, but did not provide a suitable replacement,
  1047. // so ignore the deprecation warning.
  1048. #pragma clang diagnostic push
  1049. @@ -122,6 +137,9 @@ bool Seatbelt::Init(const char* profile, uint64_t flags, std::string* error) {
  1050. int rv = ::sandbox_init(profile, flags, &errorbuf);
  1051. return HandleSandboxResult(rv, errorbuf, error);
  1052. #pragma clang diagnostic pop
  1053. +#else
  1054. + return true;
  1055. +#endif
  1056. }
  1057. // static
  1058. @@ -129,16 +147,21 @@ bool Seatbelt::InitWithParams(const std::string& profile,
  1059. uint64_t flags,
  1060. const std::vector<std::string>& parameters,
  1061. std::string* error) {
  1062. +#if !IS_MAS_BUILD()
  1063. std::vector<const char*> weak_params;
  1064. for (const std::string& param : parameters) {
  1065. weak_params.push_back(param.c_str());
  1066. }
  1067. // The parameters array must be null terminated.
  1068. weak_params.push_back(nullptr);
  1069. +
  1070. char* errorbuf = nullptr;
  1071. int rv = ::sandbox_init_with_parameters(profile.c_str(), flags,
  1072. weak_params.data(), &errorbuf);
  1073. return HandleSandboxResult(rv, errorbuf, error);
  1074. +#else
  1075. + return true;
  1076. +#endif
  1077. }
  1078. // static
  1079. @@ -146,6 +169,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. @@ -155,33 +179,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 17b3ddd66513a01a631d77535cfeb1ae94881e0e..bde6c61489fe4f88abba79fd2fb809c292a3f99a 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 4cbd3fc082ead782e64a950dd5314b1de7e550d5..0f4be1fa6b78c2340ebadb57a62cd47f9b10cebf 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. @@ -108,7 +111,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 cfb80b21ada7f04ff615b0437403ac1c6c95bb14..34341007de140aba2e6eeb9d8e8de0ea492c2466 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. @@ -30,6 +31,7 @@
  1300. allow_av_sample_buffer_display_layer_(
  1301. allow_av_sample_buffer_display_layer),
  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. @@ -58,6 +60,7 @@
  1308. #endif
  1309. ca_context_.layer = root_ca_layer_;
  1310. }
  1311. +#endif
  1312. }
  1313. CALayerTreeCoordinator::~CALayerTreeCoordinator() = default;
  1314. @@ -161,9 +164,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 302e40d573b0a102019cb15c0c615f99c7765b1a..a671a0a3de1794ad9a81ddc0f01e615804a6b28b 100644
  1369. --- a/ui/accessibility/platform/browser_accessibility_manager_mac.mm
  1370. +++ b/ui/accessibility/platform/browser_accessibility_manager_mac.mm
  1371. @@ -13,6 +13,7 @@
  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/accessibility_features.h"
  1378. #include "ui/accessibility/ax_role_properties.h"
  1379. @@ -20,7 +21,9 @@
  1380. #include "ui/accessibility/platform/ax_private_webkit_constants_mac.h"
  1381. #import "ui/accessibility/platform/browser_accessibility_cocoa.h"
  1382. #import "ui/accessibility/platform/browser_accessibility_mac.h"
  1383. +#if !IS_MAS_BUILD()
  1384. #include "ui/base/cocoa/remote_accessibility_api.h"
  1385. +#endif
  1386. namespace {
  1387. @@ -228,6 +231,7 @@ void PostAnnouncementNotification(NSString* announcement,
  1388. return;
  1389. }
  1390. +#if !IS_MAS_BUILD()
  1391. BrowserAccessibilityManager* root_manager = GetManagerForRootFrame();
  1392. if (root_manager) {
  1393. BrowserAccessibilityManagerMac* root_manager_mac =
  1394. @@ -250,6 +254,7 @@ void PostAnnouncementNotification(NSString* announcement,
  1395. return;
  1396. }
  1397. }
  1398. +#endif
  1399. // Use native VoiceOver support for live regions.
  1400. BrowserAccessibilityCocoa* retained_node = native_node;
  1401. @@ -662,6 +667,7 @@ void PostAnnouncementNotification(NSString* announcement,
  1402. return window == [NSApp accessibilityFocusedWindow];
  1403. }
  1404. +#if !IS_MAS_BUILD()
  1405. // TODO(accessibility): We need a solution to the problem described below.
  1406. // If the window is NSAccessibilityRemoteUIElement, there are some challenges:
  1407. // 1. NSApp is the browser which spawned the PWA, and what it considers the
  1408. @@ -690,6 +696,7 @@ void PostAnnouncementNotification(NSString* announcement,
  1409. if ([window isKindOfClass:[NSAccessibilityRemoteUIElement class]]) {
  1410. return true;
  1411. }
  1412. +#endif
  1413. return false;
  1414. }
  1415. diff --git a/ui/accessibility/platform/inspect/ax_transform_mac.mm b/ui/accessibility/platform/inspect/ax_transform_mac.mm
  1416. index c8171f0527fe5194f0ea73b57c4444d4c630fbc4..c2ac4da580e3e7f749a0a4de1e859af62de11672 100644
  1417. --- a/ui/accessibility/platform/inspect/ax_transform_mac.mm
  1418. +++ b/ui/accessibility/platform/inspect/ax_transform_mac.mm
  1419. @@ -11,6 +11,7 @@
  1420. #include "base/apple/foundation_util.h"
  1421. #include "base/strings/sys_string_conversions.h"
  1422. +#include "electron/mas.h"
  1423. #include "ui/accessibility/ax_range.h"
  1424. #include "ui/accessibility/platform/ax_platform_node.h"
  1425. #include "ui/accessibility/platform/ax_platform_node_cocoa.h"
  1426. @@ -111,6 +112,7 @@
  1427. }
  1428. }
  1429. +#if !IS_MAS_BUILD()
  1430. // AXTextMarker
  1431. if (IsAXTextMarker(value)) {
  1432. return AXTextMarkerToBaseValue(value, indexer);
  1433. @@ -120,6 +122,7 @@
  1434. if (IsAXTextMarkerRange(value)) {
  1435. return AXTextMarkerRangeToBaseValue(value, indexer);
  1436. }
  1437. +#endif
  1438. // Accessible object
  1439. if (AXElementWrapper::IsValidElement(value)) {
  1440. diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
  1441. index 5ca4c8fc961d24985aa4e0459dc2c42003a5346f..2f5880d1d3fbc3aa1461bbe611c33f789a6f4dde 100644
  1442. --- a/ui/base/BUILD.gn
  1443. +++ b/ui/base/BUILD.gn
  1444. @@ -363,6 +363,13 @@ component("base") {
  1445. ]
  1446. }
  1447. + if (is_mas_build) {
  1448. + sources -= [
  1449. + "cocoa/remote_accessibility_api.h",
  1450. + "cocoa/remote_accessibility_api.mm",
  1451. + ]
  1452. + }
  1453. +
  1454. if (is_ios) {
  1455. sources += [
  1456. "device_form_factor_ios.mm",
  1457. @@ -514,6 +521,12 @@ component("base") {
  1458. "//url",
  1459. ]
  1460. + if (is_mac) {
  1461. + deps += [
  1462. + "//electron/build/config:generate_mas_config"
  1463. + ]
  1464. + }
  1465. +
  1466. if (is_debug || dcheck_always_on) {
  1467. deps += [ "//third_party/re2" ]
  1468. }
  1469. diff --git a/ui/base/cocoa/remote_accessibility_api.h b/ui/base/cocoa/remote_accessibility_api.h
  1470. index 3182458838aa96d34911280ab4c6c3aa4aa22d6d..6dc85c366b7e61c8bd0302e501c3223a19223313 100644
  1471. --- a/ui/base/cocoa/remote_accessibility_api.h
  1472. +++ b/ui/base/cocoa/remote_accessibility_api.h
  1473. @@ -10,9 +10,12 @@
  1474. #include <vector>
  1475. #include "base/component_export.h"
  1476. +#include "electron/mas.h"
  1477. // NSAccessibilityRemoteUIElement is a private class in AppKit.
  1478. +#if !IS_MAS_BUILD()
  1479. +
  1480. @interface NSAccessibilityRemoteUIElement : NSObject
  1481. + (void)setRemoteUIApp:(BOOL)flag;
  1482. + (BOOL)isRemoteUIApp;
  1483. @@ -38,4 +41,6 @@ class COMPONENT_EXPORT(UI_BASE) RemoteAccessibility {
  1484. } // namespace ui
  1485. +#endif // MAS_BUILD
  1486. +
  1487. #endif // UI_BASE_COCOA_REMOTE_ACCESSIBILITY_API_H_
  1488. diff --git a/ui/base/cocoa/remote_layer_api.h b/ui/base/cocoa/remote_layer_api.h
  1489. index 59dc2f82214cfd883b6ebef3b0fb25af6387a9cd..912c5252d1b30d943a1552739b9eef9a8eae2d7a 100644
  1490. --- a/ui/base/cocoa/remote_layer_api.h
  1491. +++ b/ui/base/cocoa/remote_layer_api.h
  1492. @@ -9,6 +9,7 @@
  1493. #include "base/component_export.h"
  1494. #include "build/build_config.h"
  1495. +#include "electron/mas.h"
  1496. #if defined(__OBJC__)
  1497. #import <Foundation/Foundation.h>
  1498. @@ -17,6 +18,7 @@
  1499. #if BUILDFLAG(IS_MAC)
  1500. +#if !IS_MAS_BUILD()
  1501. // The CGSConnectionID is used to create the CAContext in the process that is
  1502. // going to share the CALayers that it is rendering to another process to
  1503. // display.
  1504. @@ -68,6 +70,8 @@ extern NSString* const kCAContextIgnoresHitTest;
  1505. #endif // __OBJC__
  1506. +#endif // MAS_BUILD
  1507. +
  1508. namespace ui {
  1509. // This function will check if all of the interfaces listed above are supported
  1510. diff --git a/ui/base/cocoa/remote_layer_api.mm b/ui/base/cocoa/remote_layer_api.mm
  1511. index fc25ba79d2b0e1acdb7ba54b89e7d6e16f94771b..de771ef414b9a69e331261524f08e9a12145ec60 100644
  1512. --- a/ui/base/cocoa/remote_layer_api.mm
  1513. +++ b/ui/base/cocoa/remote_layer_api.mm
  1514. @@ -5,11 +5,13 @@
  1515. #include "ui/base/cocoa/remote_layer_api.h"
  1516. #include "base/feature_list.h"
  1517. +#include "electron/mas.h"
  1518. #include <objc/runtime.h>
  1519. namespace ui {
  1520. +#if !IS_MAS_BUILD()
  1521. namespace {
  1522. // Control use of cross-process CALayers to display content directly from the
  1523. // GPU process on Mac.
  1524. @@ -17,8 +19,10 @@
  1525. "RemoteCoreAnimationAPI",
  1526. base::FEATURE_ENABLED_BY_DEFAULT);
  1527. } // namespace
  1528. +#endif
  1529. bool RemoteLayerAPISupported() {
  1530. +#if !IS_MAS_BUILD()
  1531. if (!base::FeatureList::IsEnabled(kRemoteCoreAnimationAPI))
  1532. return false;
  1533. @@ -55,6 +59,9 @@ bool RemoteLayerAPISupported() {
  1534. // If everything is there, we should be able to use the API.
  1535. return true;
  1536. +#else
  1537. + return false;
  1538. +#endif // MAS_BUILD
  1539. }
  1540. } // namespace
  1541. diff --git a/ui/display/BUILD.gn b/ui/display/BUILD.gn
  1542. index eea9eb92fadfcb72adfffffb0e43082a79bcf3a7..dd2110c1e9393f7ad33a0e64c09ef732b3292a54 100644
  1543. --- a/ui/display/BUILD.gn
  1544. +++ b/ui/display/BUILD.gn
  1545. @@ -125,6 +125,12 @@ component("display") {
  1546. "//ui/gfx/geometry",
  1547. ]
  1548. + if (is_mac) {
  1549. + deps += [
  1550. + "//electron/build/config:generate_mas_config"
  1551. + ]
  1552. + }
  1553. +
  1554. if (is_ios) {
  1555. deps += [ "//build:ios_buildflags" ]
  1556. }
  1557. diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm
  1558. index 29ae2da6a8a2c2a612dfb92f7f9c03ca5fa306b1..440c139a32a0c205e77b657d4aab64684661a01d 100644
  1559. --- a/ui/display/mac/screen_mac.mm
  1560. +++ b/ui/display/mac/screen_mac.mm
  1561. @@ -30,6 +30,7 @@
  1562. #include "base/trace_event/trace_event.h"
  1563. #include "build/build_config.h"
  1564. #include "components/device_event_log/device_event_log.h"
  1565. +#include "electron/mas.h"
  1566. #include "ui/display/display.h"
  1567. #include "ui/display/display_change_notifier.h"
  1568. #include "ui/display/util/display_util.h"
  1569. @@ -176,7 +177,17 @@ DisplayMac BuildDisplayForScreen(NSScreen* screen) {
  1570. display.set_color_depth(Display::kDefaultBitsPerPixel);
  1571. display.set_depth_per_component(Display::kDefaultBitsPerComponent);
  1572. }
  1573. +#if IS_MAS_BUILD()
  1574. + // This is equivalent to the CGDisplayUsesForceToGray() API as at 2018-08-06,
  1575. + // but avoids usage of the private API.
  1576. + CFStringRef app = CFSTR("com.apple.CoreGraphics");
  1577. + CFStringRef key = CFSTR("DisplayUseForcedGray");
  1578. + Boolean key_valid = false;
  1579. + display.set_is_monochrome(
  1580. + CFPreferencesGetAppBooleanValue(key, app, &key_valid));
  1581. +#else
  1582. display.set_is_monochrome(CGDisplayUsesForceToGray());
  1583. +#endif
  1584. // Query the display's refresh rate.
  1585. if (@available(macos 12.0, *)) {
  1586. diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn
  1587. index 230a9e8266fa494f870ed7fc7dc444d1db5bbb48..99facff7a8e98cbc175354ae4e1d1f592197320a 100644
  1588. --- a/ui/gfx/BUILD.gn
  1589. +++ b/ui/gfx/BUILD.gn
  1590. @@ -332,6 +332,12 @@ component("gfx") {
  1591. "//ui/base:ui_data_pack",
  1592. ]
  1593. + if (is_mac) {
  1594. + deps += [
  1595. + "//electron/build/config:generate_mas_config"
  1596. + ]
  1597. + }
  1598. +
  1599. if (!is_apple) {
  1600. sources += [
  1601. "platform_font_skia.cc",
  1602. diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm
  1603. index fe3f85073e31de487a08e57d7f9b07aa4eccf8f3..cf5b07203c8bd559a404600cc98cc8eccdefd4d7 100644
  1604. --- a/ui/gfx/platform_font_mac.mm
  1605. +++ b/ui/gfx/platform_font_mac.mm
  1606. @@ -19,6 +19,7 @@
  1607. #include "base/numerics/safe_conversions.h"
  1608. #include "base/strings/sys_string_conversions.h"
  1609. #include "base/strings/utf_string_conversions.h"
  1610. +#include "electron/mas.h"
  1611. #include "third_party/skia/include/ports/SkTypeface_mac.h"
  1612. #include "ui/gfx/canvas.h"
  1613. #include "ui/gfx/font.h"
  1614. @@ -28,9 +29,11 @@
  1615. using Weight = Font::Weight;
  1616. +#if !IS_MAS_BUILD()
  1617. extern "C" {
  1618. bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
  1619. }
  1620. +#endif
  1621. namespace {
  1622. @@ -250,7 +253,13 @@ CTFontRef SystemFontForConstructorOfType(
  1623. // TODO(avi, etienneb): Figure out this font stuff.
  1624. base::apple::ScopedCFTypeRef<CTFontDescriptorRef> descriptor(
  1625. CTFontCopyFontDescriptor(font));
  1626. +#if IS_MAS_BUILD()
  1627. + CFNumberRef priority = (CFNumberRef)CTFontDescriptorCopyAttribute(descriptor.get(), (CFStringRef)kCTFontPriorityAttribute);
  1628. + SInt64 v;
  1629. + if (CFNumberGetValue(priority, kCFNumberSInt64Type, &v) && v == kCTFontPrioritySystem) {
  1630. +#else
  1631. if (CTFontDescriptorIsSystemUIFont(descriptor.get())) {
  1632. +#endif
  1633. // Assume it's the standard system font. The fact that this much is known is
  1634. // enough.
  1635. return PlatformFontMac::SystemFontType::kGeneral;
  1636. diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn
  1637. index 94afec13361d4ee8d0441da3cbe37d62e287c94b..fd13add3291b113dc57c69700f35ac9943124786 100644
  1638. --- a/ui/views/BUILD.gn
  1639. +++ b/ui/views/BUILD.gn
  1640. @@ -718,6 +718,8 @@ component("views") {
  1641. "IOSurface.framework",
  1642. "QuartzCore.framework",
  1643. ]
  1644. +
  1645. + deps += ["//electron/build/config:generate_mas_config"]
  1646. }
  1647. if (is_win) {
  1648. @@ -1135,6 +1137,8 @@ source_set("test_support") {
  1649. "//ui/base/mojom:ui_base_types",
  1650. ]
  1651. + deps += ["//electron/build/config:generate_mas_config"]
  1652. +
  1653. if (is_win) {
  1654. sources += [
  1655. "test/desktop_window_tree_host_win_test_api.cc",
  1656. diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.h b/ui/views/cocoa/native_widget_mac_ns_window_host.h
  1657. index 6a18c94e8c9d531ab3a59faf6027848caed8de57..63aa6b3ba824a3fa71c5a3db94b9ac5e8d0ea7c0 100644
  1658. --- a/ui/views/cocoa/native_widget_mac_ns_window_host.h
  1659. +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.h
  1660. @@ -18,6 +18,7 @@
  1661. #include "components/remote_cocoa/browser/scoped_cg_window_id.h"
  1662. #include "components/remote_cocoa/common/native_widget_ns_window.mojom.h"
  1663. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  1664. +#include "electron/mas.h"
  1665. #include "mojo/public/cpp/bindings/associated_receiver.h"
  1666. #include "mojo/public/cpp/bindings/associated_remote.h"
  1667. #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
  1668. @@ -33,7 +34,9 @@
  1669. #include "ui/views/window/dialog_observer.h"
  1670. @class NativeWidgetMacNSWindow;
  1671. +#if !IS_MAS_BUILD()
  1672. @class NSAccessibilityRemoteUIElement;
  1673. +#endif
  1674. @class NSView;
  1675. namespace remote_cocoa {
  1676. @@ -487,10 +490,12 @@ class VIEWS_EXPORT NativeWidgetMacNSWindowHost
  1677. mojo::AssociatedRemote<remote_cocoa::mojom::NativeWidgetNSWindow>
  1678. remote_ns_window_remote_;
  1679. +#if !IS_MAS_BUILD()
  1680. // Remote accessibility objects corresponding to the NSWindow and its root
  1681. // NSView.
  1682. NSAccessibilityRemoteUIElement* __strong remote_window_accessible_;
  1683. NSAccessibilityRemoteUIElement* __strong remote_view_accessible_;
  1684. +#endif
  1685. // Used to force the NSApplication's focused accessibility element to be the
  1686. // views::Views accessibility tree when the NSView for this is focused.
  1687. diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.mm b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
  1688. index 7e5047fabe59fb2773f13836145cfce64bc1a135..fed3d6a70139443d76ce6181df69bb490c46a081 100644
  1689. --- a/ui/views/cocoa/native_widget_mac_ns_window_host.mm
  1690. +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
  1691. @@ -21,6 +21,7 @@
  1692. #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
  1693. #include "components/remote_cocoa/browser/ns_view_ids.h"
  1694. #include "components/remote_cocoa/browser/window.h"
  1695. +#include "electron/mas.h"
  1696. #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
  1697. #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
  1698. #include "ui/accessibility/accessibility_features.h"
  1699. @@ -352,7 +353,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1700. if (in_process_ns_window_bridge_) {
  1701. return in_process_ns_window_bridge_->ns_view();
  1702. }
  1703. +#if !IS_MAS_BUILD()
  1704. return remote_view_accessible_;
  1705. +#else
  1706. + return nullptr;
  1707. +#endif
  1708. }
  1709. gfx::NativeViewAccessible
  1710. @@ -367,7 +372,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1711. return [in_process_ns_window_bridge_->ns_view() window];
  1712. }
  1713. +#if !IS_MAS_BUILD()
  1714. return remote_window_accessible_;
  1715. +#else
  1716. + return nullptr;
  1717. +#endif
  1718. }
  1719. remote_cocoa::mojom::NativeWidgetNSWindow*
  1720. @@ -1371,9 +1380,11 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1721. // for PWAs. However this breaks accessibility on in-process windows,
  1722. // so set it back to NO when a local window gains focus. See
  1723. // https://crbug.com/41485830.
  1724. +#if !IS_MAS_BUILD()
  1725. if (is_key && features::IsAccessibilityRemoteUIAppEnabled()) {
  1726. [NSAccessibilityRemoteUIElement setRemoteUIApp:!!application_host_];
  1727. }
  1728. +#endif
  1729. // Explicitly set the keyboard accessibility state on regaining key
  1730. // window status.
  1731. if (is_key && is_content_first_responder) {
  1732. @@ -1514,17 +1525,20 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1733. void NativeWidgetMacNSWindowHost::SetRemoteAccessibilityTokens(
  1734. const std::vector<uint8_t>& window_token,
  1735. const std::vector<uint8_t>& view_token) {
  1736. +#if !IS_MAS_BUILD()
  1737. remote_window_accessible_ =
  1738. ui::RemoteAccessibility::GetRemoteElementFromToken(window_token);
  1739. remote_view_accessible_ =
  1740. ui::RemoteAccessibility::GetRemoteElementFromToken(view_token);
  1741. [remote_view_accessible_ setWindowUIElement:remote_window_accessible_];
  1742. [remote_view_accessible_ setTopLevelUIElement:remote_window_accessible_];
  1743. +#endif
  1744. }
  1745. bool NativeWidgetMacNSWindowHost::GetRootViewAccessibilityToken(
  1746. base::ProcessId* pid,
  1747. std::vector<uint8_t>* token) {
  1748. +#if !IS_MAS_BUILD()
  1749. *pid = getpid();
  1750. id element_id = GetNativeViewAccessible();
  1751. @@ -1537,6 +1551,7 @@ void HandleAccelerator(const ui::Accelerator& accelerator,
  1752. }
  1753. *token = ui::RemoteAccessibility::GetTokenForLocalElement(element_id);
  1754. +#endif
  1755. return true;
  1756. }
  1757. diff --git a/ui/views/controls/webview/BUILD.gn b/ui/views/controls/webview/BUILD.gn
  1758. index 111d6432586f47833dde50678b908c76ad88d37a..429ca4402652a2d89ead228d92971f0cb3b6222c 100644
  1759. --- a/ui/views/controls/webview/BUILD.gn
  1760. +++ b/ui/views/controls/webview/BUILD.gn
  1761. @@ -46,6 +46,12 @@ component("webview") {
  1762. "//url",
  1763. ]
  1764. + if (is_mac) {
  1765. + deps += [
  1766. + "//electron/build/config:generate_mas_config",
  1767. + ]
  1768. + }
  1769. +
  1770. public_deps = [
  1771. "//base",
  1772. "//content/public/browser",