diff --git a/src/api/nw_window_api.cc b/src/api/nw_window_api.cc index be0e82c77d..dfa377cca8 100644 --- a/src/api/nw_window_api.cc +++ b/src/api/nw_window_api.cc @@ -891,6 +891,15 @@ NwCurrentWindowInternalToggleKioskModeInternalFunction::Run() { return RespondNow(NoArguments()); } +bool NwCurrentWindowInternalIsAACActiveInternalFunction::RunNWSync(base::ListValue* response, std::string* error) { +#if defined(OS_MAC) + response->AppendBoolean((NWGetAACActive())); +#else + response->AppendBoolean(false); +#endif + return true; +} + bool NwCurrentWindowInternalIsKioskInternalFunction::RunNWSync(base::ListValue* response, std::string* error) { if (base::FeatureList::IsEnabled(::features::kNWNewWin)) { int id = 0; diff --git a/src/api/nw_window_api.h b/src/api/nw_window_api.h index e24359e7b3..d060fdae70 100644 --- a/src/api/nw_window_api.h +++ b/src/api/nw_window_api.h @@ -259,6 +259,16 @@ class NwCurrentWindowInternalToggleKioskModeInternalFunction : public ExtensionF DECLARE_EXTENSION_FUNCTION("nw.currentWindowInternal.toggleKioskModeInternal", UNKNOWN) }; +class NwCurrentWindowInternalIsAACActiveInternalFunction : public NWSyncExtensionFunction { + public: + NwCurrentWindowInternalIsAACActiveInternalFunction() {} + bool RunNWSync(base::ListValue* response, std::string* error) override; + + protected: + ~NwCurrentWindowInternalIsAACActiveInternalFunction() override {} + DECLARE_EXTENSION_FUNCTION("nw.currentWindowInternal.isAACActiveInternal", UNKNOWN) +}; + class NwCurrentWindowInternalIsKioskInternalFunction : public NWSyncExtensionFunction { public: NwCurrentWindowInternalIsKioskInternalFunction() {} diff --git a/src/nw_content_mac.h b/src/nw_content_mac.h index 8d49bd6135..ed3d019a30 100644 --- a/src/nw_content_mac.h +++ b/src/nw_content_mac.h @@ -17,4 +17,5 @@ void NWSetNSWindowShowInTaskbar(extensions::NativeAppWindow* win, bool show); void NWSetNSWindowShowInTaskbar(gfx::NativeWindow win, bool show); void NWSetNSAppKioskOptions(void); void NWRestoreNSAppKioskOptions(void); +bool NWGetAACActive(void); #endif diff --git a/src/nw_content_mac.mm b/src/nw_content_mac.mm index 49a900ee11..28d2ed2e23 100644 --- a/src/nw_content_mac.mm +++ b/src/nw_content_mac.mm @@ -175,3 +175,10 @@ void NWRestoreNSAppKioskOptions(void) { } } } + +bool NWGetAACActive(void) { + if (@available(macOS 10.15.4, *)) { + return [session isActive]; + } + return false; +} diff --git a/src/resources/api_nw_window.js b/src/resources/api_nw_window.js index 7e50dadc26..8abc5a4265 100644 --- a/src/resources/api_nw_window.js +++ b/src/resources/api_nw_window.js @@ -588,6 +588,11 @@ apiBridge.registerCustomHook(function(bindingsAPI) { return this.appWindow.alphaEnabled(); } }); + Object.defineProperty(NWWindow.prototype, 'isAACActive', { + get: function() { + return currentNWWindowInternal.isAACActiveInternal(); + } + }); Object.defineProperty(NWWindow.prototype, 'isKioskMode', { get: function() { return currentNWWindowInternal.isKioskInternal();