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

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

Issue 861773003: Inform the WebFrameClient of BeforeUnload/Unload handlers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed nit Created 5 years, 11 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 | « no previous file | Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/LocalDOMWindow.cpp
diff --git a/Source/core/frame/LocalDOMWindow.cpp b/Source/core/frame/LocalDOMWindow.cpp
index 2bf805eb1633fed52ff5ab329a28ba2c3c861f5a..e78d9a57326fd8f7f8911e01b84ae32566bd8a69 100644
--- a/Source/core/frame/LocalDOMWindow.cpp
+++ b/Source/core/frame/LocalDOMWindow.cpp
@@ -231,6 +231,10 @@ static void addUnloadEventListener(LocalDOMWindow* domWindow)
if (set.isEmpty())
disableSuddenTermination();
set.add(domWindow);
+ if (domWindow->frame()) {
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ 1, FrameLoaderClient::UnloadHandler);
+ }
}
static void removeUnloadEventListener(LocalDOMWindow* domWindow)
@@ -242,6 +246,10 @@ static void removeUnloadEventListener(LocalDOMWindow* domWindow)
set.remove(it);
if (set.isEmpty())
enableSuddenTermination();
+ if (domWindow->frame()) {
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ -1, FrameLoaderClient::UnloadHandler);
+ }
}
static void removeAllUnloadEventListeners(LocalDOMWindow* domWindow)
@@ -250,9 +258,14 @@ static void removeAllUnloadEventListeners(LocalDOMWindow* domWindow)
DOMWindowSet::iterator it = set.find(domWindow);
if (it == set.end())
return;
+ int numHandlers = set.count(domWindow);
set.removeAll(it);
if (set.isEmpty())
enableSuddenTermination();
+ if (domWindow->frame()) {
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ -numHandlers, FrameLoaderClient::UnloadHandler);
+ }
}
static void addBeforeUnloadEventListener(LocalDOMWindow* domWindow)
@@ -261,6 +274,10 @@ static void addBeforeUnloadEventListener(LocalDOMWindow* domWindow)
if (set.isEmpty())
disableSuddenTermination();
set.add(domWindow);
+ if (domWindow->frame()) {
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ 1, FrameLoaderClient::BeforeUnloadHandler);
+ }
}
static void removeBeforeUnloadEventListener(LocalDOMWindow* domWindow)
@@ -272,6 +289,10 @@ static void removeBeforeUnloadEventListener(LocalDOMWindow* domWindow)
set.remove(it);
if (set.isEmpty())
enableSuddenTermination();
+ if (domWindow->frame()) {
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ -1, FrameLoaderClient::BeforeUnloadHandler);
+ }
}
static void removeAllBeforeUnloadEventListeners(LocalDOMWindow* domWindow)
@@ -280,9 +301,14 @@ static void removeAllBeforeUnloadEventListeners(LocalDOMWindow* domWindow)
DOMWindowSet::iterator it = set.find(domWindow);
if (it == set.end())
return;
+ int numHandlers = set.count(domWindow);
set.removeAll(it);
if (set.isEmpty())
enableSuddenTermination();
+ if (domWindow->frame()) {
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ -numHandlers, FrameLoaderClient::BeforeUnloadHandler);
+ }
}
static bool allowsBeforeUnloadListeners(LocalDOMWindow* window)
« no previous file with comments | « no previous file | Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698