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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 22893051: Add support for BeforeUnloadEvent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 return true; 2330 return true;
2331 2331
2332 RefPtr<Document> protect(this); 2332 RefPtr<Document> protect(this);
2333 2333
2334 RefPtr<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent::create(); 2334 RefPtr<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent::create();
2335 m_loadEventProgress = BeforeUnloadEventInProgress; 2335 m_loadEventProgress = BeforeUnloadEventInProgress;
2336 dispatchWindowEvent(beforeUnloadEvent.get(), this); 2336 dispatchWindowEvent(beforeUnloadEvent.get(), this);
2337 m_loadEventProgress = BeforeUnloadEventCompleted; 2337 m_loadEventProgress = BeforeUnloadEventCompleted;
2338 if (!beforeUnloadEvent->defaultPrevented()) 2338 if (!beforeUnloadEvent->defaultPrevented())
2339 defaultEventHandler(beforeUnloadEvent.get()); 2339 defaultEventHandler(beforeUnloadEvent.get());
2340 if (beforeUnloadEvent->result().isNull()) 2340 if (beforeUnloadEvent->returnValue().isNull())
2341 return true; 2341 return true;
2342 2342
2343 if (navigatingDocument->m_didAllowNavigationViaBeforeUnloadConfirmationPanel ) { 2343 if (navigatingDocument->m_didAllowNavigationViaBeforeUnloadConfirmationPanel ) {
2344 addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Blocked attempt t o show multiple 'beforeunload' confirmation panels for a single navigation."); 2344 addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Blocked attempt t o show multiple 'beforeunload' confirmation panels for a single navigation.");
2345 return true; 2345 return true;
2346 } 2346 }
2347 2347
2348 String text = displayStringModifiedByEncoding(beforeUnloadEvent->result()); 2348 String text = displayStringModifiedByEncoding(beforeUnloadEvent->returnValue ());
2349 if (chrome.runBeforeUnloadConfirmPanel(text, m_frame)) { 2349 if (chrome.runBeforeUnloadConfirmPanel(text, m_frame)) {
2350 navigatingDocument->m_didAllowNavigationViaBeforeUnloadConfirmationPanel = true; 2350 navigatingDocument->m_didAllowNavigationViaBeforeUnloadConfirmationPanel = true;
2351 return true; 2351 return true;
2352 } 2352 }
2353 return false; 2353 return false;
2354 } 2354 }
2355 2355
2356 void Document::dispatchUnloadEvents() 2356 void Document::dispatchUnloadEvents()
2357 { 2357 {
2358 RefPtr<Document> protect(this); 2358 RefPtr<Document> protect(this);
(...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 { 5239 {
5240 return DocumentLifecycleNotifier::create(this); 5240 return DocumentLifecycleNotifier::create(this);
5241 } 5241 }
5242 5242
5243 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5243 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5244 { 5244 {
5245 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5245 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5246 } 5246 }
5247 5247
5248 } // namespace WebCore 5248 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698