OLD | NEW |
---|---|
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_delegate.h" | 29 #include "content/browser/renderer_host/render_view_host_delegate.h" |
29 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 30 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
30 #include "content/browser/renderer_host/render_view_host_impl.h" | 31 #include "content/browser/renderer_host/render_view_host_impl.h" |
31 #include "content/browser/renderer_host/render_widget_host_impl.h" | 32 #include "content/browser/renderer_host/render_widget_host_impl.h" |
32 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 33 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
33 #include "content/browser/transition_request_manager.h" | 34 #include "content/browser/transition_request_manager.h" |
34 #include "content/common/accessibility_messages.h" | 35 #include "content/common/accessibility_messages.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 | 464 |
464 gfx::NativeViewAccessible | 465 gfx::NativeViewAccessible |
465 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { | 466 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { |
466 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 467 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
467 render_view_host_->GetView()); | 468 render_view_host_->GetView()); |
468 if (view) | 469 if (view) |
469 return view->AccessibilityGetNativeViewAccessible(); | 470 return view->AccessibilityGetNativeViewAccessible(); |
470 return NULL; | 471 return NULL; |
471 } | 472 } |
472 | 473 |
474 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( | |
475 int64 frame_tree_node_id) { | |
476 FrameTreeNode* child_node = FrameTree::GloballyFindByID(frame_tree_node_id); | |
477 if (!child_node) | |
478 return NULL; | |
479 | |
480 // We should have gotten a node in the same frame tree. | |
481 CHECK(child_node->frame_tree() == frame_tree_node()->frame_tree()); | |
482 | |
483 RenderFrameHostImpl* child_rfhi = child_node->current_frame_host(); | |
484 | |
485 // Return NULL if this isn't an out-of-process iframe. Same-process iframes | |
486 // are already part of the accessibility tree. | |
487 if (child_rfhi->GetProcess()->GetID() == GetProcess()->GetID()) | |
488 return NULL; | |
489 | |
490 return child_rfhi->GetOrCreateBrowserAccessibilityManager(); | |
491 } | |
492 | |
493 BrowserAccessibilityManager* | |
494 RenderFrameHostImpl::AccessibilityGetParentFrame() { | |
495 FrameTreeNode* parent_node = frame_tree_node()->parent(); | |
496 if (!parent_node) | |
497 return NULL; | |
498 | |
499 RenderFrameHostImpl* parent_frame = parent_node->current_frame_host(); | |
500 if (!parent_frame) | |
501 return NULL; | |
502 | |
503 return parent_frame->GetOrCreateBrowserAccessibilityManager(); | |
504 } | |
505 | |
473 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { | 506 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { |
474 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); | 507 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); |
475 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 508 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
476 | 509 |
477 // The process may (if we're sharing a process with another host that already | 510 // The process may (if we're sharing a process with another host that already |
478 // initialized it) or may not (we have our own process or the old process | 511 // initialized it) or may not (we have our own process or the old process |
479 // crashed) have been initialized. Calling Init multiple times will be | 512 // crashed) have been initialized. Calling Init multiple times will be |
480 // ignored, so this is safe. | 513 // ignored, so this is safe. |
481 if (!GetProcess()->Init()) | 514 if (!GetProcess()->Init()) |
482 return false; | 515 return false; |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
964 | 997 |
965 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 998 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
966 if ((accessibility_mode != AccessibilityModeOff) && view && | 999 if ((accessibility_mode != AccessibilityModeOff) && view && |
967 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { | 1000 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { |
968 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 1001 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
969 GetOrCreateBrowserAccessibilityManager(); | 1002 GetOrCreateBrowserAccessibilityManager(); |
970 if (browser_accessibility_manager_) | 1003 if (browser_accessibility_manager_) |
971 browser_accessibility_manager_->OnAccessibilityEvents(params); | 1004 browser_accessibility_manager_->OnAccessibilityEvents(params); |
972 } | 1005 } |
973 | 1006 |
1007 if (browser_accessibility_manager_) { | |
1008 // Get the frame routing ids from out-of-process iframes and use them | |
1009 // to notify our BrowserAccessibilityManager of the frame tree node id of | |
1010 // any of its child frames. | |
1011 for (unsigned int i = 0; i < params.size(); ++i) { | |
nasko
2014/09/05 16:29:02
Let's use size_t instead of unsigned int here.
| |
1012 const AccessibilityHostMsg_EventParams& param = params[i]; | |
1013 std::map<int32, int>::const_iterator iter; | |
1014 for (iter = param.node_to_frame_routing_id_map.begin(); | |
1015 iter != param.node_to_frame_routing_id_map.end(); | |
1016 ++iter) { | |
1017 // This is the id of the accessibility node that has a child frame. | |
1018 int32 node_id = iter->first; | |
1019 // The routing id from either a RenderFrame or a RenderFrameProxy. | |
1020 int frame_routing_id = iter->second; | |
1021 | |
1022 FrameTree* frame_tree = frame_tree_node()->frame_tree(); | |
1023 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID( | |
1024 GetProcess()->GetID(), frame_routing_id); | |
1025 if (child_frame_tree_node) { | |
1026 browser_accessibility_manager_->SetChildFrameTreeNodeId( | |
1027 node_id, child_frame_tree_node->frame_tree_node_id()); | |
1028 } | |
1029 } | |
1030 } | |
1031 } | |
1032 | |
1033 // Send the updates to the automation extension API. | |
974 std::vector<AXEventNotificationDetails> details; | 1034 std::vector<AXEventNotificationDetails> details; |
975 details.reserve(params.size()); | 1035 details.reserve(params.size()); |
976 for (size_t i = 0; i < params.size(); ++i) { | 1036 for (size_t i = 0; i < params.size(); ++i) { |
977 const AccessibilityHostMsg_EventParams& param = params[i]; | 1037 const AccessibilityHostMsg_EventParams& param = params[i]; |
978 AXEventNotificationDetails detail(param.update.node_id_to_clear, | 1038 AXEventNotificationDetails detail(param.update.node_id_to_clear, |
979 param.update.nodes, | 1039 param.update.nodes, |
980 param.event_type, | 1040 param.event_type, |
981 param.id, | 1041 param.id, |
982 GetProcess()->GetID(), | 1042 GetProcess()->GetID(), |
983 routing_id_); | 1043 routing_id_); |
984 details.push_back(detail); | 1044 details.push_back(detail); |
985 } | 1045 } |
986 | 1046 |
987 delegate_->AccessibilityEventReceived(details); | 1047 delegate_->AccessibilityEventReceived(details); |
988 } | 1048 } |
989 | 1049 |
990 // Always send an ACK or the renderer can be in a bad state. | 1050 // Always send an ACK or the renderer can be in a bad state. |
991 Send(new AccessibilityMsg_Events_ACK(routing_id_)); | 1051 Send(new AccessibilityMsg_Events_ACK(routing_id_)); |
992 | 1052 |
993 // The rest of this code is just for testing; bail out if we're not | 1053 // The rest of this code is just for testing; bail out if we're not |
994 // in that mode. | 1054 // in that mode. |
995 if (accessibility_testing_callback_.is_null()) | 1055 if (accessibility_testing_callback_.is_null()) |
996 return; | 1056 return; |
997 | 1057 |
998 for (size_t i = 0; i < params.size(); i++) { | 1058 for (size_t i = 0; i < params.size(); i++) { |
999 const AccessibilityHostMsg_EventParams& param = params[i]; | 1059 const AccessibilityHostMsg_EventParams& param = params[i]; |
1000 if (static_cast<int>(param.event_type) < 0) | 1060 if (static_cast<int>(param.event_type) < 0) |
1001 continue; | 1061 continue; |
1062 | |
1002 if (!ax_tree_for_testing_) { | 1063 if (!ax_tree_for_testing_) { |
1003 ax_tree_for_testing_.reset(new ui::AXTree(param.update)); | 1064 if (browser_accessibility_manager_) { |
1065 ax_tree_for_testing_.reset(new ui::AXTree( | |
1066 browser_accessibility_manager_->SnapshotAXTreeForTesting())); | |
1067 } else { | |
1068 ax_tree_for_testing_.reset(new ui::AXTree()); | |
1069 CHECK(ax_tree_for_testing_->Unserialize(param.update)) | |
1070 << ax_tree_for_testing_->error(); | |
1071 } | |
1004 } else { | 1072 } else { |
1005 CHECK(ax_tree_for_testing_->Unserialize(param.update)) | 1073 CHECK(ax_tree_for_testing_->Unserialize(param.update)) |
1006 << ax_tree_for_testing_->error(); | 1074 << ax_tree_for_testing_->error(); |
1007 } | 1075 } |
1008 accessibility_testing_callback_.Run(param.event_type, param.id); | 1076 accessibility_testing_callback_.Run(param.event_type, param.id); |
1009 } | 1077 } |
1010 } | 1078 } |
1011 | 1079 |
1012 void RenderFrameHostImpl::OnAccessibilityLocationChanges( | 1080 void RenderFrameHostImpl::OnAccessibilityLocationChanges( |
1013 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 1081 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 // Clear any state if a pending navigation is canceled or preempted. | 1404 // Clear any state if a pending navigation is canceled or preempted. |
1337 if (suspended_nav_params_) | 1405 if (suspended_nav_params_) |
1338 suspended_nav_params_.reset(); | 1406 suspended_nav_params_.reset(); |
1339 | 1407 |
1340 TRACE_EVENT_ASYNC_END0("navigation", | 1408 TRACE_EVENT_ASYNC_END0("navigation", |
1341 "RenderFrameHostImpl navigation suspended", this); | 1409 "RenderFrameHostImpl navigation suspended", this); |
1342 navigations_suspended_ = false; | 1410 navigations_suspended_ = false; |
1343 } | 1411 } |
1344 | 1412 |
1345 } // namespace content | 1413 } // namespace content |
OLD | NEW |