summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 23:02:30 +0000
committerctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 23:02:30 +0000
commitf5b6e247f1d29be30f53a293610e689e233dc5ff (patch)
tree86c6c1996b65faf226e805c8a0631ec1500d0e9d /chrome/browser
parent5b59c6bb5ca490f5425d679f81983e28a8bc5a1e (diff)
downloadchromium_src-f5b6e247f1d29be30f53a293610e689e233dc5ff.zip
chromium_src-f5b6e247f1d29be30f53a293610e689e233dc5ff.tar.gz
chromium_src-f5b6e247f1d29be30f53a293610e689e233dc5ff.tar.bz2
Enable renderer accessibility by default.
BUG=25564 TEST=none Review URL: http://codereview.chromium.org/2358003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/accessibility_win_browsertest.cc26
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc34
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h22
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc51
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.h10
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc13
-rw-r--r--chrome/browser/tab_contents/tab_contents.h9
7 files changed, 122 insertions, 43 deletions
diff --git a/chrome/browser/accessibility_win_browsertest.cc b/chrome/browser/accessibility_win_browsertest.cc
index 580a8fe..2199a07 100644
--- a/chrome/browser/accessibility_win_browsertest.cc
+++ b/chrome/browser/accessibility_win_browsertest.cc
@@ -19,13 +19,6 @@
namespace {
class AccessibilityWinBrowserTest : public InProcessBrowserTest {
- public:
- void SetUpCommandLine(CommandLine* command_line) {
- // Turns on the accessibility in the renderer. Off by default until
- // http://crbug.com/25564 is fixed.
- command_line->AppendSwitch(switches::kEnableRendererAccessibility);
- }
-
protected:
IAccessible* GetRenderWidgetHostViewClientAccessible();
};
@@ -181,6 +174,20 @@ void AccessibleChecker::CheckAccessibleChildren(IAccessible* parent) {
IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
TestRendererAccessibilityTree) {
+ // By requesting an accessible chrome will believe a screen reader has been
+ // detected.
+ ScopedComPtr<IAccessible> document_accessible(
+ GetRenderWidgetHostViewClientAccessible());
+
+ // The initial accessible returned should have state STATE_SYSTEM_BUSY while
+ // the accessibility tree is being requested from the renderer.
+ VARIANT var_state;
+ HRESULT hr = document_accessible->
+ get_accState(CreateI4Variant(CHILDID_SELF), &var_state);
+ EXPECT_EQ(hr, S_OK);
+ EXPECT_EQ(V_VT(&var_state), VT_I4);
+ EXPECT_EQ(V_I4(&var_state), STATE_SYSTEM_BUSY);
+
GURL tree_url(
"data:text/html,<html><head><title>Accessibility Win Test</title></head>"
"<body><input type='button' value='push' /><input type='checkbox' />"
@@ -189,8 +196,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
ui_test_utils::WaitForNotification(
NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
- ScopedComPtr<IAccessible> document_accessible(
- GetRenderWidgetHostViewClientAccessible());
+ document_accessible = GetRenderWidgetHostViewClientAccessible();
ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
AccessibleChecker button_checker(L"push", ROLE_SYSTEM_PUSHBUTTON);
@@ -208,7 +214,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
// Check that document accessible has a parent accessible.
ScopedComPtr<IDispatch> parent_dispatch;
- HRESULT hr = document_accessible->get_accParent(parent_dispatch.Receive());
+ hr = document_accessible->get_accParent(parent_dispatch.Receive());
EXPECT_EQ(hr, S_OK);
EXPECT_NE(parent_dispatch, reinterpret_cast<IDispatch*>(NULL));
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 673a237..125c8a9 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/renderer_host/render_widget_host.h"
#include "base/auto_reset.h"
+#include "base/command_line.h"
#include "base/histogram.h"
#include "base/keyboard_codes.h"
#include "base/message_loop.h"
@@ -16,6 +17,7 @@
#include "chrome/browser/renderer_host/render_widget_host_painting_observer.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/renderer_host/video_layer.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/render_messages.h"
#include "webkit/glue/webcursor.h"
@@ -58,6 +60,9 @@ static const int kHungRendererDelayMs = 20000;
// in trailing scrolls after the user ends their input.
static const int kMaxTimeBetweenWheelMessagesMs = 250;
+// static
+bool RenderWidgetHost::renderer_accessible_ = false;
+
///////////////////////////////////////////////////////////////////////////////
// RenderWidgetHost
@@ -1111,6 +1116,35 @@ void RenderWidgetHost::RequestAccessibilityTree() {
Send(new ViewMsg_GetAccessibilityTree(routing_id()));
}
+void RenderWidgetHost::SetDocumentLoaded(bool document_loaded) {
+ document_loaded_ = document_loaded;
+
+ if (!document_loaded_)
+ requested_accessibility_tree_ = false;
+
+ if (renderer_accessible_ && document_loaded_) {
+ RequestAccessibilityTree();
+ requested_accessibility_tree_ = true;
+ }
+}
+
+void RenderWidgetHost::EnableRendererAccessibility() {
+ if (renderer_accessible_)
+ return;
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableRendererAccessibility)) {
+ return;
+ }
+
+ renderer_accessible_ = true;
+
+ if (document_loaded_ && !requested_accessibility_tree_) {
+ RequestAccessibilityTree();
+ requested_accessibility_tree_ = true;
+ }
+}
+
void RenderWidgetHost::SetAccessibilityFocus(int acc_obj_id) {
Send(new ViewMsg_SetAccessibilityFocus(routing_id(), acc_obj_id));
}
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index ab64ef7..27bb5dd 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -6,6 +6,8 @@
#define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_
#include <deque>
+#include <string>
+#include <vector>
#include "app/surface/transport_dib.h"
#include "base/gtest_prod_util.h"
@@ -370,6 +372,14 @@ class RenderWidgetHost : public IPC::Channel::Listener,
// Requests a snapshot of an accessible DOM tree from the renderer.
void RequestAccessibilityTree();
+ // Aid for determining when an accessibility tree request can be made. Set by
+ // TabContents to true on document load and to false on page nativigation.
+ void SetDocumentLoaded(bool document_loaded);
+
+ // Enable renderer accessibility. This should only be called when a
+ // screenreader is detected.
+ void EnableRendererAccessibility();
+
// Relays a request from assistive technology to set focus to the
// node with this accessibility object id.
void SetAccessibilityFocus(int acc_obj_id);
@@ -530,6 +540,10 @@ class RenderWidgetHost : public IPC::Channel::Listener,
// input messages to be coalesced.
void ProcessWheelAck();
+ // True if renderer accessibility is enabled. This should only be set when a
+ // screenreader is detected as it can potentially slow down Chrome.
+ static bool renderer_accessible_;
+
// The View associated with the RenderViewHost. The lifetime of this object
// is associated with the lifetime of the Render process. If the Renderer
// crashes, its View is destroyed and this pointer becomes NULL, even though
@@ -667,6 +681,14 @@ class RenderWidgetHost : public IPC::Channel::Listener,
// changed.
bool suppress_next_char_events_;
+ // Keep track of if we have a loaded document so that we can request an
+ // accessibility tree on demand when renderer accessibility is enabled.
+ bool document_loaded_;
+
+ // Keep track of if we've already requested the accessibility tree so
+ // we don't do it more than once.
+ bool requested_accessibility_tree_;
+
// Optional video YUV layer for used for out-of-process compositing.
scoped_ptr<VideoLayer> video_layer_;
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index e195317..a6ce128 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -252,7 +252,6 @@ void DrawDeemphasized(const gfx::Rect& paint_rect,
paint_rect.width(), paint_rect.height());
canvas.getTopPlatformDevice().drawToHDC(paint_dc, paint_rect.x(),
paint_rect.y(), NULL);
-
}
} // namespace
@@ -284,12 +283,15 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
is_loading_(false),
visually_deemphasized_(false) {
render_widget_host_->set_view(this);
- renderer_accessible_ =
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableRendererAccessibility);
registrar_.Add(this,
NotificationType::RENDERER_PROCESS_TERMINATED,
NotificationService::AllSources());
+
+ BOOL screenreader_running = FALSE;
+ if (SystemParametersInfo(SPI_GETSCREENREADER, 0, &screenreader_running, 0) &&
+ screenreader_running) {
+ render_widget_host_->EnableRendererAccessibility();
+ }
}
RenderWidgetHostViewWin::~RenderWidgetHostViewWin() {
@@ -1483,6 +1485,9 @@ void RenderWidgetHostViewWin::UpdateAccessibilityTree(
const webkit_glue::WebAccessibility& tree) {
browser_accessibility_manager_.reset(
new BrowserAccessibilityManager(m_hWnd, tree, this));
+
+ ::NotifyWinEvent(
+ IA2_EVENT_DOCUMENT_LOAD_COMPLETE, m_hWnd, OBJID_CLIENT, CHILDID_SELF);
}
void RenderWidgetHostViewWin::OnAccessibilityFocusChange(int acc_obj_id) {
@@ -1542,18 +1547,46 @@ void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) {
LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam,
LPARAM lparam, BOOL& handled) {
- // TODO(dmazzoni): http://crbug.com/25564 Disabling accessibility in the
- // renderer is a temporary work-around until that bug is fixed.
- if (!renderer_accessible_) {
+ if (lparam != OBJID_CLIENT) {
handled = false;
return static_cast<LRESULT>(0L);
}
- if (lparam == OBJID_CLIENT && browser_accessibility_manager_.get()) {
+ if (!browser_accessibility_manager_.get()) {
+ render_widget_host_->EnableRendererAccessibility();
+
+ if (!loading_accessible_.get()) {
+ // Create IAccessible to return while waiting for the accessibility tree
+ // from the renderer.
+ HRESULT hr = ::CreateStdAccessibleObject(
+ m_hWnd, OBJID_CLIENT, IID_IAccessible,
+ reinterpret_cast<void **>(&loading_accessible_));
+
+ // Annotate with STATE_SYSTEM_BUSY to indicate that the page is loading.
+ // We annotate the HWND, not the loading_accessible IAccessible, but the
+ // IAccessible will reflect the state annotation.
+ ScopedComPtr<IAccPropServices> pAccPropServices;
+ hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER,
+ IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices));
+ if (SUCCEEDED(hr)) {
+ VARIANT var;
+ var.vt = VT_I4;
+ var.lVal = STATE_SYSTEM_BUSY;
+ pAccPropServices->SetHwndProp(m_hWnd, OBJID_CLIENT,
+ CHILDID_SELF, PROPID_ACC_STATE, var);
+ }
+ }
+
+ if (loading_accessible_.get()) {
+ return LresultFromObject(
+ IID_IAccessible, wparam,
+ static_cast<IAccessible*>(loading_accessible_));
+ }
+ } else {
BrowserAccessibility* root = browser_accessibility_manager_->GetRoot();
if (root) {
return LresultFromObject(IID_IAccessible, wparam,
- static_cast<IAccessible*>(root->NewReference()));
+ static_cast<IAccessible*>(root->NewReference()));
}
}
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h
index c298f58..9580e88 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.h
@@ -10,6 +10,8 @@
#include <atlcrack.h>
#include <atlmisc.h>
+#include <vector>
+
#include "base/scoped_comptr_win.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
@@ -249,6 +251,9 @@ class RenderWidgetHostViewWin
// Whether the window should be activated.
bool IsActivatable() const;
+ // MSAA IAccessible returned while page contents is loading.
+ ScopedComPtr<IAccessible> loading_accessible_;
+
// The associated Model.
RenderWidgetHost* render_widget_host_;
@@ -320,11 +325,6 @@ class RenderWidgetHostViewWin
// value returns true for is_null() if we are not recording whiteout times.
base::TimeTicks whiteout_start_time_;
- // Whether the renderer is made accessible.
- // TODO(jcampan): http://b/issue?id=1432077 This is a temporary work-around
- // until that bug is fixed.
- bool renderer_accessible_;
-
// The time it took after this view was selected for it to be fully painted.
base::TimeTicks tab_switch_paint_time_;
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 2fd0504..e2bbfe8 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -296,7 +296,6 @@ TabContents::TabContents(Profile* profile,
opener_dom_ui_type_(DOMUIFactory::kNoDOMUI),
language_state_(&controller_),
geolocation_settings_state_(profile),
- requested_accessibility_tree_(false),
closed_by_user_gesture_(false) {
ClearBlockedContentSettings();
renderer_preferences_util::UpdateFromSystemSettings(
@@ -355,10 +354,6 @@ TabContents::TabContents(Profile* profile,
// Set-up the showing of the omnibox search infobar if applicable.
if (OmniboxSearchHint::IsEnabled(profile))
omnibox_search_hint_.reset(new OmniboxSearchHint(this));
-
- renderer_accessible_ =
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableRendererAccessibility);
}
TabContents::~TabContents() {
@@ -2147,10 +2142,8 @@ void TabContents::DidFailProvisionalLoadWithError(
void TabContents::DocumentLoadedInFrame() {
controller_.DocumentLoadedInFrame();
- if (renderer_accessible_ && !requested_accessibility_tree_) {
- render_view_host()->RequestAccessibilityTree();
- requested_accessibility_tree_ = true;
- }
+
+ render_view_host()->SetDocumentLoaded(true);
}
void TabContents::OnContentBlocked(ContentSettingsType type) {
@@ -2320,7 +2313,7 @@ void TabContents::DidNavigate(RenderViewHost* rvh,
const ViewHostMsg_FrameNavigate_Params& params) {
int extra_invalidate_flags = 0;
- requested_accessibility_tree_ = false;
+ render_view_host()->SetDocumentLoaded(false);
if (PageTransition::IsMainFrame(params.transition)) {
bool was_bookmark_bar_visible = ShouldShowBookmarkBar();
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 42c409b..62dd896 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -1282,15 +1282,6 @@ class TabContents : public PageNavigator,
// Manages information about Geolocation API usage in this page.
GeolocationSettingsState geolocation_settings_state_;
- // Whether the renderer is made accessible.
- // TODO(dmazzoni): http://crbug.com/25564 This is a temporary work-around
- // until that bug is fixed.
- bool renderer_accessible_;
-
- // Keep track of if we've already requested the accessibility tree so
- // we don't do it more than once.
- bool requested_accessibility_tree_;
-
// See description above setter.
bool closed_by_user_gesture_;