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

Unified Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 2284683002: PlzNavigate: support upgrade-insecure-navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adressed comments (Nate) Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
index 1d8a489187bf24ba71847999558509e59898b068..1811ba1772f84ec7656aa0abb630008915a01bb2 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -669,40 +669,7 @@ SecurityOrigin* FrameFetchContext::getSecurityOrigin() const
void FrameFetchContext::upgradeInsecureRequest(ResourceRequest& resourceRequest)
{
- // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational requests, as described in
- // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect
- if (resourceRequest.frameType() != WebURLRequest::FrameTypeNone) {
-
- // Early return if the request has already been upgraded.
- if (resourceRequest.httpHeaderField("Upgrade-Insecure-Requests") == AtomicString("1"))
- return;
-
- resourceRequest.addHTTPHeaderField("Upgrade-Insecure-Requests", "1");
- }
-
- KURL url = resourceRequest.url();
-
- // If we don't yet have an |m_document| (because we're loading an iframe, for instance), check the FrameLoader's policy.
- WebInsecureRequestPolicy relevantPolicy = m_document ? m_document->getInsecureRequestPolicy() : frame()->loader().getInsecureRequestPolicy();
- SecurityContext::InsecureNavigationsSet* relevantNavigationSet = m_document ? m_document->insecureNavigationsToUpgrade() : frame()->loader().insecureNavigationsToUpgrade();
-
- if (url.protocolIs("http") && relevantPolicy & kUpgradeInsecureRequests) {
- // We always upgrade requests that meet any of the following criteria:
- //
- // 1. Are for subresources (including nested frames).
- // 2. Are form submissions.
- // 3. Whose hosts are contained in the document's InsecureNavigationSet.
- if (resourceRequest.frameType() == WebURLRequest::FrameTypeNone
- || resourceRequest.frameType() == WebURLRequest::FrameTypeNested
- || resourceRequest.requestContext() == WebURLRequest::RequestContextForm
- || (!url.host().isNull() && relevantNavigationSet->contains(url.host().impl()->hash()))) {
- UseCounter::count(m_document, UseCounter::UpgradeInsecureRequestsUpgradedRequest);
- url.setProtocol("https");
- if (url.port() == 80)
- url.setPort(443);
- resourceRequest.setURL(url);
- }
- }
+ frame()->loader().upgradeInsecureRequest(resourceRequest, m_document);
}
void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest)
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.cpp ('k') | third_party/WebKit/Source/core/loader/FrameLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698