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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2488743003: (Re-)introduce AncestorThrottle to handle 'X-Frame-Options'. (Closed)
Patch Set: Display a blank page instead of an error page. ( and add checks in NavigationRequest) Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 1710
1711 takeObjectSnapshot(); 1711 takeObjectSnapshot();
1712 } 1712 }
1713 1713
1714 void FrameLoader::applyUserAgent(ResourceRequest& request) { 1714 void FrameLoader::applyUserAgent(ResourceRequest& request) {
1715 String userAgent = this->userAgent(); 1715 String userAgent = this->userAgent();
1716 DCHECK(!userAgent.isNull()); 1716 DCHECK(!userAgent.isNull());
1717 request.setHTTPUserAgent(AtomicString(userAgent)); 1717 request.setHTTPUserAgent(AtomicString(userAgent));
1718 } 1718 }
1719 1719
1720 bool FrameLoader::shouldInterruptLoadForXFrameOptions(
1721 const String& content,
1722 const KURL& url,
1723 unsigned long requestIdentifier) {
1724 UseCounter::count(m_frame->domWindow()->document(),
1725 UseCounter::XFrameOptions);
1726
1727 Frame* topFrame = m_frame->tree().top();
1728 if (m_frame == topFrame)
1729 return false;
1730
1731 XFrameOptionsDisposition disposition = parseXFrameOptionsHeader(content);
1732
1733 switch (disposition) {
1734 case XFrameOptionsSameOrigin: {
1735 UseCounter::count(m_frame->domWindow()->document(),
1736 UseCounter::XFrameOptionsSameOrigin);
1737 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url);
1738 // Out-of-process ancestors are always a different origin.
1739 if (!topFrame->isLocalFrame() ||
1740 !origin->isSameSchemeHostPort(
1741 toLocalFrame(topFrame)->document()->getSecurityOrigin()))
1742 return true;
1743 for (Frame* frame = m_frame->tree().parent(); frame;
1744 frame = frame->tree().parent()) {
1745 if (!frame->isLocalFrame() ||
1746 !origin->isSameSchemeHostPort(
1747 toLocalFrame(frame)->document()->getSecurityOrigin())) {
1748 UseCounter::count(
1749 m_frame->domWindow()->document(),
1750 UseCounter::XFrameOptionsSameOriginWithBadAncestorChain);
1751 break;
1752 }
1753 }
1754 return false;
1755 }
1756 case XFrameOptionsDeny:
1757 return true;
1758 case XFrameOptionsAllowAll:
1759 return false;
1760 case XFrameOptionsConflict: {
1761 ConsoleMessage* consoleMessage = ConsoleMessage::createForRequest(
1762 JSMessageSource, ErrorMessageLevel,
1763 "Multiple 'X-Frame-Options' headers with conflicting values ('" +
1764 content + "') encountered when loading '" + url.elidedString() +
1765 "'. Falling back to 'DENY'.",
1766 url, requestIdentifier);
1767 m_frame->document()->addConsoleMessage(consoleMessage);
1768 return true;
1769 }
1770 case XFrameOptionsInvalid: {
1771 ConsoleMessage* consoleMessage = ConsoleMessage::createForRequest(
1772 JSMessageSource, ErrorMessageLevel,
1773 "Invalid 'X-Frame-Options' header encountered when loading '" +
1774 url.elidedString() + "': '" + content +
1775 "' is not a recognized directive. The header will be ignored.",
1776 url, requestIdentifier);
1777 m_frame->document()->addConsoleMessage(consoleMessage);
1778 return false;
1779 }
1780 default:
1781 NOTREACHED();
1782 return false;
1783 }
1784 }
1785
1786 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const { 1720 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const {
1787 return m_currentItem && url == m_currentItem->url(); 1721 return m_currentItem && url == m_currentItem->url();
1788 } 1722 }
1789 1723
1790 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const { 1724 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const {
1791 if (!url.isAboutSrcdocURL()) 1725 if (!url.isAboutSrcdocURL())
1792 return false; 1726 return false;
1793 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 1727 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
1794 if (!isHTMLIFrameElement(ownerElement)) 1728 if (!isHTMLIFrameElement(ownerElement))
1795 return false; 1729 return false;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 m_documentLoader ? m_documentLoader->url() : String()); 1886 m_documentLoader ? m_documentLoader->url() : String());
1953 return tracedValue; 1887 return tracedValue;
1954 } 1888 }
1955 1889
1956 inline void FrameLoader::takeObjectSnapshot() const { 1890 inline void FrameLoader::takeObjectSnapshot() const {
1957 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1891 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1958 toTracedValue()); 1892 toTracedValue());
1959 } 1893 }
1960 1894
1961 } // namespace blink 1895 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698