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