Chromium Code Reviews| 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 31d6081e55d3bebf3b97a73875fa9e5347cffe99..b28b104331f0757057c28a169686a30215be4bf6 100644 |
| --- a/third_party/WebKit/Source/core/loader/LinkLoader.cpp |
| +++ b/third_party/WebKit/Source/core/loader/LinkLoader.cpp |
| @@ -267,7 +267,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; |
| @@ -313,6 +314,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()); |
| @@ -368,10 +375,18 @@ void LinkLoader::loadLinksFromHeader( |
| (viewportDescriptionWrapper && viewportDescriptionWrapper->set) |
| ? &(viewportDescriptionWrapper->description) |
| : nullptr; |
| + |
| + ReferrerPolicy referrerPolicy = ReferrerPolicyDefault; |
| + if (!header.referrerPolicy().isNull()) { |
| + SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords( |
| + 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. |
| } |
| @@ -382,6 +397,7 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, |
| const String& type, |
| const String& as, |
| const String& media, |
| + const String& referrerPolicy, |
| const KURL& href, |
| Document& document, |
| const NetworkHintsInterface& networkHintsInterface) { |
| @@ -396,10 +412,11 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, |
| networkHintsInterface, LinkCalledFromMarkup); |
| bool errorOccurred = false; |
| - if (m_client->shouldLoadLink()) |
| + if (m_client->shouldLoadLink()) { |
| createLinkPreloadResourceClient(preloadIfNeeded( |
| relAttribute, href, document, as, type, media, crossOrigin, |
| - LinkCalledFromMarkup, errorOccurred, nullptr)); |
| + LinkCalledFromMarkup, errorOccurred, nullptr, ReferrerPolicyDefault)); |
|
estark
2016/10/18 04:55:54
This should be `referrerPolicy` instead of `Referr
Yoav Weiss
2016/10/20 23:01:37
yes and yes. (and now that the tests have an expec
|
| + } |
| if (errorOccurred) |
| m_linkLoadingErrorTimer.startOneShot(0, BLINK_FROM_HERE); |