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_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // in progress. Sanity check this for http://crbug.com/276333. | 274 // in progress. Sanity check this for http://crbug.com/276333. |
275 CHECK(pending_render_frame_host_); | 275 CHECK(pending_render_frame_host_); |
276 | 276 |
277 // Unload handlers run in the background, so we should never get an | 277 // Unload handlers run in the background, so we should never get an |
278 // unresponsiveness warning for them. | 278 // unresponsiveness warning for them. |
279 CHECK(!render_frame_host_->IsWaitingForUnloadACK()); | 279 CHECK(!render_frame_host_->IsWaitingForUnloadACK()); |
280 | 280 |
281 // If the tab becomes unresponsive during beforeunload while doing a | 281 // If the tab becomes unresponsive during beforeunload while doing a |
282 // cross-site navigation, proceed with the navigation. (This assumes that | 282 // cross-site navigation, proceed with the navigation. (This assumes that |
283 // the pending RenderFrameHost is still responsive.) | 283 // the pending RenderFrameHost is still responsive.) |
284 if (render_frame_host_->is_waiting_for_beforeunload_ack()) { | 284 if (render_frame_host_->IsWaitingForBeforeUnloadACK()) { |
285 // Haven't gotten around to starting the request, because we're still | 285 // Haven't gotten around to starting the request, because we're still |
286 // waiting for the beforeunload handler to finish. We'll pretend that it | 286 // waiting for the beforeunload handler to finish. We'll pretend that it |
287 // did finish, to let the navigation proceed. Note that there's a danger | 287 // did finish, to let the navigation proceed. Note that there's a danger |
288 // that the beforeunload handler will later finish and possibly return | 288 // that the beforeunload handler will later finish and possibly return |
289 // false (meaning the navigation should not proceed), but we'll ignore it | 289 // false (meaning the navigation should not proceed), but we'll ignore it |
290 // in this case because it took too long. | 290 // in this case because it took too long. |
291 if (pending_render_frame_host_->are_navigations_suspended()) { | 291 if (pending_render_frame_host_->are_navigations_suspended()) { |
292 pending_render_frame_host_->SetNavigationsSuspended( | 292 pending_render_frame_host_->SetNavigationsSuspended( |
293 false, base::TimeTicks::Now()); | 293 false, base::TimeTicks::Now()); |
294 } | 294 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 453 |
454 // Even when there is no pending RVH, there may be a pending Web UI. | 454 // Even when there is no pending RVH, there may be a pending Web UI. |
455 if (pending_web_ui()) | 455 if (pending_web_ui()) |
456 CommitPending(); | 456 CommitPending(); |
457 return; | 457 return; |
458 } | 458 } |
459 | 459 |
460 if (render_frame_host == pending_render_frame_host_) { | 460 if (render_frame_host == pending_render_frame_host_) { |
461 // The pending cross-site navigation completed, so show the renderer. | 461 // The pending cross-site navigation completed, so show the renderer. |
462 CommitPending(); | 462 CommitPending(); |
463 cross_navigation_pending_ = false; | |
464 } else if (render_frame_host == render_frame_host_) { | 463 } else if (render_frame_host == render_frame_host_) { |
465 if (was_caused_by_user_gesture) { | 464 if (was_caused_by_user_gesture) { |
466 // A navigation in the original page has taken place. Cancel the pending | 465 // A navigation in the original page has taken place. Cancel the pending |
467 // one. Only do it for user gesture originated navigations to prevent | 466 // one. Only do it for user gesture originated navigations to prevent |
468 // page doing any shenanigans to prevent user from navigating. | 467 // page doing any shenanigans to prevent user from navigating. |
469 // See https://code.google.com/p/chromium/issues/detail?id=75195 | 468 // See https://code.google.com/p/chromium/issues/detail?id=75195 |
470 CancelPending(); | 469 CancelPending(); |
471 cross_navigation_pending_ = false; | 470 cross_navigation_pending_ = false; |
472 } | 471 } |
473 } else { | 472 } else { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 if (!navigation_rfh->IsRenderFrameLive()) { | 729 if (!navigation_rfh->IsRenderFrameLive()) { |
731 // Recreate the opener chain. | 730 // Recreate the opener chain. |
732 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( | 731 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( |
733 navigation_rfh->GetSiteInstance()); | 732 navigation_rfh->GetSiteInstance()); |
734 if (!InitRenderView(navigation_rfh->render_view_host(), opener_route_id, | 733 if (!InitRenderView(navigation_rfh->render_view_host(), opener_route_id, |
735 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame())) { | 734 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame())) { |
736 return nullptr; | 735 return nullptr; |
737 } | 736 } |
738 } | 737 } |
739 | 738 |
| 739 cross_navigation_pending_ = navigation_rfh != render_frame_host_.get(); |
740 return navigation_rfh; | 740 return navigation_rfh; |
741 } | 741 } |
742 | 742 |
743 // PlzNavigate | 743 // PlzNavigate |
744 void RenderFrameHostManager::CleanUpNavigation() { | 744 void RenderFrameHostManager::CleanUpNavigation() { |
745 if (speculative_render_frame_host_) | 745 if (speculative_render_frame_host_) |
746 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); | 746 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); |
747 } | 747 } |
748 | 748 |
749 // PlzNavigate | 749 // PlzNavigate |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 if (!browser_side_navigation) { | 1514 if (!browser_side_navigation) { |
1515 DCHECK(!speculative_render_frame_host_); | 1515 DCHECK(!speculative_render_frame_host_); |
1516 old_render_frame_host = | 1516 old_render_frame_host = |
1517 SetRenderFrameHost(pending_render_frame_host_.Pass()); | 1517 SetRenderFrameHost(pending_render_frame_host_.Pass()); |
1518 } else { | 1518 } else { |
1519 // PlzNavigate | 1519 // PlzNavigate |
1520 DCHECK(speculative_render_frame_host_); | 1520 DCHECK(speculative_render_frame_host_); |
1521 old_render_frame_host = | 1521 old_render_frame_host = |
1522 SetRenderFrameHost(speculative_render_frame_host_.Pass()); | 1522 SetRenderFrameHost(speculative_render_frame_host_.Pass()); |
1523 } | 1523 } |
| 1524 cross_navigation_pending_ = false; |
1524 | 1525 |
1525 if (is_main_frame) | 1526 if (is_main_frame) |
1526 render_frame_host_->render_view_host()->AttachToFrameTree(); | 1527 render_frame_host_->render_view_host()->AttachToFrameTree(); |
1527 | 1528 |
1528 // The process will no longer try to exit, so we can decrement the count. | 1529 // The process will no longer try to exit, so we can decrement the count. |
1529 render_frame_host_->GetProcess()->RemovePendingView(); | 1530 render_frame_host_->GetProcess()->RemovePendingView(); |
1530 | 1531 |
1531 // Show the new view (or a sad tab) if necessary. | 1532 // Show the new view (or a sad tab) if necessary. |
1532 bool new_rfh_has_view = !!render_frame_host_->render_view_host()->GetView(); | 1533 bool new_rfh_has_view = !!render_frame_host_->render_view_host()->GetView(); |
1533 if (!delegate_->IsHidden() && new_rfh_has_view) { | 1534 if (!delegate_->IsHidden() && new_rfh_has_view) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1868 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1869 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1869 SiteInstance* instance) { | 1870 SiteInstance* instance) { |
1870 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1871 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1871 if (iter != proxy_hosts_.end()) { | 1872 if (iter != proxy_hosts_.end()) { |
1872 delete iter->second; | 1873 delete iter->second; |
1873 proxy_hosts_.erase(iter); | 1874 proxy_hosts_.erase(iter); |
1874 } | 1875 } |
1875 } | 1876 } |
1876 | 1877 |
1877 } // namespace content | 1878 } // namespace content |
OLD | NEW |