| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 // navigations can just continue and wait to run the unload handler (by | 430 // navigations can just continue and wait to run the unload handler (by |
| 431 // swapping out) when the new navigation commits. | 431 // swapping out) when the new navigation commits. |
| 432 CHECK(cross_site_transferring_request); | 432 CHECK(cross_site_transferring_request); |
| 433 | 433 |
| 434 // A transfer should only have come from our pending or current RFH. | 434 // A transfer should only have come from our pending or current RFH. |
| 435 // TODO(creis): We need to handle the case that the pending RFH has changed | 435 // TODO(creis): We need to handle the case that the pending RFH has changed |
| 436 // in the mean time, while this was being posted from the IO thread. We | 436 // in the mean time, while this was being posted from the IO thread. We |
| 437 // should probably cancel the request in that case. | 437 // should probably cancel the request in that case. |
| 438 DCHECK(pending_render_frame_host == pending_render_frame_host_.get() || | 438 DCHECK(pending_render_frame_host == pending_render_frame_host_.get() || |
| 439 pending_render_frame_host == render_frame_host_.get()); | 439 pending_render_frame_host == render_frame_host_.get()); |
| 440 DCHECK(frame_tree_node_->IsLoading()); |
| 440 | 441 |
| 441 // Store the transferring request so that we can release it if the transfer | 442 // Store the transferring request so that we can release it if the transfer |
| 442 // navigation matches. | 443 // navigation matches. |
| 443 cross_site_transferring_request_ = std::move(cross_site_transferring_request); | 444 cross_site_transferring_request_ = std::move(cross_site_transferring_request); |
| 444 | 445 |
| 445 // Store the NavigationHandle to give it to the appropriate RenderFrameHost | 446 // Store the NavigationHandle to give it to the appropriate RenderFrameHost |
| 446 // after it started navigating. | 447 // after it started navigating. |
| 447 transfer_navigation_handle_ = | 448 transfer_navigation_handle_ = |
| 448 pending_render_frame_host->PassNavigationHandleOwnership(); | 449 pending_render_frame_host->PassNavigationHandleOwnership(); |
| 449 DCHECK(transfer_navigation_handle_); | 450 DCHECK(transfer_navigation_handle_); |
| 450 | 451 |
| 452 // Set the transferring RenderFrameHost as not loading, so that it does not |
| 453 // emit a DidStopLoading notification if it is destroyed when creating the |
| 454 // new navigating RenderFrameHost. |
| 455 pending_render_frame_host->set_is_loading(false); |
| 456 |
| 451 // Sanity check that the params are for the correct frame and process. | 457 // Sanity check that the params are for the correct frame and process. |
| 452 // These should match the RenderFrameHost that made the request. | 458 // These should match the RenderFrameHost that made the request. |
| 453 // If it started as a cross-process navigation via OpenURL, this is the | 459 // If it started as a cross-process navigation via OpenURL, this is the |
| 454 // pending one. If it wasn't cross-process until the transfer, this is | 460 // pending one. If it wasn't cross-process until the transfer, this is |
| 455 // the current one. | 461 // the current one. |
| 456 int render_frame_id = pending_render_frame_host_ | 462 int render_frame_id = pending_render_frame_host_ |
| 457 ? pending_render_frame_host_->GetRoutingID() | 463 ? pending_render_frame_host_->GetRoutingID() |
| 458 : render_frame_host_->GetRoutingID(); | 464 : render_frame_host_->GetRoutingID(); |
| 459 DCHECK_EQ(render_frame_id, pending_render_frame_host->GetRoutingID()); | 465 DCHECK_EQ(render_frame_id, pending_render_frame_host->GetRoutingID()); |
| 460 int process_id = pending_render_frame_host_ ? | 466 int process_id = pending_render_frame_host_ ? |
| (...skipping 12 matching lines...) Expand all Loading... |
| 473 pending_render_frame_host, transfer_url, rest_of_chain, referrer, | 479 pending_render_frame_host, transfer_url, rest_of_chain, referrer, |
| 474 page_transition, global_request_id, should_replace_current_entry); | 480 page_transition, global_request_id, should_replace_current_entry); |
| 475 | 481 |
| 476 // The transferring request was only needed during the RequestTransferURL | 482 // The transferring request was only needed during the RequestTransferURL |
| 477 // call, so it is safe to clear at this point. | 483 // call, so it is safe to clear at this point. |
| 478 cross_site_transferring_request_.reset(); | 484 cross_site_transferring_request_.reset(); |
| 479 | 485 |
| 480 // If the navigation continued, the NavigationHandle should have been | 486 // If the navigation continued, the NavigationHandle should have been |
| 481 // transfered to a RenderFrameHost. In the other cases, it should be cleared. | 487 // transfered to a RenderFrameHost. In the other cases, it should be cleared. |
| 482 transfer_navigation_handle_.reset(); | 488 transfer_navigation_handle_.reset(); |
| 489 |
| 490 // If the navigation in the new renderer did not start, inform the |
| 491 // FrameTreeNode that it stopped loading. |
| 492 if (!frame_tree_node_->IsLoading()) |
| 493 frame_tree_node_->DidStopLoading(); |
| 483 } | 494 } |
| 484 | 495 |
| 485 void RenderFrameHostManager::DidNavigateFrame( | 496 void RenderFrameHostManager::DidNavigateFrame( |
| 486 RenderFrameHostImpl* render_frame_host, | 497 RenderFrameHostImpl* render_frame_host, |
| 487 bool was_caused_by_user_gesture) { | 498 bool was_caused_by_user_gesture) { |
| 488 CommitPendingIfNecessary(render_frame_host, was_caused_by_user_gesture); | 499 CommitPendingIfNecessary(render_frame_host, was_caused_by_user_gesture); |
| 489 | 500 |
| 490 // Make sure any dynamic changes to this frame's sandbox flags that were made | 501 // Make sure any dynamic changes to this frame's sandbox flags that were made |
| 491 // prior to navigation take effect. | 502 // prior to navigation take effect. |
| 492 CommitPendingSandboxFlags(); | 503 CommitPendingSandboxFlags(); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 if (notify_webui_of_rv_creation && GetNavigatingWebUI()) | 916 if (notify_webui_of_rv_creation && GetNavigatingWebUI()) |
| 906 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host()); | 917 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host()); |
| 907 | 918 |
| 908 return navigation_rfh; | 919 return navigation_rfh; |
| 909 } | 920 } |
| 910 | 921 |
| 911 // PlzNavigate | 922 // PlzNavigate |
| 912 void RenderFrameHostManager::CleanUpNavigation() { | 923 void RenderFrameHostManager::CleanUpNavigation() { |
| 913 CHECK(IsBrowserSideNavigationEnabled()); | 924 CHECK(IsBrowserSideNavigationEnabled()); |
| 914 render_frame_host_->ClearPendingWebUI(); | 925 render_frame_host_->ClearPendingWebUI(); |
| 915 if (speculative_render_frame_host_) | 926 if (speculative_render_frame_host_) { |
| 927 bool was_loading = speculative_render_frame_host_->is_loading(); |
| 916 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); | 928 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); |
| 929 if (was_loading) |
| 930 frame_tree_node_->DidStopLoading(); |
| 931 } |
| 917 } | 932 } |
| 918 | 933 |
| 919 // PlzNavigate | 934 // PlzNavigate |
| 920 scoped_ptr<RenderFrameHostImpl> | 935 scoped_ptr<RenderFrameHostImpl> |
| 921 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { | 936 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { |
| 922 CHECK(IsBrowserSideNavigationEnabled()); | 937 CHECK(IsBrowserSideNavigationEnabled()); |
| 923 speculative_render_frame_host_->GetProcess()->RemovePendingView(); | 938 speculative_render_frame_host_->GetProcess()->RemovePendingView(); |
| 924 return std::move(speculative_render_frame_host_); | 939 return std::move(speculative_render_frame_host_); |
| 925 } | 940 } |
| 926 | 941 |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 if (!delegate_->IsHidden() && new_rfh_has_view) { | 2010 if (!delegate_->IsHidden() && new_rfh_has_view) { |
| 1996 // In most cases, we need to show the new view. | 2011 // In most cases, we need to show the new view. |
| 1997 render_frame_host_->GetView()->Show(); | 2012 render_frame_host_->GetView()->Show(); |
| 1998 } | 2013 } |
| 1999 if (!new_rfh_has_view) { | 2014 if (!new_rfh_has_view) { |
| 2000 // If the view is gone, then this RenderViewHost died while it was hidden. | 2015 // If the view is gone, then this RenderViewHost died while it was hidden. |
| 2001 // We ignored the RenderProcessGone call at the time, so we should send it | 2016 // We ignored the RenderProcessGone call at the time, so we should send it |
| 2002 // now to make sure the sad tab shows up, etc. | 2017 // now to make sure the sad tab shows up, etc. |
| 2003 DCHECK(!render_frame_host_->IsRenderFrameLive()); | 2018 DCHECK(!render_frame_host_->IsRenderFrameLive()); |
| 2004 DCHECK(!render_frame_host_->render_view_host()->IsRenderViewLive()); | 2019 DCHECK(!render_frame_host_->render_view_host()->IsRenderViewLive()); |
| 2020 render_frame_host_->ResetLoadingState(); |
| 2005 delegate_->RenderProcessGoneFromRenderManager( | 2021 delegate_->RenderProcessGoneFromRenderManager( |
| 2006 render_frame_host_->render_view_host()); | 2022 render_frame_host_->render_view_host()); |
| 2007 } | 2023 } |
| 2008 | 2024 |
| 2009 // For top-level frames, also hide the old RenderViewHost's view. | 2025 // For top-level frames, also hide the old RenderViewHost's view. |
| 2010 // TODO(creis): As long as show/hide are on RVH, we don't want to hide on | 2026 // TODO(creis): As long as show/hide are on RVH, we don't want to hide on |
| 2011 // subframe navigations or we will interfere with the top-level frame. | 2027 // subframe navigations or we will interfere with the top-level frame. |
| 2012 if (is_main_frame && | 2028 if (is_main_frame && |
| 2013 old_render_frame_host->render_view_host()->GetWidget()->GetView()) { | 2029 old_render_frame_host->render_view_host()->GetWidget()->GetView()) { |
| 2014 old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide(); | 2030 old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2246 render_frame_host_->pending_web_ui()->RenderViewCreated( | 2262 render_frame_host_->pending_web_ui()->RenderViewCreated( |
| 2247 render_frame_host_->render_view_host()); | 2263 render_frame_host_->render_view_host()); |
| 2248 } | 2264 } |
| 2249 } | 2265 } |
| 2250 } | 2266 } |
| 2251 | 2267 |
| 2252 void RenderFrameHostManager::CancelPending() { | 2268 void RenderFrameHostManager::CancelPending() { |
| 2253 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending", | 2269 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending", |
| 2254 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 2270 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
| 2255 render_frame_host_->ClearPendingWebUI(); | 2271 render_frame_host_->ClearPendingWebUI(); |
| 2272 |
| 2273 bool pending_was_loading = pending_render_frame_host_->is_loading(); |
| 2256 DiscardUnusedFrame(UnsetPendingRenderFrameHost()); | 2274 DiscardUnusedFrame(UnsetPendingRenderFrameHost()); |
| 2275 if (pending_was_loading) |
| 2276 frame_tree_node_->DidStopLoading(); |
| 2257 } | 2277 } |
| 2258 | 2278 |
| 2259 scoped_ptr<RenderFrameHostImpl> | 2279 scoped_ptr<RenderFrameHostImpl> |
| 2260 RenderFrameHostManager::UnsetPendingRenderFrameHost() { | 2280 RenderFrameHostManager::UnsetPendingRenderFrameHost() { |
| 2261 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = | 2281 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = |
| 2262 std::move(pending_render_frame_host_); | 2282 std::move(pending_render_frame_host_); |
| 2263 | 2283 |
| 2264 RenderFrameDevToolsAgentHost::OnCancelPendingNavigation( | 2284 RenderFrameDevToolsAgentHost::OnCancelPendingNavigation( |
| 2265 pending_render_frame_host.get(), | 2285 pending_render_frame_host.get(), |
| 2266 render_frame_host_.get()); | 2286 render_frame_host_.get()); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2504 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
| 2485 if (!frame_tree_node_->opener()) | 2505 if (!frame_tree_node_->opener()) |
| 2486 return MSG_ROUTING_NONE; | 2506 return MSG_ROUTING_NONE; |
| 2487 | 2507 |
| 2488 return frame_tree_node_->opener() | 2508 return frame_tree_node_->opener() |
| 2489 ->render_manager() | 2509 ->render_manager() |
| 2490 ->GetRoutingIdForSiteInstance(instance); | 2510 ->GetRoutingIdForSiteInstance(instance); |
| 2491 } | 2511 } |
| 2492 | 2512 |
| 2493 } // namespace content | 2513 } // namespace content |
| OLD | NEW |