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

Unified Diff: Source/core/html/parser/HTMLPreloadScanner.cpp

Issue 1291613010: Implement referrerpolicy attribute for img elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: yoav comments round 2 Created 5 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: Source/core/html/parser/HTMLPreloadScanner.cpp
diff --git a/Source/core/html/parser/HTMLPreloadScanner.cpp b/Source/core/html/parser/HTMLPreloadScanner.cpp
index 055e811b23f9025c037f00a0e4963680a3e4e484..c027ecd0205d3f3211d209d9a339fcd842b8aaa3 100644
--- a/Source/core/html/parser/HTMLPreloadScanner.cpp
+++ b/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -123,6 +123,7 @@ public:
, m_defer(FetchRequest::NoDefer)
, m_allowCredentials(DoNotAllowStoredCredentials)
, m_mediaValues(mediaValues)
+ , m_referrerPolicy(ReferrerPolicyDefault)
{
ASSERT(m_mediaValues->isCached());
if (match(m_tagImpl, imgTag)
@@ -174,7 +175,7 @@ public:
}
}
- PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL, const SegmentedString& source, const ClientHintsPreferences& clientHintsPreferences, const PictureData& pictureData, const ReferrerPolicy referrerPolicy)
+ PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL, const SegmentedString& source, const ClientHintsPreferences& clientHintsPreferences, const PictureData& pictureData, const ReferrerPolicy documentReferrerPolicy)
{
PreloadRequest::RequestType requestType = PreloadRequest::RequestTypePreload;
if (shouldPreconnect())
@@ -195,6 +196,9 @@ public:
resourceWidth.isSet = true;
}
+ // The element's 'referrerpolicy' attribute (if present) takes
+ // precedence over the document's referrer policy.
+ ReferrerPolicy referrerPolicy = m_referrerPolicy != ReferrerPolicyDefault ? m_referrerPolicy : documentReferrerPolicy;
OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_tagImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), referrerPolicy, resourceWidth, clientHintsPreferences, requestType);
if (isCORSEnabled())
request->setCrossOriginEnabled(allowStoredCredentials());
@@ -237,6 +241,9 @@ private:
m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValues->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue);
setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacement);
}
+ } else if (match(attributeName, referrerpolicyAttr) && !attributeValue.isNull()) {
Yoav Weiss 2015/08/19 06:23:04 Sorry for missing it earlier, but we need to prote
estark 2015/08/19 16:17:01 Done.
+ m_referrerPolicy = ReferrerPolicyDefault;
Yoav Weiss 2015/08/19 06:23:04 Is there a scenario where initialization at the co
estark 2015/08/19 16:17:01 No, removed.
+ SecurityPolicy::referrerPolicyFromString(attributeValue, &m_referrerPolicy);
}
}
@@ -411,6 +418,7 @@ private:
FetchRequest::DeferOption m_defer;
StoredCredentials m_allowCredentials;
RefPtrWillBeMember<MediaValues> m_mediaValues;
+ ReferrerPolicy m_referrerPolicy;
};
TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParameters)

Powered by Google App Engine
This is Rietveld 408576698