Add accessibility setter to the app

This commit is contained in:
Ivan Mir 2017-08-24 11:22:28 -03:00
parent 9605e6cb40
commit 6717f0d2bb
4 changed files with 38 additions and 6 deletions

View file

@ -869,6 +869,18 @@ bool App::IsAccessibilitySupportEnabled() {
return ax_state->IsAccessibleBrowser();
}
void App::SetAccessibilitySupportEnabled(bool value) {
auto ax_state = content::BrowserAccessibilityState::GetInstance();
if (value) {
ax_state->OnScreenReaderDetected();
} else {
ax_state->DisableAccessibility();
}
Browser::Get()->OnAccessibilitySupportChanged();
}
Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
Browser::LoginItemSettings options;
args->GetNext(&options);
@ -1141,6 +1153,8 @@ void App::BuildPrototype(
.SetMethod("relaunch", &App::Relaunch)
.SetMethod("isAccessibilitySupportEnabled",
&App::IsAccessibilitySupportEnabled)
.SetMethod("setAccessibilitySupportEnabled",
&App::SetAccessibilitySupportEnabled)
.SetMethod("disableHardwareAcceleration",
&App::DisableHardwareAcceleration)
.SetMethod("disableDomainBlockingFor3DAPIs",

View file

@ -171,6 +171,7 @@ class App : public AtomBrowserClient::Delegate,
void DisableHardwareAcceleration(mate::Arguments* args);
void DisableDomainBlockingFor3DAPIs(mate::Arguments* args);
bool IsAccessibilitySupportEnabled();
void SetAccessibilitySupportEnabled(bool value);
Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
#if defined(USE_NSS_CERTS)
void ImportCertificate(const base::DictionaryValue& options,

View file

@ -890,6 +890,15 @@ technologies, such as screen readers, has been detected. See
https://www.chromium.org/developers/design-documents/accessibility for more
details.
### `app.setAccessibilitySupportEnabled(value)` _macOS_ _Windows_
* `value` Boolean - A value for switching the accessibility support
Manually enables Chrome's accessibility support, allowing to expose accessibility switch to users in application settings. https://www.chromium.org/developers/design-documents/accessibility for more
details.
**Note:** Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
### `app.setAboutPanelOptions(options)` _macOS_
* `options` Object

View file

@ -8,7 +8,7 @@ Accessibility concerns in Electron applications are similar to those of websites
These new features bring those auditing tools to your Electron app. You can choose to add audits to your tests with Spectron or use them within DevTools with Devtron. Read on for a summary of the tools or checkout our [accessibility documentation](https://electron.atom.io/docs/tutorial/accessibility) for more information.
### Spectron
## Spectron
In the testing framework Spectron, you can now audit each window and `<webview>` tag in your application. For example:
@ -22,7 +22,7 @@ app.client.auditAccessibility().then(function (audit) {
You can read more about this feature in [Spectron's documentation](https://github.com/electron/spectron#accessibility-testing).
### Devtron
## Devtron
In Devtron, there is a new accessibility tab which will allow you to audit a page in your app, sort and filter the results.
@ -32,11 +32,19 @@ Both of these tools are using the [Accessibility Developer Tools](https://github
If you know of other great accessibility tools for Electron, add them to the [accessibility documentation](https://electron.atom.io/docs/tutorial/accessibility) with a pull request.
### Accessibility on Mac
## Enabling Accessibility
Electron applications keep accessibility disabled by default and there are two ways to enable it:
1. By turning on VoiceOver in the Accessibility menu in macOS System Preferences
2. By setting the attribute `AXManualAccessibility` programmatically from the host or 3rd party application.
Electron applications keep accessibility disabled by default for performance reasons but there are multiple ways to enable it.
### Inside Application
By using [`app.setAccessibilitySupportEnabled(value)`](https://electron.atom.io/docs/api/app.md#appsetaccessibilitysupportenabledvalue-macos-windows), you can expose accessibility switch to users in the application preferences.
### Assistive Technology
Electron application will enable accessibility automatically when it detects assistive technology (Windows) or VoiceOver (macOS). See Chrome's [accessibility documentation](https://www.chromium.org/developers/design-documents/accessibility#TOC-How-Chrome-detects-the-presence-of-Assistive-Technology) for more details.
On macOS 3rd party assistive technology can switch accessibility inside Electron applications by setting the attribute `AXManualAccessibility` programmatically:
```objc
CFStringRef kAXManualAccessibility = CFSTR("AXManualAccessibility");