Index: content/browser/renderer_host/render_view_host_impl.cc |
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc |
index a5b1d60bf3e68d657fe029a21db820d4e4bfbfdd..4184fde32d613879b9beb6d88fcd3d0da94eecf6 100644 |
--- a/content/browser/renderer_host/render_view_host_impl.cc |
+++ b/content/browser/renderer_host/render_view_host_impl.cc |
@@ -23,6 +23,7 @@ |
#include "base/time/time.h" |
#include "base/values.h" |
#include "cc/base/switches.h" |
+#include "content/browser/accessibility/browser_accessibility_manager.h" |
#include "content/browser/child_process_security_policy_impl.h" |
#include "content/browser/cross_site_request_manager.h" |
#include "content/browser/dom_storage/session_storage_namespace_impl.h" |
@@ -40,6 +41,7 @@ |
#include "content/browser/renderer_host/render_view_host_delegate.h" |
#include "content/browser/renderer_host/render_view_host_delegate_view.h" |
#include "content/browser/renderer_host/render_widget_host_view_base.h" |
+#include "content/common/accessibility_messages.h" |
#include "content/common/browser_plugin/browser_plugin_messages.h" |
#include "content/common/content_switches_internal.h" |
#include "content/common/drag_messages.h" |
@@ -74,6 +76,7 @@ |
#include "net/base/network_change_notifier.h" |
#include "net/url_request/url_request_context_getter.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
+#include "ui/accessibility/ax_tree.h" |
#include "ui/base/touch/touch_device.h" |
#include "ui/base/touch/touch_enabled.h" |
#include "ui/base/ui_base_switches.h" |
@@ -305,6 +308,7 @@ |
params.window_was_created_with_opener = window_was_created_with_opener; |
params.next_page_id = next_page_id; |
GetWebScreenInfo(¶ms.screen_info); |
+ params.accessibility_mode = accessibility_mode(); |
Send(new ViewMsg_New(params)); |
@@ -973,6 +977,9 @@ |
IPC_MESSAGE_HANDLER(ViewHostMsg_HidePopup, OnHidePopup) |
#endif |
IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) |
+ IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) |
+ IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, |
+ OnAccessibilityLocationChanges) |
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) |
// Have the super handle all other messages. |
IPC_MESSAGE_UNHANDLED( |
@@ -1430,6 +1437,11 @@ |
Send(new ViewMsg_DisownOpener(GetRoutingID())); |
} |
+void RenderViewHostImpl::SetAccessibilityCallbackForTesting( |
+ const base::Callback<void(ui::AXEvent, int)>& callback) { |
+ accessibility_testing_callback_ = callback; |
+} |
+ |
void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { |
Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); |
} |
@@ -1493,6 +1505,67 @@ |
void RenderViewHostImpl::NotifyMoveOrResizeStarted() { |
Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); |
+} |
+ |
+void RenderViewHostImpl::OnAccessibilityEvents( |
+ const std::vector<AccessibilityHostMsg_EventParams>& params) { |
+ if ((accessibility_mode() != AccessibilityModeOff) && view_ && |
+ IsRVHStateActive(rvh_state_)) { |
+ if (accessibility_mode() & AccessibilityModeFlagPlatform) { |
+ view_->CreateBrowserAccessibilityManagerIfNeeded(); |
+ BrowserAccessibilityManager* manager = |
+ view_->GetBrowserAccessibilityManager(); |
+ if (manager) |
+ manager->OnAccessibilityEvents(params); |
+ } |
+ |
+ std::vector<AXEventNotificationDetails> details; |
+ for (unsigned int i = 0; i < params.size(); ++i) { |
+ const AccessibilityHostMsg_EventParams& param = params[i]; |
+ AXEventNotificationDetails detail(param.update.node_id_to_clear, |
+ param.update.nodes, |
+ param.event_type, |
+ param.id, |
+ GetProcess()->GetID(), |
+ GetRoutingID()); |
+ details.push_back(detail); |
+ } |
+ |
+ delegate_->AccessibilityEventReceived(details); |
+ } |
+ |
+ // Always send an ACK or the renderer can be in a bad state. |
+ Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); |
+ |
+ // The rest of this code is just for testing; bail out if we're not |
+ // in that mode. |
+ if (accessibility_testing_callback_.is_null()) |
+ return; |
+ |
+ for (unsigned i = 0; i < params.size(); i++) { |
+ const AccessibilityHostMsg_EventParams& param = params[i]; |
+ if (static_cast<int>(param.event_type) < 0) |
+ continue; |
+ if (!ax_tree_) |
+ ax_tree_.reset(new ui::AXTree(param.update)); |
+ else |
+ CHECK(ax_tree_->Unserialize(param.update)) << ax_tree_->error(); |
+ accessibility_testing_callback_.Run(param.event_type, param.id); |
+ } |
+} |
+ |
+void RenderViewHostImpl::OnAccessibilityLocationChanges( |
+ const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
+ if (view_ && IsRVHStateActive(rvh_state_)) { |
+ if (accessibility_mode() & AccessibilityModeFlagPlatform) { |
+ view_->CreateBrowserAccessibilityManagerIfNeeded(); |
+ BrowserAccessibilityManager* manager = |
+ view_->GetBrowserAccessibilityManager(); |
+ if (manager) |
+ manager->OnLocationChanges(params); |
+ } |
+ // TODO(aboxhall): send location change events to web contents observers too |
+ } |
} |
void RenderViewHostImpl::OnDidZoomURL(double zoom_level, |