Merge pull request #6446 from electron/accessibility-api
Add API for Chrome's accessibility support state
This commit is contained in:
commit
df0d2b89cd
9 changed files with 56 additions and 0 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "brightray/browser/brightray_paths.h"
|
#include "brightray/browser/brightray_paths.h"
|
||||||
#include "chrome/common/chrome_paths.h"
|
#include "chrome/common/chrome_paths.h"
|
||||||
|
#include "content/public/browser/browser_accessibility_state.h"
|
||||||
#include "content/public/browser/client_certificate_delegate.h"
|
#include "content/public/browser/client_certificate_delegate.h"
|
||||||
#include "content/public/browser/gpu_data_manager.h"
|
#include "content/public/browser/gpu_data_manager.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
|
@ -281,6 +282,10 @@ void App::OnFinishLaunching() {
|
||||||
Emit("ready");
|
Emit("ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void App::OnAccessibilitySupportChanged() {
|
||||||
|
Emit("accessibility-support-changed", IsAccessibilitySupportEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void App::OnContinueUserActivity(
|
void App::OnContinueUserActivity(
|
||||||
bool* prevent_default,
|
bool* prevent_default,
|
||||||
|
@ -486,6 +491,11 @@ void App::DisableHardwareAcceleration(mate::Arguments* args) {
|
||||||
content::GpuDataManager::GetInstance()->DisableHardwareAcceleration();
|
content::GpuDataManager::GetInstance()->DisableHardwareAcceleration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool App::IsAccessibilitySupportEnabled() {
|
||||||
|
auto ax_state = content::BrowserAccessibilityState::GetInstance();
|
||||||
|
return ax_state->IsAccessibleBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(USE_NSS_CERTS)
|
#if defined(USE_NSS_CERTS)
|
||||||
void App::ImportCertificate(
|
void App::ImportCertificate(
|
||||||
const base::DictionaryValue& options,
|
const base::DictionaryValue& options,
|
||||||
|
@ -578,6 +588,8 @@ void App::BuildPrototype(
|
||||||
.SetMethod("makeSingleInstance", &App::MakeSingleInstance)
|
.SetMethod("makeSingleInstance", &App::MakeSingleInstance)
|
||||||
.SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance)
|
.SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance)
|
||||||
.SetMethod("relaunch", &App::Relaunch)
|
.SetMethod("relaunch", &App::Relaunch)
|
||||||
|
.SetMethod("isAccessibilitySupportEnabled",
|
||||||
|
&App::IsAccessibilitySupportEnabled)
|
||||||
.SetMethod("disableHardwareAcceleration",
|
.SetMethod("disableHardwareAcceleration",
|
||||||
&App::DisableHardwareAcceleration);
|
&App::DisableHardwareAcceleration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
void OnFinishLaunching() override;
|
void OnFinishLaunching() override;
|
||||||
void OnLogin(LoginHandler* login_handler,
|
void OnLogin(LoginHandler* login_handler,
|
||||||
const base::DictionaryValue& request_details) override;
|
const base::DictionaryValue& request_details) override;
|
||||||
|
void OnAccessibilitySupportChanged() override;
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void OnContinueUserActivity(
|
void OnContinueUserActivity(
|
||||||
bool* prevent_default,
|
bool* prevent_default,
|
||||||
|
@ -113,6 +114,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
void ReleaseSingleInstance();
|
void ReleaseSingleInstance();
|
||||||
bool Relaunch(mate::Arguments* args);
|
bool Relaunch(mate::Arguments* args);
|
||||||
void DisableHardwareAcceleration(mate::Arguments* args);
|
void DisableHardwareAcceleration(mate::Arguments* args);
|
||||||
|
bool IsAccessibilitySupportEnabled();
|
||||||
#if defined(USE_NSS_CERTS)
|
#if defined(USE_NSS_CERTS)
|
||||||
void ImportCertificate(const base::DictionaryValue& options,
|
void ImportCertificate(const base::DictionaryValue& options,
|
||||||
const net::CompletionCallback& callback);
|
const net::CompletionCallback& callback);
|
||||||
|
|
|
@ -155,6 +155,12 @@ void Browser::DidFinishLaunching() {
|
||||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching());
|
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Browser::OnAccessibilitySupportChanged() {
|
||||||
|
FOR_EACH_OBSERVER(BrowserObserver,
|
||||||
|
observers_,
|
||||||
|
OnAccessibilitySupportChanged());
|
||||||
|
}
|
||||||
|
|
||||||
void Browser::RequestLogin(
|
void Browser::RequestLogin(
|
||||||
LoginHandler* login_handler,
|
LoginHandler* login_handler,
|
||||||
std::unique_ptr<base::DictionaryValue> request_details) {
|
std::unique_ptr<base::DictionaryValue> request_details) {
|
||||||
|
|
|
@ -185,6 +185,8 @@ class Browser : public WindowListObserver {
|
||||||
void WillFinishLaunching();
|
void WillFinishLaunching();
|
||||||
void DidFinishLaunching();
|
void DidFinishLaunching();
|
||||||
|
|
||||||
|
void OnAccessibilitySupportChanged();
|
||||||
|
|
||||||
// Request basic auth login.
|
// Request basic auth login.
|
||||||
void RequestLogin(LoginHandler* login_handler,
|
void RequestLogin(LoginHandler* login_handler,
|
||||||
std::unique_ptr<base::DictionaryValue> request_details);
|
std::unique_ptr<base::DictionaryValue> request_details);
|
||||||
|
|
|
@ -52,6 +52,9 @@ class BrowserObserver {
|
||||||
virtual void OnLogin(LoginHandler* login_handler,
|
virtual void OnLogin(LoginHandler* login_handler,
|
||||||
const base::DictionaryValue& request_details) {}
|
const base::DictionaryValue& request_details) {}
|
||||||
|
|
||||||
|
// The browser's accessibility suppport has changed.
|
||||||
|
virtual void OnAccessibilitySupportChanged() {}
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
// The browser wants to resume a user activity via handoff. (macOS only)
|
// The browser wants to resume a user activity via handoff. (macOS only)
|
||||||
virtual void OnContinueUserActivity(
|
virtual void OnContinueUserActivity(
|
||||||
|
|
|
@ -83,6 +83,8 @@
|
||||||
} else {
|
} else {
|
||||||
ax_state->DisableAccessibility();
|
ax_state->DisableAccessibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atom::Browser::Get()->OnAccessibilitySupportChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/browser/browser.h"
|
||||||
#include "atom/browser/native_window_views.h"
|
#include "atom/browser/native_window_views.h"
|
||||||
#include "content/public/browser/browser_accessibility_state.h"
|
#include "content/public/browser/browser_accessibility_state.h"
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ bool NativeWindowViews::PreHandleMSG(
|
||||||
if (axState && !axState->IsAccessibleBrowser()) {
|
if (axState && !axState->IsAccessibleBrowser()) {
|
||||||
axState->OnScreenReaderDetected();
|
axState->OnScreenReaderDetected();
|
||||||
enabled_a11y_support_ = true;
|
enabled_a11y_support_ = true;
|
||||||
|
Browser::Get()->OnAccessibilitySupportChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,6 +259,19 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||||
|
|
||||||
Emitted when the gpu process crashes.
|
Emitted when the gpu process crashes.
|
||||||
|
|
||||||
|
### Event: 'accessibility-support-changed' _macOS_ _Windows_
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
* `event` Event
|
||||||
|
* `accessibilitySupportEnabled` Boolean - `true` when Chrome's accessibility
|
||||||
|
support is enabled, `false` otherwise.
|
||||||
|
|
||||||
|
Emitted when Chrome's accessibility support changes. This event fires when
|
||||||
|
assistive technologies, such as screen readers, are enabled or disabled.
|
||||||
|
See https://www.chromium.org/developers/design-documents/accessibility for more
|
||||||
|
details.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
The `app` object has the following methods:
|
The `app` object has the following methods:
|
||||||
|
@ -625,6 +638,14 @@ Return an Object with the login item settings of the app.
|
||||||
|
|
||||||
Set the app's login item settings.
|
Set the app's login item settings.
|
||||||
|
|
||||||
|
### `app.isAccessibilitySupportEnabled()` _macOS_ _Windows_
|
||||||
|
|
||||||
|
Returns a `Boolean`, `true` if Chrome's accessibility support is enabled,
|
||||||
|
`false` otherwise. This API will return `true` if the use of assistive
|
||||||
|
technologies, such as screen readers, has been detected. See
|
||||||
|
https://www.chromium.org/developers/design-documents/accessibility for more
|
||||||
|
details.
|
||||||
|
|
||||||
### `app.commandLine.appendSwitch(switch[, value])`
|
### `app.commandLine.appendSwitch(switch[, value])`
|
||||||
|
|
||||||
Append a switch (with optional `value`) to Chromium's command line.
|
Append a switch (with optional `value`) to Chromium's command line.
|
||||||
|
|
|
@ -339,4 +339,10 @@ describe('app module', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('isAccessibilitySupportEnabled API', function () {
|
||||||
|
it('returns whether the Chrome has accessibility APIs enabled', function () {
|
||||||
|
assert.equal(typeof app.isAccessibilitySupportEnabled(), 'boolean')
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue