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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 return base::i18n::RIGHT_TO_LEFT; | 127 return base::i18n::RIGHT_TO_LEFT; |
128 default: | 128 default: |
129 NOTREACHED(); | 129 NOTREACHED(); |
130 return base::i18n::UNKNOWN_DIRECTION; | 130 return base::i18n::UNKNOWN_DIRECTION; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 } // namespace | 134 } // namespace |
135 | 135 |
136 // static | 136 // static |
137 bool RenderFrameHostImpl::IsRFHStateActive(RenderFrameHostImplState rfh_state) { | |
138 return rfh_state == STATE_DEFAULT; | |
139 } | |
140 | |
141 // static | |
142 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, | 137 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, |
143 int render_frame_id) { | 138 int render_frame_id) { |
144 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | 139 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); |
145 } | 140 } |
146 | 141 |
147 #if defined(OS_ANDROID) | 142 #if defined(OS_ANDROID) |
148 // static | 143 // static |
149 void RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView() { | 144 void RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView() { |
150 g_allow_injecting_javascript = true; | 145 g_allow_injecting_javascript = true; |
151 } | 146 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 : render_view_host_(render_view_host), | 183 : render_view_host_(render_view_host), |
189 delegate_(delegate), | 184 delegate_(delegate), |
190 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), | 185 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), |
191 process_(site_instance->GetProcess()), | 186 process_(site_instance->GetProcess()), |
192 cross_process_frame_connector_(NULL), | 187 cross_process_frame_connector_(NULL), |
193 render_frame_proxy_host_(NULL), | 188 render_frame_proxy_host_(NULL), |
194 frame_tree_(frame_tree), | 189 frame_tree_(frame_tree), |
195 frame_tree_node_(frame_tree_node), | 190 frame_tree_node_(frame_tree_node), |
196 render_widget_host_(nullptr), | 191 render_widget_host_(nullptr), |
197 routing_id_(routing_id), | 192 routing_id_(routing_id), |
198 rfh_state_(STATE_DEFAULT), | 193 is_waiting_for_swapout_ack_(false), |
199 render_frame_created_(false), | 194 render_frame_created_(false), |
200 navigations_suspended_(false), | 195 navigations_suspended_(false), |
201 is_waiting_for_beforeunload_ack_(false), | 196 is_waiting_for_beforeunload_ack_(false), |
202 unload_ack_is_for_navigation_(false), | 197 unload_ack_is_for_navigation_(false), |
203 is_loading_(false), | 198 is_loading_(false), |
204 pending_commit_(false), | 199 pending_commit_(false), |
205 nav_entry_id_(0), | 200 nav_entry_id_(0), |
206 accessibility_reset_token_(0), | 201 accessibility_reset_token_(0), |
207 accessibility_reset_count_(0), | 202 accessibility_reset_count_(0), |
208 no_create_browser_accessibility_manager_for_testing_(false), | 203 no_create_browser_accessibility_manager_for_testing_(false), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 | 255 |
261 GetProcess()->RemoveRoute(routing_id_); | 256 GetProcess()->RemoveRoute(routing_id_); |
262 g_routing_id_frame_map.Get().erase( | 257 g_routing_id_frame_map.Get().erase( |
263 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 258 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
264 | 259 |
265 site_instance_->RemoveObserver(this); | 260 site_instance_->RemoveObserver(this); |
266 | 261 |
267 if (delegate_ && render_frame_created_) | 262 if (delegate_ && render_frame_created_) |
268 delegate_->RenderFrameDeleted(this); | 263 delegate_->RenderFrameDeleted(this); |
269 | 264 |
270 bool is_active = IsRFHStateActive(rfh_state_); | |
271 | |
272 // If this RenderFrameHost is swapped out, it already decremented the active | 265 // If this RenderFrameHost is swapped out, it already decremented the active |
273 // frame count of the SiteInstance it belongs to. | 266 // frame count of the SiteInstance it belongs to. |
274 if (is_active) | 267 if (is_active()) |
275 GetSiteInstance()->DecrementActiveFrameCount(); | 268 GetSiteInstance()->DecrementActiveFrameCount(); |
276 | 269 |
277 // If this RenderFrameHost is swapping with a RenderFrameProxyHost, the | 270 // If this RenderFrameHost is swapping with a RenderFrameProxyHost, the |
278 // RenderFrame will already be deleted in the renderer process. Main frame | 271 // RenderFrame will already be deleted in the renderer process. Main frame |
279 // RenderFrames will be cleaned up as part of deleting its RenderView. In all | 272 // RenderFrames will be cleaned up as part of deleting its RenderView. In all |
280 // other cases, the RenderFrame should be cleaned up (if it exists). | 273 // other cases, the RenderFrame should be cleaned up (if it exists). |
281 if (is_active && !frame_tree_node_->IsMainFrame() && render_frame_created_) | 274 if (is_active() && !frame_tree_node_->IsMainFrame() && render_frame_created_) |
282 Send(new FrameMsg_Delete(routing_id_)); | 275 Send(new FrameMsg_Delete(routing_id_)); |
283 | 276 |
284 // NULL out the swapout timer; in crash dumps this member will be null only if | 277 // NULL out the swapout timer; in crash dumps this member will be null only if |
285 // the dtor has run. | 278 // the dtor has run. |
286 swapout_event_monitor_timeout_.reset(); | 279 swapout_event_monitor_timeout_.reset(); |
287 | 280 |
288 for (const auto& iter: visual_state_callbacks_) { | 281 for (const auto& iter: visual_state_callbacks_) { |
289 iter.second.Run(false); | 282 iter.second.Run(false); |
290 } | 283 } |
291 | 284 |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 const std::string& frame_unique_name, | 809 const std::string& frame_unique_name, |
817 blink::WebSandboxFlags sandbox_flags, | 810 blink::WebSandboxFlags sandbox_flags, |
818 const blink::WebFrameOwnerProperties& frame_owner_properties) { | 811 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
819 // TODO(lukasza): Call ReceivedBadMessage when |frame_unique_name| is empty. | 812 // TODO(lukasza): Call ReceivedBadMessage when |frame_unique_name| is empty. |
820 DCHECK(!frame_unique_name.empty()); | 813 DCHECK(!frame_unique_name.empty()); |
821 | 814 |
822 // It is possible that while a new RenderFrameHost was committed, the | 815 // It is possible that while a new RenderFrameHost was committed, the |
823 // RenderFrame corresponding to this host sent an IPC message to create a | 816 // RenderFrame corresponding to this host sent an IPC message to create a |
824 // frame and it is delivered after this host is swapped out. | 817 // frame and it is delivered after this host is swapped out. |
825 // Ignore such messages, as we know this RenderFrameHost is going away. | 818 // Ignore such messages, as we know this RenderFrameHost is going away. |
826 if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT || | 819 if (!is_active() || frame_tree_node_->current_frame_host() != this) |
827 frame_tree_node_->current_frame_host() != this) | |
828 return; | 820 return; |
829 | 821 |
830 frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(), new_routing_id, | 822 frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(), new_routing_id, |
831 scope, frame_name, frame_unique_name, sandbox_flags, | 823 scope, frame_name, frame_unique_name, sandbox_flags, |
832 frame_owner_properties); | 824 frame_owner_properties); |
833 } | 825 } |
834 | 826 |
835 void RenderFrameHostImpl::OnDetach() { | 827 void RenderFrameHostImpl::OnDetach() { |
836 frame_tree_->RemoveFrame(frame_tree_node_); | 828 frame_tree_->RemoveFrame(frame_tree_node_); |
837 } | 829 } |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1163 | 1155 |
1164 void RenderFrameHostImpl::SwapOut( | 1156 void RenderFrameHostImpl::SwapOut( |
1165 RenderFrameProxyHost* proxy, | 1157 RenderFrameProxyHost* proxy, |
1166 bool is_loading) { | 1158 bool is_loading) { |
1167 // The end of this event is in OnSwapOutACK when the RenderFrame has completed | 1159 // The end of this event is in OnSwapOutACK when the RenderFrame has completed |
1168 // the operation and sends back an IPC message. | 1160 // the operation and sends back an IPC message. |
1169 // The trace event may not end properly if the ACK times out. We expect this | 1161 // The trace event may not end properly if the ACK times out. We expect this |
1170 // to be fixed when RenderViewHostImpl::OnSwapOut moves to RenderFrameHost. | 1162 // to be fixed when RenderViewHostImpl::OnSwapOut moves to RenderFrameHost. |
1171 TRACE_EVENT_ASYNC_BEGIN0("navigation", "RenderFrameHostImpl::SwapOut", this); | 1163 TRACE_EVENT_ASYNC_BEGIN0("navigation", "RenderFrameHostImpl::SwapOut", this); |
1172 | 1164 |
1173 // If this RenderFrameHost is not in the default state, it must have already | 1165 // If this RenderFrameHost is not in the default state, it must have already |
Charlie Reis
2016/04/04 17:16:36
s/not in the default state/already pending deletio
nasko
2016/04/08 17:42:07
Done.
| |
1174 // gone through this, therefore just return. | 1166 // gone through this, therefore just return. |
1175 if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT) { | 1167 if (!is_active()) { |
1176 NOTREACHED() << "RFH should be in default state when calling SwapOut."; | 1168 NOTREACHED() << "RFH should be in default state when calling SwapOut."; |
1177 return; | 1169 return; |
1178 } | 1170 } |
1179 | 1171 |
1180 swapout_event_monitor_timeout_->Start( | 1172 swapout_event_monitor_timeout_->Start( |
1181 base::TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); | 1173 base::TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); |
1182 | 1174 |
1183 // There may be no proxy if there are no active views in the process. | 1175 // There may be no proxy if there are no active views in the process. |
1184 int proxy_routing_id = MSG_ROUTING_NONE; | 1176 int proxy_routing_id = MSG_ROUTING_NONE; |
1185 FrameReplicationState replication_state; | 1177 FrameReplicationState replication_state; |
1186 if (proxy) { | 1178 if (proxy) { |
1187 set_render_frame_proxy_host(proxy); | 1179 set_render_frame_proxy_host(proxy); |
1188 proxy_routing_id = proxy->GetRoutingID(); | 1180 proxy_routing_id = proxy->GetRoutingID(); |
1189 replication_state = proxy->frame_tree_node()->current_replication_state(); | 1181 replication_state = proxy->frame_tree_node()->current_replication_state(); |
1190 } | 1182 } |
1191 | 1183 |
1192 if (IsRenderFrameLive()) { | 1184 if (IsRenderFrameLive()) { |
1193 Send(new FrameMsg_SwapOut(routing_id_, proxy_routing_id, is_loading, | 1185 Send(new FrameMsg_SwapOut(routing_id_, proxy_routing_id, is_loading, |
1194 replication_state)); | 1186 replication_state)); |
1195 } | 1187 } |
1196 | 1188 |
1197 // If this is the last active frame in the SiteInstance, the SetState call | 1189 // TODO(nasko): If the frame is not live, shouldn't we just delete the RFH by |
1198 // below will trigger the deletion of the SiteInstance's proxies. | 1190 // simulating the receipt of swap out ack? |
Charlie Reis
2016/04/04 17:16:36
Yes, that sounds right. Want to do that here or i
nasko
2016/04/08 17:42:07
Separate CL, unless you feel strongly for includin
Charlie Reis
2016/04/08 20:25:37
Acknowledged.
| |
1199 SetState(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT); | 1191 is_waiting_for_swapout_ack_ = true; |
1192 if (frame_tree_node_->IsMainFrame()) | |
1193 render_view_host_->set_is_active(false); | |
1194 | |
1195 // If this is the last active frame in the SiteInstance, the | |
1196 // DecrementActiveFrameCount call will trigger the deletion of the | |
1197 // SiteInstance's proxies. | |
1198 GetSiteInstance()->DecrementActiveFrameCount(); | |
1200 | 1199 |
1201 if (!GetParent()) | 1200 if (!GetParent()) |
1202 delegate_->SwappedOut(this); | 1201 delegate_->SwappedOut(this); |
1203 } | 1202 } |
1204 | 1203 |
1205 void RenderFrameHostImpl::OnBeforeUnloadACK( | 1204 void RenderFrameHostImpl::OnBeforeUnloadACK( |
1206 bool proceed, | 1205 bool proceed, |
1207 const base::TimeTicks& renderer_before_unload_start_time, | 1206 const base::TimeTicks& renderer_before_unload_start_time, |
1208 const base::TimeTicks& renderer_before_unload_end_time) { | 1207 const base::TimeTicks& renderer_before_unload_end_time) { |
1209 TRACE_EVENT_ASYNC_END1("navigation", "RenderFrameHostImpl BeforeUnload", this, | 1208 TRACE_EVENT_ASYNC_END1("navigation", "RenderFrameHostImpl BeforeUnload", this, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1289 before_unload_end_time); | 1288 before_unload_end_time); |
1290 } | 1289 } |
1291 | 1290 |
1292 // If canceled, notify the delegate to cancel its pending navigation entry. | 1291 // If canceled, notify the delegate to cancel its pending navigation entry. |
1293 if (!proceed) | 1292 if (!proceed) |
1294 render_view_host_->GetDelegate()->DidCancelLoading(); | 1293 render_view_host_->GetDelegate()->DidCancelLoading(); |
1295 } | 1294 } |
1296 | 1295 |
1297 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { | 1296 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const { |
1298 return render_view_host_->is_waiting_for_close_ack_ || | 1297 return render_view_host_->is_waiting_for_close_ack_ || |
1299 rfh_state_ == STATE_PENDING_SWAP_OUT; | 1298 is_waiting_for_swapout_ack_; |
1300 } | 1299 } |
1301 | 1300 |
1302 void RenderFrameHostImpl::OnSwapOutACK() { | 1301 void RenderFrameHostImpl::OnSwapOutACK() { |
1303 OnSwappedOut(); | 1302 OnSwappedOut(); |
1304 } | 1303 } |
1305 | 1304 |
1306 void RenderFrameHostImpl::OnRenderProcessGone(int status, int exit_code) { | 1305 void RenderFrameHostImpl::OnRenderProcessGone(int status, int exit_code) { |
1307 if (frame_tree_node_->IsMainFrame()) { | 1306 if (frame_tree_node_->IsMainFrame()) { |
1308 // Keep the termination status so we can get at it later when we | 1307 // Keep the termination status so we can get at it later when we |
1309 // need to know why it died. | 1308 // need to know why it died. |
(...skipping 17 matching lines...) Expand all Loading... | |
1327 iter.second.Run(ui::AXTreeUpdate()); | 1326 iter.second.Run(ui::AXTreeUpdate()); |
1328 ax_tree_snapshot_callbacks_.clear(); | 1327 ax_tree_snapshot_callbacks_.clear(); |
1329 | 1328 |
1330 // Note: don't add any more code at this point in the function because | 1329 // Note: don't add any more code at this point in the function because |
1331 // |this| may be deleted. Any additional cleanup should happen before | 1330 // |this| may be deleted. Any additional cleanup should happen before |
1332 // the last block of code here. | 1331 // the last block of code here. |
1333 } | 1332 } |
1334 | 1333 |
1335 void RenderFrameHostImpl::OnSwappedOut() { | 1334 void RenderFrameHostImpl::OnSwappedOut() { |
1336 // Ignore spurious swap out ack. | 1335 // Ignore spurious swap out ack. |
1337 if (rfh_state_ != STATE_PENDING_SWAP_OUT) | 1336 if (!is_waiting_for_swapout_ack_) |
1338 return; | 1337 return; |
1339 | 1338 |
1340 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); | 1339 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); |
1341 swapout_event_monitor_timeout_->Stop(); | 1340 swapout_event_monitor_timeout_->Stop(); |
1342 | 1341 |
1343 ClearAllWebUI(); | 1342 ClearAllWebUI(); |
1344 | 1343 |
1345 // If this is a main frame RFH that's about to be deleted, update its RVH's | 1344 // If this is a main frame RFH that's about to be deleted, update its RVH's |
1346 // swapped-out state here, since SetState won't be called once this RFH is | 1345 // swapped-out state here. https://crbug.com/505887 |
1347 // deleted below. https://crbug.com/505887 | |
1348 if (frame_tree_node_->IsMainFrame() && | 1346 if (frame_tree_node_->IsMainFrame() && |
1349 frame_tree_node_->render_manager()->IsPendingDeletion(this)) { | 1347 frame_tree_node_->render_manager()->IsPendingDeletion(this)) { |
1350 render_view_host_->set_is_active(false); | 1348 render_view_host_->set_is_active(false); |
1351 render_view_host_->set_is_swapped_out(true); | 1349 render_view_host_->set_is_swapped_out(true); |
1352 } | 1350 } |
1353 | 1351 |
1354 bool deleted = | 1352 bool deleted = |
1355 frame_tree_node_->render_manager()->DeleteFromPendingList(this); | 1353 frame_tree_node_->render_manager()->DeleteFromPendingList(this); |
1356 CHECK(deleted); | 1354 CHECK(deleted); |
1357 } | 1355 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1611 // reset but this message includes a reset token. | 1609 // reset but this message includes a reset token. |
1612 if (accessibility_reset_token_ != reset_token) { | 1610 if (accessibility_reset_token_ != reset_token) { |
1613 Send(new AccessibilityMsg_Events_ACK(routing_id_)); | 1611 Send(new AccessibilityMsg_Events_ACK(routing_id_)); |
1614 return; | 1612 return; |
1615 } | 1613 } |
1616 accessibility_reset_token_ = 0; | 1614 accessibility_reset_token_ = 0; |
1617 | 1615 |
1618 RenderWidgetHostViewBase* view = GetViewForAccessibility(); | 1616 RenderWidgetHostViewBase* view = GetViewForAccessibility(); |
1619 | 1617 |
1620 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 1618 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
1621 if ((accessibility_mode != AccessibilityModeOff) && view && | 1619 if ((accessibility_mode != AccessibilityModeOff) && view && is_active()) { |
1622 RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { | |
1623 if (accessibility_mode & AccessibilityModeFlagPlatform) | 1620 if (accessibility_mode & AccessibilityModeFlagPlatform) |
1624 GetOrCreateBrowserAccessibilityManager(); | 1621 GetOrCreateBrowserAccessibilityManager(); |
1625 | 1622 |
1626 std::vector<AXEventNotificationDetails> details; | 1623 std::vector<AXEventNotificationDetails> details; |
1627 details.reserve(params.size()); | 1624 details.reserve(params.size()); |
1628 for (size_t i = 0; i < params.size(); ++i) { | 1625 for (size_t i = 0; i < params.size(); ++i) { |
1629 const AccessibilityHostMsg_EventParams& param = params[i]; | 1626 const AccessibilityHostMsg_EventParams& param = params[i]; |
1630 AXEventNotificationDetails detail; | 1627 AXEventNotificationDetails detail; |
1631 detail.event_type = param.event_type; | 1628 detail.event_type = param.event_type; |
1632 detail.id = param.id; | 1629 detail.id = param.id; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1682 Send(new AccessibilityMsg_Events_ACK(routing_id_)); | 1679 Send(new AccessibilityMsg_Events_ACK(routing_id_)); |
1683 } | 1680 } |
1684 | 1681 |
1685 void RenderFrameHostImpl::OnAccessibilityLocationChanges( | 1682 void RenderFrameHostImpl::OnAccessibilityLocationChanges( |
1686 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 1683 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
1687 if (accessibility_reset_token_) | 1684 if (accessibility_reset_token_) |
1688 return; | 1685 return; |
1689 | 1686 |
1690 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 1687 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
1691 render_view_host_->GetWidget()->GetView()); | 1688 render_view_host_->GetWidget()->GetView()); |
1692 if (view && RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { | 1689 if (view && is_active()) { |
1693 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 1690 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
1694 if (accessibility_mode & AccessibilityModeFlagPlatform) { | 1691 if (accessibility_mode & AccessibilityModeFlagPlatform) { |
1695 BrowserAccessibilityManager* manager = | 1692 BrowserAccessibilityManager* manager = |
1696 GetOrCreateBrowserAccessibilityManager(); | 1693 GetOrCreateBrowserAccessibilityManager(); |
1697 if (manager) | 1694 if (manager) |
1698 manager->OnLocationChanges(params); | 1695 manager->OnLocationChanges(params); |
1699 } | 1696 } |
1700 // TODO(aboxhall): send location change events to web contents observers too | 1697 // TODO(aboxhall): send location change events to web contents observers too |
1701 } | 1698 } |
1702 } | 1699 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1753 if (IsBrowserSideNavigationEnabled() && to_different_document) { | 1750 if (IsBrowserSideNavigationEnabled() && to_different_document) { |
1754 bad_message::ReceivedBadMessage(GetProcess(), | 1751 bad_message::ReceivedBadMessage(GetProcess(), |
1755 bad_message::RFH_UNEXPECTED_LOAD_START); | 1752 bad_message::RFH_UNEXPECTED_LOAD_START); |
1756 return; | 1753 return; |
1757 } | 1754 } |
1758 bool was_previously_loading = frame_tree_node_->frame_tree()->IsLoading(); | 1755 bool was_previously_loading = frame_tree_node_->frame_tree()->IsLoading(); |
1759 is_loading_ = true; | 1756 is_loading_ = true; |
1760 | 1757 |
1761 // Only inform the FrameTreeNode of a change in load state if the load state | 1758 // Only inform the FrameTreeNode of a change in load state if the load state |
1762 // of this RenderFrameHost is being tracked. | 1759 // of this RenderFrameHost is being tracked. |
1763 if (rfh_state_ == STATE_DEFAULT) { | 1760 if (is_active()) { |
1764 frame_tree_node_->DidStartLoading(to_different_document, | 1761 frame_tree_node_->DidStartLoading(to_different_document, |
1765 was_previously_loading); | 1762 was_previously_loading); |
1766 } | 1763 } |
1767 } | 1764 } |
1768 | 1765 |
1769 void RenderFrameHostImpl::OnDidStopLoading() { | 1766 void RenderFrameHostImpl::OnDidStopLoading() { |
1770 // This method should never be called when the frame is not loading. | 1767 // This method should never be called when the frame is not loading. |
1771 // Unfortunately, it can happen if a history navigation happens during a | 1768 // Unfortunately, it can happen if a history navigation happens during a |
1772 // BeforeUnload or Unload event. | 1769 // BeforeUnload or Unload event. |
1773 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | 1770 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been |
1774 // refactored in Blink. See crbug.com/466089 | 1771 // refactored in Blink. See crbug.com/466089 |
1775 if (!is_loading_) { | 1772 if (!is_loading_) { |
1776 LOG(WARNING) << "OnDidStopLoading was called twice."; | 1773 LOG(WARNING) << "OnDidStopLoading was called twice."; |
1777 return; | 1774 return; |
1778 } | 1775 } |
1779 | 1776 |
1780 is_loading_ = false; | 1777 is_loading_ = false; |
1781 navigation_handle_.reset(); | 1778 navigation_handle_.reset(); |
1782 | 1779 |
1783 // Only inform the FrameTreeNode of a change in load state if the load state | 1780 // Only inform the FrameTreeNode of a change in load state if the load state |
1784 // of this RenderFrameHost is being tracked. | 1781 // of this RenderFrameHost is being tracked. |
1785 if (rfh_state_ == STATE_DEFAULT) | 1782 if (is_active()) |
1786 frame_tree_node_->DidStopLoading(); | 1783 frame_tree_node_->DidStopLoading(); |
1787 } | 1784 } |
1788 | 1785 |
1789 void RenderFrameHostImpl::OnDidChangeLoadProgress(double load_progress) { | 1786 void RenderFrameHostImpl::OnDidChangeLoadProgress(double load_progress) { |
1790 frame_tree_node_->DidChangeLoadProgress(load_progress); | 1787 frame_tree_node_->DidChangeLoadProgress(load_progress); |
1791 } | 1788 } |
1792 | 1789 |
1793 void RenderFrameHostImpl::OnSerializeAsMHTMLResponse( | 1790 void RenderFrameHostImpl::OnSerializeAsMHTMLResponse( |
1794 int job_id, | 1791 int job_id, |
1795 bool success, | 1792 bool success, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1879 | 1876 |
1880 if (browser_command_line.HasSwitch(switches::kEnableWebVR)) { | 1877 if (browser_command_line.HasSwitch(switches::kEnableWebVR)) { |
1881 GetServiceRegistry()->AddService(base::Bind(&VRDeviceManager::BindRequest)); | 1878 GetServiceRegistry()->AddService(base::Bind(&VRDeviceManager::BindRequest)); |
1882 } | 1879 } |
1883 #endif | 1880 #endif |
1884 | 1881 |
1885 GetContentClient()->browser()->RegisterRenderFrameMojoServices( | 1882 GetContentClient()->browser()->RegisterRenderFrameMojoServices( |
1886 GetServiceRegistry(), this); | 1883 GetServiceRegistry(), this); |
1887 } | 1884 } |
1888 | 1885 |
1889 void RenderFrameHostImpl::SetState(RenderFrameHostImplState rfh_state) { | 1886 void RenderFrameHostImpl::ResetWaitingState() { |
1890 // We decrement the number of RenderFrameHosts in a SiteInstance when the | |
1891 // status of a RenderFrameHost gets flipped from active. | |
1892 if (IsRFHStateActive(rfh_state_) && !IsRFHStateActive(rfh_state)) | |
1893 GetSiteInstance()->DecrementActiveFrameCount(); | |
1894 | |
1895 // The active state of the RVH is determined by its main frame, since | 1887 // The active state of the RVH is determined by its main frame, since |
1896 // subframes should have their own widgets. | 1888 // subframes should have their own widgets. |
1897 if (frame_tree_node_->IsMainFrame()) { | 1889 if (frame_tree_node_->IsMainFrame()) { |
1898 render_view_host_->set_is_active(IsRFHStateActive(rfh_state)); | 1890 render_view_host_->set_is_active(true); |
1899 render_view_host_->set_is_swapped_out(false); | 1891 render_view_host_->set_is_swapped_out(false); |
1900 } | 1892 } |
1901 | 1893 |
1902 // Whenever we change the RFH state to and from active state, we should not be | 1894 if (!is_active()) |
Charlie Reis
2016/04/04 17:16:36
How can is_active() be false in this call? Wouldn
nasko
2016/04/08 17:42:07
Done.
| |
1903 // waiting for beforeunload or close acks. We clear them here to be safe, | 1895 return; |
1904 // since they can cause navigations to be ignored in | 1896 |
1905 // OnDidCommitProvisionalLoad. | 1897 // Whenever we reset the RFH state, we should not be waiting for beforeunload |
1906 // TODO(creis): Move is_waiting_for_beforeunload_ack_ into the state machine. | 1898 // or close acks. We clear them here to be safe, since they can cause |
1907 if (rfh_state == STATE_DEFAULT || rfh_state_ == STATE_DEFAULT) { | 1899 // navigations to be ignored in OnDidCommitProvisionalLoad. |
1908 if (is_waiting_for_beforeunload_ack_) { | 1900 if (is_waiting_for_beforeunload_ack_) { |
1909 is_waiting_for_beforeunload_ack_ = false; | 1901 is_waiting_for_beforeunload_ack_ = false; |
1910 render_view_host_->GetWidget()->decrement_in_flight_event_count(); | 1902 render_view_host_->GetWidget()->decrement_in_flight_event_count(); |
1911 render_view_host_->GetWidget()->StopHangMonitorTimeout(); | 1903 render_view_host_->GetWidget()->StopHangMonitorTimeout(); |
1912 } | |
1913 send_before_unload_start_time_ = base::TimeTicks(); | |
1914 render_view_host_->is_waiting_for_close_ack_ = false; | |
1915 } | 1904 } |
1916 rfh_state_ = rfh_state; | 1905 send_before_unload_start_time_ = base::TimeTicks(); |
1906 render_view_host_->is_waiting_for_close_ack_ = false; | |
1917 } | 1907 } |
1918 | 1908 |
1919 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { | 1909 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { |
1920 // TODO(creis): We should also check for WebUI pages here. Also, when the | 1910 // TODO(creis): We should also check for WebUI pages here. Also, when the |
1921 // out-of-process iframes implementation is ready, we should check for | 1911 // out-of-process iframes implementation is ready, we should check for |
1922 // cross-site URLs that are not allowed to commit in this process. | 1912 // cross-site URLs that are not allowed to commit in this process. |
1923 | 1913 |
1924 // Give the client a chance to disallow URLs from committing. | 1914 // Give the client a chance to disallow URLs from committing. |
1925 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); | 1915 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); |
1926 } | 1916 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1973 // Only send the message if we aren't suspended at the start of a cross-site | 1963 // Only send the message if we aren't suspended at the start of a cross-site |
1974 // request. | 1964 // request. |
1975 if (navigations_suspended_) { | 1965 if (navigations_suspended_) { |
1976 // This may replace an existing set of params, if this is a pending RFH that | 1966 // This may replace an existing set of params, if this is a pending RFH that |
1977 // is navigated twice consecutively. | 1967 // is navigated twice consecutively. |
1978 suspended_nav_params_.reset( | 1968 suspended_nav_params_.reset( |
1979 new NavigationParams(common_params, start_params, request_params)); | 1969 new NavigationParams(common_params, start_params, request_params)); |
1980 } else { | 1970 } else { |
1981 // Get back to a clean state, in case we start a new navigation without | 1971 // Get back to a clean state, in case we start a new navigation without |
1982 // completing a RFH swap or unload handler. | 1972 // completing a RFH swap or unload handler. |
1983 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 1973 ResetWaitingState(); |
1984 SendNavigateMessage(common_params, start_params, request_params); | 1974 SendNavigateMessage(common_params, start_params, request_params); |
1985 } | 1975 } |
1986 | 1976 |
1987 // Force the throbber to start. This is done because Blink's "started loading" | 1977 // Force the throbber to start. This is done because Blink's "started loading" |
1988 // message will be received asynchronously from the UI of the browser. But the | 1978 // message will be received asynchronously from the UI of the browser. But the |
1989 // throbber needs to be kept in sync with what's happening in the UI. For | 1979 // throbber needs to be kept in sync with what's happening in the UI. For |
1990 // example, the throbber will start immediately when the user navigates even | 1980 // example, the throbber will start immediately when the user navigates even |
1991 // if the renderer is delayed. There is also an issue with the throbber | 1981 // if the renderer is delayed. There is also an issue with the throbber |
1992 // starting because the WebUI (which controls whether the favicon is | 1982 // starting because the WebUI (which controls whether the favicon is |
1993 // displayed) happens synchronously. If the start loading messages was | 1983 // displayed) happens synchronously. If the start loading messages was |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2139 scoped_ptr<StreamHandle> body, | 2129 scoped_ptr<StreamHandle> body, |
2140 const CommonNavigationParams& common_params, | 2130 const CommonNavigationParams& common_params, |
2141 const RequestNavigationParams& request_params, | 2131 const RequestNavigationParams& request_params, |
2142 bool is_view_source) { | 2132 bool is_view_source) { |
2143 DCHECK((response && body.get()) || | 2133 DCHECK((response && body.get()) || |
2144 !ShouldMakeNetworkRequestForURL(common_params.url)); | 2134 !ShouldMakeNetworkRequestForURL(common_params.url)); |
2145 UpdatePermissionsForNavigation(common_params, request_params); | 2135 UpdatePermissionsForNavigation(common_params, request_params); |
2146 | 2136 |
2147 // Get back to a clean state, in case we start a new navigation without | 2137 // Get back to a clean state, in case we start a new navigation without |
2148 // completing a RFH swap or unload handler. | 2138 // completing a RFH swap or unload handler. |
2149 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 2139 ResetWaitingState(); |
2150 | 2140 |
2151 // The renderer can exit view source mode when any error or cancellation | 2141 // The renderer can exit view source mode when any error or cancellation |
2152 // happen. When reusing the same renderer, overwrite to recover the mode. | 2142 // happen. When reusing the same renderer, overwrite to recover the mode. |
2153 if (is_view_source && | 2143 if (is_view_source && |
2154 this == frame_tree_node_->render_manager()->current_frame_host()) { | 2144 this == frame_tree_node_->render_manager()->current_frame_host()) { |
2155 DCHECK(!GetParent()); | 2145 DCHECK(!GetParent()); |
2156 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); | 2146 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); |
2157 } | 2147 } |
2158 | 2148 |
2159 const GURL body_url = body.get() ? body->GetURL() : GURL(); | 2149 const GURL body_url = body.get() ? body->GetURL() : GURL(); |
(...skipping 20 matching lines...) Expand all Loading... | |
2180 } | 2170 } |
2181 } | 2171 } |
2182 | 2172 |
2183 void RenderFrameHostImpl::FailedNavigation( | 2173 void RenderFrameHostImpl::FailedNavigation( |
2184 const CommonNavigationParams& common_params, | 2174 const CommonNavigationParams& common_params, |
2185 const RequestNavigationParams& request_params, | 2175 const RequestNavigationParams& request_params, |
2186 bool has_stale_copy_in_cache, | 2176 bool has_stale_copy_in_cache, |
2187 int error_code) { | 2177 int error_code) { |
2188 // Get back to a clean state, in case a new navigation started without | 2178 // Get back to a clean state, in case a new navigation started without |
2189 // completing a RFH swap or unload handler. | 2179 // completing a RFH swap or unload handler. |
2190 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 2180 ResetWaitingState(); |
2191 | 2181 |
2192 Send(new FrameMsg_FailedNavigation(routing_id_, common_params, request_params, | 2182 Send(new FrameMsg_FailedNavigation(routing_id_, common_params, request_params, |
2193 has_stale_copy_in_cache, error_code)); | 2183 has_stale_copy_in_cache, error_code)); |
2194 | 2184 |
2195 // An error page is expected to commit, hence why is_loading_ is set to true. | 2185 // An error page is expected to commit, hence why is_loading_ is set to true. |
2196 is_loading_ = true; | 2186 is_loading_ = true; |
2197 frame_tree_node_->ResetNavigationRequest(true); | 2187 frame_tree_node_->ResetNavigationRequest(true); |
2198 } | 2188 } |
2199 | 2189 |
2200 void RenderFrameHostImpl::SetUpMojoIfNeeded() { | 2190 void RenderFrameHostImpl::SetUpMojoIfNeeded() { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2347 mojo::GetProxy(&mojo_image_downloader_)); | 2337 mojo::GetProxy(&mojo_image_downloader_)); |
2348 } | 2338 } |
2349 return mojo_image_downloader_; | 2339 return mojo_image_downloader_; |
2350 } | 2340 } |
2351 | 2341 |
2352 void RenderFrameHostImpl::ResetLoadingState() { | 2342 void RenderFrameHostImpl::ResetLoadingState() { |
2353 if (is_loading()) { | 2343 if (is_loading()) { |
2354 // When pending deletion, just set the loading state to not loading. | 2344 // When pending deletion, just set the loading state to not loading. |
2355 // Otherwise, OnDidStopLoading will take care of that, as well as sending | 2345 // Otherwise, OnDidStopLoading will take care of that, as well as sending |
2356 // notification to the FrameTreeNode about the change in loading state. | 2346 // notification to the FrameTreeNode about the change in loading state. |
2357 if (rfh_state_ != STATE_DEFAULT) | 2347 if (!is_active()) |
2358 is_loading_ = false; | 2348 is_loading_ = false; |
2359 else | 2349 else |
2360 OnDidStopLoading(); | 2350 OnDidStopLoading(); |
2361 } | 2351 } |
2362 } | 2352 } |
2363 | 2353 |
2364 bool RenderFrameHostImpl::IsSameSiteInstance( | 2354 bool RenderFrameHostImpl::IsSameSiteInstance( |
2365 RenderFrameHostImpl* other_render_frame_host) { | 2355 RenderFrameHostImpl* other_render_frame_host) { |
2366 // As a sanity check, make sure the frame belongs to the same BrowserContext. | 2356 // As a sanity check, make sure the frame belongs to the same BrowserContext. |
2367 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), | 2357 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), |
(...skipping 13 matching lines...) Expand all Loading... | |
2381 ax_tree_snapshot_callbacks_.insert(std::make_pair(callback_id, callback)); | 2371 ax_tree_snapshot_callbacks_.insert(std::make_pair(callback_id, callback)); |
2382 } | 2372 } |
2383 | 2373 |
2384 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( | 2374 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
2385 const base::Callback<void(ui::AXEvent, int)>& callback) { | 2375 const base::Callback<void(ui::AXEvent, int)>& callback) { |
2386 accessibility_testing_callback_ = callback; | 2376 accessibility_testing_callback_ = callback; |
2387 } | 2377 } |
2388 | 2378 |
2389 void RenderFrameHostImpl::UpdateAXTreeData() { | 2379 void RenderFrameHostImpl::UpdateAXTreeData() { |
2390 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 2380 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
2391 if (accessibility_mode == AccessibilityModeOff || | 2381 if (accessibility_mode == AccessibilityModeOff || !is_active()) { |
2392 !RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { | |
2393 return; | 2382 return; |
2394 } | 2383 } |
2395 | 2384 |
2396 std::vector<AXEventNotificationDetails> details; | 2385 std::vector<AXEventNotificationDetails> details; |
2397 details.reserve(1U); | 2386 details.reserve(1U); |
2398 AXEventNotificationDetails detail; | 2387 AXEventNotificationDetails detail; |
2399 detail.ax_tree_id = GetAXTreeID(); | 2388 detail.ax_tree_id = GetAXTreeID(); |
2400 detail.update.has_tree_data = true; | 2389 detail.update.has_tree_data = true; |
2401 AXContentTreeDataToAXTreeData(&detail.update.tree_data); | 2390 AXContentTreeDataToAXTreeData(&detail.update.tree_data); |
2402 details.push_back(detail); | 2391 details.push_back(detail); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2513 if (navigations_suspended_) { | 2502 if (navigations_suspended_) { |
2514 TRACE_EVENT_ASYNC_BEGIN0("navigation", | 2503 TRACE_EVENT_ASYNC_BEGIN0("navigation", |
2515 "RenderFrameHostImpl navigation suspended", this); | 2504 "RenderFrameHostImpl navigation suspended", this); |
2516 } else { | 2505 } else { |
2517 TRACE_EVENT_ASYNC_END0("navigation", | 2506 TRACE_EVENT_ASYNC_END0("navigation", |
2518 "RenderFrameHostImpl navigation suspended", this); | 2507 "RenderFrameHostImpl navigation suspended", this); |
2519 } | 2508 } |
2520 | 2509 |
2521 if (!suspend && suspended_nav_params_) { | 2510 if (!suspend && suspended_nav_params_) { |
2522 // There's navigation message params waiting to be sent. Now that we're not | 2511 // There's navigation message params waiting to be sent. Now that we're not |
2523 // suspended anymore, resume navigation by sending them. If we were swapped | 2512 // suspended anymore, resume navigation by sending them. |
2524 // out, we should also stop filtering out the IPC messages now. | 2513 ResetWaitingState(); |
2525 SetState(RenderFrameHostImpl::STATE_DEFAULT); | |
2526 | 2514 |
2527 DCHECK(!proceed_time.is_null()); | 2515 DCHECK(!proceed_time.is_null()); |
2528 // TODO(csharrison): Make sure that PlzNavigate and the current architecture | 2516 // TODO(csharrison): Make sure that PlzNavigate and the current architecture |
2529 // measure navigation start in the same way in the presence of the | 2517 // measure navigation start in the same way in the presence of the |
2530 // BeforeUnload event. | 2518 // BeforeUnload event. |
2531 suspended_nav_params_->common_params.navigation_start = proceed_time; | 2519 suspended_nav_params_->common_params.navigation_start = proceed_time; |
2532 SendNavigateMessage(suspended_nav_params_->common_params, | 2520 SendNavigateMessage(suspended_nav_params_->common_params, |
2533 suspended_nav_params_->start_params, | 2521 suspended_nav_params_->start_params, |
2534 suspended_nav_params_->request_params); | 2522 suspended_nav_params_->request_params); |
2535 suspended_nav_params_.reset(); | 2523 suspended_nav_params_.reset(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2695 FrameTreeNode* focused_frame_tree_node = frame_tree_->GetFocusedFrame(); | 2683 FrameTreeNode* focused_frame_tree_node = frame_tree_->GetFocusedFrame(); |
2696 if (!focused_frame_tree_node) | 2684 if (!focused_frame_tree_node) |
2697 return; | 2685 return; |
2698 RenderFrameHostImpl* focused_frame = | 2686 RenderFrameHostImpl* focused_frame = |
2699 focused_frame_tree_node->current_frame_host(); | 2687 focused_frame_tree_node->current_frame_host(); |
2700 DCHECK(focused_frame); | 2688 DCHECK(focused_frame); |
2701 dst->focused_tree_id = focused_frame->GetAXTreeID(); | 2689 dst->focused_tree_id = focused_frame->GetAXTreeID(); |
2702 } | 2690 } |
2703 | 2691 |
2704 } // namespace content | 2692 } // namespace content |
OLD | NEW |