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

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

Issue 1988933003: Revert "Introduce AncestorThrottle, which will process 'X-Frame-Options' headers." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 return WebURLRequest::RequestContextLocation; 872 return WebURLRequest::RequestContextLocation;
873 873
874 case NavigationTypeFormResubmitted: 874 case NavigationTypeFormResubmitted:
875 case NavigationTypeFormSubmitted: 875 case NavigationTypeFormSubmitted:
876 return WebURLRequest::RequestContextForm; 876 return WebURLRequest::RequestContextForm;
877 877
878 case NavigationTypeBackForward: 878 case NavigationTypeBackForward:
879 case NavigationTypeReload: 879 case NavigationTypeReload:
880 return WebURLRequest::RequestContextInternal; 880 return WebURLRequest::RequestContextInternal;
881 } 881 }
882 ASSERT_NOT_REACHED(); 882 NOTREACHED();
883 return WebURLRequest::RequestContextHyperlink; 883 return WebURLRequest::RequestContextHyperlink;
884 } 884 }
885 885
886 static NavigationPolicy navigationPolicyForRequest(const FrameLoadRequest& reque st) 886 static NavigationPolicy navigationPolicyForRequest(const FrameLoadRequest& reque st)
887 { 887 {
888 NavigationPolicy policy = NavigationPolicyCurrentTab; 888 NavigationPolicy policy = NavigationPolicyCurrentTab;
889 Event* event = request.triggeringEvent(); 889 Event* event = request.triggeringEvent();
890 if (!event) 890 if (!event)
891 return policy; 891 return policy;
892 892
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 takeObjectSnapshot(); 1453 takeObjectSnapshot();
1454 } 1454 }
1455 1455
1456 void FrameLoader::applyUserAgent(ResourceRequest& request) 1456 void FrameLoader::applyUserAgent(ResourceRequest& request)
1457 { 1457 {
1458 String userAgent = this->userAgent(); 1458 String userAgent = this->userAgent();
1459 ASSERT(!userAgent.isNull()); 1459 ASSERT(!userAgent.isNull());
1460 request.setHTTPUserAgent(AtomicString(userAgent)); 1460 request.setHTTPUserAgent(AtomicString(userAgent));
1461 } 1461 }
1462 1462
1463 bool FrameLoader::shouldInterruptLoadForXFrameOptions(const String& content, con st KURL& url, unsigned long requestIdentifier)
1464 {
1465 UseCounter::count(m_frame->domWindow()->document(), UseCounter::XFrameOption s);
1466
1467 Frame* topFrame = m_frame->tree().top();
1468 if (m_frame == topFrame)
1469 return false;
1470
1471 XFrameOptionsDisposition disposition = parseXFrameOptionsHeader(content);
1472
1473 switch (disposition) {
1474 case XFrameOptionsSameOrigin: {
1475 UseCounter::count(m_frame->domWindow()->document(), UseCounter::XFrameOp tionsSameOrigin);
1476 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url);
1477 // Out-of-process ancestors are always a different origin.
1478 if (!topFrame->isLocalFrame() || !origin->isSameSchemeHostPort(toLocalFr ame(topFrame)->document()->getSecurityOrigin()))
1479 return true;
1480 for (Frame* frame = m_frame->tree().parent(); frame; frame = frame->tree ().parent()) {
1481 if (!frame->isLocalFrame() || !origin->isSameSchemeHostPort(toLocalF rame(frame)->document()->getSecurityOrigin())) {
1482 UseCounter::count(m_frame->domWindow()->document(), UseCounter:: XFrameOptionsSameOriginWithBadAncestorChain);
1483 break;
1484 }
1485 }
1486 return false;
1487 }
1488 case XFrameOptionsDeny:
1489 return true;
1490 case XFrameOptionsAllowAll:
1491 return false;
1492 case XFrameOptionsConflict: {
1493 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, "Multiple 'X-Frame-Options' headers with conflicting values ('" + content + "') encountered when loading '" + url.elidedString() + "'. Falli ng back to 'DENY'.");
1494 consoleMessage->setRequestIdentifier(requestIdentifier);
1495 m_frame->document()->addConsoleMessage(consoleMessage);
1496 return true;
1497 }
1498 case XFrameOptionsInvalid: {
1499 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, "Invalid 'X-Frame-Options' header encountered when loading ' " + url.elidedString() + "': '" + content + "' is not a recognized directive. Th e header will be ignored.");
1500 consoleMessage->setRequestIdentifier(requestIdentifier);
1501 m_frame->document()->addConsoleMessage(consoleMessage);
1502 return false;
1503 }
1504 default:
1505 NOTREACHED();
1506 return false;
1507 }
1508 }
1509
1463 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const 1510 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const
1464 { 1511 {
1465 return m_currentItem && url == m_currentItem->url(); 1512 return m_currentItem && url == m_currentItem->url();
1466 } 1513 }
1467 1514
1468 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const 1515 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const
1469 { 1516 {
1470 if (!url.isAboutSrcdocURL()) 1517 if (!url.isAboutSrcdocURL())
1471 return false; 1518 return false;
1472 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 1519 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1625 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1579 return tracedValue; 1626 return tracedValue;
1580 } 1627 }
1581 1628
1582 inline void FrameLoader::takeObjectSnapshot() const 1629 inline void FrameLoader::takeObjectSnapshot() const
1583 { 1630 {
1584 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1631 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1585 } 1632 }
1586 1633
1587 } // namespace blink 1634 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | third_party/WebKit/Source/core/loader/HttpEquiv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698