| 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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 | 944 |
| 945 Page* page = m_frame->page(); | 945 Page* page = m_frame->page(); |
| 946 if (!page) | 946 if (!page) |
| 947 return; | 947 return; |
| 948 | 948 |
| 949 if (m_frame != page->mainFrame()) | 949 if (m_frame != page->mainFrame()) |
| 950 return; | 950 return; |
| 951 | 951 |
| 952 if (context) { | 952 if (context) { |
| 953 ASSERT(isMainThread()); | 953 ASSERT(isMainThread()); |
| 954 Frame* activeFrame = static_cast<Document*>(context)->frame(); | 954 Document* activeDocument = static_cast<Document*>(context); |
| 955 if (!activeFrame) | 955 if (!activeDocument) |
| 956 return; | 956 return; |
| 957 | 957 |
| 958 if (!activeFrame->loader()->shouldAllowNavigation(m_frame)) | 958 if (!activeDocument->canNavigate(m_frame)) |
| 959 return; | 959 return; |
| 960 } | 960 } |
| 961 | 961 |
| 962 Settings* settings = m_frame->settings(); | 962 Settings* settings = m_frame->settings(); |
| 963 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseW
indows(); | 963 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseW
indows(); |
| 964 | 964 |
| 965 if (!(page->openedByDOM() || page->backForward()->count() <= 1 || allowScrip
tsToCloseWindows)) | 965 if (!(page->openedByDOM() || page->backForward()->count() <= 1 || allowScrip
tsToCloseWindows)) |
| 966 return; | 966 return; |
| 967 | 967 |
| 968 if (!m_frame->loader()->shouldClose()) | 968 if (!m_frame->loader()->shouldClose()) |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 EventTargetData* DOMWindow::ensureEventTargetData() | 1667 EventTargetData* DOMWindow::ensureEventTargetData() |
| 1668 { | 1668 { |
| 1669 return &m_eventTargetData; | 1669 return &m_eventTargetData; |
| 1670 } | 1670 } |
| 1671 | 1671 |
| 1672 void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DO
MWindow* firstWindow, SetLocationLocking locking) | 1672 void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DO
MWindow* firstWindow, SetLocationLocking locking) |
| 1673 { | 1673 { |
| 1674 if (!isCurrentlyDisplayedInFrame()) | 1674 if (!isCurrentlyDisplayedInFrame()) |
| 1675 return; | 1675 return; |
| 1676 | 1676 |
| 1677 Frame* activeFrame = activeWindow->frame(); | 1677 Document* activeDocument = activeWindow->document(); |
| 1678 if (!activeFrame) | 1678 if (!activeDocument) |
| 1679 return; | 1679 return; |
| 1680 | 1680 |
| 1681 if (!activeFrame->loader()->shouldAllowNavigation(m_frame)) | 1681 if (!activeDocument->canNavigate(m_frame)) |
| 1682 return; | 1682 return; |
| 1683 | 1683 |
| 1684 Frame* firstFrame = firstWindow->frame(); | 1684 Frame* firstFrame = firstWindow->frame(); |
| 1685 if (!firstFrame) | 1685 if (!firstFrame) |
| 1686 return; | 1686 return; |
| 1687 | 1687 |
| 1688 KURL completedURL = firstFrame->document()->completeURL(urlString); | 1688 KURL completedURL = firstFrame->document()->completeURL(urlString); |
| 1689 if (completedURL.isNull()) | 1689 if (completedURL.isNull()) |
| 1690 return; | 1690 return; |
| 1691 | 1691 |
| 1692 if (isInsecureScriptAccess(activeWindow, completedURL)) | 1692 if (isInsecureScriptAccess(activeWindow, completedURL)) |
| 1693 return; | 1693 return; |
| 1694 | 1694 |
| 1695 // We want a new history item if we are processing a user gesture. | 1695 // We want a new history item if we are processing a user gesture. |
| 1696 m_frame->navigationScheduler()->scheduleLocationChange(activeFrame->document
()->securityOrigin(), | 1696 m_frame->navigationScheduler()->scheduleLocationChange(activeDocument->secur
ityOrigin(), |
| 1697 completedURL, activeFrame->loader()->outgoingReferrer(), | 1697 // FIXME: What if activeDocument()->frame() is 0? |
| 1698 completedURL, activeDocument->frame()->loader()->outgoingReferrer(), |
| 1698 locking != LockHistoryBasedOnGestureState || !ScriptController::processi
ngUserGesture(), | 1699 locking != LockHistoryBasedOnGestureState || !ScriptController::processi
ngUserGesture(), |
| 1699 locking != LockHistoryBasedOnGestureState); | 1700 locking != LockHistoryBasedOnGestureState); |
| 1700 } | 1701 } |
| 1701 | 1702 |
| 1702 void DOMWindow::printErrorMessage(const String& message) | 1703 void DOMWindow::printErrorMessage(const String& message) |
| 1703 { | 1704 { |
| 1704 if (message.isEmpty()) | 1705 if (message.isEmpty()) |
| 1705 return; | 1706 return; |
| 1706 | 1707 |
| 1707 Settings* settings = m_frame->settings(); | 1708 Settings* settings = m_frame->settings(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 } | 1795 } |
| 1795 | 1796 |
| 1796 return newFrame; | 1797 return newFrame; |
| 1797 } | 1798 } |
| 1798 | 1799 |
| 1799 PassRefPtr<DOMWindow> DOMWindow::open(const String& urlString, const AtomicStrin
g& frameName, const String& windowFeaturesString, | 1800 PassRefPtr<DOMWindow> DOMWindow::open(const String& urlString, const AtomicStrin
g& frameName, const String& windowFeaturesString, |
| 1800 DOMWindow* activeWindow, DOMWindow* firstWindow) | 1801 DOMWindow* activeWindow, DOMWindow* firstWindow) |
| 1801 { | 1802 { |
| 1802 if (!isCurrentlyDisplayedInFrame()) | 1803 if (!isCurrentlyDisplayedInFrame()) |
| 1803 return 0; | 1804 return 0; |
| 1804 Frame* activeFrame = activeWindow->frame(); | 1805 Document* activeDocument = activeWindow->document(); |
| 1805 if (!activeFrame) | 1806 if (!activeDocument) |
| 1806 return 0; | 1807 return 0; |
| 1807 Frame* firstFrame = firstWindow->frame(); | 1808 Frame* firstFrame = firstWindow->frame(); |
| 1808 if (!firstFrame) | 1809 if (!firstFrame) |
| 1809 return 0; | 1810 return 0; |
| 1810 | 1811 |
| 1811 if (!firstWindow->allowPopUp()) { | 1812 if (!firstWindow->allowPopUp()) { |
| 1812 // Because FrameTree::find() returns true for empty strings, we must che
ck for empty frame names. | 1813 // Because FrameTree::find() returns true for empty strings, we must che
ck for empty frame names. |
| 1813 // Otherwise, illegitimate window.open() calls with no name will pass ri
ght through the popup blocker. | 1814 // Otherwise, illegitimate window.open() calls with no name will pass ri
ght through the popup blocker. |
| 1814 if (frameName.isEmpty() || !m_frame->tree()->find(frameName)) | 1815 if (frameName.isEmpty() || !m_frame->tree()->find(frameName)) |
| 1815 return 0; | 1816 return 0; |
| 1816 } | 1817 } |
| 1817 | 1818 |
| 1818 // Get the target frame for the special cases of _top and _parent. | 1819 // Get the target frame for the special cases of _top and _parent. |
| 1819 // In those cases, we schedule a location change right now and return early. | 1820 // In those cases, we schedule a location change right now and return early. |
| 1820 Frame* targetFrame = 0; | 1821 Frame* targetFrame = 0; |
| 1821 if (frameName == "_top") | 1822 if (frameName == "_top") |
| 1822 targetFrame = m_frame->tree()->top(); | 1823 targetFrame = m_frame->tree()->top(); |
| 1823 else if (frameName == "_parent") { | 1824 else if (frameName == "_parent") { |
| 1824 if (Frame* parent = m_frame->tree()->parent()) | 1825 if (Frame* parent = m_frame->tree()->parent()) |
| 1825 targetFrame = parent; | 1826 targetFrame = parent; |
| 1826 else | 1827 else |
| 1827 targetFrame = m_frame; | 1828 targetFrame = m_frame; |
| 1828 } | 1829 } |
| 1829 if (targetFrame) { | 1830 if (targetFrame) { |
| 1830 if (!activeFrame->loader()->shouldAllowNavigation(targetFrame)) | 1831 if (!activeDocument->canNavigate(targetFrame)) |
| 1831 return 0; | 1832 return 0; |
| 1832 | 1833 |
| 1833 KURL completedURL = firstFrame->document()->completeURL(urlString); | 1834 KURL completedURL = firstFrame->document()->completeURL(urlString); |
| 1834 | 1835 |
| 1835 if (targetFrame->domWindow()->isInsecureScriptAccess(activeWindow, compl
etedURL)) | 1836 if (targetFrame->domWindow()->isInsecureScriptAccess(activeWindow, compl
etedURL)) |
| 1836 return targetFrame->domWindow(); | 1837 return targetFrame->domWindow(); |
| 1837 | 1838 |
| 1838 if (urlString.isEmpty()) | 1839 if (urlString.isEmpty()) |
| 1839 return targetFrame->domWindow(); | 1840 return targetFrame->domWindow(); |
| 1840 | 1841 |
| 1841 // For whatever reason, Firefox uses the first window rather than the ac
tive window to | 1842 // For whatever reason, Firefox uses the first window rather than the ac
tive window to |
| 1842 // determine the outgoing referrer. We replicate that behavior here. | 1843 // determine the outgoing referrer. We replicate that behavior here. |
| 1843 bool lockHistory = !ScriptController::processingUserGesture(); | 1844 bool lockHistory = !ScriptController::processingUserGesture(); |
| 1844 targetFrame->navigationScheduler()->scheduleLocationChange( | 1845 targetFrame->navigationScheduler()->scheduleLocationChange( |
| 1845 activeFrame->document()->securityOrigin(), | 1846 activeDocument->securityOrigin(), |
| 1846 completedURL, | 1847 completedURL, |
| 1847 firstFrame->loader()->outgoingReferrer(), | 1848 firstFrame->loader()->outgoingReferrer(), |
| 1848 lockHistory, | 1849 lockHistory, |
| 1849 false); | 1850 false); |
| 1850 return targetFrame->domWindow(); | 1851 return targetFrame->domWindow(); |
| 1851 } | 1852 } |
| 1852 | 1853 |
| 1853 WindowFeatures windowFeatures(windowFeaturesString); | 1854 WindowFeatures windowFeatures(windowFeaturesString); |
| 1854 FloatRect windowRect(windowFeatures.xSet ? windowFeatures.x : 0, windowFeatu
res.ySet ? windowFeatures.y : 0, | 1855 FloatRect windowRect(windowFeatures.xSet ? windowFeatures.x : 0, windowFeatu
res.ySet ? windowFeatures.y : 0, |
| 1855 windowFeatures.widthSet ? windowFeatures.width : 0, windowFeatures.heigh
tSet ? windowFeatures.height : 0); | 1856 windowFeatures.widthSet ? windowFeatures.width : 0, windowFeatures.heigh
tSet ? windowFeatures.height : 0); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 #if ENABLE(QUOTA) | 1900 #if ENABLE(QUOTA) |
| 1900 StorageInfo* DOMWindow::webkitStorageInfo() const | 1901 StorageInfo* DOMWindow::webkitStorageInfo() const |
| 1901 { | 1902 { |
| 1902 if (!m_storageInfo && isCurrentlyDisplayedInFrame()) | 1903 if (!m_storageInfo && isCurrentlyDisplayedInFrame()) |
| 1903 m_storageInfo = StorageInfo::create(); | 1904 m_storageInfo = StorageInfo::create(); |
| 1904 return m_storageInfo.get(); | 1905 return m_storageInfo.get(); |
| 1905 } | 1906 } |
| 1906 #endif | 1907 #endif |
| 1907 | 1908 |
| 1908 } // namespace WebCore | 1909 } // namespace WebCore |
| OLD | NEW |