Chromium Code Reviews| Index: content/browser/frame_host/navigator_impl.cc |
| diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc |
| index aff92459639e88b0a6b77752b4de2b3ae1ea43d8..f4a04fb59f90d5c5e5819ed97b24adef61cbcf31 100644 |
| --- a/content/browser/frame_host/navigator_impl.cc |
| +++ b/content/browser/frame_host/navigator_impl.cc |
| @@ -600,8 +600,9 @@ void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, |
| DCHECK_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, |
| navigation_request->state()); |
| + // If the navigation is allowed to proceed, send the request to the IO thread. |
| if (proceed) |
| - BeginNavigation(frame_tree_node); |
| + navigation_request->BeginNavigation(); |
| else |
| CancelNavigation(frame_tree_node); |
| } |
| @@ -655,7 +656,7 @@ void NavigatorImpl::OnBeginNavigation( |
| navigation_data_.reset(); |
| } |
| - BeginNavigation(frame_tree_node); |
| + frame_tree_node->navigation_request()->BeginNavigation(); |
| } |
| // PlzNavigate |
| @@ -805,40 +806,29 @@ void NavigatorImpl::RequestNavigation( |
| DCHECK(frame_tree_node); |
| FrameMsg_Navigate_Type::Value navigation_type = |
| GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| - scoped_ptr<NavigationRequest> navigation_request = |
| + // This value must be set here because SetNavigationRequest might change the |
| + // renderer live/non-live status and change this result. |
| + bool should_dispatch_beforeunload = |
| + frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); |
| + frame_tree_node->SetNavigationRequest( |
| NavigationRequest::CreateBrowserInitiated(frame_tree_node, entry, |
| navigation_type, |
| - navigation_start, controller_); |
| - frame_tree_node->SetNavigationRequest(navigation_request.Pass()); |
| - frame_tree_node->navigation_request()->SetWaitingForRendererResponse(); |
| + navigation_start, controller_)); |
| + NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| // Have the current renderer execute its beforeUnload event if needed. If it |
| - // is not needed (eg. the renderer is not live), BeginNavigation should get |
| - // called. If the navigation is synchronous and same-site, then it can be sent |
| - // directly to the renderer (currently this is the case for navigations that |
| - // do not make network requests such as data urls or Javascript urls). |
| - if (NavigationRequest::ShouldMakeNetworkRequest( |
| - frame_tree_node->navigation_request()->common_params().url)) { |
| + // is not needed (eg. the renderer is not live), |
| + // NavigationRequest::BeginNavigation should get called. If the navigation is |
|
clamy
2015/06/10 12:30:27
I think this comment needs a bit of rephrasing to
carlosk
2015/06/10 13:15:05
Done.
|
| + // synchronous and same-site, then it can be sent directly to the current |
| + // renderer (currently this is the case for navigations that do not make |
| + // network requests such as data urls or Javascript urls). |
| + if (should_dispatch_beforeunload && |
| + NavigationRequest::ShouldMakeNetworkRequest( |
| + navigation_request->common_params().url)) { |
| + navigation_request->SetWaitingForRendererResponse(); |
| frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); |
| } else { |
| - BeginNavigation(frame_tree_node); |
| - } |
| -} |
| - |
| -void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) { |
| - NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| - |
| - // A browser-initiated navigation could have been cancelled while it was |
| - // waiting for the BeforeUnload event to execute. |
| - if (!navigation_request) |
| - return; |
| - |
| - // Start the request. |
| - if (navigation_request->BeginNavigation()) { |
| - // If the request was sent to the IO thread, notify the |
| - // RenderFrameHostManager so it can speculatively create a RenderFrameHost |
| - // (and potentially a new renderer process) in parallel. |
| - frame_tree_node->render_manager()->BeginNavigation(*navigation_request); |
| + navigation_request->BeginNavigation(); |
| } |
| } |