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

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: Fix compile error 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/debug/crash_logging.h" 10 #include "base/debug/crash_logging.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/metrics/user_metrics_action.h" 13 #include "base/metrics/user_metrics_action.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "content/browser/accessibility/accessibility_mode_helper.h" 16 #include "content/browser/accessibility/accessibility_mode_helper.h"
17 #include "content/browser/accessibility/browser_accessibility_manager.h" 17 #include "content/browser/accessibility/browser_accessibility_manager.h"
18 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 18 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
19 #include "content/browser/child_process_security_policy_impl.h" 19 #include "content/browser/child_process_security_policy_impl.h"
20 #include "content/browser/frame_host/cross_process_frame_connector.h" 20 #include "content/browser/frame_host/cross_process_frame_connector.h"
21 #include "content/browser/frame_host/cross_site_transferring_request.h" 21 #include "content/browser/frame_host/cross_site_transferring_request.h"
22 #include "content/browser/frame_host/frame_tree.h" 22 #include "content/browser/frame_host/frame_tree.h"
23 #include "content/browser/frame_host/frame_tree_node.h" 23 #include "content/browser/frame_host/frame_tree_node.h"
24 #include "content/browser/frame_host/navigator.h" 24 #include "content/browser/frame_host/navigator.h"
25 #include "content/browser/frame_host/render_frame_host_delegate.h" 25 #include "content/browser/frame_host/render_frame_host_delegate.h"
26 #include "content/browser/frame_host/render_frame_proxy_host.h" 26 #include "content/browser/frame_host/render_frame_proxy_host.h"
27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
27 #include "content/browser/renderer_host/input/input_router.h" 28 #include "content/browser/renderer_host/input/input_router.h"
28 #include "content/browser/renderer_host/input/timeout_monitor.h" 29 #include "content/browser/renderer_host/input/timeout_monitor.h"
29 #include "content/browser/renderer_host/render_process_host_impl.h" 30 #include "content/browser/renderer_host/render_process_host_impl.h"
30 #include "content/browser/renderer_host/render_view_host_delegate.h" 31 #include "content/browser/renderer_host/render_view_host_delegate.h"
31 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 32 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
32 #include "content/browser/renderer_host/render_view_host_impl.h" 33 #include "content/browser/renderer_host/render_view_host_impl.h"
33 #include "content/browser/renderer_host/render_widget_host_impl.h" 34 #include "content/browser/renderer_host/render_widget_host_impl.h"
34 #include "content/browser/renderer_host/render_widget_host_view_base.h" 35 #include "content/browser/renderer_host/render_widget_host_view_base.h"
35 #include "content/browser/transition_request_manager.h" 36 #include "content/browser/transition_request_manager.h"
36 #include "content/common/accessibility_messages.h" 37 #include "content/common/accessibility_messages.h"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 467
467 gfx::NativeViewAccessible 468 gfx::NativeViewAccessible
468 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { 469 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() {
469 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 470 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
470 render_view_host_->GetView()); 471 render_view_host_->GetView());
471 if (view) 472 if (view)
472 return view->AccessibilityGetNativeViewAccessible(); 473 return view->AccessibilityGetNativeViewAccessible();
473 return NULL; 474 return NULL;
474 } 475 }
475 476
477 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame(
478 int64 frame_tree_node_id) {
479 FrameTreeNode* child_node = FrameTree::GloballyFindByID(frame_tree_node_id);
480 if (!child_node)
481 return NULL;
482
483 // We should have gotten a node in the same frame tree.
484 CHECK(child_node->frame_tree() == frame_tree_node()->frame_tree());
485
486 RenderFrameHostImpl* child_rfhi = child_node->current_frame_host();
487
488 // Return NULL if this isn't an out-of-process iframe. Same-process iframes
489 // are already part of the accessibility tree.
490 if (child_rfhi->GetProcess()->GetID() == GetProcess()->GetID())
491 return NULL;
492
493 return child_rfhi->GetOrCreateBrowserAccessibilityManager();
494 }
495
496 BrowserAccessibilityManager*
497 RenderFrameHostImpl::AccessibilityGetParentFrame() {
498 FrameTreeNode* parent_node = frame_tree_node()->parent();
499 if (!parent_node)
500 return NULL;
501
502 RenderFrameHostImpl* parent_frame = parent_node->current_frame_host();
503 if (!parent_frame)
504 return NULL;
505
506 return parent_frame->GetOrCreateBrowserAccessibilityManager();
507 }
508
476 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { 509 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) {
477 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); 510 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame");
478 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; 511 DCHECK(!IsRenderFrameLive()) << "Creating frame twice";
479 512
480 // The process may (if we're sharing a process with another host that already 513 // The process may (if we're sharing a process with another host that already
481 // initialized it) or may not (we have our own process or the old process 514 // initialized it) or may not (we have our own process or the old process
482 // crashed) have been initialized. Calling Init multiple times will be 515 // crashed) have been initialized. Calling Init multiple times will be
483 // ignored, so this is safe. 516 // ignored, so this is safe.
484 if (!GetProcess()->Init()) 517 if (!GetProcess()->Init())
485 return false; 518 return false;
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 1026
994 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); 1027 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
995 if ((accessibility_mode != AccessibilityModeOff) && view && 1028 if ((accessibility_mode != AccessibilityModeOff) && view &&
996 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { 1029 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
997 if (accessibility_mode & AccessibilityModeFlagPlatform) { 1030 if (accessibility_mode & AccessibilityModeFlagPlatform) {
998 GetOrCreateBrowserAccessibilityManager(); 1031 GetOrCreateBrowserAccessibilityManager();
999 if (browser_accessibility_manager_) 1032 if (browser_accessibility_manager_)
1000 browser_accessibility_manager_->OnAccessibilityEvents(params); 1033 browser_accessibility_manager_->OnAccessibilityEvents(params);
1001 } 1034 }
1002 1035
1036 if (browser_accessibility_manager_) {
1037 // Get the frame routing ids from out-of-process iframes and use them
1038 // to notify our BrowserAccessibilityManager of the frame tree node id of
1039 // any of its child frames.
1040 for (unsigned int i = 0; i < params.size(); ++i) {
1041 const AccessibilityHostMsg_EventParams& param = params[i];
1042 std::map<int32, int>::const_iterator iter;
1043 for (iter = param.node_to_frame_routing_id_map.begin();
1044 iter != param.node_to_frame_routing_id_map.end();
1045 ++iter) {
1046 // This is the id of the accessibility node that has a child frame.
1047 int32 node_id = iter->first;
1048 // The routing id from either a RenderFrame or a RenderFrameProxy.
1049 int frame_routing_id = iter->second;
1050
1051 FrameTree* frame_tree = frame_tree_node()->frame_tree();
1052 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID(
1053 GetProcess()->GetID(), frame_routing_id);
1054 if (child_frame_tree_node) {
1055 browser_accessibility_manager_->SetChildFrameTreeNodeId(
1056 node_id, child_frame_tree_node->frame_tree_node_id());
1057 }
1058 }
1059 }
1060 }
1061
1062 // Send the updates to the automation extension API.
1003 std::vector<AXEventNotificationDetails> details; 1063 std::vector<AXEventNotificationDetails> details;
1004 details.reserve(params.size()); 1064 details.reserve(params.size());
1005 for (size_t i = 0; i < params.size(); ++i) { 1065 for (size_t i = 0; i < params.size(); ++i) {
1006 const AccessibilityHostMsg_EventParams& param = params[i]; 1066 const AccessibilityHostMsg_EventParams& param = params[i];
1007 AXEventNotificationDetails detail(param.update.node_id_to_clear, 1067 AXEventNotificationDetails detail(param.update.node_id_to_clear,
1008 param.update.nodes, 1068 param.update.nodes,
1009 param.event_type, 1069 param.event_type,
1010 param.id, 1070 param.id,
1011 GetProcess()->GetID(), 1071 GetProcess()->GetID(),
1012 routing_id_); 1072 routing_id_);
1013 details.push_back(detail); 1073 details.push_back(detail);
1014 } 1074 }
1015 1075
1016 delegate_->AccessibilityEventReceived(details); 1076 delegate_->AccessibilityEventReceived(details);
1017 } 1077 }
1018 1078
1019 // Always send an ACK or the renderer can be in a bad state. 1079 // Always send an ACK or the renderer can be in a bad state.
1020 Send(new AccessibilityMsg_Events_ACK(routing_id_)); 1080 Send(new AccessibilityMsg_Events_ACK(routing_id_));
1021 1081
1022 // The rest of this code is just for testing; bail out if we're not 1082 // The rest of this code is just for testing; bail out if we're not
1023 // in that mode. 1083 // in that mode.
1024 if (accessibility_testing_callback_.is_null()) 1084 if (accessibility_testing_callback_.is_null())
1025 return; 1085 return;
1026 1086
1027 for (size_t i = 0; i < params.size(); i++) { 1087 for (size_t i = 0; i < params.size(); i++) {
1028 const AccessibilityHostMsg_EventParams& param = params[i]; 1088 const AccessibilityHostMsg_EventParams& param = params[i];
1029 if (static_cast<int>(param.event_type) < 0) 1089 if (static_cast<int>(param.event_type) < 0)
1030 continue; 1090 continue;
1091
1031 if (!ax_tree_for_testing_) { 1092 if (!ax_tree_for_testing_) {
1032 ax_tree_for_testing_.reset(new ui::AXTree(param.update)); 1093 if (browser_accessibility_manager_) {
1094 ax_tree_for_testing_.reset(new ui::AXTree(
1095 browser_accessibility_manager_->SnapshotAXTreeForTesting()));
1096 } else {
1097 ax_tree_for_testing_.reset(new ui::AXTree());
1098 CHECK(ax_tree_for_testing_->Unserialize(param.update))
1099 << ax_tree_for_testing_->error();
1100 }
1033 } else { 1101 } else {
1034 CHECK(ax_tree_for_testing_->Unserialize(param.update)) 1102 CHECK(ax_tree_for_testing_->Unserialize(param.update))
1035 << ax_tree_for_testing_->error(); 1103 << ax_tree_for_testing_->error();
1036 } 1104 }
1037 accessibility_testing_callback_.Run(param.event_type, param.id); 1105 accessibility_testing_callback_.Run(param.event_type, param.id);
1038 } 1106 }
1039 } 1107 }
1040 1108
1041 void RenderFrameHostImpl::OnAccessibilityLocationChanges( 1109 void RenderFrameHostImpl::OnAccessibilityLocationChanges(
1042 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 1110 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 // Clear any state if a pending navigation is canceled or preempted. 1433 // Clear any state if a pending navigation is canceled or preempted.
1366 if (suspended_nav_params_) 1434 if (suspended_nav_params_)
1367 suspended_nav_params_.reset(); 1435 suspended_nav_params_.reset();
1368 1436
1369 TRACE_EVENT_ASYNC_END0("navigation", 1437 TRACE_EVENT_ASYNC_END0("navigation",
1370 "RenderFrameHostImpl navigation suspended", this); 1438 "RenderFrameHostImpl navigation suspended", this);
1371 navigations_suspended_ = false; 1439 navigations_suspended_ = false;
1372 } 1440 }
1373 1441
1374 } // namespace content 1442 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_proxy_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698