summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-25 06:41:14 +0000
committerctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-25 06:41:14 +0000
commitdea2d37cbf7cfa80b8c357d81ca706ac856325b6 (patch)
treea2c6b4991563ffa0567729693951e2eb7e187ee5 /chrome/browser/renderer_host
parent9d3f7d5e85d9834495434d7b925c1ba7933a344f (diff)
downloadchromium_src-dea2d37cbf7cfa80b8c357d81ca706ac856325b6.zip
chromium_src-dea2d37cbf7cfa80b8c357d81ca706ac856325b6.tar.gz
chromium_src-dea2d37cbf7cfa80b8c357d81ca706ac856325b6.tar.bz2
Support additional webkit accessibility notifications and states.
1. Update WebAccessibility::ConvertState to function similarly to WebCore's AccessibleBase::get_accState. 2. Use WebKit's load complete notification to send the renderer's tree to the browser. We enable accessibility on the renderer now instead of requesting a tree. 3. Use WebKit's focused ui element notification to send renderer focus events to the browser. BUG=13291 BUG=38106 TEST=interactive_ui_tests:AccessibilityWinBrowserTest.TestNotificationActiveDescendantChanged TEST=interactive_ui_tests:AccessibilityWinBrowserTest.TestNotificationFocusChanged Review URL: http://codereview.chromium.org/3380017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60569 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc9
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.h5
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.cc3
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.h2
-rw-r--r--chrome/browser/renderer_host/render_process_host.h3
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc46
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc22
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h16
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h1
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm8
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc37
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.h4
14 files changed, 48 insertions, 112 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index c380801..b6939a6 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -201,6 +201,7 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_(
base::TimeDelta::FromSeconds(5),
this, &BrowserRenderProcessHost::ClearTransportDIBCache)),
+ accessibility_enabled_(false),
extension_process_(false) {
widget_helper_ = new RenderWidgetHelper();
@@ -246,12 +247,15 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() {
ClearTransportDIBCache();
}
-bool BrowserRenderProcessHost::Init(bool is_extensions_process) {
+bool BrowserRenderProcessHost::Init(
+ bool is_accessibility_enabled, bool is_extensions_process) {
// calling Init() more than once does nothing, this makes it more convenient
// for the view host which may not be sure in some cases
if (channel_.get())
return true;
+ accessibility_enabled_ = is_accessibility_enabled;
+
// It is possible for an extension process to be reused for non-extension
// content, e.g. if an extension calls window.open.
extension_process_ = extension_process_ || is_extensions_process;
@@ -449,6 +453,9 @@ void BrowserRenderProcessHost::AppendRendererCommandLine(
if (logging::DialogsAreSuppressed())
command_line->AppendSwitch(switches::kNoErrorDialogs);
+ if (accessibility_enabled_)
+ command_line->AppendSwitch(switches::kEnableAccessibility);
+
// Now send any options from our own command line we want to propogate.
const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
PropagateBrowserCommandLineToRenderer(browser_command_line, command_line);
diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h
index 3200947..9983c84 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.h
+++ b/chrome/browser/renderer_host/browser_render_process_host.h
@@ -61,7 +61,7 @@ class BrowserRenderProcessHost : public RenderProcessHost,
~BrowserRenderProcessHost();
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_extensions_process);
+ virtual bool Init(bool is_accessibility_enabled, bool is_extensions_process);
virtual int GetNextRoutingID();
virtual void CancelResourceRequests(int render_widget_id);
virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params);
@@ -198,6 +198,9 @@ class BrowserRenderProcessHost : public RenderProcessHost,
// Buffer visited links and send them to to renderer.
scoped_ptr<VisitedLinkUpdater> visited_link_updater_;
+ // True if this prcoess should have accessibility enabled;
+ bool accessibility_enabled_;
+
// True iff this process is being used as an extension process. Not valid
// when running in single-process mode.
bool extension_process_;
diff --git a/chrome/browser/renderer_host/mock_render_process_host.cc b/chrome/browser/renderer_host/mock_render_process_host.cc
index 3866239..63272f5 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.cc
+++ b/chrome/browser/renderer_host/mock_render_process_host.cc
@@ -20,7 +20,8 @@ MockRenderProcessHost::~MockRenderProcessHost() {
delete transport_dib_;
}
-bool MockRenderProcessHost::Init(bool is_extensions_process) {
+bool MockRenderProcessHost::Init(
+ bool is_accessibility_enabled, bool is_extensions_process) {
return true;
}
diff --git a/chrome/browser/renderer_host/mock_render_process_host.h b/chrome/browser/renderer_host/mock_render_process_host.h
index 608821d..34f00f9 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.h
+++ b/chrome/browser/renderer_host/mock_render_process_host.h
@@ -31,7 +31,7 @@ class MockRenderProcessHost : public RenderProcessHost {
int bad_msg_count() const { return bad_msg_count_; }
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_extensions_process);
+ virtual bool Init(bool is_accessibility_enabled, bool is_extensions_process);
virtual int GetNextRoutingID();
virtual void CancelResourceRequests(int render_widget_id);
virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params);
diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h
index f2b26fb..19911f0 100644
--- a/chrome/browser/renderer_host/render_process_host.h
+++ b/chrome/browser/renderer_host/render_process_host.h
@@ -148,7 +148,8 @@ class RenderProcessHost : public IPC::Channel::Sender,
// be called once before the object can be used, but can be called after
// that with no effect. Therefore, if the caller isn't sure about whether
// the process has been created, it should just call Init().
- virtual bool Init(bool is_extensions_process) = 0;
+ virtual bool Init(
+ bool is_accessibility_enabled, bool is_extensions_process) = 0;
// Gets the next available routing id.
virtual int GetNextRoutingID() = 0;
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 1cad374..7fe1ce5 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -157,7 +157,7 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) {
// initialized it) or may not (we have our own process or the old process
// crashed) have been initialized. Calling Init multiple times will be
// ignored, so this is safe.
- if (!process()->Init(is_extension_process_))
+ if (!process()->Init(renderer_accessible(), is_extension_process_))
return false;
DCHECK(process()->HasConnection());
DCHECK(process()->profile());
@@ -844,8 +844,6 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionPostMessage,
OnExtensionPostMessage)
- IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityFocusChange,
- OnAccessibilityFocusChange)
IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications,
OnAccessibilityNotifications)
IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted)
@@ -854,7 +852,6 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked)
IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed)
IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed)
- IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityTree, OnAccessibilityTree)
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetDisplayingPDFContent,
OnSetDisplayingPDFContent)
@@ -1023,12 +1020,6 @@ void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) {
FilterURL(policy, renderer_id, &validated_params.password_form.origin);
FilterURL(policy, renderer_id, &validated_params.password_form.action);
- if (!validated_params.was_within_same_page) {
- // Only set that the document is not loaded if the navigation was not within
- // the current page. If it was within the same page, the document will not
- // load again.
- SetDocumentLoaded(false);
- }
delegate_->DidNavigate(this, validated_params);
}
@@ -1326,7 +1317,6 @@ void RenderViewHost::OnMsgDocumentLoadedInFrame() {
delegate_->GetResourceDelegate();
if (resource_delegate)
resource_delegate->DocumentLoadedInFrame();
- SetDocumentLoaded(true);
}
void RenderViewHost::DisassociateFromPopupCount() {
@@ -1958,36 +1948,34 @@ void RenderViewHost::OnExtensionPostMessage(
}
}
-void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) {
- if (view())
- view()->OnAccessibilityFocusChange(acc_obj_id);
-}
-
void RenderViewHost::OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) {
if (view())
view()->OnAccessibilityNotifications(params);
if (params.size() > 0) {
+ for (unsigned i = 0; i < params.size(); i++) {
+ const ViewHostMsg_AccessibilityNotification_Params& param = params[i];
+
+ if (param.notification_type ==
+ ViewHostMsg_AccessibilityNotification_Params::
+ NOTIFICATION_TYPE_LOAD_COMPLETE) {
+ // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications.
+ if (view())
+ view()->UpdateAccessibilityTree(param.acc_obj);
+
+ if (save_accessibility_tree_for_testing_)
+ accessibility_tree_ = param.acc_obj;
+ }
+ }
+
NotificationService::current()->Notify(
NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
Source<RenderViewHost>(this),
NotificationService::NoDetails());
}
-}
-
-void RenderViewHost::OnAccessibilityTree(
- const webkit_glue::WebAccessibility& tree) {
- if (view())
- view()->UpdateAccessibilityTree(tree);
- if (save_accessibility_tree_for_testing_)
- accessibility_tree_ = tree;
-
- NotificationService::current()->Notify(
- NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
- Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ AccessibilityNotificationsAck();
}
void RenderViewHost::OnCSSInserted() {
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 6d3d156..5fce6d9 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -657,10 +657,8 @@ class RenderViewHost : public RenderWidgetHost {
void OnExtensionRequest(const ViewHostMsg_DomMessage_Params& params);
void OnExtensionPostMessage(int port_id, const std::string& message);
- void OnAccessibilityFocusChange(int acc_obj_id);
void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
- void OnAccessibilityTree(const webkit_glue::WebAccessibility& tree);
void OnCSSInserted();
void OnPageContents(const GURL& url,
int32 page_id,
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index cb757ab..6153331 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -1138,22 +1138,6 @@ void RenderWidgetHost::AdvanceToNextMisspelling() {
Send(new ViewMsg_AdvanceToNextMisspelling(routing_id_));
}
-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;
@@ -1165,9 +1149,9 @@ void RenderWidgetHost::EnableRendererAccessibility() {
renderer_accessible_ = true;
- if (document_loaded_ && !requested_accessibility_tree_) {
- RequestAccessibilityTree();
- requested_accessibility_tree_ = true;
+ if (process_->HasConnection()) {
+ // Renderer accessibility wasn't enabled on process launch. Enable it now.
+ Send(new ViewMsg_EnableAccessibility(routing_id()));
}
}
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index 8fcedd1..390cc31 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -146,6 +146,7 @@ class RenderWidgetHost : public IPC::Channel::Listener,
RenderProcessHost* process() const { return process_; }
int routing_id() const { return routing_id_; }
+ static bool renderer_accessible() { return renderer_accessible_; }
// Set the PaintObserver on this object. Takes ownership.
void set_paint_observer(PaintObserver* paint_observer) {
@@ -399,13 +400,6 @@ class RenderWidgetHost : public IPC::Channel::Listener,
}
protected:
- // Aid for determining when an accessibility tree request can be made. Set by
- // TabContents to true on document load and to false on page navigation.
- void SetDocumentLoaded(bool document_loaded);
-
- // Requests a snapshot of an accessible DOM tree from the renderer.
- void RequestAccessibilityTree();
-
// Internal implementation of the public Forward*Event() methods.
void ForwardInputEvent(const WebKit::WebInputEvent& input_event,
int event_size, bool is_keyboard_shortcut);
@@ -688,14 +682,6 @@ 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.h b/chrome/browser/renderer_host/render_widget_host_view.h
index 1dab773..4258a86 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -252,7 +252,6 @@ class RenderWidgetHostView {
virtual void UpdateAccessibilityTree(
const webkit_glue::WebAccessibility& tree) { }
- virtual void OnAccessibilityFocusChange(int acc_obj_id) { }
virtual void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) {
}
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index 688ee42..41b4316 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -219,8 +219,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
virtual bool ContainsNativeView(gfx::NativeView native_view) const;
virtual void UpdateAccessibilityTree(
const webkit_glue::WebAccessibility& tree);
- virtual void OnAccessibilityFocusChange(int acc_obj_id);
- virtual void OnAccessibilityObjectStateChange(int acc_obj_id);
// Methods associated with GPU-accelerated plug-in instances and the
// accelerated compositor.
virtual gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque,
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index b727b81..1345f84 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -1099,14 +1099,6 @@ void RenderWidgetHostViewMac::UpdateAccessibilityTree(
}
}
-void RenderWidgetHostViewMac::OnAccessibilityFocusChange(int acc_obj_id) {
- NOTIMPLEMENTED();
-}
-
-void RenderWidgetHostViewMac::OnAccessibilityObjectStateChange(int acc_obj_id) {
- NOTIMPLEMENTED();
-}
-
void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
if (active) {
if (text_input_type_ == WebKit::WebTextInputTypePassword)
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 ad85f03..2640163 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -1477,31 +1477,18 @@ LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM,
return MA_ACTIVATE;
}
-void RenderWidgetHostViewWin::UpdateAccessibilityTree(
- const webkit_glue::WebAccessibility& tree) {
- browser_accessibility_manager_.reset(
- new BrowserAccessibilityManager(m_hWnd, tree, this));
-
- BrowserAccessibility* root = browser_accessibility_manager_.get()->GetRoot();
- LONG root_id;
- if (root && SUCCEEDED(root->get_uniqueID(&root_id))) {
- ::NotifyWinEvent(
- EVENT_OBJECT_FOCUS, m_hWnd, OBJID_CLIENT, root_id);
- ::NotifyWinEvent(
- IA2_EVENT_DOCUMENT_LOAD_COMPLETE, m_hWnd, OBJID_CLIENT, root_id);
- }
-}
-
-void RenderWidgetHostViewWin::OnAccessibilityFocusChange(int acc_obj_id) {
- if (browser_accessibility_manager_.get()) {
- browser_accessibility_manager_->OnAccessibilityFocusChange(acc_obj_id);
- }
-}
-
void RenderWidgetHostViewWin::OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) {
- if (browser_accessibility_manager_.get())
- browser_accessibility_manager_->OnAccessibilityNotifications(params);
+ if (!browser_accessibility_manager_.get()) {
+ // Use empty document to process notifications
+ webkit_glue::WebAccessibility empty_document;
+ empty_document.role = WebAccessibility::ROLE_DOCUMENT;
+ empty_document.state = 0;
+ browser_accessibility_manager_.reset(
+ new BrowserAccessibilityManager(m_hWnd, empty_document, this));
+ }
+
+ browser_accessibility_manager_->OnAccessibilityNotifications(params);
}
void RenderWidgetHostViewWin::Observe(NotificationType type,
@@ -1546,10 +1533,6 @@ void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) {
render_widget_host_->AccessibilityDoDefaultAction(acc_obj_id);
}
-void RenderWidgetHostViewWin::AccessibilityNotificationsAck() {
- render_widget_host_->AccessibilityNotificationsAck();
-}
-
LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam,
LPARAM lparam, BOOL& handled) {
if (lparam != OBJID_CLIENT) {
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 8f00a38..87dd687 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.h
@@ -153,9 +153,6 @@ class RenderWidgetHostViewWin
virtual void SetBackground(const SkBitmap& background);
virtual bool ContainsNativeView(gfx::NativeView native_view) const;
virtual void SetVisuallyDeemphasized(bool deemphasized);
- virtual void UpdateAccessibilityTree(
- const webkit_glue::WebAccessibility& tree);
- virtual void OnAccessibilityFocusChange(int acc_obj_id);
virtual void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
@@ -167,7 +164,6 @@ class RenderWidgetHostViewWin
// Implementation of BrowserAccessibilityDelegate:
virtual void SetAccessibilityFocus(int acc_obj_id);
virtual void AccessibilityDoDefaultAction(int acc_obj_id);
- virtual void AccessibilityNotificationsAck();
protected:
// Windows Message Handlers