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

Unified Diff: third_party/WebKit/Source/core/loader/resource/CSSStyleSheetResource.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/loader/resource/CSSStyleSheetResource.cpp
diff --git a/third_party/WebKit/Source/core/loader/resource/CSSStyleSheetResource.cpp b/third_party/WebKit/Source/core/loader/resource/CSSStyleSheetResource.cpp
index ccecd6dc73cf8081ffc128e9477535e11ece8b3e..a143ed1c77d6edc4195a91534c01fb20285fb2ef 100644
--- a/third_party/WebKit/Source/core/loader/resource/CSSStyleSheetResource.cpp
+++ b/third_party/WebKit/Source/core/loader/resource/CSSStyleSheetResource.cpp
@@ -28,11 +28,13 @@
#include "core/css/StyleSheetContents.h"
#include "core/loader/resource/StyleSheetResourceClient.h"
+#include "platform/HTTPNames.h"
#include "platform/SharedBuffer.h"
#include "platform/loader/fetch/FetchRequest.h"
#include "platform/loader/fetch/MemoryCache.h"
#include "platform/loader/fetch/ResourceClientWalker.h"
#include "platform/loader/fetch/ResourceFetcher.h"
+#include "platform/weborigin/SecurityPolicy.h"
#include "wtf/CurrentTime.h"
namespace blink {
@@ -99,8 +101,17 @@ void CSSStyleSheetResource::didAddClient(ResourceClient* c) {
// |c| might be removed in didAppendFirstData, so ensure it is still a client.
if (hasClient(c) && !isLoading()) {
+ ReferrerPolicy referrerPolicy = ReferrerPolicyDefault;
+ String referrerPolicyHeader =
+ response().httpHeaderField(HTTPNames::Referrer_Policy);
+ if (!referrerPolicyHeader.isNull()) {
+ SecurityPolicy::referrerPolicyFromHeaderValue(
+ referrerPolicyHeader, DoNotSupportReferrerPolicyLegacyKeywords,
+ &referrerPolicy);
+ }
static_cast<StyleSheetResourceClient*>(c)->setCSSStyleSheet(
- resourceRequest().url(), response().url(), encoding(), this);
+ resourceRequest().url(), response().url(), referrerPolicy, encoding(),
+ this);
}
}
@@ -139,11 +150,20 @@ void CSSStyleSheetResource::checkNotify() {
if (data())
setDecodedSheetText(decodedText());
+ ReferrerPolicy referrerPolicy = ReferrerPolicyDefault;
+ String referrerPolicyHeader =
+ response().httpHeaderField(HTTPNames::Referrer_Policy);
+ if (!referrerPolicyHeader.isNull()) {
+ SecurityPolicy::referrerPolicyFromHeaderValue(
+ referrerPolicyHeader, DoNotSupportReferrerPolicyLegacyKeywords,
+ &referrerPolicy);
+ }
+
ResourceClientWalker<StyleSheetResourceClient> w(clients());
while (StyleSheetResourceClient* c = w.next()) {
markClientFinished(c);
- c->setCSSStyleSheet(resourceRequest().url(), response().url(), encoding(),
- this);
+ c->setCSSStyleSheet(resourceRequest().url(), response().url(),
+ referrerPolicy, encoding(), this);
}
// Clear raw bytes as now we have the full decoded sheet text.

Powered by Google App Engine
This is Rietveld 408576698