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_impl.h" | 29 #include "content/browser/renderer_host/render_view_host_impl.h" |
29 #include "content/browser/renderer_host/render_widget_host_impl.h" | 30 #include "content/browser/renderer_host/render_widget_host_impl.h" |
30 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 31 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
31 #include "content/browser/transition_request_manager.h" | 32 #include "content/browser/transition_request_manager.h" |
32 #include "content/common/accessibility_messages.h" | 33 #include "content/common/accessibility_messages.h" |
33 #include "content/common/desktop_notification_messages.h" | 34 #include "content/common/desktop_notification_messages.h" |
34 #include "content/common/frame_messages.h" | 35 #include "content/common/frame_messages.h" |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 | 447 |
447 gfx::NativeViewAccessible | 448 gfx::NativeViewAccessible |
448 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { | 449 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { |
449 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 450 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
450 render_view_host_->GetView()); | 451 render_view_host_->GetView()); |
451 if (view) | 452 if (view) |
452 return view->AccessibilityGetNativeViewAccessible(); | 453 return view->AccessibilityGetNativeViewAccessible(); |
453 return NULL; | 454 return NULL; |
454 } | 455 } |
455 | 456 |
457 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( | |
458 int64 frame_tree_node_id) { | |
459 FrameTree* frame_tree = frame_tree_node()->frame_tree(); | |
460 FrameTreeNode* node = frame_tree->FindByID(frame_tree_node_id); | |
461 if (!node) | |
462 return NULL; | |
463 | |
464 RenderFrameHostImpl* render_frame_host = node->current_frame_host(); | |
Charlie Reis
2014/08/21 19:23:27
Should we be concerned if a process swap occurs in
dmazzoni
2014/08/25 06:49:36
We're using this safely; when BrowserAccessibility
| |
465 return render_frame_host->GetOrCreateBrowserAccessibilityManager(); | |
466 } | |
467 | |
468 BrowserAccessibilityManager* | |
469 RenderFrameHostImpl::AccessibilityGetParentFrame() { | |
470 FrameTreeNode* parent_node = frame_tree_node()->parent(); | |
471 if (!parent_node) | |
472 return NULL; | |
473 | |
474 RenderFrameHostImpl* parent_frame = parent_node->current_frame_host(); | |
475 if (!parent_frame) | |
476 return NULL; | |
477 | |
478 return parent_frame->GetOrCreateBrowserAccessibilityManager(); | |
479 } | |
480 | |
456 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { | 481 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { |
457 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); | 482 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); |
458 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 483 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
459 | 484 |
460 // The process may (if we're sharing a process with another host that already | 485 // The process may (if we're sharing a process with another host that already |
461 // initialized it) or may not (we have our own process or the old process | 486 // initialized it) or may not (we have our own process or the old process |
462 // crashed) have been initialized. Calling Init multiple times will be | 487 // crashed) have been initialized. Calling Init multiple times will be |
463 // ignored, so this is safe. | 488 // ignored, so this is safe. |
464 if (!GetProcess()->Init()) | 489 if (!GetProcess()->Init()) |
465 return false; | 490 return false; |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
934 | 959 |
935 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 960 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
936 if ((accessibility_mode != AccessibilityModeOff) && view && | 961 if ((accessibility_mode != AccessibilityModeOff) && view && |
937 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { | 962 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { |
938 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 963 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
939 GetOrCreateBrowserAccessibilityManager(); | 964 GetOrCreateBrowserAccessibilityManager(); |
940 if (browser_accessibility_manager_) | 965 if (browser_accessibility_manager_) |
941 browser_accessibility_manager_->OnAccessibilityEvents(params); | 966 browser_accessibility_manager_->OnAccessibilityEvents(params); |
942 } | 967 } |
943 | 968 |
969 // Get the frame routing ids from out-of-process iframes and use them | |
970 // to notify out BrowserAccessibilityManager of the frame tree node id of | |
Charlie Reis
2014/08/21 19:23:27
nit: out -> our?
dmazzoni
2014/08/25 06:49:36
Done.
| |
971 // any of its child frames. | |
972 std::map<int32, int>::const_iterator iter; | |
Charlie Reis
2014/08/21 19:23:27
Can we add a comment about this map being from nod
dmazzoni
2014/08/25 06:49:36
Done. I think it should allow RenderFrameProxy IDs
| |
973 for (unsigned int i = 0; i < params.size(); ++i) { | |
974 const AccessibilityHostMsg_EventParams& param = params[i]; | |
975 for (iter = param.frame_routing_ids.begin(); | |
976 iter != param.frame_routing_ids.end(); | |
977 ++iter) { | |
978 int32 node_id = iter->first; | |
979 int frame_routing_id = iter->second; | |
980 | |
981 RenderFrameHostImpl* child = RenderFrameHostImpl::FromID( | |
982 GetProcess()->GetID(), frame_routing_id); | |
Charlie Reis
2014/08/21 19:23:27
How does this work for iframes that are already ou
dmazzoni
2014/08/25 06:49:36
Agreed, this should handle RenderFrameProxyHosts t
| |
983 if (browser_accessibility_manager_) { | |
984 browser_accessibility_manager_->SetChildFrameId( | |
985 node_id, child->frame_tree_node()->frame_tree_node_id()); | |
986 } | |
987 } | |
988 } | |
989 | |
990 // Send the updates to the automation extension API. | |
944 std::vector<AXEventNotificationDetails> details; | 991 std::vector<AXEventNotificationDetails> details; |
945 details.reserve(params.size()); | 992 details.reserve(params.size()); |
946 for (size_t i = 0; i < params.size(); ++i) { | 993 for (size_t i = 0; i < params.size(); ++i) { |
947 const AccessibilityHostMsg_EventParams& param = params[i]; | 994 const AccessibilityHostMsg_EventParams& param = params[i]; |
948 AXEventNotificationDetails detail(param.update.node_id_to_clear, | 995 AXEventNotificationDetails detail(param.update.node_id_to_clear, |
949 param.update.nodes, | 996 param.update.nodes, |
950 param.event_type, | 997 param.event_type, |
951 param.id, | 998 param.id, |
952 GetProcess()->GetID(), | 999 GetProcess()->GetID(), |
953 routing_id_); | 1000 routing_id_); |
954 details.push_back(detail); | 1001 details.push_back(detail); |
955 } | 1002 } |
956 | 1003 |
957 delegate_->AccessibilityEventReceived(details); | 1004 delegate_->AccessibilityEventReceived(details); |
958 } | 1005 } |
959 | 1006 |
960 // Always send an ACK or the renderer can be in a bad state. | 1007 // Always send an ACK or the renderer can be in a bad state. |
961 Send(new AccessibilityMsg_Events_ACK(routing_id_)); | 1008 Send(new AccessibilityMsg_Events_ACK(routing_id_)); |
962 | 1009 |
963 // The rest of this code is just for testing; bail out if we're not | 1010 // The rest of this code is just for testing; bail out if we're not |
964 // in that mode. | 1011 // in that mode. |
965 if (accessibility_testing_callback_.is_null()) | 1012 if (accessibility_testing_callback_.is_null()) |
966 return; | 1013 return; |
967 | 1014 |
968 for (size_t i = 0; i < params.size(); i++) { | 1015 for (size_t i = 0; i < params.size(); i++) { |
969 const AccessibilityHostMsg_EventParams& param = params[i]; | 1016 const AccessibilityHostMsg_EventParams& param = params[i]; |
970 if (static_cast<int>(param.event_type) < 0) | 1017 if (static_cast<int>(param.event_type) < 0) |
971 continue; | 1018 continue; |
1019 | |
972 if (!ax_tree_for_testing_) { | 1020 if (!ax_tree_for_testing_) { |
973 ax_tree_for_testing_.reset(new ui::AXTree(param.update)); | 1021 if (browser_accessibility_manager_) { |
1022 ax_tree_for_testing_.reset(new ui::AXTree( | |
1023 browser_accessibility_manager_->SnapshotAXTreeForTesting())); | |
1024 } else { | |
1025 ax_tree_for_testing_.reset(new ui::AXTree()); | |
1026 CHECK(ax_tree_for_testing_->Unserialize(param.update)) | |
1027 << ax_tree_for_testing_->error(); | |
1028 } | |
974 } else { | 1029 } else { |
975 CHECK(ax_tree_for_testing_->Unserialize(param.update)) | 1030 CHECK(ax_tree_for_testing_->Unserialize(param.update)) |
976 << ax_tree_for_testing_->error(); | 1031 << ax_tree_for_testing_->error(); |
977 } | 1032 } |
978 accessibility_testing_callback_.Run(param.event_type, param.id); | 1033 accessibility_testing_callback_.Run(param.event_type, param.id); |
979 } | 1034 } |
980 } | 1035 } |
981 | 1036 |
982 void RenderFrameHostImpl::OnAccessibilityLocationChanges( | 1037 void RenderFrameHostImpl::OnAccessibilityLocationChanges( |
983 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 1038 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1236 } | 1291 } |
1237 | 1292 |
1238 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1293 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
1239 // Clear any state if a pending navigation is canceled or preempted. | 1294 // Clear any state if a pending navigation is canceled or preempted. |
1240 if (suspended_nav_params_) | 1295 if (suspended_nav_params_) |
1241 suspended_nav_params_.reset(); | 1296 suspended_nav_params_.reset(); |
1242 navigations_suspended_ = false; | 1297 navigations_suspended_ = false; |
1243 } | 1298 } |
1244 | 1299 |
1245 } // namespace content | 1300 } // namespace content |
OLD | NEW |