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

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

Issue 307223002: Make sure we never pass a null Frame to Document::canNavigate() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 Page* page = m_frame->page(); 949 Page* page = m_frame->page();
950 if (!page) 950 if (!page)
951 return; 951 return;
952 952
953 if (context) { 953 if (context) {
954 ASSERT(isMainThread()); 954 ASSERT(isMainThread());
955 Document* activeDocument = toDocument(context); 955 Document* activeDocument = toDocument(context);
956 if (!activeDocument) 956 if (!activeDocument)
957 return; 957 return;
958 958
959 if (!activeDocument->canNavigate(m_frame)) 959 if (!activeDocument->canNavigate(*m_frame))
960 return; 960 return;
961 } 961 }
962 962
963 Settings* settings = m_frame->settings(); 963 Settings* settings = m_frame->settings();
964 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseW indows(); 964 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseW indows();
965 965
966 if (!(page->openedByDOM() || page->backForward().backForwardListCount() <= 1 || allowScriptsToCloseWindows)) { 966 if (!(page->openedByDOM() || page->backForward().backForwardListCount() <= 1 || allowScriptsToCloseWindows)) {
967 frameConsole()->addMessage(JSMessageSource, WarningMessageLevel, "Script s may close only the windows that were opened by it."); 967 frameConsole()->addMessage(JSMessageSource, WarningMessageLevel, "Script s may close only the windows that were opened by it.");
968 return; 968 return;
969 } 969 }
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 1651
1652 void DOMWindow::setLocation(const String& urlString, DOMWindow* callingWindow, D OMWindow* enteredWindow, SetLocationLocking locking) 1652 void DOMWindow::setLocation(const String& urlString, DOMWindow* callingWindow, D OMWindow* enteredWindow, SetLocationLocking locking)
1653 { 1653 {
1654 if (!isCurrentlyDisplayedInFrame()) 1654 if (!isCurrentlyDisplayedInFrame())
1655 return; 1655 return;
1656 1656
1657 Document* activeDocument = callingWindow->document(); 1657 Document* activeDocument = callingWindow->document();
1658 if (!activeDocument) 1658 if (!activeDocument)
1659 return; 1659 return;
1660 1660
1661 if (!activeDocument->canNavigate(m_frame)) 1661 ASSERT(m_frame);
1662 if (!activeDocument->canNavigate(*m_frame))
1662 return; 1663 return;
1663 1664
1664 LocalFrame* firstFrame = enteredWindow->frame(); 1665 LocalFrame* firstFrame = enteredWindow->frame();
1665 if (!firstFrame) 1666 if (!firstFrame)
1666 return; 1667 return;
1667 1668
1668 KURL completedURL = firstFrame->document()->completeURL(urlString); 1669 KURL completedURL = firstFrame->document()->completeURL(urlString);
1669 if (completedURL.isNull()) 1670 if (completedURL.isNull())
1670 return; 1671 return;
1671 1672
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 LocalFrame* targetFrame = 0; 1804 LocalFrame* targetFrame = 0;
1804 if (frameName == "_top") 1805 if (frameName == "_top")
1805 targetFrame = m_frame->tree().top(); 1806 targetFrame = m_frame->tree().top();
1806 else if (frameName == "_parent") { 1807 else if (frameName == "_parent") {
1807 if (LocalFrame* parent = m_frame->tree().parent()) 1808 if (LocalFrame* parent = m_frame->tree().parent())
1808 targetFrame = parent; 1809 targetFrame = parent;
1809 else 1810 else
1810 targetFrame = m_frame; 1811 targetFrame = m_frame;
1811 } 1812 }
1812 if (targetFrame) { 1813 if (targetFrame) {
1813 if (!activeDocument->canNavigate(targetFrame)) 1814 if (!activeDocument->canNavigate(*targetFrame))
1814 return nullptr; 1815 return nullptr;
1815 1816
1816 KURL completedURL = firstFrame->document()->completeURL(urlString); 1817 KURL completedURL = firstFrame->document()->completeURL(urlString);
1817 1818
1818 if (targetFrame->domWindow()->isInsecureScriptAccess(*callingWindow, com pletedURL)) 1819 if (targetFrame->domWindow()->isInsecureScriptAccess(*callingWindow, com pletedURL))
1819 return targetFrame->domWindow(); 1820 return targetFrame->domWindow();
1820 1821
1821 if (urlString.isEmpty()) 1822 if (urlString.isEmpty())
1822 return targetFrame->domWindow(); 1823 return targetFrame->domWindow();
1823 1824
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 visitor->trace(m_sessionStorage); 1904 visitor->trace(m_sessionStorage);
1904 visitor->trace(m_localStorage); 1905 visitor->trace(m_localStorage);
1905 visitor->trace(m_applicationCache); 1906 visitor->trace(m_applicationCache);
1906 visitor->trace(m_performance); 1907 visitor->trace(m_performance);
1907 visitor->trace(m_css); 1908 visitor->trace(m_css);
1908 WillBeHeapSupplementable<DOMWindow>::trace(visitor); 1909 WillBeHeapSupplementable<DOMWindow>::trace(visitor);
1909 EventTargetWithInlineData::trace(visitor); 1910 EventTargetWithInlineData::trace(visitor);
1910 } 1911 }
1911 1912
1912 } // namespace WebCore 1913 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698