| 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 FrameTreeNode* child_node = FrameTree::GloballyFindByID(frame_tree_node_id); |
| 470 if (!child_node) |
| 471 return NULL; |
| 472 |
| 473 // We should have gotten a node in the same frame tree. |
| 474 CHECK(child_node->frame_tree() == frame_tree_node()->frame_tree()); |
| 475 |
| 476 RenderFrameHostImpl* child_rfhi = child_node->current_frame_host(); |
| 477 return child_rfhi->GetOrCreateBrowserAccessibilityManager(); |
| 478 } |
| 479 |
| 480 BrowserAccessibilityManager* |
| 481 RenderFrameHostImpl::AccessibilityGetParentFrame() { |
| 482 FrameTreeNode* parent_node = frame_tree_node()->parent(); |
| 483 if (!parent_node) |
| 484 return NULL; |
| 485 |
| 486 RenderFrameHostImpl* parent_frame = parent_node->current_frame_host(); |
| 487 if (!parent_frame) |
| 488 return NULL; |
| 489 |
| 490 return parent_frame->GetOrCreateBrowserAccessibilityManager(); |
| 491 } |
| 492 |
| 466 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { | 493 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { |
| 467 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); | 494 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); |
| 468 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 495 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
| 469 | 496 |
| 470 // The process may (if we're sharing a process with another host that already | 497 // 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 | 498 // 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 | 499 // crashed) have been initialized. Calling Init multiple times will be |
| 473 // ignored, so this is safe. | 500 // ignored, so this is safe. |
| 474 if (!GetProcess()->Init()) | 501 if (!GetProcess()->Init()) |
| 475 return false; | 502 return false; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 | 971 |
| 945 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 972 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
| 946 if ((accessibility_mode != AccessibilityModeOff) && view && | 973 if ((accessibility_mode != AccessibilityModeOff) && view && |
| 947 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { | 974 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { |
| 948 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 975 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
| 949 GetOrCreateBrowserAccessibilityManager(); | 976 GetOrCreateBrowserAccessibilityManager(); |
| 950 if (browser_accessibility_manager_) | 977 if (browser_accessibility_manager_) |
| 951 browser_accessibility_manager_->OnAccessibilityEvents(params); | 978 browser_accessibility_manager_->OnAccessibilityEvents(params); |
| 952 } | 979 } |
| 953 | 980 |
| 981 if (browser_accessibility_manager_) { |
| 982 // Get the frame routing ids from out-of-process iframes and use them |
| 983 // to notify our BrowserAccessibilityManager of the frame tree node id of |
| 984 // any of its child frames. |
| 985 for (unsigned int i = 0; i < params.size(); ++i) { |
| 986 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 987 std::map<int32, int>::const_iterator iter; |
| 988 for (iter = param.node_to_frame_routing_id_map.begin(); |
| 989 iter != param.node_to_frame_routing_id_map.end(); |
| 990 ++iter) { |
| 991 // This is the id of the accessibility node that has a child frame. |
| 992 int32 node_id = iter->first; |
| 993 // The routing id from either a RenderFrame or a RenderFrameProxy. |
| 994 int frame_routing_id = iter->second; |
| 995 |
| 996 FrameTree* frame_tree = frame_tree_node()->frame_tree(); |
| 997 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID( |
| 998 GetProcess()->GetID(), frame_routing_id); |
| 999 if (child_frame_tree_node) { |
| 1000 browser_accessibility_manager_->SetChildFrameTreeNodeId( |
| 1001 node_id, child_frame_tree_node->frame_tree_node_id()); |
| 1002 } |
| 1003 } |
| 1004 } |
| 1005 } |
| 1006 |
| 1007 // Send the updates to the automation extension API. |
| 954 std::vector<AXEventNotificationDetails> details; | 1008 std::vector<AXEventNotificationDetails> details; |
| 955 details.reserve(params.size()); | 1009 details.reserve(params.size()); |
| 956 for (size_t i = 0; i < params.size(); ++i) { | 1010 for (size_t i = 0; i < params.size(); ++i) { |
| 957 const AccessibilityHostMsg_EventParams& param = params[i]; | 1011 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 958 AXEventNotificationDetails detail(param.update.node_id_to_clear, | 1012 AXEventNotificationDetails detail(param.update.node_id_to_clear, |
| 959 param.update.nodes, | 1013 param.update.nodes, |
| 960 param.event_type, | 1014 param.event_type, |
| 961 param.id, | 1015 param.id, |
| 962 GetProcess()->GetID(), | 1016 GetProcess()->GetID(), |
| 963 routing_id_); | 1017 routing_id_); |
| 964 details.push_back(detail); | 1018 details.push_back(detail); |
| 965 } | 1019 } |
| 966 | 1020 |
| 967 delegate_->AccessibilityEventReceived(details); | 1021 delegate_->AccessibilityEventReceived(details); |
| 968 } | 1022 } |
| 969 | 1023 |
| 970 // Always send an ACK or the renderer can be in a bad state. | 1024 // Always send an ACK or the renderer can be in a bad state. |
| 971 Send(new AccessibilityMsg_Events_ACK(routing_id_)); | 1025 Send(new AccessibilityMsg_Events_ACK(routing_id_)); |
| 972 | 1026 |
| 973 // The rest of this code is just for testing; bail out if we're not | 1027 // The rest of this code is just for testing; bail out if we're not |
| 974 // in that mode. | 1028 // in that mode. |
| 975 if (accessibility_testing_callback_.is_null()) | 1029 if (accessibility_testing_callback_.is_null()) |
| 976 return; | 1030 return; |
| 977 | 1031 |
| 978 for (size_t i = 0; i < params.size(); i++) { | 1032 for (size_t i = 0; i < params.size(); i++) { |
| 979 const AccessibilityHostMsg_EventParams& param = params[i]; | 1033 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 980 if (static_cast<int>(param.event_type) < 0) | 1034 if (static_cast<int>(param.event_type) < 0) |
| 981 continue; | 1035 continue; |
| 1036 |
| 982 if (!ax_tree_for_testing_) { | 1037 if (!ax_tree_for_testing_) { |
| 983 ax_tree_for_testing_.reset(new ui::AXTree(param.update)); | 1038 if (browser_accessibility_manager_) { |
| 1039 ax_tree_for_testing_.reset(new ui::AXTree( |
| 1040 browser_accessibility_manager_->SnapshotAXTreeForTesting())); |
| 1041 } else { |
| 1042 ax_tree_for_testing_.reset(new ui::AXTree()); |
| 1043 CHECK(ax_tree_for_testing_->Unserialize(param.update)) |
| 1044 << ax_tree_for_testing_->error(); |
| 1045 } |
| 984 } else { | 1046 } else { |
| 985 CHECK(ax_tree_for_testing_->Unserialize(param.update)) | 1047 CHECK(ax_tree_for_testing_->Unserialize(param.update)) |
| 986 << ax_tree_for_testing_->error(); | 1048 << ax_tree_for_testing_->error(); |
| 987 } | 1049 } |
| 988 accessibility_testing_callback_.Run(param.event_type, param.id); | 1050 accessibility_testing_callback_.Run(param.event_type, param.id); |
| 989 } | 1051 } |
| 990 } | 1052 } |
| 991 | 1053 |
| 992 void RenderFrameHostImpl::OnAccessibilityLocationChanges( | 1054 void RenderFrameHostImpl::OnAccessibilityLocationChanges( |
| 993 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 1055 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 } | 1365 } |
| 1304 | 1366 |
| 1305 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1367 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
| 1306 // Clear any state if a pending navigation is canceled or preempted. | 1368 // Clear any state if a pending navigation is canceled or preempted. |
| 1307 if (suspended_nav_params_) | 1369 if (suspended_nav_params_) |
| 1308 suspended_nav_params_.reset(); | 1370 suspended_nav_params_.reset(); |
| 1309 navigations_suspended_ = false; | 1371 navigations_suspended_ = false; |
| 1310 } | 1372 } |
| 1311 | 1373 |
| 1312 } // namespace content | 1374 } // namespace content |
| OLD | NEW |