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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 | 457 |
457 gfx::NativeViewAccessible | 458 gfx::NativeViewAccessible |
458 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { | 459 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { |
459 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 460 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
460 render_view_host_->GetView()); | 461 render_view_host_->GetView()); |
461 if (view) | 462 if (view) |
462 return view->AccessibilityGetNativeViewAccessible(); | 463 return view->AccessibilityGetNativeViewAccessible(); |
463 return NULL; | 464 return NULL; |
464 } | 465 } |
465 | 466 |
467 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( | |
468 int64 frame_tree_node_id) { | |
469 FrameTree* frame_tree = frame_tree_node()->frame_tree(); | |
470 FrameTreeNode* node = frame_tree->FindByID(frame_tree_node_id); | |
Charlie Reis
2014/08/27 17:28:34
This will probably do for now, but it would be nic
dmazzoni
2014/08/28 05:40:14
Oh, I never would have guessed that it wasn't stor
Charlie Reis
2014/08/28 18:18:51
We were adding tree accessors as they were needed,
| |
471 if (!node) | |
472 return NULL; | |
473 | |
474 RenderFrameHostImpl* render_frame_host = node->current_frame_host(); | |
475 return render_frame_host->GetOrCreateBrowserAccessibilityManager(); | |
476 } | |
477 | |
478 BrowserAccessibilityManager* | |
479 RenderFrameHostImpl::AccessibilityGetParentFrame() { | |
480 FrameTreeNode* parent_node = frame_tree_node()->parent(); | |
481 if (!parent_node) | |
482 return NULL; | |
483 | |
484 RenderFrameHostImpl* parent_frame = parent_node->current_frame_host(); | |
485 if (!parent_frame) | |
486 return NULL; | |
487 | |
488 return parent_frame->GetOrCreateBrowserAccessibilityManager(); | |
489 } | |
490 | |
466 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { | 491 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { |
467 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); | 492 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); |
468 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 493 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
469 | 494 |
470 // The process may (if we're sharing a process with another host that already | 495 // The process may (if we're sharing a process with another host that already |
471 // initialized it) or may not (we have our own process or the old process | 496 // initialized it) or may not (we have our own process or the old process |
472 // crashed) have been initialized. Calling Init multiple times will be | 497 // crashed) have been initialized. Calling Init multiple times will be |
473 // ignored, so this is safe. | 498 // ignored, so this is safe. |
474 if (!GetProcess()->Init()) | 499 if (!GetProcess()->Init()) |
475 return false; | 500 return false; |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
944 | 969 |
945 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 970 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
946 if ((accessibility_mode != AccessibilityModeOff) && view && | 971 if ((accessibility_mode != AccessibilityModeOff) && view && |
947 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { | 972 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { |
948 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 973 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
949 GetOrCreateBrowserAccessibilityManager(); | 974 GetOrCreateBrowserAccessibilityManager(); |
950 if (browser_accessibility_manager_) | 975 if (browser_accessibility_manager_) |
951 browser_accessibility_manager_->OnAccessibilityEvents(params); | 976 browser_accessibility_manager_->OnAccessibilityEvents(params); |
952 } | 977 } |
953 | 978 |
979 if (browser_accessibility_manager_) { | |
980 // Get the frame routing ids from out-of-process iframes and use them | |
981 // to notify our BrowserAccessibilityManager of the frame tree node id of | |
982 // any of its child frames. | |
983 for (unsigned int i = 0; i < params.size(); ++i) { | |
984 const AccessibilityHostMsg_EventParams& param = params[i]; | |
985 std::map<int32, int>::const_iterator iter; | |
986 for (iter = param.node_to_frame_routing_id_map.begin(); | |
987 iter != param.node_to_frame_routing_id_map.end(); | |
988 ++iter) { | |
989 // This is the id of the accessibility node that has a child frame. | |
990 int32 node_id = iter->first; | |
991 // The routing id from either a RenderFrame or a RenderFrameProxy. | |
992 int frame_routing_id = iter->second; | |
993 | |
994 RenderFrameHostImpl* child = RenderFrameHostImpl::FromID( | |
Charlie Reis
2014/08/27 17:28:35
Here's another block that FrameTree should be prov
dmazzoni
2014/08/28 05:40:14
Good idea! Is this what you had in mind?
Charlie Reis
2014/08/28 18:18:51
Perfect!
| |
995 GetProcess()->GetID(), frame_routing_id); | |
996 if (child) { | |
997 browser_accessibility_manager_->SetChildFrameTreeNodeId( | |
998 node_id, child->frame_tree_node()->frame_tree_node_id()); | |
999 } else { | |
1000 RenderFrameProxyHost* child_proxy = RenderFrameProxyHost::FromID( | |
1001 GetProcess()->GetID(), frame_routing_id); | |
1002 if (child_proxy) { | |
1003 browser_accessibility_manager_->SetChildFrameTreeNodeId( | |
1004 node_id, | |
1005 child_proxy->frame_tree_node()->frame_tree_node_id()); | |
1006 } | |
1007 } | |
1008 } | |
1009 } | |
1010 } | |
1011 | |
1012 // Send the updates to the automation extension API. | |
954 std::vector<AXEventNotificationDetails> details; | 1013 std::vector<AXEventNotificationDetails> details; |
955 details.reserve(params.size()); | 1014 details.reserve(params.size()); |
956 for (size_t i = 0; i < params.size(); ++i) { | 1015 for (size_t i = 0; i < params.size(); ++i) { |
957 const AccessibilityHostMsg_EventParams& param = params[i]; | 1016 const AccessibilityHostMsg_EventParams& param = params[i]; |
958 AXEventNotificationDetails detail(param.update.node_id_to_clear, | 1017 AXEventNotificationDetails detail(param.update.node_id_to_clear, |
959 param.update.nodes, | 1018 param.update.nodes, |
960 param.event_type, | 1019 param.event_type, |
961 param.id, | 1020 param.id, |
962 GetProcess()->GetID(), | 1021 GetProcess()->GetID(), |
963 routing_id_); | 1022 routing_id_); |
964 details.push_back(detail); | 1023 details.push_back(detail); |
965 } | 1024 } |
966 | 1025 |
967 delegate_->AccessibilityEventReceived(details); | 1026 delegate_->AccessibilityEventReceived(details); |
968 } | 1027 } |
969 | 1028 |
970 // Always send an ACK or the renderer can be in a bad state. | 1029 // Always send an ACK or the renderer can be in a bad state. |
971 Send(new AccessibilityMsg_Events_ACK(routing_id_)); | 1030 Send(new AccessibilityMsg_Events_ACK(routing_id_)); |
972 | 1031 |
973 // The rest of this code is just for testing; bail out if we're not | 1032 // The rest of this code is just for testing; bail out if we're not |
974 // in that mode. | 1033 // in that mode. |
975 if (accessibility_testing_callback_.is_null()) | 1034 if (accessibility_testing_callback_.is_null()) |
976 return; | 1035 return; |
977 | 1036 |
978 for (size_t i = 0; i < params.size(); i++) { | 1037 for (size_t i = 0; i < params.size(); i++) { |
979 const AccessibilityHostMsg_EventParams& param = params[i]; | 1038 const AccessibilityHostMsg_EventParams& param = params[i]; |
980 if (static_cast<int>(param.event_type) < 0) | 1039 if (static_cast<int>(param.event_type) < 0) |
981 continue; | 1040 continue; |
1041 | |
982 if (!ax_tree_for_testing_) { | 1042 if (!ax_tree_for_testing_) { |
983 ax_tree_for_testing_.reset(new ui::AXTree(param.update)); | 1043 if (browser_accessibility_manager_) { |
1044 ax_tree_for_testing_.reset(new ui::AXTree( | |
1045 browser_accessibility_manager_->SnapshotAXTreeForTesting())); | |
1046 } else { | |
1047 ax_tree_for_testing_.reset(new ui::AXTree()); | |
1048 CHECK(ax_tree_for_testing_->Unserialize(param.update)) | |
1049 << ax_tree_for_testing_->error(); | |
1050 } | |
984 } else { | 1051 } else { |
985 CHECK(ax_tree_for_testing_->Unserialize(param.update)) | 1052 CHECK(ax_tree_for_testing_->Unserialize(param.update)) |
986 << ax_tree_for_testing_->error(); | 1053 << ax_tree_for_testing_->error(); |
987 } | 1054 } |
988 accessibility_testing_callback_.Run(param.event_type, param.id); | 1055 accessibility_testing_callback_.Run(param.event_type, param.id); |
989 } | 1056 } |
990 } | 1057 } |
991 | 1058 |
992 void RenderFrameHostImpl::OnAccessibilityLocationChanges( | 1059 void RenderFrameHostImpl::OnAccessibilityLocationChanges( |
993 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 1060 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1303 } | 1370 } |
1304 | 1371 |
1305 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1372 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
1306 // Clear any state if a pending navigation is canceled or preempted. | 1373 // Clear any state if a pending navigation is canceled or preempted. |
1307 if (suspended_nav_params_) | 1374 if (suspended_nav_params_) |
1308 suspended_nav_params_.reset(); | 1375 suspended_nav_params_.reset(); |
1309 navigations_suspended_ = false; | 1376 navigations_suspended_ = false; |
1310 } | 1377 } |
1311 | 1378 |
1312 } // namespace content | 1379 } // namespace content |
OLD | NEW |