| 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" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #if defined(OS_MACOSX) | 61 #if defined(OS_MACOSX) |
| 62 #include "content/browser/frame_host/popup_menu_helper_mac.h" | 62 #include "content/browser/frame_host/popup_menu_helper_mac.h" |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 using base::TimeDelta; | 65 using base::TimeDelta; |
| 66 | 66 |
| 67 namespace content { | 67 namespace content { |
| 68 | 68 |
| 69 namespace { | 69 namespace { |
| 70 | 70 |
| 71 // The next value to use for the accessibility reset token. | |
| 72 int g_next_accessibility_reset_token = 1; | |
| 73 | |
| 74 // The (process id, routing id) pair that identifies one RenderFrame. | 71 // The (process id, routing id) pair that identifies one RenderFrame. |
| 75 typedef std::pair<int32, int32> RenderFrameHostID; | 72 typedef std::pair<int32, int32> RenderFrameHostID; |
| 76 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> | 73 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> |
| 77 RoutingIDFrameMap; | 74 RoutingIDFrameMap; |
| 78 base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = | 75 base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = |
| 79 LAZY_INSTANCE_INITIALIZER; | 76 LAZY_INSTANCE_INITIALIZER; |
| 80 | 77 |
| 81 class DesktopNotificationDelegateImpl : public DesktopNotificationDelegate { | 78 class DesktopNotificationDelegateImpl : public DesktopNotificationDelegate { |
| 82 public: | 79 public: |
| 83 DesktopNotificationDelegateImpl(RenderFrameHost* render_frame_host, | 80 DesktopNotificationDelegateImpl(RenderFrameHost* render_frame_host, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 delegate_(delegate), | 180 delegate_(delegate), |
| 184 cross_process_frame_connector_(NULL), | 181 cross_process_frame_connector_(NULL), |
| 185 render_frame_proxy_host_(NULL), | 182 render_frame_proxy_host_(NULL), |
| 186 frame_tree_(frame_tree), | 183 frame_tree_(frame_tree), |
| 187 frame_tree_node_(frame_tree_node), | 184 frame_tree_node_(frame_tree_node), |
| 188 routing_id_(routing_id), | 185 routing_id_(routing_id), |
| 189 render_frame_created_(false), | 186 render_frame_created_(false), |
| 190 navigations_suspended_(false), | 187 navigations_suspended_(false), |
| 191 is_waiting_for_beforeunload_ack_(false), | 188 is_waiting_for_beforeunload_ack_(false), |
| 192 unload_ack_is_for_cross_site_transition_(false), | 189 unload_ack_is_for_cross_site_transition_(false), |
| 193 accessibility_reset_token_(0), | |
| 194 accessibility_reset_count_(0), | |
| 195 disallow_browser_accessibility_manager_for_testing_(false), | |
| 196 weak_ptr_factory_(this) { | 190 weak_ptr_factory_(this) { |
| 197 frame_tree_->RegisterRenderFrameHost(this); | 191 frame_tree_->RegisterRenderFrameHost(this); |
| 198 GetProcess()->AddRoute(routing_id_, this); | 192 GetProcess()->AddRoute(routing_id_, this); |
| 199 g_routing_id_frame_map.Get().insert(std::make_pair( | 193 g_routing_id_frame_map.Get().insert(std::make_pair( |
| 200 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 194 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
| 201 this)); | 195 this)); |
| 202 | 196 |
| 203 if (is_swapped_out) { | 197 if (is_swapped_out) { |
| 204 rfh_state_ = STATE_SWAPPED_OUT; | 198 rfh_state_ = STATE_SWAPPED_OUT; |
| 205 } else { | 199 } else { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 if (view) | 466 if (view) |
| 473 return view->AccessibilityOriginInScreen(bounds); | 467 return view->AccessibilityOriginInScreen(bounds); |
| 474 return gfx::Point(); | 468 return gfx::Point(); |
| 475 } | 469 } |
| 476 | 470 |
| 477 void RenderFrameHostImpl::AccessibilityHitTest(const gfx::Point& point) { | 471 void RenderFrameHostImpl::AccessibilityHitTest(const gfx::Point& point) { |
| 478 Send(new AccessibilityMsg_HitTest(routing_id_, point)); | 472 Send(new AccessibilityMsg_HitTest(routing_id_, point)); |
| 479 } | 473 } |
| 480 | 474 |
| 481 void RenderFrameHostImpl::AccessibilityFatalError() { | 475 void RenderFrameHostImpl::AccessibilityFatalError() { |
| 476 Send(new AccessibilityMsg_FatalError(routing_id_)); |
| 482 browser_accessibility_manager_.reset(NULL); | 477 browser_accessibility_manager_.reset(NULL); |
| 483 if (accessibility_reset_token_) | |
| 484 return; | |
| 485 | |
| 486 accessibility_reset_count_++; | |
| 487 if (accessibility_reset_count_ >= kMaxAccessibilityResets) { | |
| 488 Send(new AccessibilityMsg_FatalError(routing_id_)); | |
| 489 } else { | |
| 490 accessibility_reset_token_ = g_next_accessibility_reset_token++; | |
| 491 UMA_HISTOGRAM_COUNTS("Accessibility.FrameResetCount", 1); | |
| 492 Send(new AccessibilityMsg_Reset(routing_id_, accessibility_reset_token_)); | |
| 493 } | |
| 494 } | 478 } |
| 495 | 479 |
| 496 gfx::AcceleratedWidget | 480 gfx::AcceleratedWidget |
| 497 RenderFrameHostImpl::AccessibilityGetAcceleratedWidget() { | 481 RenderFrameHostImpl::AccessibilityGetAcceleratedWidget() { |
| 498 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 482 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
| 499 render_view_host_->GetView()); | 483 render_view_host_->GetView()); |
| 500 if (view) | 484 if (view) |
| 501 return view->AccessibilityGetAcceleratedWidget(); | 485 return view->AccessibilityGetAcceleratedWidget(); |
| 502 return gfx::kNullAcceleratedWidget; | 486 return gfx::kNullAcceleratedWidget; |
| 503 } | 487 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 process->FilterURL(true, &validated_params.searchable_form_url); | 734 process->FilterURL(true, &validated_params.searchable_form_url); |
| 751 | 735 |
| 752 // Without this check, the renderer can trick the browser into using | 736 // Without this check, the renderer can trick the browser into using |
| 753 // filenames it can't access in a future session restore. | 737 // filenames it can't access in a future session restore. |
| 754 if (!render_view_host_->CanAccessFilesOfPageState( | 738 if (!render_view_host_->CanAccessFilesOfPageState( |
| 755 validated_params.page_state)) { | 739 validated_params.page_state)) { |
| 756 GetProcess()->ReceivedBadMessage(); | 740 GetProcess()->ReceivedBadMessage(); |
| 757 return; | 741 return; |
| 758 } | 742 } |
| 759 | 743 |
| 760 accessibility_reset_count_ = 0; | |
| 761 frame_tree_node()->navigator()->DidNavigate(this, validated_params); | 744 frame_tree_node()->navigator()->DidNavigate(this, validated_params); |
| 762 } | 745 } |
| 763 | 746 |
| 764 RenderWidgetHostImpl* RenderFrameHostImpl::GetRenderWidgetHost() { | 747 RenderWidgetHostImpl* RenderFrameHostImpl::GetRenderWidgetHost() { |
| 765 return static_cast<RenderWidgetHostImpl*>(render_view_host_); | 748 return static_cast<RenderWidgetHostImpl*>(render_view_host_); |
| 766 } | 749 } |
| 767 | 750 |
| 768 int RenderFrameHostImpl::GetEnabledBindings() { | 751 int RenderFrameHostImpl::GetEnabledBindings() { |
| 769 return render_view_host_->GetEnabledBindings(); | 752 return render_view_host_->GetEnabledBindings(); |
| 770 } | 753 } |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 void RenderFrameHostImpl::OnBeginNavigation( | 1057 void RenderFrameHostImpl::OnBeginNavigation( |
| 1075 const FrameHostMsg_BeginNavigation_Params& params, | 1058 const FrameHostMsg_BeginNavigation_Params& params, |
| 1076 const CommonNavigationParams& common_params) { | 1059 const CommonNavigationParams& common_params) { |
| 1077 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 1060 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
| 1078 switches::kEnableBrowserSideNavigation)); | 1061 switches::kEnableBrowserSideNavigation)); |
| 1079 frame_tree_node()->navigator()->OnBeginNavigation( | 1062 frame_tree_node()->navigator()->OnBeginNavigation( |
| 1080 frame_tree_node(), params, common_params); | 1063 frame_tree_node(), params, common_params); |
| 1081 } | 1064 } |
| 1082 | 1065 |
| 1083 void RenderFrameHostImpl::OnAccessibilityEvents( | 1066 void RenderFrameHostImpl::OnAccessibilityEvents( |
| 1084 const std::vector<AccessibilityHostMsg_EventParams>& params, | 1067 const std::vector<AccessibilityHostMsg_EventParams>& params) { |
| 1085 int reset_token) { | |
| 1086 // Don't process this IPC if either we're waiting on a reset and this | |
| 1087 // IPC doesn't have the matching token ID, or if we're not waiting on a | |
| 1088 // reset but this message includes a reset token. | |
| 1089 if (accessibility_reset_token_ != reset_token) { | |
| 1090 Send(new AccessibilityMsg_Events_ACK(routing_id_)); | |
| 1091 return; | |
| 1092 } | |
| 1093 accessibility_reset_token_ = 0; | |
| 1094 | |
| 1095 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 1068 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
| 1096 render_view_host_->GetView()); | 1069 render_view_host_->GetView()); |
| 1097 | 1070 |
| 1098 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 1071 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
| 1099 if ((accessibility_mode != AccessibilityModeOff) && view && | 1072 if ((accessibility_mode != AccessibilityModeOff) && view && |
| 1100 RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { | 1073 RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { |
| 1101 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 1074 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
| 1102 GetOrCreateBrowserAccessibilityManager(); | 1075 GetOrCreateBrowserAccessibilityManager(); |
| 1103 if (browser_accessibility_manager_) | 1076 if (browser_accessibility_manager_) |
| 1104 browser_accessibility_manager_->OnAccessibilityEvents(params); | 1077 browser_accessibility_manager_->OnAccessibilityEvents(params); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 } else { | 1132 } else { |
| 1160 CHECK(ax_tree_for_testing_->Unserialize(param.update)) | 1133 CHECK(ax_tree_for_testing_->Unserialize(param.update)) |
| 1161 << ax_tree_for_testing_->error(); | 1134 << ax_tree_for_testing_->error(); |
| 1162 } | 1135 } |
| 1163 accessibility_testing_callback_.Run(param.event_type, param.id); | 1136 accessibility_testing_callback_.Run(param.event_type, param.id); |
| 1164 } | 1137 } |
| 1165 } | 1138 } |
| 1166 | 1139 |
| 1167 void RenderFrameHostImpl::OnAccessibilityLocationChanges( | 1140 void RenderFrameHostImpl::OnAccessibilityLocationChanges( |
| 1168 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 1141 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
| 1169 if (accessibility_reset_token_) | |
| 1170 return; | |
| 1171 | |
| 1172 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 1142 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
| 1173 render_view_host_->GetView()); | 1143 render_view_host_->GetView()); |
| 1174 if (view && RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { | 1144 if (view && RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { |
| 1175 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 1145 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
| 1176 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 1146 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
| 1177 if (!browser_accessibility_manager_) { | 1147 if (!browser_accessibility_manager_) { |
| 1178 browser_accessibility_manager_.reset( | 1148 browser_accessibility_manager_.reset( |
| 1179 view->CreateBrowserAccessibilityManager(this)); | 1149 view->CreateBrowserAccessibilityManager(this)); |
| 1180 } | 1150 } |
| 1181 if (browser_accessibility_manager_) | 1151 if (browser_accessibility_manager_) |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 const base::Callback<void(ui::AXEvent, int)>& callback) { | 1441 const base::Callback<void(ui::AXEvent, int)>& callback) { |
| 1472 accessibility_testing_callback_ = callback; | 1442 accessibility_testing_callback_ = callback; |
| 1473 } | 1443 } |
| 1474 | 1444 |
| 1475 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { | 1445 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { |
| 1476 return ax_tree_for_testing_.get(); | 1446 return ax_tree_for_testing_.get(); |
| 1477 } | 1447 } |
| 1478 | 1448 |
| 1479 BrowserAccessibilityManager* | 1449 BrowserAccessibilityManager* |
| 1480 RenderFrameHostImpl::GetOrCreateBrowserAccessibilityManager() { | 1450 RenderFrameHostImpl::GetOrCreateBrowserAccessibilityManager() { |
| 1481 if (disallow_browser_accessibility_manager_for_testing_) | |
| 1482 return NULL; | |
| 1483 | |
| 1484 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 1451 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
| 1485 render_view_host_->GetView()); | 1452 render_view_host_->GetView()); |
| 1486 if (view && !browser_accessibility_manager_) { | 1453 if (view && |
| 1454 !browser_accessibility_manager_) { |
| 1487 browser_accessibility_manager_.reset( | 1455 browser_accessibility_manager_.reset( |
| 1488 view->CreateBrowserAccessibilityManager(this)); | 1456 view->CreateBrowserAccessibilityManager(this)); |
| 1489 if (browser_accessibility_manager_) | |
| 1490 UMA_HISTOGRAM_COUNTS("Accessibility.FrameEnabledCount", 1); | |
| 1491 else | |
| 1492 UMA_HISTOGRAM_COUNTS("Accessibility.FrameDidNotEnableCount", 1); | |
| 1493 } | 1457 } |
| 1494 return browser_accessibility_manager_.get(); | 1458 return browser_accessibility_manager_.get(); |
| 1495 } | 1459 } |
| 1496 | 1460 |
| 1497 #if defined(OS_WIN) | 1461 #if defined(OS_WIN) |
| 1498 | 1462 |
| 1499 void RenderFrameHostImpl::SetParentNativeViewAccessible( | 1463 void RenderFrameHostImpl::SetParentNativeViewAccessible( |
| 1500 gfx::NativeViewAccessible accessible_parent) { | 1464 gfx::NativeViewAccessible accessible_parent) { |
| 1501 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 1465 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
| 1502 render_view_host_->GetView()); | 1466 render_view_host_->GetView()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 // Clear any state if a pending navigation is canceled or preempted. | 1541 // Clear any state if a pending navigation is canceled or preempted. |
| 1578 if (suspended_nav_params_) | 1542 if (suspended_nav_params_) |
| 1579 suspended_nav_params_.reset(); | 1543 suspended_nav_params_.reset(); |
| 1580 | 1544 |
| 1581 TRACE_EVENT_ASYNC_END0("navigation", | 1545 TRACE_EVENT_ASYNC_END0("navigation", |
| 1582 "RenderFrameHostImpl navigation suspended", this); | 1546 "RenderFrameHostImpl navigation suspended", this); |
| 1583 navigations_suspended_ = false; | 1547 navigations_suspended_ = false; |
| 1584 } | 1548 } |
| 1585 | 1549 |
| 1586 } // namespace content | 1550 } // namespace content |
| OLD | NEW |