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

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

Issue 2424943002: Add ReferrerPolicy support to preload (Closed)
Patch Set: Test fix Created 4 years, 2 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/LinkLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/LinkLoader.cpp b/third_party/WebKit/Source/core/loader/LinkLoader.cpp
index d7ac4afe95f540436f5790aaa60ee820c6f41a5a..ddea909a2986908fde64e5c7f90b99963bf2183d 100644
--- a/third_party/WebKit/Source/core/loader/LinkLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/LinkLoader.cpp
@@ -268,7 +268,8 @@ static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute,
CrossOriginAttributeValue crossOrigin,
LinkCaller caller,
bool& errorOccurred,
- ViewportDescription* viewportDescription) {
+ ViewportDescription* viewportDescription,
+ ReferrerPolicy referrerPolicy) {
if (!document.loader() || !relAttribute.isLinkPreload())
return nullptr;
@@ -315,6 +316,12 @@ static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute,
ResourceRequest resourceRequest(document.completeURL(href));
ResourceFetcher::determineRequestContext(resourceRequest, resourceType,
false);
+
+ if (referrerPolicy != ReferrerPolicyDefault) {
+ resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer(
+ referrerPolicy, href, document.outgoingReferrer()));
+ }
+
FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link,
document.encodingName());
@@ -372,10 +379,12 @@ void LinkLoader::loadLinksFromHeader(
(viewportDescriptionWrapper && viewportDescriptionWrapper->set)
? &(viewportDescriptionWrapper->description)
: nullptr;
+
preloadIfNeeded(relAttribute, url, *document, header.as(),
header.mimeType(), header.media(),
crossOriginAttributeValue(header.crossOrigin()),
- LinkCalledFromHeader, errorOccurred, viewportDescription);
+ LinkCalledFromHeader, errorOccurred, viewportDescription,
+ ReferrerPolicyDefault);
}
// TODO(yoav): Add more supported headers as needed.
}
@@ -386,6 +395,7 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute,
const String& type,
const String& as,
const String& media,
+ ReferrerPolicy referrerPolicy,
const KURL& href,
Document& document,
const NetworkHintsInterface& networkHintsInterface) {
@@ -406,7 +416,7 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute,
if (m_client->shouldLoadLink()) {
createLinkPreloadResourceClient(preloadIfNeeded(
relAttribute, href, document, as, type, media, crossOrigin,
- LinkCalledFromMarkup, errorOccurred, nullptr));
+ LinkCalledFromMarkup, errorOccurred, nullptr, referrerPolicy));
}
if (errorOccurred)
m_linkLoadingErrorTimer.startOneShot(0, BLINK_FROM_HERE);
« no previous file with comments | « third_party/WebKit/Source/core/loader/LinkLoader.h ('k') | third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698