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

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

Issue 2424943002: Add ReferrerPolicy support to preload (Closed)
Patch Set: Fix test. Again 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 4d80182e8987cc079191209a35d856c5b810e577..116562a71b6f03a03be0b8963446d9fa7ac18fd3 100644
--- a/third_party/WebKit/Source/core/loader/LinkLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/LinkLoader.cpp
@@ -269,7 +269,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;
@@ -316,6 +317,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());
@@ -373,10 +380,18 @@ void LinkLoader::loadLinksFromHeader(
(viewportDescriptionWrapper && viewportDescriptionWrapper->set)
? &(viewportDescriptionWrapper->description)
: nullptr;
+
+ ReferrerPolicy referrerPolicy = ReferrerPolicyDefault;
+ if (!header.referrerPolicy().isNull()) {
+ SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords(
Mike West 2016/10/23 05:25:46 Same question regarding legacy.
+ header.referrerPolicy(), &referrerPolicy);
+ }
+
preloadIfNeeded(relAttribute, url, *document, header.as(),
header.mimeType(), header.media(),
crossOriginAttributeValue(header.crossOrigin()),
- LinkCalledFromHeader, errorOccurred, viewportDescription);
+ LinkCalledFromHeader, errorOccurred, viewportDescription,
+ referrerPolicy);
}
// TODO(yoav): Add more supported headers as needed.
}
@@ -387,6 +402,7 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute,
const String& type,
const String& as,
const String& media,
+ const String& referrerPolicyString,
const KURL& href,
Document& document,
const NetworkHintsInterface& networkHintsInterface) {
@@ -404,10 +420,15 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute,
networkHintsInterface, LinkCalledFromMarkup);
bool errorOccurred = false;
+ ReferrerPolicy referrerPolicy = ReferrerPolicyDefault;
+ if (!referrerPolicyString.isNull()) {
+ SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords(
Mike West 2016/10/23 05:25:46 Ditto.
+ referrerPolicyString, &referrerPolicy);
+ }
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);

Powered by Google App Engine
This is Rietveld 408576698