Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: content/browser/renderer_host/legacy_render_widget_host_win.cc

Issue 272803003: Add back the ALERT trick to detect screen readers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/legacy_render_widget_host_win.cc
diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.cc b/content/browser/renderer_host/legacy_render_widget_host_win.cc
index e4f603f0feb475c100332a997c237ef4be2fdb9e..84d95aced8ba6c667138154caec7a8c9a6e2a6e5 100644
--- a/content/browser/renderer_host/legacy_render_widget_host_win.cc
+++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc
@@ -9,6 +9,7 @@
#include "base/win/windows_version.h"
#include "content/browser/accessibility/browser_accessibility_manager_win.h"
#include "content/browser/accessibility/browser_accessibility_win.h"
+#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/common/content_switches.h"
#include "ui/base/touch/touch_enabled.h"
#include "ui/base/view_prop.h"
@@ -18,6 +19,11 @@
namespace content {
+// A custom MSAA object id used to determine if a screen reader or some
+// other client is listening on MSAA events - if so, we enable full web
+// accessibility support.
+const int kIdScreenReaderHoneyPot = 1;
+
LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() {
::DestroyWindow(hwnd());
}
@@ -100,6 +106,14 @@ bool LegacyRenderWidgetHostHWND::Init() {
hwnd(), OBJID_WINDOW, IID_IAccessible,
reinterpret_cast<void **>(window_accessible_.Receive()));
DCHECK(SUCCEEDED(hr));
+
+ if (!BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) {
+ // Attempt to detect screen readers or other clients who want full
+ // accessibility support, by seeing if they respond to this event.
+ NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kIdScreenReaderHoneyPot,
+ CHILDID_SELF);
+ }
+
return !!SUCCEEDED(hr);
}
@@ -119,6 +133,13 @@ LRESULT LegacyRenderWidgetHostHWND::OnEraseBkGnd(UINT message,
LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message,
WPARAM w_param,
LPARAM l_param) {
+ if (kIdScreenReaderHoneyPot == l_param) {
+ // When an MSAA client has responded to our fake event on this id,
+ // enable screen reader support.
+ BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected();
+ return static_cast<LRESULT>(0L);
+ }
+
if (OBJID_CLIENT != l_param || !manager_)
return static_cast<LRESULT>(0L);
@@ -303,4 +324,4 @@ LRESULT LegacyRenderWidgetHostHWND::OnSize(UINT message,
return 0;
}
-} // namespace content
+} // namespace content
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698