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

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

Issue 1176843006: Move window.close implementation to DOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Cleanup some leftover changes. Created 5 years, 6 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) 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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 if (frame()->isMainFrame() && allowFocus) 729 if (frame()->isMainFrame() && allowFocus)
730 host->chromeClient().focus(); 730 host->chromeClient().focus();
731 731
732 frame()->eventHandler().focusDocumentView(); 732 frame()->eventHandler().focusDocumentView();
733 } 733 }
734 734
735 void LocalDOMWindow::blur() 735 void LocalDOMWindow::blur()
736 { 736 {
737 } 737 }
738 738
739 void LocalDOMWindow::close(ExecutionContext* context)
740 {
741 if (!frame() || !frame()->isMainFrame())
742 return;
743
744 Page* page = frame()->page();
745 if (!page)
746 return;
747
748 if (context) {
749 ASSERT(isMainThread());
750 Document* activeDocument = toDocument(context);
751 if (!activeDocument)
752 return;
753
754 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*f rame()))
755 return;
756 }
757
758 Settings* settings = frame()->settings();
759 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseW indows();
760
761 if (!page->openedByDOM() && frame()->loader().client()->backForwardLength() > 1 && !allowScriptsToCloseWindows) {
762 frameConsole()->addMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Scripts may close only the windows that were opened by it."));
763 return;
764 }
765
766 if (!frame()->loader().shouldClose())
767 return;
768
769 InspectorInstrumentation::willCloseWindow(context);
770
771 page->chromeClient().closeWindowSoon();
772 // So as to make window.closed return the expected result
773 // after window.close(), separately record the to-be-closed
774 // state of this window. Scripts may access window.closed
775 // before the deferred close operation has gone ahead.
776 m_windowIsClosing = true;
777 }
778
779 void LocalDOMWindow::print() 739 void LocalDOMWindow::print()
780 { 740 {
781 if (!frame()) 741 if (!frame())
782 return; 742 return;
783 743
784 FrameHost* host = frame()->host(); 744 FrameHost* host = frame()->host();
785 if (!host) 745 if (!host)
786 return; 746 return;
787 747
788 if (frame()->document()->isSandboxed(SandboxModals)) { 748 if (frame()->document()->isSandboxed(SandboxModals)) {
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 DOMWindow::trace(visitor); 1483 DOMWindow::trace(visitor);
1524 DOMWindowLifecycleNotifier::trace(visitor); 1484 DOMWindowLifecycleNotifier::trace(visitor);
1525 } 1485 }
1526 1486
1527 LocalFrame* LocalDOMWindow::frame() const 1487 LocalFrame* LocalDOMWindow::frame() const
1528 { 1488 {
1529 return m_frameObserver->frame(); 1489 return m_frameObserver->frame();
1530 } 1490 }
1531 1491
1532 } // namespace blink 1492 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698