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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 268543008: Cross-process iframe accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/user_metrics_action.h" 12 #include "base/metrics/user_metrics_action.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "content/browser/accessibility/accessibility_mode_helper.h" 14 #include "content/browser/accessibility/accessibility_mode_helper.h"
15 #include "content/browser/accessibility/browser_accessibility_manager.h" 15 #include "content/browser/accessibility/browser_accessibility_manager.h"
16 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 16 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
17 #include "content/browser/child_process_security_policy_impl.h" 17 #include "content/browser/child_process_security_policy_impl.h"
18 #include "content/browser/frame_host/cross_process_frame_connector.h" 18 #include "content/browser/frame_host/cross_process_frame_connector.h"
19 #include "content/browser/frame_host/cross_site_transferring_request.h" 19 #include "content/browser/frame_host/cross_site_transferring_request.h"
20 #include "content/browser/frame_host/frame_tree.h" 20 #include "content/browser/frame_host/frame_tree.h"
21 #include "content/browser/frame_host/frame_tree_node.h" 21 #include "content/browser/frame_host/frame_tree_node.h"
22 #include "content/browser/frame_host/navigator.h" 22 #include "content/browser/frame_host/navigator.h"
23 #include "content/browser/frame_host/render_frame_host_delegate.h" 23 #include "content/browser/frame_host/render_frame_host_delegate.h"
24 #include "content/browser/frame_host/render_frame_proxy_host.h" 24 #include "content/browser/frame_host/render_frame_proxy_host.h"
25 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
25 #include "content/browser/renderer_host/input/input_router.h" 26 #include "content/browser/renderer_host/input/input_router.h"
26 #include "content/browser/renderer_host/input/timeout_monitor.h" 27 #include "content/browser/renderer_host/input/timeout_monitor.h"
27 #include "content/browser/renderer_host/render_process_host_impl.h" 28 #include "content/browser/renderer_host/render_process_host_impl.h"
28 #include "content/browser/renderer_host/render_view_host_impl.h" 29 #include "content/browser/renderer_host/render_view_host_impl.h"
29 #include "content/browser/renderer_host/render_widget_host_impl.h" 30 #include "content/browser/renderer_host/render_widget_host_impl.h"
30 #include "content/browser/renderer_host/render_widget_host_view_base.h" 31 #include "content/browser/renderer_host/render_widget_host_view_base.h"
31 #include "content/browser/transition_request_manager.h" 32 #include "content/browser/transition_request_manager.h"
32 #include "content/common/accessibility_messages.h" 33 #include "content/common/accessibility_messages.h"
33 #include "content/common/desktop_notification_messages.h" 34 #include "content/common/desktop_notification_messages.h"
34 #include "content/common/frame_messages.h" 35 #include "content/common/frame_messages.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 447
447 gfx::NativeViewAccessible 448 gfx::NativeViewAccessible
448 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { 449 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() {
449 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 450 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
450 render_view_host_->GetView()); 451 render_view_host_->GetView());
451 if (view) 452 if (view)
452 return view->AccessibilityGetNativeViewAccessible(); 453 return view->AccessibilityGetNativeViewAccessible();
453 return NULL; 454 return NULL;
454 } 455 }
455 456
457 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame(
458 int64 frame_tree_node_id) {
459 FrameTree* frame_tree = frame_tree_node()->frame_tree();
460 FrameTreeNode* node = frame_tree->FindByID(frame_tree_node_id);
461 if (!node)
462 return NULL;
463
464 RenderFrameHostImpl* render_frame_host = node->current_frame_host();
465 return render_frame_host->GetOrCreateBrowserAccessibilityManager();
466 }
467
468 BrowserAccessibilityManager*
469 RenderFrameHostImpl::AccessibilityGetParentFrame() {
470 FrameTreeNode* parent_node = frame_tree_node()->parent();
471 if (!parent_node)
472 return NULL;
473
474 RenderFrameHostImpl* parent_frame = parent_node->current_frame_host();
475 if (!parent_frame)
476 return NULL;
477
478 return parent_frame->GetOrCreateBrowserAccessibilityManager();
479 }
480
456 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { 481 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) {
457 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); 482 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame");
458 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; 483 DCHECK(!IsRenderFrameLive()) << "Creating frame twice";
459 484
460 // The process may (if we're sharing a process with another host that already 485 // The process may (if we're sharing a process with another host that already
461 // initialized it) or may not (we have our own process or the old process 486 // initialized it) or may not (we have our own process or the old process
462 // crashed) have been initialized. Calling Init multiple times will be 487 // crashed) have been initialized. Calling Init multiple times will be
463 // ignored, so this is safe. 488 // ignored, so this is safe.
464 if (!GetProcess()->Init()) 489 if (!GetProcess()->Init())
465 return false; 490 return false;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 959
935 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); 960 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
936 if ((accessibility_mode != AccessibilityModeOff) && view && 961 if ((accessibility_mode != AccessibilityModeOff) && view &&
937 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { 962 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
938 if (accessibility_mode & AccessibilityModeFlagPlatform) { 963 if (accessibility_mode & AccessibilityModeFlagPlatform) {
939 GetOrCreateBrowserAccessibilityManager(); 964 GetOrCreateBrowserAccessibilityManager();
940 if (browser_accessibility_manager_) 965 if (browser_accessibility_manager_)
941 browser_accessibility_manager_->OnAccessibilityEvents(params); 966 browser_accessibility_manager_->OnAccessibilityEvents(params);
942 } 967 }
943 968
969 if (browser_accessibility_manager_) {
970 // Get the frame routing ids from out-of-process iframes and use them
971 // to notify our BrowserAccessibilityManager of the frame tree node id of
972 // any of its child frames.
973 for (unsigned int i = 0; i < params.size(); ++i) {
974 const AccessibilityHostMsg_EventParams& param = params[i];
975 std::map<int32, int>::const_iterator iter;
976 for (iter = param.node_to_frame_routing_id_map.begin();
977 iter != param.node_to_frame_routing_id_map.end();
978 ++iter) {
979 // This is the id of the accessibility node that has a child frame.
980 int32 node_id = iter->first;
981 // The routing id from either a RenderFrame or a RenderFrameProxy.
982 int frame_routing_id = iter->second;
983
984 RenderFrameHostImpl* child = RenderFrameHostImpl::FromID(
985 GetProcess()->GetID(), frame_routing_id);
986 if (child) {
987 browser_accessibility_manager_->SetChildFrameTreeNodeId(
988 node_id, child->frame_tree_node()->frame_tree_node_id());
989 } else {
990 RenderFrameProxyHost* child = RenderFrameProxyHost::FromID(
Charlie Reis 2014/08/25 20:58:43 nit: Let's not shadow the previous |child|. |prox
dmazzoni 2014/08/26 23:31:03 Done.
991 GetProcess()->GetID(), frame_routing_id);
992 if (child) {
993 browser_accessibility_manager_->SetChildFrameTreeNodeId(
994 node_id, child->frame_tree_node()->frame_tree_node_id());
995 }
996 }
997 }
998 }
999 }
1000
1001 // Send the updates to the automation extension API.
944 std::vector<AXEventNotificationDetails> details; 1002 std::vector<AXEventNotificationDetails> details;
945 details.reserve(params.size()); 1003 details.reserve(params.size());
946 for (size_t i = 0; i < params.size(); ++i) { 1004 for (size_t i = 0; i < params.size(); ++i) {
947 const AccessibilityHostMsg_EventParams& param = params[i]; 1005 const AccessibilityHostMsg_EventParams& param = params[i];
948 AXEventNotificationDetails detail(param.update.node_id_to_clear, 1006 AXEventNotificationDetails detail(param.update.node_id_to_clear,
949 param.update.nodes, 1007 param.update.nodes,
950 param.event_type, 1008 param.event_type,
951 param.id, 1009 param.id,
952 GetProcess()->GetID(), 1010 GetProcess()->GetID(),
953 routing_id_); 1011 routing_id_);
954 details.push_back(detail); 1012 details.push_back(detail);
955 } 1013 }
956 1014
957 delegate_->AccessibilityEventReceived(details); 1015 delegate_->AccessibilityEventReceived(details);
958 } 1016 }
959 1017
960 // Always send an ACK or the renderer can be in a bad state. 1018 // Always send an ACK or the renderer can be in a bad state.
961 Send(new AccessibilityMsg_Events_ACK(routing_id_)); 1019 Send(new AccessibilityMsg_Events_ACK(routing_id_));
962 1020
963 // The rest of this code is just for testing; bail out if we're not 1021 // The rest of this code is just for testing; bail out if we're not
964 // in that mode. 1022 // in that mode.
965 if (accessibility_testing_callback_.is_null()) 1023 if (accessibility_testing_callback_.is_null())
966 return; 1024 return;
967 1025
968 for (size_t i = 0; i < params.size(); i++) { 1026 for (size_t i = 0; i < params.size(); i++) {
969 const AccessibilityHostMsg_EventParams& param = params[i]; 1027 const AccessibilityHostMsg_EventParams& param = params[i];
970 if (static_cast<int>(param.event_type) < 0) 1028 if (static_cast<int>(param.event_type) < 0)
971 continue; 1029 continue;
1030
972 if (!ax_tree_for_testing_) { 1031 if (!ax_tree_for_testing_) {
973 ax_tree_for_testing_.reset(new ui::AXTree(param.update)); 1032 if (browser_accessibility_manager_) {
1033 ax_tree_for_testing_.reset(new ui::AXTree(
1034 browser_accessibility_manager_->SnapshotAXTreeForTesting()));
1035 } else {
1036 ax_tree_for_testing_.reset(new ui::AXTree());
1037 CHECK(ax_tree_for_testing_->Unserialize(param.update))
1038 << ax_tree_for_testing_->error();
1039 }
974 } else { 1040 } else {
975 CHECK(ax_tree_for_testing_->Unserialize(param.update)) 1041 CHECK(ax_tree_for_testing_->Unserialize(param.update))
976 << ax_tree_for_testing_->error(); 1042 << ax_tree_for_testing_->error();
977 } 1043 }
978 accessibility_testing_callback_.Run(param.event_type, param.id); 1044 accessibility_testing_callback_.Run(param.event_type, param.id);
979 } 1045 }
980 } 1046 }
981 1047
982 void RenderFrameHostImpl::OnAccessibilityLocationChanges( 1048 void RenderFrameHostImpl::OnAccessibilityLocationChanges(
983 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 1049 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 } 1302 }
1237 1303
1238 void RenderFrameHostImpl::CancelSuspendedNavigations() { 1304 void RenderFrameHostImpl::CancelSuspendedNavigations() {
1239 // Clear any state if a pending navigation is canceled or preempted. 1305 // Clear any state if a pending navigation is canceled or preempted.
1240 if (suspended_nav_params_) 1306 if (suspended_nav_params_)
1241 suspended_nav_params_.reset(); 1307 suspended_nav_params_.reset();
1242 navigations_suspended_ = false; 1308 navigations_suspended_ = false;
1243 } 1309 }
1244 1310
1245 } // namespace content 1311 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698