Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add js variable to check if AAC is successful or not #7755

Open
wants to merge 2 commits into
base: nw55
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/api/nw_window_api.cc
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/api/nw_window_api.h
Expand Up @@ -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() {}
Expand Down
1 change: 1 addition & 0 deletions src/nw_content_mac.h
Expand Up @@ -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
7 changes: 7 additions & 0 deletions src/nw_content_mac.mm
Expand Up @@ -175,3 +175,10 @@ void NWRestoreNSAppKioskOptions(void) {
}
}
}

bool NWGetAACActive(void) {
if (@available(macOS 10.15.4, *)) {
return [session isActive];
}
return false;
}
5 changes: 5 additions & 0 deletions src/resources/api_nw_window.js
Expand Up @@ -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();
Expand Down