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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 2812743002: Revert of Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: manual merge 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 unified diff | 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 »
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 DOMWindowSet::iterator it = set.Find(dom_window); 248 DOMWindowSet::iterator it = set.Find(dom_window);
249 if (it == set.end()) 249 if (it == set.end())
250 return; 250 return;
251 set.RemoveAll(it); 251 set.RemoveAll(it);
252 if (set.IsEmpty()) { 252 if (set.IsEmpty()) {
253 UpdateSuddenTerminationStatus(dom_window, false, 253 UpdateSuddenTerminationStatus(dom_window, false,
254 LocalFrameClient::kBeforeUnloadHandler); 254 LocalFrameClient::kBeforeUnloadHandler);
255 } 255 }
256 } 256 }
257 257
258 static bool AllowsBeforeUnloadListeners(LocalDOMWindow* window) {
259 DCHECK(window);
260 LocalFrame* frame = window->GetFrame();
261 if (!frame)
262 return false;
263 return frame->IsMainFrame();
264 }
265
258 unsigned LocalDOMWindow::PendingUnloadEventListeners() const { 266 unsigned LocalDOMWindow::PendingUnloadEventListeners() const {
259 return WindowsWithUnloadEventListeners().Count( 267 return WindowsWithUnloadEventListeners().Count(
260 const_cast<LocalDOMWindow*>(this)); 268 const_cast<LocalDOMWindow*>(this));
261 } 269 }
262 270
263 bool LocalDOMWindow::AllowPopUp(LocalFrame& first_frame) { 271 bool LocalDOMWindow::AllowPopUp(LocalFrame& first_frame) {
264 if (UserGestureIndicator::UtilizeUserGesture()) 272 if (UserGestureIndicator::UtilizeUserGesture())
265 return true; 273 return true;
266 274
267 Settings* settings = first_frame.GetSettings(); 275 Settings* settings = first_frame.GetSettings();
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 1441
1434 for (auto& it : event_listener_observers_) { 1442 for (auto& it : event_listener_observers_) {
1435 it->DidAddEventListener(this, event_type); 1443 it->DidAddEventListener(this, event_type);
1436 } 1444 }
1437 1445
1438 if (event_type == EventTypeNames::unload) { 1446 if (event_type == EventTypeNames::unload) {
1439 UseCounter::Count(document(), UseCounter::kDocumentUnloadRegistered); 1447 UseCounter::Count(document(), UseCounter::kDocumentUnloadRegistered);
1440 AddUnloadEventListener(this); 1448 AddUnloadEventListener(this);
1441 } else if (event_type == EventTypeNames::beforeunload) { 1449 } else if (event_type == EventTypeNames::beforeunload) {
1442 UseCounter::Count(document(), UseCounter::kDocumentBeforeUnloadRegistered); 1450 UseCounter::Count(document(), UseCounter::kDocumentBeforeUnloadRegistered);
1443 AddBeforeUnloadEventListener(this); 1451 if (AllowsBeforeUnloadListeners(this)) {
1444 if (GetFrame() && !GetFrame()->IsMainFrame()) 1452 // This is confusingly named. It doesn't actually add the listener. It
1453 // just increments a count so that we know we have listeners registered
1454 // for the purposes of determining if we can fast terminate the renderer
1455 // process.
1456 AddBeforeUnloadEventListener(this);
1457 } else {
1458 // Subframes return false from allowsBeforeUnloadListeners.
1445 UseCounter::Count(document(), 1459 UseCounter::Count(document(),
1446 UseCounter::kSubFrameBeforeUnloadRegistered); 1460 UseCounter::kSubFrameBeforeUnloadRegistered);
1461 }
1447 } 1462 }
1448 } 1463 }
1449 1464
1450 void LocalDOMWindow::RemovedEventListener( 1465 void LocalDOMWindow::RemovedEventListener(
1451 const AtomicString& event_type, 1466 const AtomicString& event_type,
1452 const RegisteredEventListener& registered_listener) { 1467 const RegisteredEventListener& registered_listener) {
1453 DOMWindow::RemovedEventListener(event_type, registered_listener); 1468 DOMWindow::RemovedEventListener(event_type, registered_listener);
1454 if (GetFrame() && GetFrame()->GetPage()) 1469 if (GetFrame() && GetFrame()->GetPage())
1455 GetFrame()->GetPage()->GetEventHandlerRegistry().DidRemoveEventHandler( 1470 GetFrame()->GetPage()->GetEventHandlerRegistry().DidRemoveEventHandler(
1456 *this, event_type, registered_listener.Options()); 1471 *this, event_type, registered_listener.Options());
1457 1472
1458 for (auto& it : event_listener_observers_) { 1473 for (auto& it : event_listener_observers_) {
1459 it->DidRemoveEventListener(this, event_type); 1474 it->DidRemoveEventListener(this, event_type);
1460 } 1475 }
1461 1476
1462 if (event_type == EventTypeNames::unload) { 1477 if (event_type == EventTypeNames::unload) {
1463 RemoveUnloadEventListener(this); 1478 RemoveUnloadEventListener(this);
1464 } else if (event_type == EventTypeNames::beforeunload) { 1479 } else if (event_type == EventTypeNames::beforeunload &&
1480 AllowsBeforeUnloadListeners(this)) {
1465 RemoveBeforeUnloadEventListener(this); 1481 RemoveBeforeUnloadEventListener(this);
1466 } 1482 }
1467 } 1483 }
1468 1484
1469 void LocalDOMWindow::WarnUnusedPreloads(TimerBase* base) { 1485 void LocalDOMWindow::WarnUnusedPreloads(TimerBase* base) {
1470 if (GetFrame() && GetFrame()->Loader().GetDocumentLoader()) { 1486 if (GetFrame() && GetFrame()->Loader().GetDocumentLoader()) {
1471 ResourceFetcher* fetcher = 1487 ResourceFetcher* fetcher =
1472 GetFrame()->Loader().GetDocumentLoader()->Fetcher(); 1488 GetFrame()->Loader().GetDocumentLoader()->Fetcher();
1473 DCHECK(fetcher); 1489 DCHECK(fetcher);
1474 if (fetcher->CountPreloads()) 1490 if (fetcher->CountPreloads())
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 DOMWindow::Trace(visitor); 1679 DOMWindow::Trace(visitor);
1664 Supplementable<LocalDOMWindow>::Trace(visitor); 1680 Supplementable<LocalDOMWindow>::Trace(visitor);
1665 } 1681 }
1666 1682
1667 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) { 1683 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) {
1668 visitor->TraceWrappers(custom_elements_); 1684 visitor->TraceWrappers(custom_elements_);
1669 DOMWindow::TraceWrappers(visitor); 1685 DOMWindow::TraceWrappers(visitor);
1670 } 1686 }
1671 1687
1672 } // namespace blink 1688 } // namespace blink
OLDNEW
« 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