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

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: 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') | Source/core/loader/FrameLoaderClient.h » ('J')
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 ee80a05b0ddfa044471e6f6a30942a0f01963611..f1b8ebc6bc82ac8507f303beabca82b9a0626671 100644
--- a/Source/core/frame/LocalDOMWindow.cpp
+++ b/Source/core/frame/LocalDOMWindow.cpp
@@ -231,6 +231,8 @@ static void addUnloadEventListener(LocalDOMWindow* domWindow)
if (set.isEmpty())
disableSuddenTermination();
set.add(domWindow);
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ 1, FrameLoaderClient::UnloadHandler);
}
static void removeUnloadEventListener(LocalDOMWindow* domWindow)
@@ -242,6 +244,8 @@ static void removeUnloadEventListener(LocalDOMWindow* domWindow)
set.remove(it);
if (set.isEmpty())
enableSuddenTermination();
Nate Chapin 2015/01/20 18:46:49 Will we eventually be able to remove these enable/
clamy 2015/01/21 13:46:31 Yes, when the chromium side patch lands we should
Nate Chapin 2015/01/21 19:51:42 Interesting, I would have thought that local stora
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
Nate Chapin 2015/01/20 18:46:49 Is this safe? domWindow->frame() can be null at ve
clamy 2015/01/21 13:46:31 In that case I added a check for domWindow->frame(
Nate Chapin 2015/01/21 19:51:42 I did a quick look and didn't see anything that wo
+ -1, FrameLoaderClient::UnloadHandler);
}
static void removeAllUnloadEventListeners(LocalDOMWindow* domWindow)
@@ -250,9 +254,12 @@ 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();
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ -numHandlers, FrameLoaderClient::UnloadHandler);
}
static void addBeforeUnloadEventListener(LocalDOMWindow* domWindow)
@@ -261,6 +268,8 @@ static void addBeforeUnloadEventListener(LocalDOMWindow* domWindow)
if (set.isEmpty())
disableSuddenTermination();
set.add(domWindow);
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ 1, FrameLoaderClient::BeforeUnloadHandler);
}
static void removeBeforeUnloadEventListener(LocalDOMWindow* domWindow)
@@ -272,6 +281,8 @@ static void removeBeforeUnloadEventListener(LocalDOMWindow* domWindow)
set.remove(it);
if (set.isEmpty())
enableSuddenTermination();
+ domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
+ -1, FrameLoaderClient::BeforeUnloadHandler);
}
static void removeAllBeforeUnloadEventListeners(LocalDOMWindow* domWindow)
@@ -280,9 +291,12 @@ 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();
+ 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') | Source/core/loader/FrameLoaderClient.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698