Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 1890493002: PlzNavigate: properly execute BeforeUnload on renderer initiated navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed dcheng's comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // and so no tracing is done. 329 // and so no tracing is done.
330 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( 330 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1(
331 "navigation", "Navigation timeToNetworkStack", 331 "navigation", "Navigation timeToNetworkStack",
332 frame_tree_node->navigation_request()->navigation_handle(), 332 frame_tree_node->navigation_request()->navigation_handle(),
333 navigation_start.ToInternalValue(), 333 navigation_start.ToInternalValue(),
334 "FrameTreeNode id", frame_tree_node->frame_tree_node_id()); 334 "FrameTreeNode id", frame_tree_node->frame_tree_node_id());
335 } 335 }
336 336
337 } else { 337 } else {
338 RenderFrameHostImpl* dest_render_frame_host = 338 RenderFrameHostImpl* dest_render_frame_host =
339 frame_tree_node->render_manager()->Navigate(dest_url, frame_entry, 339 frame_tree_node->render_manager()->Navigate(
340 entry); 340 dest_url, frame_entry, entry,
341 reload_type != NavigationController::NO_RELOAD);
341 if (!dest_render_frame_host) 342 if (!dest_render_frame_host)
342 return false; // Unable to create the desired RenderFrameHost. 343 return false; // Unable to create the desired RenderFrameHost.
343 344
344 // Make sure no code called via RFHM::Navigate clears the pending entry. 345 // Make sure no code called via RFHM::Navigate clears the pending entry.
345 if (is_pending_entry) 346 if (is_pending_entry)
346 CHECK_EQ(controller_->GetPendingEntry(), &entry); 347 CHECK_EQ(controller_->GetPendingEntry(), &entry);
347 348
348 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 349 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
349 // Double check that here. 350 // Double check that here.
350 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); 351 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 navigation_request->CreateNavigationHandle(entry.GetUniqueID()); 997 navigation_request->CreateNavigationHandle(entry.GetUniqueID());
997 998
998 // Have the current renderer execute its beforeunload event if needed. If it 999 // Have the current renderer execute its beforeunload event if needed. If it
999 // is not needed (when beforeunload dispatch is not needed or this navigation 1000 // is not needed (when beforeunload dispatch is not needed or this navigation
1000 // is synchronous and same-site) then NavigationRequest::BeginNavigation 1001 // is synchronous and same-site) then NavigationRequest::BeginNavigation
1001 // should be directly called instead. 1002 // should be directly called instead.
1002 if (should_dispatch_beforeunload && 1003 if (should_dispatch_beforeunload &&
1003 ShouldMakeNetworkRequestForURL( 1004 ShouldMakeNetworkRequestForURL(
1004 navigation_request->common_params().url)) { 1005 navigation_request->common_params().url)) {
1005 navigation_request->SetWaitingForRendererResponse(); 1006 navigation_request->SetWaitingForRendererResponse();
1006 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); 1007 frame_tree_node->current_frame_host()->DispatchBeforeUnload(
1008 true, reload_type != NavigationController::NO_RELOAD);
1007 } else { 1009 } else {
1008 navigation_request->BeginNavigation(); 1010 navigation_request->BeginNavigation();
1009 } 1011 }
1010 } 1012 }
1011 1013
1012 void NavigatorImpl::RecordNavigationMetrics( 1014 void NavigatorImpl::RecordNavigationMetrics(
1013 const LoadCommittedDetails& details, 1015 const LoadCommittedDetails& details,
1014 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1016 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1015 SiteInstance* site_instance) { 1017 SiteInstance* site_instance) {
1016 DCHECK(site_instance->HasProcess()); 1018 DCHECK(site_instance->HasProcess());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 if (pending_entry != controller_->GetVisibleEntry() || 1147 if (pending_entry != controller_->GetVisibleEntry() ||
1146 !should_preserve_entry) { 1148 !should_preserve_entry) {
1147 controller_->DiscardPendingEntry(true); 1149 controller_->DiscardPendingEntry(true);
1148 1150
1149 // Also force the UI to refresh. 1151 // Also force the UI to refresh.
1150 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 1152 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
1151 } 1153 }
1152 } 1154 }
1153 1155
1154 } // namespace content 1156 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698