| OLD | NEW |
| 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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 if (frame()->isMainFrame() && allowFocus) | 750 if (frame()->isMainFrame() && allowFocus) |
| 751 host->chromeClient().focus(); | 751 host->chromeClient().focus(); |
| 752 | 752 |
| 753 frame()->eventHandler().focusDocumentView(); | 753 frame()->eventHandler().focusDocumentView(); |
| 754 } | 754 } |
| 755 | 755 |
| 756 void LocalDOMWindow::blur() | 756 void LocalDOMWindow::blur() |
| 757 { | 757 { |
| 758 } | 758 } |
| 759 | 759 |
| 760 void LocalDOMWindow::close(ExecutionContext* context) | |
| 761 { | |
| 762 if (!frame() || !frame()->isMainFrame()) | |
| 763 return; | |
| 764 | |
| 765 Page* page = frame()->page(); | |
| 766 if (!page) | |
| 767 return; | |
| 768 | |
| 769 if (context) { | |
| 770 ASSERT(isMainThread()); | |
| 771 Document* activeDocument = toDocument(context); | |
| 772 if (!activeDocument) | |
| 773 return; | |
| 774 | |
| 775 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*f
rame())) | |
| 776 return; | |
| 777 } | |
| 778 | |
| 779 Settings* settings = frame()->settings(); | |
| 780 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseW
indows(); | |
| 781 | |
| 782 if (!page->openedByDOM() && frame()->loader().client()->backForwardLength()
> 1 && !allowScriptsToCloseWindows) { | |
| 783 frameConsole()->addMessage(ConsoleMessage::create(JSMessageSource, Warni
ngMessageLevel, "Scripts may close only the windows that were opened by it.")); | |
| 784 return; | |
| 785 } | |
| 786 | |
| 787 if (!frame()->loader().shouldClose()) | |
| 788 return; | |
| 789 | |
| 790 InspectorInstrumentation::willCloseWindow(context); | |
| 791 | |
| 792 page->chromeClient().closeWindowSoon(); | |
| 793 // So as to make window.closed return the expected result | |
| 794 // after window.close(), separately record the to-be-closed | |
| 795 // state of this window. Scripts may access window.closed | |
| 796 // before the deferred close operation has gone ahead. | |
| 797 m_windowIsClosing = true; | |
| 798 } | |
| 799 | |
| 800 void LocalDOMWindow::print() | 760 void LocalDOMWindow::print() |
| 801 { | 761 { |
| 802 if (!frame()) | 762 if (!frame()) |
| 803 return; | 763 return; |
| 804 | 764 |
| 805 FrameHost* host = frame()->host(); | 765 FrameHost* host = frame()->host(); |
| 806 if (!host) | 766 if (!host) |
| 807 return; | 767 return; |
| 808 | 768 |
| 809 if (frame()->document()->isSandboxed(SandboxModals)) { | 769 if (frame()->document()->isSandboxed(SandboxModals)) { |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 DOMWindow::trace(visitor); | 1486 DOMWindow::trace(visitor); |
| 1527 DOMWindowLifecycleNotifier::trace(visitor); | 1487 DOMWindowLifecycleNotifier::trace(visitor); |
| 1528 } | 1488 } |
| 1529 | 1489 |
| 1530 LocalFrame* LocalDOMWindow::frame() const | 1490 LocalFrame* LocalDOMWindow::frame() const |
| 1531 { | 1491 { |
| 1532 return m_frameObserver->frame(); | 1492 return m_frameObserver->frame(); |
| 1533 } | 1493 } |
| 1534 | 1494 |
| 1535 } // namespace blink | 1495 } // namespace blink |
| OLD | NEW |