Chromium Code Reviews| Index: content/renderer/render_frame_impl.cc |
| diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
| index 4a1b6f93e2d16a899f2d54a0f0c1a2ffc38e3a16..292b513d2f28e21313098c4db418f4d5d6b35b12 100644 |
| --- a/content/renderer/render_frame_impl.cc |
| +++ b/content/renderer/render_frame_impl.cc |
| @@ -4671,6 +4671,7 @@ void RenderFrameImpl::OnFailedNavigation( |
| WebURLRequest failed_request = CreateURLRequestForNavigation( |
| common_params, std::unique_ptr<StreamOverrideParameters>(), |
| frame_->isViewSourceModeEnabled()); |
| + failed_request.setBypassBeforeUnload(true); |
| SendFailedProvisionalLoad(failed_request, error, frame_); |
| // This check should have been done on the browser side already. |
| @@ -4858,9 +4859,15 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( |
| if (IsBrowserSideNavigationEnabled() && |
| info.urlRequest.checkForBrowserSideNavigation() && |
| ShouldMakeNetworkRequestForURL(url)) { |
| - BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, |
| - info.isClientRedirect); |
| - return blink::WebNavigationPolicyHandledByClient; |
| + // Check if the navigation can be sent to the browser, otherwise ignore it. |
| + bool proceeding_with_navigation = |
| + BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, |
| + info.isClientRedirect); |
| + // DO NOT ADD CODE AFTER THIS FUNCTION. It executes the BeforeUnload event |
|
nasko
2016/04/15 14:42:22
nit: "AFTER THIS FUNCTION" < The function or funct
|
| + // for the frame, which may delete the RenderFrameImpl. |
| + return proceeding_with_navigation |
| + ? blink::WebNavigationPolicyHandledByClient |
| + : blink::WebNavigationPolicyIgnore; |
|
nasko
2016/04/15 14:42:22
Isn't the beforeunload event already invoked befor
clamy
2016/04/15 14:45:54
No it's executed right afterwards (hence why I hav
dcheng
2016/04/15 17:21:42
Hmm, we should try to figure out how to make Blink
clamy
2016/04/25 11:36:55
The problem is that the call to decidePolicyForNav
dcheng
2016/04/26 06:32:31
Hmm, I see the problem, but I think it's awkward t
clamy
2016/04/26 10:07:09
The bit in WebURLRequest is not coming from this p
dcheng
2016/04/27 09:21:29
Part of me thinks that it's weird to expose intern
clamy
2016/04/27 11:29:27
I'm not really sure how OOPIF works here in the cu
dcheng
2016/04/27 13:42:04
I think there should only be one place that runs t
|
| } |
| return info.defaultPolicy; |
| @@ -5291,6 +5298,13 @@ void RenderFrameImpl::NavigateInternal( |
| CreateURLRequestForNavigation(common_params, std::move(stream_params), |
| frame_->isViewSourceModeEnabled()); |
| + // PlzNavigate: If the navigation made a network request, the BeforeUnload |
| + // event has already executed. Bypass it when committing the navigation. |
| + if (IsBrowserSideNavigationEnabled() && |
| + ShouldMakeNetworkRequestForURL(common_params.url)) { |
| + request.setBypassBeforeUnload(true); |
| + } |
| + |
| // Used to determine whether this frame is actually loading a request as part |
| // of a history navigation. |
| bool has_history_navigation_in_frame = false; |
| @@ -5597,12 +5611,16 @@ void RenderFrameImpl::PrepareRenderViewForNavigation( |
| } |
| } |
| -void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, |
| +bool RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, |
| bool should_replace_current_entry, |
| bool is_client_redirect) { |
| CHECK(IsBrowserSideNavigationEnabled()); |
| DCHECK(request); |
| - // TODO(clamy): Execute the beforeunload event. |
| + |
| + // Execute the BeforeUnload for main frames, If asked not to proceed, do not |
| + // send the navigation request to the browser. |
| + if (!frame_->dispatchBeforeUnloadEvent()) |
| + return false; |
| // 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 |
| @@ -5653,6 +5671,7 @@ void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, |
| request->skipServiceWorker(), |
| GetRequestContextTypeForWebURLRequest(*request)), |
| GetRequestBodyForWebURLRequest(*request))); |
| + return true; |
| } |
| void RenderFrameImpl::LoadDataURL( |