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

Unified Diff: content/renderer/render_frame_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: Now only calling BeforeUnload from the embedder Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 8994b8d093f887cd8d38540fc01250776adc17f6..cb15dcad42600a890ed2a2f22da489d90424c264 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -1516,7 +1516,9 @@ void RenderFrameImpl::OnBeforeUnload() {
CHECK(!frame_->parent());
base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
- bool proceed = frame_->dispatchBeforeUnloadEvent();
+ bool proceed;
+ if (!frame_->dispatchBeforeUnloadEvent(&proceed))
+ return;
base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed,
before_unload_start_time,
@@ -4852,6 +4854,17 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
return blink::WebNavigationPolicyIgnore;
}
+ // Execute the BeforeUnload event. If asked not to proceed or the frame is
+ // destroyed, ignore the navigation.
+ bool proceed = false;
+ if (!IsBrowserSideNavigationEnabled() ||
+ info.urlRequest.checkForBrowserSideNavigation()) {
+ // PlzNavigate: this is not executed when commiting the navigation.
+ if (!frame_->dispatchBeforeUnloadEvent(&proceed) || !proceed) {
+ return blink::WebNavigationPolicyIgnore;
+ }
+ }
+
// PlzNavigate: if the navigation is not synchronous, send it to the browser.
// This includes navigations with no request being sent to the network stack.
if (IsBrowserSideNavigationEnabled() &&
@@ -5603,7 +5616,6 @@ void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request,
bool is_client_redirect) {
CHECK(IsBrowserSideNavigationEnabled());
DCHECK(request);
- // TODO(clamy): Execute the beforeunload event.
// Note: At this stage, the goal is to apply all the modifications the
// renderer wants to make to the request, and then send it to the browser, so

Powered by Google App Engine
This is Rietveld 408576698