Check harder before enabling Accessibility support

This commit is contained in:
Paul Betts 2016-10-13 11:46:55 -07:00
parent 7584e73d70
commit 0df21afcdf
3 changed files with 24 additions and 8 deletions

View file

@ -18,6 +18,8 @@
#include "atom/browser/ui/win/message_handler_delegate.h" #include "atom/browser/ui/win/message_handler_delegate.h"
#include "atom/browser/ui/win/taskbar_host.h" #include "atom/browser/ui/win/taskbar_host.h"
#include "base/win/scoped_gdi_object.h" #include "base/win/scoped_gdi_object.h"
#include "ui/base/win/accessibility_misc_utils.h"
#include <UIAutomationCoreApi.h>
#endif #endif
namespace views { namespace views {
@ -228,6 +230,9 @@ class NativeWindowViews : public NativeWindow,
// In charge of running taskbar related APIs. // In charge of running taskbar related APIs.
TaskbarHost taskbar_host_; TaskbarHost taskbar_host_;
// Memoized version of a11y check
bool checked_for_a11y_support_;
// If true we have enabled a11y // If true we have enabled a11y
bool enabled_a11y_support_; bool enabled_a11y_support_;

View file

@ -92,16 +92,26 @@ bool NativeWindowViews::PreHandleMSG(
// accessibility object. // accessibility object.
case WM_GETOBJECT: { case WM_GETOBJECT: {
const DWORD obj_id = static_cast<DWORD>(l_param); const DWORD obj_id = static_cast<DWORD>(l_param);
if (enabled_a11y_support_) return false; if (checked_for_a11y_support_) return false;
checked_for_a11y_support_ = true;
if (obj_id != OBJID_CLIENT) {
return false;
}
UINT screenReader = 0;
SystemParametersInfo(SPI_GETSCREENREADER, 0, &screenReader, 0);
if (!screenReader || !UiaClientsAreListening()) {
return false;
}
if (obj_id == OBJID_CLIENT) {
const auto axState = content::BrowserAccessibilityState::GetInstance(); const auto axState = content::BrowserAccessibilityState::GetInstance();
if (axState && !axState->IsAccessibleBrowser()) { if (axState && !axState->IsAccessibleBrowser()) {
axState->OnScreenReaderDetected(); axState->OnScreenReaderDetected();
enabled_a11y_support_ = true; enabled_a11y_support_ = true;
Browser::Get()->OnAccessibilitySupportChanged(); Browser::Get()->OnAccessibilitySupportChanged();
} }
}
return false; return false;
} }

View file

@ -281,6 +281,7 @@
'-lwininet.lib', '-lwininet.lib',
'-lwinmm.lib', '-lwinmm.lib',
'-lcrypt32.lib', '-lcrypt32.lib',
'-luiautomationcore.lib',
], ],
}, },
'dependencies': [ 'dependencies': [