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

Unified Diff: third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp

Issue 2780533002: Use Referrer-Policy headers for CSS stylesheets (Closed)
Patch Set: updates Created 3 years, 9 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/html/parser/CSSPreloadScanner.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
index 2a0fbc16cda139ca5f91c1c64ad65593d72d2675..1f81eba47f1be1b2009d06e3de3c625917e6baa2 100644
--- a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
@@ -27,16 +27,18 @@
#include "core/html/parser/CSSPreloadScanner.h"
+#include <memory>
#include "core/dom/Document.h"
#include "core/frame/Settings.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/parser/HTMLResourcePreloader.h"
#include "core/loader/DocumentLoader.h"
#include "core/loader/resource/CSSStyleSheetResource.h"
+#include "platform/HTTPNames.h"
#include "platform/Histogram.h"
#include "platform/loader/fetch/FetchInitiatorTypeNames.h"
#include "platform/text/SegmentedString.h"
-#include <memory>
+#include "platform/weborigin/SecurityPolicy.h"
namespace blink {
@@ -268,6 +270,7 @@ CSSPreloaderResourceClient::~CSSPreloaderResourceClient() {}
void CSSPreloaderResourceClient::setCSSStyleSheet(
const String& href,
const KURL& baseURL,
+ ReferrerPolicy referrerPolicy,
const String& charset,
const CSSStyleSheetResource*) {
clearResource();
@@ -301,6 +304,16 @@ void CSSPreloaderResourceClient::scanCSS(
if (chunk.isNull())
return;
CSSPreloadScanner cssPreloadScanner;
+
+ ReferrerPolicy referrerPolicy = ReferrerPolicyDefault;
+ String referrerPolicyHeader =
+ resource->response().httpHeaderField(HTTPNames::Referrer_Policy);
+ if (!referrerPolicyHeader.isNull()) {
+ SecurityPolicy::referrerPolicyFromHeaderValue(
+ referrerPolicyHeader, DoNotSupportReferrerPolicyLegacyKeywords,
+ &referrerPolicy);
+ }
+ cssPreloadScanner.setReferrerPolicy(referrerPolicy);
PreloadRequestStream preloads;
cssPreloadScanner.scan(chunk, SegmentedString(), preloads,
resource->response().url());

Powered by Google App Engine
This is Rietveld 408576698