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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 static DOMWindowSet& windowsWithBeforeUnloadEventListeners() 222 static DOMWindowSet& windowsWithBeforeUnloadEventListeners()
223 { 223 {
224 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithBeforeUnloadEventListeners, ()) ; 224 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithBeforeUnloadEventListeners, ()) ;
225 return windowsWithBeforeUnloadEventListeners; 225 return windowsWithBeforeUnloadEventListeners;
226 } 226 }
227 227
228 static void addUnloadEventListener(LocalDOMWindow* domWindow) 228 static void addUnloadEventListener(LocalDOMWindow* domWindow)
229 { 229 {
230 DOMWindowSet& set = windowsWithUnloadEventListeners(); 230 DOMWindowSet& set = windowsWithUnloadEventListeners();
231 if (set.isEmpty()) 231 if (set.isEmpty())
232 disableSuddenTermination(); 232 disableSuddenTermination();
clamy 2015/01/20 16:47:01 Note: this call as well as the equivalent ones dow
233 set.add(domWindow); 233 set.add(domWindow);
234 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
235 true, FrameLoaderClient::UnloadHandler);
234 } 236 }
235 237
236 static void removeUnloadEventListener(LocalDOMWindow* domWindow) 238 static void removeUnloadEventListener(LocalDOMWindow* domWindow)
237 { 239 {
238 DOMWindowSet& set = windowsWithUnloadEventListeners(); 240 DOMWindowSet& set = windowsWithUnloadEventListeners();
239 DOMWindowSet::iterator it = set.find(domWindow); 241 DOMWindowSet::iterator it = set.find(domWindow);
240 if (it == set.end()) 242 if (it == set.end())
241 return; 243 return;
242 set.remove(it); 244 set.remove(it);
243 if (set.isEmpty()) 245 if (set.isEmpty())
244 enableSuddenTermination(); 246 enableSuddenTermination();
247 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
248 false, FrameLoaderClient::UnloadHandler);
245 } 249 }
246 250
247 static void removeAllUnloadEventListeners(LocalDOMWindow* domWindow) 251 static void removeAllUnloadEventListeners(LocalDOMWindow* domWindow)
248 { 252 {
249 DOMWindowSet& set = windowsWithUnloadEventListeners(); 253 DOMWindowSet& set = windowsWithUnloadEventListeners();
250 DOMWindowSet::iterator it = set.find(domWindow); 254 DOMWindowSet::iterator it = set.find(domWindow);
251 if (it == set.end()) 255 if (it == set.end())
252 return; 256 return;
253 set.removeAll(it); 257 set.removeAll(it);
254 if (set.isEmpty()) 258 if (set.isEmpty())
255 enableSuddenTermination(); 259 enableSuddenTermination();
260 // TODO: remove the right number here
256 } 261 }
257 262
258 static void addBeforeUnloadEventListener(LocalDOMWindow* domWindow) 263 static void addBeforeUnloadEventListener(LocalDOMWindow* domWindow)
259 { 264 {
260 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); 265 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
261 if (set.isEmpty()) 266 if (set.isEmpty())
262 disableSuddenTermination(); 267 disableSuddenTermination();
263 set.add(domWindow); 268 set.add(domWindow);
269 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
270 true, FrameLoaderClient::BeforeUnloadHandler);
264 } 271 }
265 272
266 static void removeBeforeUnloadEventListener(LocalDOMWindow* domWindow) 273 static void removeBeforeUnloadEventListener(LocalDOMWindow* domWindow)
267 { 274 {
268 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); 275 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
269 DOMWindowSet::iterator it = set.find(domWindow); 276 DOMWindowSet::iterator it = set.find(domWindow);
270 if (it == set.end()) 277 if (it == set.end())
271 return; 278 return;
272 set.remove(it); 279 set.remove(it);
273 if (set.isEmpty()) 280 if (set.isEmpty())
274 enableSuddenTermination(); 281 enableSuddenTermination();
282 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
283 false, FrameLoaderClient::BeforeUnloadHandler);
275 } 284 }
276 285
277 static void removeAllBeforeUnloadEventListeners(LocalDOMWindow* domWindow) 286 static void removeAllBeforeUnloadEventListeners(LocalDOMWindow* domWindow)
278 { 287 {
279 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); 288 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
280 DOMWindowSet::iterator it = set.find(domWindow); 289 DOMWindowSet::iterator it = set.find(domWindow);
281 if (it == set.end()) 290 if (it == set.end())
282 return; 291 return;
283 set.removeAll(it); 292 set.removeAll(it);
284 if (set.isEmpty()) 293 if (set.isEmpty())
285 enableSuddenTermination(); 294 enableSuddenTermination();
295 // TODO: remove the right number here
286 } 296 }
287 297
288 static bool allowsBeforeUnloadListeners(LocalDOMWindow* window) 298 static bool allowsBeforeUnloadListeners(LocalDOMWindow* window)
289 { 299 {
290 ASSERT_ARG(window, window); 300 ASSERT_ARG(window, window);
291 LocalFrame* frame = window->frame(); 301 LocalFrame* frame = window->frame();
292 if (!frame) 302 if (!frame)
293 return false; 303 return false;
294 return frame->isMainFrame(); 304 return frame->isMainFrame();
295 } 305 }
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 return m_frameObserver->frame(); 1925 return m_frameObserver->frame();
1916 } 1926 }
1917 1927
1918 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) 1928 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate)
1919 { 1929 {
1920 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. 1930 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8].
1921 return v8::Handle<v8::Object>(); 1931 return v8::Handle<v8::Object>();
1922 } 1932 }
1923 1933
1924 } // namespace blink 1934 } // namespace blink
OLDNEW
« 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