Chromium Code Reviews| 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/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_accessibility.h" | |
| 22 #include "content/browser/frame_host/frame_tree.h" | 23 #include "content/browser/frame_host/frame_tree.h" |
| 23 #include "content/browser/frame_host/frame_tree_node.h" | 24 #include "content/browser/frame_host/frame_tree_node.h" |
| 24 #include "content/browser/frame_host/navigator.h" | 25 #include "content/browser/frame_host/navigator.h" |
| 25 #include "content/browser/frame_host/render_frame_host_delegate.h" | 26 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 26 #include "content/browser/frame_host/render_frame_proxy_host.h" | 27 #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/frame_host/render_widget_host_view_child_frame.h" |
| 28 #include "content/browser/renderer_host/input/input_router.h" | 29 #include "content/browser/renderer_host/input/input_router.h" |
| 29 #include "content/browser/renderer_host/input/timeout_monitor.h" | 30 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 30 #include "content/browser/renderer_host/render_process_host_impl.h" | 31 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 31 #include "content/browser/renderer_host/render_view_host_delegate.h" | 32 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 32 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 33 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 33 #include "content/browser/renderer_host/render_view_host_impl.h" | 34 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 34 #include "content/browser/renderer_host/render_widget_host_impl.h" | 35 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 35 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 36 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 36 #include "content/browser/transition_request_manager.h" | 37 #include "content/browser/transition_request_manager.h" |
| 37 #include "content/common/accessibility_messages.h" | 38 #include "content/common/accessibility_messages.h" |
| 38 #include "content/common/desktop_notification_messages.h" | 39 #include "content/common/desktop_notification_messages.h" |
| 39 #include "content/common/frame_messages.h" | 40 #include "content/common/frame_messages.h" |
| 40 #include "content/common/input_messages.h" | 41 #include "content/common/input_messages.h" |
| 41 #include "content/common/inter_process_time_ticks_converter.h" | 42 #include "content/common/inter_process_time_ticks_converter.h" |
| 42 #include "content/common/platform_notification_messages.h" | 43 #include "content/common/platform_notification_messages.h" |
| 43 #include "content/common/render_frame_setup.mojom.h" | 44 #include "content/common/render_frame_setup.mojom.h" |
| 44 #include "content/common/swapped_out_messages.h" | 45 #include "content/common/swapped_out_messages.h" |
| 45 #include "content/public/browser/ax_event_notification_details.h" | 46 #include "content/public/browser/ax_event_notification_details.h" |
| 46 #include "content/public/browser/browser_accessibility_state.h" | 47 #include "content/public/browser/browser_accessibility_state.h" |
| 48 #include "content/public/browser/browser_context.h" | |
| 49 #include "content/public/browser/browser_plugin_guest_manager.h" | |
| 47 #include "content/public/browser/browser_thread.h" | 50 #include "content/public/browser/browser_thread.h" |
| 48 #include "content/public/browser/content_browser_client.h" | 51 #include "content/public/browser/content_browser_client.h" |
| 49 #include "content/public/browser/desktop_notification_delegate.h" | 52 #include "content/public/browser/desktop_notification_delegate.h" |
| 50 #include "content/public/browser/render_process_host.h" | 53 #include "content/public/browser/render_process_host.h" |
| 51 #include "content/public/browser/render_widget_host_view.h" | 54 #include "content/public/browser/render_widget_host_view.h" |
| 52 #include "content/public/browser/user_metrics.h" | 55 #include "content/public/browser/user_metrics.h" |
| 53 #include "content/public/common/content_constants.h" | 56 #include "content/public/common/content_constants.h" |
| 54 #include "content/public/common/content_switches.h" | 57 #include "content/public/common/content_switches.h" |
| 55 #include "content/public/common/url_constants.h" | 58 #include "content/public/common/url_constants.h" |
| 56 #include "content/public/common/url_utils.h" | 59 #include "content/public/common/url_utils.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 GetProcess()->RemoveRoute(routing_id_); | 204 GetProcess()->RemoveRoute(routing_id_); |
| 202 g_routing_id_frame_map.Get().erase( | 205 g_routing_id_frame_map.Get().erase( |
| 203 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 206 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
| 204 | 207 |
| 205 if (delegate_) | 208 if (delegate_) |
| 206 delegate_->RenderFrameDeleted(this); | 209 delegate_->RenderFrameDeleted(this); |
| 207 | 210 |
| 208 // Notify the FrameTree that this RFH is going away, allowing it to shut down | 211 // Notify the FrameTree that this RFH is going away, allowing it to shut down |
| 209 // the corresponding RenderViewHost if it is no longer needed. | 212 // the corresponding RenderViewHost if it is no longer needed. |
| 210 frame_tree_->UnregisterRenderFrameHost(this); | 213 frame_tree_->UnregisterRenderFrameHost(this); |
| 214 | |
| 215 FrameAccessibility::GetInstance()->OnRenderFrameHostDestroyed(this); | |
|
Charlie Reis
2014/09/11 21:46:21
This is a bit more related to the delegate notific
dmazzoni
2014/09/12 07:34:34
Done.
| |
| 211 } | 216 } |
| 212 | 217 |
| 213 int RenderFrameHostImpl::GetRoutingID() { | 218 int RenderFrameHostImpl::GetRoutingID() { |
| 214 return routing_id_; | 219 return routing_id_; |
| 215 } | 220 } |
| 216 | 221 |
| 217 SiteInstance* RenderFrameHostImpl::GetSiteInstance() { | 222 SiteInstance* RenderFrameHostImpl::GetSiteInstance() { |
| 218 return render_view_host_->GetSiteInstance(); | 223 return render_view_host_->GetSiteInstance(); |
| 219 } | 224 } |
| 220 | 225 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 gfx::NativeViewAccessible | 473 gfx::NativeViewAccessible |
| 469 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { | 474 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { |
| 470 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 475 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
| 471 render_view_host_->GetView()); | 476 render_view_host_->GetView()); |
| 472 if (view) | 477 if (view) |
| 473 return view->AccessibilityGetNativeViewAccessible(); | 478 return view->AccessibilityGetNativeViewAccessible(); |
| 474 return NULL; | 479 return NULL; |
| 475 } | 480 } |
| 476 | 481 |
| 477 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( | 482 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( |
| 478 int64 frame_tree_node_id) { | 483 int accessibility_node_id) { |
| 479 FrameTreeNode* child_node = FrameTree::GloballyFindByID(frame_tree_node_id); | 484 RenderFrameHostImpl* child_frame = |
| 480 if (!child_node) | 485 FrameAccessibility::GetInstance()->GetChild(this, accessibility_node_id); |
| 486 if (!child_frame) | |
| 481 return NULL; | 487 return NULL; |
| 482 | 488 |
| 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 // Return NULL if this isn't an out-of-process iframe. Same-process iframes |
| 489 // are already part of the accessibility tree. | 490 // are already part of the accessibility tree. |
| 490 if (child_rfhi->GetProcess()->GetID() == GetProcess()->GetID()) | 491 if (child_frame->GetProcess()->GetID() == GetProcess()->GetID()) |
| 491 return NULL; | 492 return NULL; |
| 492 | 493 |
| 493 return child_rfhi->GetOrCreateBrowserAccessibilityManager(); | 494 return child_frame->GetOrCreateBrowserAccessibilityManager(); |
| 494 } | 495 } |
| 495 | 496 |
| 496 BrowserAccessibilityManager* | 497 BrowserAccessibility* RenderFrameHostImpl::AccessibilityGetParentFrame() { |
| 497 RenderFrameHostImpl::AccessibilityGetParentFrame() { | 498 RenderFrameHostImpl* parent_frame = NULL; |
| 498 FrameTreeNode* parent_node = frame_tree_node()->parent(); | 499 int parent_node_id = 0; |
| 499 if (!parent_node) | 500 if (!FrameAccessibility::GetInstance()->GetParent( |
| 501 this, &parent_frame, &parent_node_id)) { | |
| 502 return NULL; | |
| 503 } | |
| 504 | |
| 505 BrowserAccessibilityManager* manager = | |
| 506 parent_frame->browser_accessibility_manager(); | |
| 507 if (!manager) | |
| 500 return NULL; | 508 return NULL; |
| 501 | 509 |
| 502 RenderFrameHostImpl* parent_frame = parent_node->current_frame_host(); | 510 return manager->GetFromID(parent_node_id); |
| 503 if (!parent_frame) | |
| 504 return NULL; | |
| 505 | |
| 506 return parent_frame->GetOrCreateBrowserAccessibilityManager(); | |
| 507 } | 511 } |
| 508 | 512 |
| 509 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { | 513 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { |
| 510 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); | 514 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); |
| 511 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 515 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
| 512 | 516 |
| 513 // The process may (if we're sharing a process with another host that already | 517 // 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 | 518 // 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 | 519 // crashed) have been initialized. Calling Init multiple times will be |
| 516 // ignored, so this is safe. | 520 // ignored, so this is safe. |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 1031 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
| 1028 if ((accessibility_mode != AccessibilityModeOff) && view && | 1032 if ((accessibility_mode != AccessibilityModeOff) && view && |
| 1029 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { | 1033 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { |
| 1030 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 1034 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
| 1031 GetOrCreateBrowserAccessibilityManager(); | 1035 GetOrCreateBrowserAccessibilityManager(); |
| 1032 if (browser_accessibility_manager_) | 1036 if (browser_accessibility_manager_) |
| 1033 browser_accessibility_manager_->OnAccessibilityEvents(params); | 1037 browser_accessibility_manager_->OnAccessibilityEvents(params); |
| 1034 } | 1038 } |
| 1035 | 1039 |
| 1036 if (browser_accessibility_manager_) { | 1040 if (browser_accessibility_manager_) { |
| 1037 // Get the frame routing ids from out-of-process iframes and use them | 1041 // Get the frame routing ids from out-of-process iframes and |
| 1038 // to notify our BrowserAccessibilityManager of the frame tree node id of | 1042 // browser plugin instance ids from guests and update the mappings in |
| 1039 // any of its child frames. | 1043 // FrameAccessibility. |
| 1040 for (unsigned int i = 0; i < params.size(); ++i) { | 1044 for (unsigned int i = 0; i < params.size(); ++i) { |
| 1041 const AccessibilityHostMsg_EventParams& param = params[i]; | 1045 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 1042 std::map<int32, int>::const_iterator iter; | 1046 std::map<int32, int>::const_iterator iter; |
| 1043 for (iter = param.node_to_frame_routing_id_map.begin(); | 1047 for (iter = param.node_to_frame_routing_id_map.begin(); |
| 1044 iter != param.node_to_frame_routing_id_map.end(); | 1048 iter != param.node_to_frame_routing_id_map.end(); |
| 1045 ++iter) { | 1049 ++iter) { |
| 1046 // This is the id of the accessibility node that has a child frame. | 1050 // This is the id of the accessibility node that has a child frame. |
| 1047 int32 node_id = iter->first; | 1051 int32 node_id = iter->first; |
| 1048 // The routing id from either a RenderFrame or a RenderFrameProxy. | 1052 // The routing id from either a RenderFrame or a RenderFrameProxy. |
| 1049 int frame_routing_id = iter->second; | 1053 int frame_routing_id = iter->second; |
| 1050 | 1054 |
| 1051 FrameTree* frame_tree = frame_tree_node()->frame_tree(); | 1055 FrameTree* frame_tree = frame_tree_node()->frame_tree(); |
| 1052 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID( | 1056 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID( |
| 1053 GetProcess()->GetID(), frame_routing_id); | 1057 GetProcess()->GetID(), frame_routing_id); |
| 1054 if (child_frame_tree_node) { | 1058 if (child_frame_tree_node) { |
| 1055 browser_accessibility_manager_->SetChildFrameTreeNodeId( | 1059 FrameAccessibility::GetInstance()->AddChildFrame( |
| 1056 node_id, child_frame_tree_node->frame_tree_node_id()); | 1060 this, node_id, child_frame_tree_node->frame_tree_node_id()); |
| 1057 } | 1061 } |
| 1058 } | 1062 } |
| 1063 | |
| 1064 for (iter = param.node_to_browser_plugin_instance_id_map.begin(); | |
| 1065 iter != param.node_to_browser_plugin_instance_id_map.end(); | |
| 1066 ++iter) { | |
| 1067 // This is the id of the accessibility node that hosts a plugin. | |
| 1068 int32 node_id = iter->first; | |
| 1069 // The id of the browser plugin. | |
| 1070 int browser_plugin_instance_id = iter->second; | |
| 1071 | |
| 1072 FrameAccessibility::GetInstance()->AddGuestWebContents( | |
| 1073 this, node_id, browser_plugin_instance_id); | |
| 1074 } | |
| 1059 } | 1075 } |
| 1060 } | 1076 } |
| 1061 | 1077 |
| 1062 // Send the updates to the automation extension API. | 1078 // Send the updates to the automation extension API. |
| 1063 std::vector<AXEventNotificationDetails> details; | 1079 std::vector<AXEventNotificationDetails> details; |
| 1064 details.reserve(params.size()); | 1080 details.reserve(params.size()); |
| 1065 for (size_t i = 0; i < params.size(); ++i) { | 1081 for (size_t i = 0; i < params.size(); ++i) { |
| 1066 const AccessibilityHostMsg_EventParams& param = params[i]; | 1082 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 1067 AXEventNotificationDetails detail(param.update.node_id_to_clear, | 1083 AXEventNotificationDetails detail(param.update.node_id_to_clear, |
| 1068 param.update.nodes, | 1084 param.update.nodes, |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1433 // Clear any state if a pending navigation is canceled or preempted. | 1449 // Clear any state if a pending navigation is canceled or preempted. |
| 1434 if (suspended_nav_params_) | 1450 if (suspended_nav_params_) |
| 1435 suspended_nav_params_.reset(); | 1451 suspended_nav_params_.reset(); |
| 1436 | 1452 |
| 1437 TRACE_EVENT_ASYNC_END0("navigation", | 1453 TRACE_EVENT_ASYNC_END0("navigation", |
| 1438 "RenderFrameHostImpl navigation suspended", this); | 1454 "RenderFrameHostImpl navigation suspended", this); |
| 1439 navigations_suspended_ = false; | 1455 navigations_suspended_ = false; |
| 1440 } | 1456 } |
| 1441 | 1457 |
| 1442 } // namespace content | 1458 } // namespace content |
| OLD | NEW |