OLD | NEW |
---|---|
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 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 NavigationType navigationType = determineNavigationType( | 1599 NavigationType navigationType = determineNavigationType( |
1600 type, | 1600 type, |
1601 frameLoadRequest.resourceRequest().httpBody() || frameLoadRequest.form(), | 1601 frameLoadRequest.resourceRequest().httpBody() || frameLoadRequest.form(), |
1602 frameLoadRequest.triggeringEvent()); | 1602 frameLoadRequest.triggeringEvent()); |
1603 frameLoadRequest.resourceRequest().setRequestContext( | 1603 frameLoadRequest.resourceRequest().setRequestContext( |
1604 determineRequestContextFromNavigationType(navigationType)); | 1604 determineRequestContextFromNavigationType(navigationType)); |
1605 frameLoadRequest.resourceRequest().setFrameType( | 1605 frameLoadRequest.resourceRequest().setFrameType( |
1606 m_frame->isMainFrame() ? WebURLRequest::FrameTypeTopLevel | 1606 m_frame->isMainFrame() ? WebURLRequest::FrameTypeTopLevel |
1607 : WebURLRequest::FrameTypeNested); | 1607 : WebURLRequest::FrameTypeNested); |
1608 ResourceRequest& request = frameLoadRequest.resourceRequest(); | 1608 ResourceRequest& request = frameLoadRequest.resourceRequest(); |
1609 upgradeInsecureRequest(request, nullptr); | 1609 |
1610 // Record the latest requiredCSP value that will be used when sending this req uest. | |
1611 recordLatestRequiredCSP(); | |
1612 modifyRequestForCSP(request, nullptr); | |
1610 if (!shouldContinueForNavigationPolicy( | 1613 if (!shouldContinueForNavigationPolicy( |
1611 request, frameLoadRequest.substituteData(), nullptr, | 1614 request, frameLoadRequest.substituteData(), nullptr, |
1612 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), | 1615 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), |
1613 navigationType, navigationPolicy, | 1616 navigationType, navigationPolicy, |
1614 type == FrameLoadTypeReplaceCurrentItem, | 1617 type == FrameLoadTypeReplaceCurrentItem, |
1615 frameLoadRequest.clientRedirect() == | 1618 frameLoadRequest.clientRedirect() == |
1616 ClientRedirectPolicy::ClientRedirect, | 1619 ClientRedirectPolicy::ClientRedirect, |
1617 frameLoadRequest.form())) | 1620 frameLoadRequest.form())) |
1618 return; | 1621 return; |
1619 | 1622 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1811 | 1814 |
1812 // FIXME: We need a way to propagate insecure requests policy flags to | 1815 // FIXME: We need a way to propagate insecure requests policy flags to |
1813 // out-of-process frames. For now, we'll always use default behavior. | 1816 // out-of-process frames. For now, we'll always use default behavior. |
1814 if (!parentFrame->isLocalFrame()) | 1817 if (!parentFrame->isLocalFrame()) |
1815 return nullptr; | 1818 return nullptr; |
1816 | 1819 |
1817 DCHECK(toLocalFrame(parentFrame)->document()); | 1820 DCHECK(toLocalFrame(parentFrame)->document()); |
1818 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade(); | 1821 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade(); |
1819 } | 1822 } |
1820 | 1823 |
1821 void FrameLoader::upgradeInsecureRequest(ResourceRequest& resourceRequest, | 1824 void FrameLoader::modifyRequestForCSP(ResourceRequest& resourceRequest, |
1822 Document* document) const { | 1825 Document* document) const { |
1823 // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational | 1826 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() && |
1824 // requests, as described in | 1827 !requiredCSP().isEmpty()) { |
1828 DCHECK(requiredCSP()); | |
Mike West
2016/10/07 12:11:59
I was going for something more like `DCHECK(requir
| |
1829 resourceRequest.setHTTPHeaderField(HTTPNames::Embedding_CSP, requiredCSP()); | |
1830 } | |
1831 | |
1832 // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational request s, as described in | |
1825 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect | 1833 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect |
1826 if (resourceRequest.frameType() != WebURLRequest::FrameTypeNone) { | 1834 if (resourceRequest.frameType() != WebURLRequest::FrameTypeNone) { |
1827 // Early return if the request has already been upgraded. | 1835 // Early return if the request has already been upgraded. |
1828 if (resourceRequest.httpHeaderField("Upgrade-Insecure-Requests") == | 1836 if (resourceRequest.httpHeaderField("Upgrade-Insecure-Requests") == |
1829 AtomicString("1")) | 1837 AtomicString("1")) |
1830 return; | 1838 return; |
1831 | 1839 |
1832 resourceRequest.addHTTPHeaderField("Upgrade-Insecure-Requests", "1"); | 1840 resourceRequest.addHTTPHeaderField("Upgrade-Insecure-Requests", "1"); |
1833 } | 1841 } |
1834 | 1842 |
1843 upgradeInsecureRequest(resourceRequest, document); | |
1844 } | |
1845 | |
1846 void FrameLoader::upgradeInsecureRequest(ResourceRequest& resourceRequest, | |
1847 Document* document) const { | |
1835 KURL url = resourceRequest.url(); | 1848 KURL url = resourceRequest.url(); |
1836 | 1849 |
1837 // If we don't yet have an |m_document| (because we're loading an iframe, for | 1850 // If we don't yet have an |m_document| (because we're loading an iframe, for |
1838 // instance), check the FrameLoader's policy. | 1851 // instance), check the FrameLoader's policy. |
1839 WebInsecureRequestPolicy relevantPolicy = | 1852 WebInsecureRequestPolicy relevantPolicy = |
1840 document ? document->getInsecureRequestPolicy() | 1853 document ? document->getInsecureRequestPolicy() |
1841 : getInsecureRequestPolicy(); | 1854 : getInsecureRequestPolicy(); |
1842 SecurityContext::InsecureNavigationsSet* relevantNavigationSet = | 1855 SecurityContext::InsecureNavigationsSet* relevantNavigationSet = |
1843 document ? document->insecureNavigationsToUpgrade() | 1856 document ? document->insecureNavigationsToUpgrade() |
1844 : insecureNavigationsToUpgrade(); | 1857 : insecureNavigationsToUpgrade(); |
(...skipping 12 matching lines...) Expand all Loading... | |
1857 UseCounter::count(document, | 1870 UseCounter::count(document, |
1858 UseCounter::UpgradeInsecureRequestsUpgradedRequest); | 1871 UseCounter::UpgradeInsecureRequestsUpgradedRequest); |
1859 url.setProtocol("https"); | 1872 url.setProtocol("https"); |
1860 if (url.port() == 80) | 1873 if (url.port() == 80) |
1861 url.setPort(443); | 1874 url.setPort(443); |
1862 resourceRequest.setURL(url); | 1875 resourceRequest.setURL(url); |
1863 } | 1876 } |
1864 } | 1877 } |
1865 } | 1878 } |
1866 | 1879 |
1880 void FrameLoader::recordLatestRequiredCSP() { | |
1881 m_requiredCSP = m_frame->owner() ? m_frame->owner()->csp() : nullAtom; | |
1882 } | |
1883 | |
1867 std::unique_ptr<TracedValue> FrameLoader::toTracedValue() const { | 1884 std::unique_ptr<TracedValue> FrameLoader::toTracedValue() const { |
1868 std::unique_ptr<TracedValue> tracedValue = TracedValue::create(); | 1885 std::unique_ptr<TracedValue> tracedValue = TracedValue::create(); |
1869 tracedValue->beginDictionary("frame"); | 1886 tracedValue->beginDictionary("frame"); |
1870 tracedValue->setString( | 1887 tracedValue->setString( |
1871 "id_ref", | 1888 "id_ref", |
1872 String::format( | 1889 String::format( |
1873 "0x%" PRIx64, | 1890 "0x%" PRIx64, |
1874 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(m_frame.get())))); | 1891 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(m_frame.get())))); |
1875 tracedValue->endDictionary(); | 1892 tracedValue->endDictionary(); |
1876 tracedValue->setBoolean("isLoadingMainFrame", isLoadingMainFrame()); | 1893 tracedValue->setBoolean("isLoadingMainFrame", isLoadingMainFrame()); |
1877 tracedValue->setString("stateMachine", m_stateMachine.toString()); | 1894 tracedValue->setString("stateMachine", m_stateMachine.toString()); |
1878 tracedValue->setString("provisionalDocumentLoaderURL", | 1895 tracedValue->setString("provisionalDocumentLoaderURL", |
1879 m_provisionalDocumentLoader | 1896 m_provisionalDocumentLoader |
1880 ? m_provisionalDocumentLoader->url() | 1897 ? m_provisionalDocumentLoader->url() |
1881 : String()); | 1898 : String()); |
1882 tracedValue->setString("documentLoaderURL", | 1899 tracedValue->setString("documentLoaderURL", |
1883 m_documentLoader ? m_documentLoader->url() : String()); | 1900 m_documentLoader ? m_documentLoader->url() : String()); |
1884 return tracedValue; | 1901 return tracedValue; |
1885 } | 1902 } |
1886 | 1903 |
1887 inline void FrameLoader::takeObjectSnapshot() const { | 1904 inline void FrameLoader::takeObjectSnapshot() const { |
1888 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, | 1905 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, |
1889 toTracedValue()); | 1906 toTracedValue()); |
1890 } | 1907 } |
1891 | 1908 |
1892 } // namespace blink | 1909 } // namespace blink |
OLD | NEW |