diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 9d799f115007..800c86ebe7c8 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -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); } diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index b550f0ba7b90..aa79b55f51b4 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -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); diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index b7d5626a82e3..2727daae449e 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -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 request_details) { diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 98f561bcd153..dbcb6b03bcec 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -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 request_details); diff --git a/atom/browser/browser_observer.h b/atom/browser/browser_observer.h index 6e85b599d038..5ef4ee127926 100644 --- a/atom/browser/browser_observer.h +++ b/atom/browser/browser_observer.h @@ -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(