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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 273423004: Migrate accessibility from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: content/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index f9e19e6cb70b888ff6a7c03f464086c824c1e4fb..111cb70b77cf0741d2907879cbab0bfe3c9dab0d 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -8,6 +8,9 @@
#include "base/containers/hash_tables.h"
#include "base/lazy_instance.h"
#include "base/metrics/user_metrics_action.h"
+#include "content/browser/accessibility/accessibility_mode_helper.h"
+#include "content/browser/accessibility/browser_accessibility_manager.h"
+#include "content/browser/accessibility/browser_accessibility_state_impl.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/frame_host/cross_process_frame_connector.h"
#include "content/browser/frame_host/cross_site_transferring_request.h"
@@ -18,11 +21,15 @@
#include "content/browser/renderer_host/input/input_router.h"
#include "content/browser/renderer_host/input/timeout_monitor.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/browser/renderer_host/render_widget_host_view_base.h"
+#include "content/common/accessibility_messages.h"
#include "content/common/desktop_notification_messages.h"
#include "content/common/frame_messages.h"
#include "content/common/input_messages.h"
#include "content/common/inter_process_time_ticks_converter.h"
#include "content/common/swapped_out_messages.h"
+#include "content/public/browser/ax_event_notification_details.h"
+#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/desktop_notification_delegate.h"
@@ -31,6 +38,7 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
+#include "ui/accessibility/ax_tree.h"
#include "url/gurl.h"
using base::TimeDelta;
@@ -137,12 +145,14 @@ RenderFrameHostImpl::RenderFrameHostImpl(
frame_tree_node_(frame_tree_node),
routing_id_(routing_id),
is_swapped_out_(is_swapped_out),
- weak_ptr_factory_(this) {
+ weak_ptr_factory_(this),
+ accessibility_mode_(AccessibilityModeOff) {
frame_tree_->RegisterRenderFrameHost(this);
GetProcess()->AddRoute(routing_id_, this);
g_routing_id_frame_map.Get().insert(std::make_pair(
RenderFrameHostID(GetProcess()->GetID(), routing_id_),
this));
+ SetAccessibilityMode(delegate->GetAccessibilityMode());
}
RenderFrameHostImpl::~RenderFrameHostImpl() {
@@ -299,6 +309,9 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
OnShowDesktopNotification)
IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
OnCancelDesktopNotification)
+ IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents)
+ IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges,
+ OnAccessibilityLocationChanges)
IPC_END_MESSAGE_MAP_EX()
if (!msg_is_ok) {
@@ -311,6 +324,74 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
return handled;
}
+void RenderFrameHostImpl::AccessibilitySetFocus(int object_id) {
+ Send(new AccessibilityMsg_SetFocus(GetRoutingID(), object_id));
nasko 2014/05/12 17:28:01 nit: The pattern in this class is to use routing_i
dmazzoni 2014/05/13 06:36:52 Done.
+ RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
+ render_view_host_->GetView());
+ if (view)
+ view->OnAccessibilitySetFocus(object_id);
+}
+
+void RenderFrameHostImpl::AccessibilityDoDefaultAction(int object_id) {
+ Send(new AccessibilityMsg_DoDefaultAction(GetRoutingID(), object_id));
+}
+
+void RenderFrameHostImpl::AccessibilityShowMenu(int object_id) {
+ RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
+ render_view_host_->GetView());
+ if (view)
+ view->AccessibilityShowMenu(object_id);
+}
+
+void RenderFrameHostImpl::AccessibilityScrollToMakeVisible(
+ int acc_obj_id, gfx::Rect subfocus) {
+ Send(new AccessibilityMsg_ScrollToMakeVisible(
+ GetRoutingID(), acc_obj_id, subfocus));
+}
+
+void RenderFrameHostImpl::AccessibilityScrollToPoint(
+ int acc_obj_id, gfx::Point point) {
+ Send(new AccessibilityMsg_ScrollToPoint(
+ GetRoutingID(), acc_obj_id, point));
+}
+
+void RenderFrameHostImpl::AccessibilitySetTextSelection(
+ int object_id, int start_offset, int end_offset) {
+ Send(new AccessibilityMsg_SetTextSelection(
+ GetRoutingID(), object_id, start_offset, end_offset));
+}
+
+bool RenderFrameHostImpl::AccessibilityViewHasFocus() const {
+ RenderWidgetHostView* view = render_view_host_->GetView();
+ if (view)
+ return view->HasFocus();
+ return false;
+}
+
+gfx::Rect RenderFrameHostImpl::AccessibilityGetViewBounds() const {
+ RenderWidgetHostView* view = render_view_host_->GetView();
+ if (view)
+ return view->GetViewBounds();
+ return gfx::Rect();
+}
+
+gfx::Point RenderFrameHostImpl::AccessibilityOriginInScreen(
+ const gfx::Rect& bounds) const {
+ RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
+ render_view_host_->GetView());
+ if (view)
+ return view->AccessibilityOriginInScreen(bounds);
+ return gfx::Point();
+}
+
+void RenderFrameHostImpl::AccessibilityFatalError() {
+ Send(new AccessibilityMsg_FatalError(GetRoutingID()));
+ RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
+ render_view_host_->GetView());
+ if (view)
+ view->SetBrowserAccessibilityManager(NULL);
+}
+
void RenderFrameHostImpl::Init() {
GetProcess()->ResumeRequestsForView(routing_id_);
}
@@ -695,6 +776,72 @@ void RenderFrameHostImpl::OnDidDisownOpener() {
delegate_->DidDisownOpener(this);
}
+void RenderFrameHostImpl::OnAccessibilityEvents(
+ const std::vector<AccessibilityHostMsg_EventParams>& params) {
+ RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
+ render_view_host_->GetView());
+
+ if ((accessibility_mode() != AccessibilityModeOff) && view &&
+ RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
+ if (accessibility_mode() & AccessibilityModeFlagPlatform) {
+ view->CreateBrowserAccessibilityManagerIfNeeded(this);
+ 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.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);
+ }
+}
+
+void RenderFrameHostImpl::OnAccessibilityLocationChanges(
+ const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
+ RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
+ render_view_host_->GetView());
+ if (view &&
+ RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
+ if (accessibility_mode() & AccessibilityModeFlagPlatform) {
+ view->CreateBrowserAccessibilityManagerIfNeeded(this);
+ BrowserAccessibilityManager* manager =
+ view->GetBrowserAccessibilityManager();
+ if (manager)
+ manager->OnLocationChanges(params);
+ }
+ // TODO(aboxhall): send location change events to web contents observers too
+ }
+}
+
void RenderFrameHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) {
render_view_host_->SetPendingShutdown(on_swap_out);
}
@@ -708,6 +855,12 @@ bool RenderFrameHostImpl::CanCommitURL(const GURL& url) {
return GetContentClient()->browser()->CanCommitURL(GetProcess(), url);
}
+void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone(
+ int callback_context) {
+ Send(new DesktopNotificationMsg_PermissionRequestDone(
+ routing_id_, callback_context));
+}
+
void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) {
TRACE_EVENT0("frame_host", "RenderFrameHostImpl::Navigate");
// Browser plugin guests are not allowed to navigate outside web-safe schemes,
@@ -855,10 +1008,32 @@ void RenderFrameHostImpl::NotificationClosed(int notification_id) {
cancel_notification_callbacks_.erase(notification_id);
}
-void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone(
- int callback_context) {
- Send(new DesktopNotificationMsg_PermissionRequestDone(
- routing_id_, callback_context));
+void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) {
+ accessibility_mode_ = mode;
+ Send(new FrameMsg_SetAccessibilityMode(GetRoutingID(), mode));
+}
+
+void RenderFrameHostImpl::SetAccessibilityCallbackForTesting(
+ const base::Callback<void(ui::AXEvent)>& callback) {
+ accessibility_testing_callback_ = callback;
+}
+
+const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() {
+ return ax_tree_.get();
+}
+
+#if defined(OS_WIN)
+void RenderFrameHostImpl::SetParentNativeViewAccessible(
+ gfx::NativeViewAccessible accessible_parent) {
+ RenderWidgetHostView* view = render_view_host_->GetView();
+ if (view)
+ view_->SetParentNativeViewAccessible(accessible_parent);
+}
+
+gfx::NativeViewAccessible
+RenderFrameHostImpl::GetParentNativeViewAccessible() const {
+ return delegate_->GetParentNativeViewAccessible();
}
+#endif
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698