Chromium Code Reviews| 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 113661648f47c297310b2eaa34e026c11805e771..3c02297bf57a83edfe0184275808495b5f56ca4b 100644 |
| --- a/content/browser/renderer_host/render_view_host_impl.cc |
| +++ b/content/browser/renderer_host/render_view_host_impl.cc |
| @@ -24,10 +24,13 @@ |
| #include "base/values.h" |
| #include "cc/base/switches.h" |
| #include "content/browser/accessibility/browser_accessibility_manager.h" |
| +#include "content/browser/accessibility/frame_tree_accessibility.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" |
| +#include "content/browser/frame_host/cross_process_frame_connector.h" |
| #include "content/browser/frame_host/frame_tree.h" |
| +#include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| #include "content/browser/gpu/compositor_util.h" |
| #include "content/browser/gpu/gpu_data_manager_impl.h" |
| #include "content/browser/gpu/gpu_process_host.h" |
| @@ -242,6 +245,8 @@ RenderViewHostImpl::RenderViewHostImpl( |
| unload_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( |
| &RenderViewHostImpl::OnSwappedOut, weak_factory_.GetWeakPtr(), true))); |
| + |
| + FrameTreeAccessibility::GetInstance()->OnFrameCreated(this); |
| } |
| RenderViewHostImpl::~RenderViewHostImpl() { |
| @@ -263,6 +268,8 @@ RenderViewHostImpl::~RenderViewHostImpl() { |
| // count of the SiteInstance it belongs to. |
| if (IsRVHStateActive(rvh_state_)) |
| instance_->decrement_active_view_count(); |
| + |
| + FrameTreeAccessibility::GetInstance()->OnFrameDeleted(this); |
| } |
| RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { |
| @@ -1601,18 +1608,61 @@ void RenderViewHostImpl::NotifyMoveOrResizeStarted() { |
| Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); |
| } |
| +static int GetAccessibleFrameId(int process_id, int frame_routing_id) { |
| + RenderFrameHostImpl* render_frame_host = RenderFrameHostImpl::FromID( |
| + process_id, frame_routing_id); |
| + if (render_frame_host) { |
| + CrossProcessFrameConnector* connector = |
| + render_frame_host->cross_process_frame_connector(); |
| + if (connector) { |
| + RenderWidgetHostViewChildFrame* view = connector->view(); |
| + if (view) { |
| + RenderWidgetHostImpl* rwhi = |
| + RenderWidgetHostImpl::From(view->GetRenderWidgetHost()); |
| + return FrameTreeAccessibility::GetInstance()->GetFrameId(rwhi); |
| + } |
| + } |
| + } |
| + |
| + return 0; |
| +} |
| + |
| void RenderViewHostImpl::OnAccessibilityEvents( |
| const std::vector<AccessibilityHostMsg_EventParams>& params) { |
| + BrowserAccessibilityManager* manager = NULL; |
| if ((accessibility_mode() != AccessibilityModeOff) && view_ && |
| IsRVHStateActive(rvh_state_)) { |
| + // Send the updates to the BrowserAccessibilityManager to support |
| + // native accessibility APIs. |
| if (accessibility_mode() & AccessibilityModeFlagPlatform) { |
| view_->CreateBrowserAccessibilityManagerIfNeeded(); |
| - BrowserAccessibilityManager* manager = |
| - view_->GetBrowserAccessibilityManager(); |
| - if (manager) |
| + manager = view_->GetBrowserAccessibilityManager(); |
| + if (manager) { |
| manager->OnAccessibilityEvents(params); |
| + FrameTreeAccessibility::GetInstance()->SetFrameAccessibilityManager( |
| + this, manager); |
| + } |
| + } |
| + |
| + // Map from guest instance ids (for a <webview> plug-in) and |
| + // frame routing ids (from out-of-process iframes) to accessibility |
| + // frame ids. |
| + std::map<int32, int>::const_iterator iter; |
| + for (unsigned int i = 0; i < params.size(); ++i) { |
| + const AccessibilityHostMsg_EventParams& param = params[i]; |
| + for (iter = param.frame_routing_ids.begin(); |
| + iter != param.frame_routing_ids.end(); |
|
ncarter (slow)
2014/05/02 19:10:02
Nothing happens with param.guest_instance_ids here
|
| + ++iter) { |
| + int32 node_id = iter->first; |
| + int frame_routing_id = iter->second; |
| + int accessible_frame_id = GetAccessibleFrameId( |
| + GetProcess()->GetID(), frame_routing_id); |
| + if (manager && accessible_frame_id) |
| + manager->SetChildFrameId(node_id, accessible_frame_id); |
| + } |
| } |
| + // Send the updates to the automation extension API. |
| std::vector<AXEventNotificationDetails> details; |
| for (unsigned int i = 0; i < params.size(); ++i) { |
| const AccessibilityHostMsg_EventParams& param = params[i]; |
| @@ -1623,7 +1673,6 @@ void RenderViewHostImpl::OnAccessibilityEvents( |
| GetRoutingID()); |
| details.push_back(detail); |
| } |
| - |
| delegate_->AccessibilityEventReceived(details); |
| } |
| @@ -1639,10 +1688,16 @@ void RenderViewHostImpl::OnAccessibilityEvents( |
| 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 |
| + if (!ax_tree_) { |
| + if (manager) { |
| + ax_tree_.reset(new ui::AXTree(manager->SnapshotAXTreeForTesting())); |
|
ncarter (slow)
2014/05/02 19:10:02
What prevents this ForTesting() path from becoming
|
| + } else { |
| + ax_tree_.reset(new ui::AXTree()); |
| + CHECK(ax_tree_->Unserialize(param.update)) << ax_tree_->error(); |
| + } |
| + } else { |
| CHECK(ax_tree_->Unserialize(param.update)) << ax_tree_->error(); |
| + } |
| accessibility_testing_callback_.Run(param.event_type); |
| } |
| } |