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_accessibility.h" | |
20 #include "content/browser/frame_host/frame_tree.h" | 21 #include "content/browser/frame_host/frame_tree.h" |
21 #include "content/browser/frame_host/frame_tree_node.h" | 22 #include "content/browser/frame_host/frame_tree_node.h" |
22 #include "content/browser/frame_host/navigator.h" | 23 #include "content/browser/frame_host/navigator.h" |
23 #include "content/browser/frame_host/render_frame_host_delegate.h" | 24 #include "content/browser/frame_host/render_frame_host_delegate.h" |
24 #include "content/browser/frame_host/render_frame_proxy_host.h" | 25 #include "content/browser/frame_host/render_frame_proxy_host.h" |
25 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 26 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
26 #include "content/browser/renderer_host/input/input_router.h" | 27 #include "content/browser/renderer_host/input/input_router.h" |
27 #include "content/browser/renderer_host/input/timeout_monitor.h" | 28 #include "content/browser/renderer_host/input/timeout_monitor.h" |
28 #include "content/browser/renderer_host/render_process_host_impl.h" | 29 #include "content/browser/renderer_host/render_process_host_impl.h" |
29 #include "content/browser/renderer_host/render_view_host_delegate.h" | 30 #include "content/browser/renderer_host/render_view_host_delegate.h" |
30 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 31 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
31 #include "content/browser/renderer_host/render_view_host_impl.h" | 32 #include "content/browser/renderer_host/render_view_host_impl.h" |
32 #include "content/browser/renderer_host/render_widget_host_impl.h" | 33 #include "content/browser/renderer_host/render_widget_host_impl.h" |
33 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 34 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
34 #include "content/browser/transition_request_manager.h" | 35 #include "content/browser/transition_request_manager.h" |
35 #include "content/common/accessibility_messages.h" | 36 #include "content/common/accessibility_messages.h" |
36 #include "content/common/desktop_notification_messages.h" | 37 #include "content/common/desktop_notification_messages.h" |
37 #include "content/common/frame_messages.h" | 38 #include "content/common/frame_messages.h" |
38 #include "content/common/input_messages.h" | 39 #include "content/common/input_messages.h" |
39 #include "content/common/inter_process_time_ticks_converter.h" | 40 #include "content/common/inter_process_time_ticks_converter.h" |
40 #include "content/common/platform_notification_messages.h" | 41 #include "content/common/platform_notification_messages.h" |
41 #include "content/common/render_frame_setup.mojom.h" | 42 #include "content/common/render_frame_setup.mojom.h" |
42 #include "content/common/swapped_out_messages.h" | 43 #include "content/common/swapped_out_messages.h" |
43 #include "content/public/browser/ax_event_notification_details.h" | 44 #include "content/public/browser/ax_event_notification_details.h" |
44 #include "content/public/browser/browser_accessibility_state.h" | 45 #include "content/public/browser/browser_accessibility_state.h" |
46 #include "content/public/browser/browser_context.h" | |
47 #include "content/public/browser/browser_plugin_guest_manager.h" | |
45 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
46 #include "content/public/browser/content_browser_client.h" | 49 #include "content/public/browser/content_browser_client.h" |
47 #include "content/public/browser/desktop_notification_delegate.h" | 50 #include "content/public/browser/desktop_notification_delegate.h" |
48 #include "content/public/browser/render_process_host.h" | 51 #include "content/public/browser/render_process_host.h" |
49 #include "content/public/browser/render_widget_host_view.h" | 52 #include "content/public/browser/render_widget_host_view.h" |
50 #include "content/public/browser/user_metrics.h" | 53 #include "content/public/browser/user_metrics.h" |
51 #include "content/public/common/content_constants.h" | 54 #include "content/public/common/content_constants.h" |
52 #include "content/public/common/content_switches.h" | 55 #include "content/public/common/content_switches.h" |
53 #include "content/public/common/url_constants.h" | 56 #include "content/public/common/url_constants.h" |
54 #include "content/public/common/url_utils.h" | 57 #include "content/public/common/url_utils.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 } | 199 } |
197 | 200 |
198 RenderFrameHostImpl::~RenderFrameHostImpl() { | 201 RenderFrameHostImpl::~RenderFrameHostImpl() { |
199 GetProcess()->RemoveRoute(routing_id_); | 202 GetProcess()->RemoveRoute(routing_id_); |
200 g_routing_id_frame_map.Get().erase( | 203 g_routing_id_frame_map.Get().erase( |
201 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 204 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
202 | 205 |
203 if (delegate_) | 206 if (delegate_) |
204 delegate_->RenderFrameDeleted(this); | 207 delegate_->RenderFrameDeleted(this); |
205 | 208 |
209 FrameAccessibility::GetInstance()->OnRenderFrameHostDestroyed(this); | |
210 | |
206 // 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 |
207 // the corresponding RenderViewHost if it is no longer needed. | 212 // the corresponding RenderViewHost if it is no longer needed. |
208 frame_tree_->UnregisterRenderFrameHost(this); | 213 frame_tree_->UnregisterRenderFrameHost(this); |
209 } | 214 } |
210 | 215 |
211 int RenderFrameHostImpl::GetRoutingID() { | 216 int RenderFrameHostImpl::GetRoutingID() { |
212 return routing_id_; | 217 return routing_id_; |
213 } | 218 } |
214 | 219 |
215 SiteInstance* RenderFrameHostImpl::GetSiteInstance() { | 220 SiteInstance* RenderFrameHostImpl::GetSiteInstance() { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 gfx::NativeViewAccessible | 471 gfx::NativeViewAccessible |
467 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { | 472 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { |
468 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 473 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
469 render_view_host_->GetView()); | 474 render_view_host_->GetView()); |
470 if (view) | 475 if (view) |
471 return view->AccessibilityGetNativeViewAccessible(); | 476 return view->AccessibilityGetNativeViewAccessible(); |
472 return NULL; | 477 return NULL; |
473 } | 478 } |
474 | 479 |
475 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( | 480 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( |
476 int64 frame_tree_node_id) { | 481 int accessibility_node_id) { |
477 FrameTreeNode* child_node = FrameTree::GloballyFindByID(frame_tree_node_id); | 482 RenderFrameHostImpl* child_frame = |
478 if (!child_node) | 483 FrameAccessibility::GetInstance()->GetChild(this, accessibility_node_id); |
484 if (!child_frame) | |
479 return NULL; | 485 return NULL; |
480 | 486 |
481 // We should have gotten a node in the same frame tree. | |
482 CHECK(child_node->frame_tree() == frame_tree_node()->frame_tree()); | |
483 | |
484 RenderFrameHostImpl* child_rfhi = child_node->current_frame_host(); | |
485 | |
486 // Return NULL if this isn't an out-of-process iframe. Same-process iframes | 487 // Return NULL if this isn't an out-of-process iframe. Same-process iframes |
487 // are already part of the accessibility tree. | 488 // are already part of the accessibility tree. |
488 if (child_rfhi->GetProcess()->GetID() == GetProcess()->GetID()) | 489 if (child_frame->GetProcess()->GetID() == GetProcess()->GetID()) |
489 return NULL; | 490 return NULL; |
490 | 491 |
491 return child_rfhi->GetOrCreateBrowserAccessibilityManager(); | 492 // As a sanity check, make sure the frame we're going to return belongs |
493 // to the same BrowserContext. | |
494 DCHECK_EQ(GetSiteInstance()->GetBrowserContext(), | |
495 child_frame->GetSiteInstance()->GetBrowserContext()); | |
496 if (GetSiteInstance()->GetBrowserContext() != | |
497 child_frame->GetSiteInstance()->GetBrowserContext()) { | |
498 return NULL; | |
Charlie Reis
2014/09/12 21:01:58
DCHECK -> NOTREACHED
(same below)
dmazzoni
2014/09/15 17:55:23
Done.
| |
499 } | |
500 | |
501 return child_frame->GetOrCreateBrowserAccessibilityManager(); | |
492 } | 502 } |
493 | 503 |
494 BrowserAccessibilityManager* | 504 BrowserAccessibility* RenderFrameHostImpl::AccessibilityGetParentFrame() { |
495 RenderFrameHostImpl::AccessibilityGetParentFrame() { | 505 RenderFrameHostImpl* parent_frame = NULL; |
496 FrameTreeNode* parent_node = frame_tree_node()->parent(); | 506 int parent_node_id = 0; |
497 if (!parent_node) | 507 if (!FrameAccessibility::GetInstance()->GetParent( |
508 this, &parent_frame, &parent_node_id)) { | |
509 return NULL; | |
510 } | |
511 | |
512 // As a sanity check, make sure the frame we're going to return belongs | |
513 // to the same BrowserContext. | |
514 DCHECK_EQ(GetSiteInstance()->GetBrowserContext(), | |
515 parent_frame->GetSiteInstance()->GetBrowserContext()); | |
516 if (GetSiteInstance()->GetBrowserContext() != | |
517 parent_frame->GetSiteInstance()->GetBrowserContext()) { | |
518 return NULL; | |
519 } | |
520 | |
521 BrowserAccessibilityManager* manager = | |
522 parent_frame->browser_accessibility_manager(); | |
523 if (!manager) | |
498 return NULL; | 524 return NULL; |
499 | 525 |
500 RenderFrameHostImpl* parent_frame = parent_node->current_frame_host(); | 526 return manager->GetFromID(parent_node_id); |
501 if (!parent_frame) | |
502 return NULL; | |
503 | |
504 return parent_frame->GetOrCreateBrowserAccessibilityManager(); | |
505 } | 527 } |
506 | 528 |
507 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { | 529 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { |
508 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); | 530 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); |
509 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 531 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
510 | 532 |
511 // The process may (if we're sharing a process with another host that already | 533 // The process may (if we're sharing a process with another host that already |
512 // initialized it) or may not (we have our own process or the old process | 534 // initialized it) or may not (we have our own process or the old process |
513 // crashed) have been initialized. Calling Init multiple times will be | 535 // crashed) have been initialized. Calling Init multiple times will be |
514 // ignored, so this is safe. | 536 // ignored, so this is safe. |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 1027 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
1006 if ((accessibility_mode != AccessibilityModeOff) && view && | 1028 if ((accessibility_mode != AccessibilityModeOff) && view && |
1007 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { | 1029 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { |
1008 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 1030 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
1009 GetOrCreateBrowserAccessibilityManager(); | 1031 GetOrCreateBrowserAccessibilityManager(); |
1010 if (browser_accessibility_manager_) | 1032 if (browser_accessibility_manager_) |
1011 browser_accessibility_manager_->OnAccessibilityEvents(params); | 1033 browser_accessibility_manager_->OnAccessibilityEvents(params); |
1012 } | 1034 } |
1013 | 1035 |
1014 if (browser_accessibility_manager_) { | 1036 if (browser_accessibility_manager_) { |
1015 // Get the frame routing ids from out-of-process iframes and use them | 1037 // Get the frame routing ids from out-of-process iframes and |
1016 // to notify our BrowserAccessibilityManager of the frame tree node id of | 1038 // browser plugin instance ids from guests and update the mappings in |
1017 // any of its child frames. | 1039 // FrameAccessibility. |
1018 for (unsigned int i = 0; i < params.size(); ++i) { | 1040 for (unsigned int i = 0; i < params.size(); ++i) { |
1019 const AccessibilityHostMsg_EventParams& param = params[i]; | 1041 const AccessibilityHostMsg_EventParams& param = params[i]; |
1020 std::map<int32, int>::const_iterator iter; | 1042 std::map<int32, int>::const_iterator iter; |
1021 for (iter = param.node_to_frame_routing_id_map.begin(); | 1043 for (iter = param.node_to_frame_routing_id_map.begin(); |
1022 iter != param.node_to_frame_routing_id_map.end(); | 1044 iter != param.node_to_frame_routing_id_map.end(); |
1023 ++iter) { | 1045 ++iter) { |
1024 // This is the id of the accessibility node that has a child frame. | 1046 // This is the id of the accessibility node that has a child frame. |
1025 int32 node_id = iter->first; | 1047 int32 node_id = iter->first; |
1026 // The routing id from either a RenderFrame or a RenderFrameProxy. | 1048 // The routing id from either a RenderFrame or a RenderFrameProxy. |
1027 int frame_routing_id = iter->second; | 1049 int frame_routing_id = iter->second; |
1028 | 1050 |
1029 FrameTree* frame_tree = frame_tree_node()->frame_tree(); | 1051 FrameTree* frame_tree = frame_tree_node()->frame_tree(); |
1030 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID( | 1052 FrameTreeNode* child_frame_tree_node = frame_tree->FindByRoutingID( |
1031 GetProcess()->GetID(), frame_routing_id); | 1053 GetProcess()->GetID(), frame_routing_id); |
1032 if (child_frame_tree_node) { | 1054 if (child_frame_tree_node) { |
1033 browser_accessibility_manager_->SetChildFrameTreeNodeId( | 1055 FrameAccessibility::GetInstance()->AddChildFrame( |
1034 node_id, child_frame_tree_node->frame_tree_node_id()); | 1056 this, node_id, child_frame_tree_node->frame_tree_node_id()); |
1035 } | 1057 } |
1036 } | 1058 } |
1059 | |
1060 for (iter = param.node_to_browser_plugin_instance_id_map.begin(); | |
nasko
2014/09/12 20:43:26
Can one message contain both a browser plugin and
dmazzoni
2014/09/15 17:55:23
Yes - one message can contain a whole DOM tree, wh
| |
1061 iter != param.node_to_browser_plugin_instance_id_map.end(); | |
1062 ++iter) { | |
1063 // This is the id of the accessibility node that hosts a plugin. | |
1064 int32 node_id = iter->first; | |
1065 // The id of the browser plugin. | |
1066 int browser_plugin_instance_id = iter->second; | |
1067 | |
1068 FrameAccessibility::GetInstance()->AddGuestWebContents( | |
1069 this, node_id, browser_plugin_instance_id); | |
1070 } | |
1037 } | 1071 } |
1038 } | 1072 } |
1039 | 1073 |
1040 // Send the updates to the automation extension API. | 1074 // Send the updates to the automation extension API. |
1041 std::vector<AXEventNotificationDetails> details; | 1075 std::vector<AXEventNotificationDetails> details; |
1042 details.reserve(params.size()); | 1076 details.reserve(params.size()); |
1043 for (size_t i = 0; i < params.size(); ++i) { | 1077 for (size_t i = 0; i < params.size(); ++i) { |
1044 const AccessibilityHostMsg_EventParams& param = params[i]; | 1078 const AccessibilityHostMsg_EventParams& param = params[i]; |
1045 AXEventNotificationDetails detail(param.update.node_id_to_clear, | 1079 AXEventNotificationDetails detail(param.update.node_id_to_clear, |
1046 param.update.nodes, | 1080 param.update.nodes, |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1411 // Clear any state if a pending navigation is canceled or preempted. | 1445 // Clear any state if a pending navigation is canceled or preempted. |
1412 if (suspended_nav_params_) | 1446 if (suspended_nav_params_) |
1413 suspended_nav_params_.reset(); | 1447 suspended_nav_params_.reset(); |
1414 | 1448 |
1415 TRACE_EVENT_ASYNC_END0("navigation", | 1449 TRACE_EVENT_ASYNC_END0("navigation", |
1416 "RenderFrameHostImpl navigation suspended", this); | 1450 "RenderFrameHostImpl navigation suspended", this); |
1417 navigations_suspended_ = false; | 1451 navigations_suspended_ = false; |
1418 } | 1452 } |
1419 | 1453 |
1420 } // namespace content | 1454 } // namespace content |
OLD | NEW |