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

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

Issue 558943002: Revert of Cross-process iframe accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
28 #include "content/browser/renderer_host/input/input_router.h" 27 #include "content/browser/renderer_host/input/input_router.h"
29 #include "content/browser/renderer_host/input/timeout_monitor.h" 28 #include "content/browser/renderer_host/input/timeout_monitor.h"
30 #include "content/browser/renderer_host/render_process_host_impl.h" 29 #include "content/browser/renderer_host/render_process_host_impl.h"
31 #include "content/browser/renderer_host/render_view_host_delegate.h" 30 #include "content/browser/renderer_host/render_view_host_delegate.h"
32 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 31 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
33 #include "content/browser/renderer_host/render_view_host_impl.h" 32 #include "content/browser/renderer_host/render_view_host_impl.h"
34 #include "content/browser/renderer_host/render_widget_host_impl.h" 33 #include "content/browser/renderer_host/render_widget_host_impl.h"
35 #include "content/browser/renderer_host/render_widget_host_view_base.h" 34 #include "content/browser/renderer_host/render_widget_host_view_base.h"
36 #include "content/browser/transition_request_manager.h" 35 #include "content/browser/transition_request_manager.h"
37 #include "content/common/accessibility_messages.h" 36 #include "content/common/accessibility_messages.h"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 466
468 gfx::NativeViewAccessible 467 gfx::NativeViewAccessible
469 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { 468 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() {
470 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 469 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
471 render_view_host_->GetView()); 470 render_view_host_->GetView());
472 if (view) 471 if (view)
473 return view->AccessibilityGetNativeViewAccessible(); 472 return view->AccessibilityGetNativeViewAccessible();
474 return NULL; 473 return NULL;
475 } 474 }
476 475
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
509 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { 476 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) {
510 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); 477 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame");
511 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; 478 DCHECK(!IsRenderFrameLive()) << "Creating frame twice";
512 479
513 // The process may (if we're sharing a process with another host that already 480 // The process may (if we're sharing a process with another host that already
514 // initialized it) or may not (we have our own process or the old process 481 // initialized it) or may not (we have our own process or the old process
515 // crashed) have been initialized. Calling Init multiple times will be 482 // crashed) have been initialized. Calling Init multiple times will be
516 // ignored, so this is safe. 483 // ignored, so this is safe.
517 if (!GetProcess()->Init()) 484 if (!GetProcess()->Init())
518 return false; 485 return false;
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 993
1027 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); 994 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
1028 if ((accessibility_mode != AccessibilityModeOff) && view && 995 if ((accessibility_mode != AccessibilityModeOff) && view &&
1029 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { 996 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
1030 if (accessibility_mode & AccessibilityModeFlagPlatform) { 997 if (accessibility_mode & AccessibilityModeFlagPlatform) {
1031 GetOrCreateBrowserAccessibilityManager(); 998 GetOrCreateBrowserAccessibilityManager();
1032 if (browser_accessibility_manager_) 999 if (browser_accessibility_manager_)
1033 browser_accessibility_manager_->OnAccessibilityEvents(params); 1000 browser_accessibility_manager_->OnAccessibilityEvents(params);
1034 } 1001 }
1035 1002
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.
1063 std::vector<AXEventNotificationDetails> details; 1003 std::vector<AXEventNotificationDetails> details;
1064 details.reserve(params.size()); 1004 details.reserve(params.size());
1065 for (size_t i = 0; i < params.size(); ++i) { 1005 for (size_t i = 0; i < params.size(); ++i) {
1066 const AccessibilityHostMsg_EventParams& param = params[i]; 1006 const AccessibilityHostMsg_EventParams& param = params[i];
1067 AXEventNotificationDetails detail(param.update.node_id_to_clear, 1007 AXEventNotificationDetails detail(param.update.node_id_to_clear,
1068 param.update.nodes, 1008 param.update.nodes,
1069 param.event_type, 1009 param.event_type,
1070 param.id, 1010 param.id,
1071 GetProcess()->GetID(), 1011 GetProcess()->GetID(),
1072 routing_id_); 1012 routing_id_);
1073 details.push_back(detail); 1013 details.push_back(detail);
1074 } 1014 }
1075 1015
1076 delegate_->AccessibilityEventReceived(details); 1016 delegate_->AccessibilityEventReceived(details);
1077 } 1017 }
1078 1018
1079 // Always send an ACK or the renderer can be in a bad state. 1019 // Always send an ACK or the renderer can be in a bad state.
1080 Send(new AccessibilityMsg_Events_ACK(routing_id_)); 1020 Send(new AccessibilityMsg_Events_ACK(routing_id_));
1081 1021
1082 // The rest of this code is just for testing; bail out if we're not 1022 // The rest of this code is just for testing; bail out if we're not
1083 // in that mode. 1023 // in that mode.
1084 if (accessibility_testing_callback_.is_null()) 1024 if (accessibility_testing_callback_.is_null())
1085 return; 1025 return;
1086 1026
1087 for (size_t i = 0; i < params.size(); i++) { 1027 for (size_t i = 0; i < params.size(); i++) {
1088 const AccessibilityHostMsg_EventParams& param = params[i]; 1028 const AccessibilityHostMsg_EventParams& param = params[i];
1089 if (static_cast<int>(param.event_type) < 0) 1029 if (static_cast<int>(param.event_type) < 0)
1090 continue; 1030 continue;
1091
1092 if (!ax_tree_for_testing_) { 1031 if (!ax_tree_for_testing_) {
1093 if (browser_accessibility_manager_) { 1032 ax_tree_for_testing_.reset(new ui::AXTree(param.update));
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 }
1101 } else { 1033 } else {
1102 CHECK(ax_tree_for_testing_->Unserialize(param.update)) 1034 CHECK(ax_tree_for_testing_->Unserialize(param.update))
1103 << ax_tree_for_testing_->error(); 1035 << ax_tree_for_testing_->error();
1104 } 1036 }
1105 accessibility_testing_callback_.Run(param.event_type, param.id); 1037 accessibility_testing_callback_.Run(param.event_type, param.id);
1106 } 1038 }
1107 } 1039 }
1108 1040
1109 void RenderFrameHostImpl::OnAccessibilityLocationChanges( 1041 void RenderFrameHostImpl::OnAccessibilityLocationChanges(
1110 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 1042 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 // Clear any state if a pending navigation is canceled or preempted. 1365 // Clear any state if a pending navigation is canceled or preempted.
1434 if (suspended_nav_params_) 1366 if (suspended_nav_params_)
1435 suspended_nav_params_.reset(); 1367 suspended_nav_params_.reset();
1436 1368
1437 TRACE_EVENT_ASYNC_END0("navigation", 1369 TRACE_EVENT_ASYNC_END0("navigation",
1438 "RenderFrameHostImpl navigation suspended", this); 1370 "RenderFrameHostImpl navigation suspended", this);
1439 navigations_suspended_ = false; 1371 navigations_suspended_ = false;
1440 } 1372 }
1441 1373
1442 } // namespace content 1374 } // 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