Add API for accessibility state and changes

This commit is contained in:
Kevin Sawicki 2016-07-11 14:04:56 -07:00
parent b06e6e9ce5
commit fc36ac8c1b
5 changed files with 22 additions and 0 deletions

View file

@ -32,6 +32,7 @@
#include "base/strings/string_util.h"
#include "brightray/browser/brightray_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/gpu_data_manager.h"
#include "content/public/browser/render_frame_host.h"
@ -281,6 +282,10 @@ void App::OnFinishLaunching() {
Emit("ready");
}
void App::OnAccessibilityChanged() {
Emit("accessibility-changed", IsAccessible());
}
#if defined(OS_MACOSX)
void App::OnContinueUserActivity(
bool* prevent_default,
@ -486,6 +491,11 @@ void App::DisableHardwareAcceleration(mate::Arguments* args) {
content::GpuDataManager::GetInstance()->DisableHardwareAcceleration();
}
bool App::IsAccessible() {
auto ax_state = content::BrowserAccessibilityState::GetInstance();
return ax_state->IsAccessibleBrowser();
}
#if defined(USE_NSS_CERTS)
void App::ImportCertificate(
const base::DictionaryValue& options,
@ -578,6 +588,7 @@ void App::BuildPrototype(
.SetMethod("makeSingleInstance", &App::MakeSingleInstance)
.SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance)
.SetMethod("relaunch", &App::Relaunch)
.SetMethod("isAccessible", &App::IsAccessible)
.SetMethod("disableHardwareAcceleration",
&App::DisableHardwareAcceleration);
}

View file

@ -72,6 +72,7 @@ class App : public AtomBrowserClient::Delegate,
void OnFinishLaunching() override;
void OnLogin(LoginHandler* login_handler,
const base::DictionaryValue& request_details) override;
void OnAccessibilityChanged() override;
#if defined(OS_MACOSX)
void OnContinueUserActivity(
bool* prevent_default,
@ -113,6 +114,7 @@ class App : public AtomBrowserClient::Delegate,
void ReleaseSingleInstance();
bool Relaunch(mate::Arguments* args);
void DisableHardwareAcceleration(mate::Arguments* args);
bool IsAccessible();
#if defined(USE_NSS_CERTS)
void ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback);

View file

@ -155,6 +155,10 @@ void Browser::DidFinishLaunching() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching());
}
void Browser::OnAccessibilityChanged() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnAccessibilityChanged());
}
void Browser::RequestLogin(
LoginHandler* login_handler,
std::unique_ptr<base::DictionaryValue> request_details) {

View file

@ -185,6 +185,8 @@ class Browser : public WindowListObserver {
void WillFinishLaunching();
void DidFinishLaunching();
void OnAccessibilityChanged();
// Request basic auth login.
void RequestLogin(LoginHandler* login_handler,
std::unique_ptr<base::DictionaryValue> request_details);

View file

@ -52,6 +52,9 @@ class BrowserObserver {
virtual void OnLogin(LoginHandler* login_handler,
const base::DictionaryValue& request_details) {}
// The browser's accessibility state has changed.
virtual void OnAccessibilityChanged() {};
#if defined(OS_MACOSX)
// The browser wants to resume a user activity via handoff. (macOS only)
virtual void OnContinueUserActivity(