fix: error if a11y support changed before ready (#16268)

This commit is contained in:
trop[bot]
2019-01-04 09:42:46 -08:00
committed by Shelley Vohr
parent c783c5eb70
commit 70af1c1b14
3 changed files with 12 additions and 3 deletions

View File

@@ -981,7 +981,14 @@ bool App::IsAccessibilitySupportEnabled() {
return ax_state->IsAccessibleBrowser();
}
void App::SetAccessibilitySupportEnabled(bool enabled) {
void App::SetAccessibilitySupportEnabled(bool enabled, mate::Arguments* args) {
if (!Browser::Get()->is_ready()) {
args->ThrowError(
"app.setAccessibilitySupportEnabled() can only be called "
"after app is ready");
return;
}
auto* ax_state = content::BrowserAccessibilityState::GetInstance();
if (enabled) {
ax_state->OnScreenReaderDetected();

View File

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

View File

@@ -1059,9 +1059,11 @@ details.
* `enabled` Boolean - Enable or disable [accessibility tree](https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/the-accessibility-tree) rendering
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
Manually enables Chrome's accessibility support, allowing to expose accessibility switch to users in application settings. See [Chromium's accessibility docs](https://www.chromium.org/developers/design-documents/accessibility) for more
details. Disabled by default.
This API must be called after the `ready` event is emitted.
**Note:** Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
### `app.showAboutPanel()` _macOS_