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

Unified Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 2803633004: Revert of Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « content/test/test_render_frame_host.h ('k') | ui/views/controls/webview/web_dialog_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
diff --git a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
index b4fd3fe539ce39913ff720a61d538780bdbdfdfb..222a4e02ce27fb3d427ec684553fc1c35090b7b8 100644
--- a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
+++ b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
@@ -254,6 +254,14 @@
}
}
+static bool allowsBeforeUnloadListeners(LocalDOMWindow* window) {
+ DCHECK(window);
+ LocalFrame* frame = window->frame();
+ if (!frame)
+ return false;
+ return frame->isMainFrame();
+}
+
unsigned LocalDOMWindow::pendingUnloadEventListeners() const {
return windowsWithUnloadEventListeners().count(
const_cast<LocalDOMWindow*>(this));
@@ -1425,9 +1433,16 @@
addUnloadEventListener(this);
} else if (eventType == EventTypeNames::beforeunload) {
UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered);
- addBeforeUnloadEventListener(this);
- if (frame() && !frame()->isMainFrame())
+ if (allowsBeforeUnloadListeners(this)) {
+ // This is confusingly named. It doesn't actually add the listener. It
+ // just increments a count so that we know we have listeners registered
+ // for the purposes of determining if we can fast terminate the renderer
+ // process.
+ addBeforeUnloadEventListener(this);
+ } else {
+ // Subframes return false from allowsBeforeUnloadListeners.
UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegistered);
+ }
}
}
@@ -1445,7 +1460,8 @@
if (eventType == EventTypeNames::unload) {
removeUnloadEventListener(this);
- } else if (eventType == EventTypeNames::beforeunload) {
+ } else if (eventType == EventTypeNames::beforeunload &&
+ allowsBeforeUnloadListeners(this)) {
removeBeforeUnloadEventListener(this);
}
}
« no previous file with comments | « content/test/test_render_frame_host.h ('k') | ui/views/controls/webview/web_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698