Commit 51213036 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Simplify beforeunload dispatching rules.

The complex rules come from http://crrev.com/eacad605 where the
navigationStart was set after the beforeunload handler. This code no
longer exists and the original conditions can be removed.

BUG=1040954

Change-Id: Ifeb7c430af1ec31498d916a5dc343ac041ba8d3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008074Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733874}
parent 6053bde0
...@@ -5943,21 +5943,11 @@ void RenderFrameImpl::BeginNavigation( ...@@ -5943,21 +5943,11 @@ void RenderFrameImpl::BeginNavigation(
} }
} }
bool should_dispatch_before_unload = if (info->navigation_policy == blink::kWebNavigationPolicyCurrentTab) {
info->navigation_policy == blink::kWebNavigationPolicyCurrentTab &&
// No need to dispatch beforeunload if the frame has not committed a
// navigation and contains an empty initial document.
// TODO(dtapuska): crbug.com/1040954 Try to remove the
// HasAccessedInitialDocument interface for this. There shouldn't be a
// beforeunload handler if it hasn't accessed the initial document so it
// should be fine to dispatch in those cases.
(frame_->HasAccessedInitialDocument() || !current_history_item_.IsNull());
if (should_dispatch_before_unload) {
// Execute the BeforeUnload event. If asked not to proceed or the frame is // Execute the BeforeUnload event. If asked not to proceed or the frame is
// destroyed, ignore the navigation. // destroyed, ignore the navigation.
// Keep a WeakPtr to this RenderFrameHost to detect if executing the // Keep a WeakPtr to this RenderFrameHost to detect if executing the
// BeforeUnload event destriyed this frame. // BeforeUnload event destroyed this frame.
base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr(); base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr();
if (!frame_->DispatchBeforeUnloadEvent(info->navigation_type == if (!frame_->DispatchBeforeUnloadEvent(info->navigation_type ==
......
...@@ -156,11 +156,6 @@ class WebLocalFrame : public WebFrame { ...@@ -156,11 +156,6 @@ class WebLocalFrame : public WebFrame {
// Runs unload handlers for this frame. // Runs unload handlers for this frame.
virtual void DispatchUnloadEvent() = 0; virtual void DispatchUnloadEvent() = 0;
// Indicates that the DOM of the initial empty document has been
// accessed via javascript. The BeforeUnload event will not be dispatched
// if the initial document has not been accessed.
virtual bool HasAccessedInitialDocument() = 0;
// Basic properties --------------------------------------------------- // Basic properties ---------------------------------------------------
// The urls of the given combination types of favicon (if any) specified by // The urls of the given combination types of favicon (if any) specified by
......
...@@ -761,11 +761,6 @@ void WebLocalFrameImpl::DispatchUnloadEvent() { ...@@ -761,11 +761,6 @@ void WebLocalFrameImpl::DispatchUnloadEvent() {
GetFrame()->Loader().DispatchUnloadEvent(nullptr, nullptr); GetFrame()->Loader().DispatchUnloadEvent(nullptr, nullptr);
} }
bool WebLocalFrameImpl::HasAccessedInitialDocument() {
DCHECK(GetFrame());
return GetFrame()->Loader().HasAccessedInitialDocument();
}
void WebLocalFrameImpl::ExecuteScript(const WebScriptSource& source) { void WebLocalFrameImpl::ExecuteScript(const WebScriptSource& source) {
DCHECK(GetFrame()); DCHECK(GetFrame());
v8::HandleScope handle_scope(ToIsolate(GetFrame())); v8::HandleScope handle_scope(ToIsolate(GetFrame()));
......
...@@ -112,7 +112,6 @@ class CORE_EXPORT WebLocalFrameImpl final ...@@ -112,7 +112,6 @@ class CORE_EXPORT WebLocalFrameImpl final
void SetContentCaptureClient(WebContentCaptureClient*) override; void SetContentCaptureClient(WebContentCaptureClient*) override;
WebContentCaptureClient* ContentCaptureClient() const override; WebContentCaptureClient* ContentCaptureClient() const override;
void DispatchUnloadEvent() override; void DispatchUnloadEvent() override;
bool HasAccessedInitialDocument() override;
WebVector<WebIconURL> IconURLs(int icon_types_mask) const override; WebVector<WebIconURL> IconURLs(int icon_types_mask) const override;
WebDocument GetDocument() const override; WebDocument GetDocument() const override;
WebString AssignedName() const override; WebString AssignedName() const override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment