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

Unified Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 314893003: Set referrer for CSS resources (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/html/HTMLBodyElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index f07a1d46a76cd796d29178ae851686605d87f4cf..6a73395a84860308455206e880ec42b9447cadae 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -320,6 +320,13 @@ inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRING);
}
+inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWithReferrer(const String& rawValue, const KURL& url)
+{
+ RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, url);
+ toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer());
+ return imageValue;
+}
+
static inline bool isComma(CSSParserValue* value)
{
return value && value->unit == CSSParserValue::Operator && value->iValue == ',';
@@ -593,7 +600,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
if (value->unit == CSSPrimitiveValue::CSS_URI) {
String uri = value->string;
if (!uri.isNull())
- image = CSSImageValue::create(uri, completeURL(uri));
+ image = createCSSImageValueWithReferrer(uri, completeURL(uri));
} else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set(")) {
image = parseImageSet(m_valueList.get());
if (!image)
@@ -718,7 +725,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
parsedValue = cssValuePool().createIdentifierValue(CSSValueNone);
m_valueList->next();
} else if (value->unit == CSSPrimitiveValue::CSS_URI) {
- parsedValue = CSSImageValue::create(value->string, completeURL(value->string));
+ parsedValue = createCSSImageValueWithReferrer(value->string, completeURL(value->string));
m_valueList->next();
} else if (isGeneratedImageValue(value)) {
if (parseGeneratedImage(m_valueList.get(), parsedValue))
@@ -2255,7 +2262,7 @@ bool CSSPropertyParser::parseContent(CSSPropertyID propId, bool important)
RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
if (val->unit == CSSPrimitiveValue::CSS_URI) {
// url
- parsedValue = CSSImageValue::create(val->string, completeURL(val->string));
+ parsedValue = createCSSImageValueWithReferrer(val->string, completeURL(val->string));
} else if (val->unit == CSSParserValue::Function) {
// attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradient(...)
CSSParserValueList* args = val->function->args.get();
@@ -2359,7 +2366,7 @@ bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
return true;
}
if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) {
- value = CSSImageValue::create(valueList->current()->string, completeURL(valueList->current()->string));
+ value = createCSSImageValueWithReferrer(valueList->current()->string, completeURL(valueList->current()->string));
return true;
}
@@ -4718,6 +4725,7 @@ bool CSSPropertyParser::parseFontWeight(bool important)
bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList)
{
RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL(m_valueList->current()->string)));
+ uriValue->setReferrer(m_context.referrer());
CSSParserValue* value = m_valueList->next();
if (!value) {
@@ -5813,7 +5821,7 @@ bool BorderImageParseContext::buildFromParser(CSSPropertyParser& parser, CSSProp
if (!context.canAdvance() && context.allowImage()) {
if (val->unit == CSSPrimitiveValue::CSS_URI) {
- context.commitImage(CSSImageValue::create(val->string, parser.m_context.completeURL(val->string)));
+ context.commitImage(parser.createCSSImageValueWithReferrer(val->string, parser.m_context.completeURL(val->string)));
} else if (isGeneratedImageValue(val)) {
RefPtrWillBeRawPtr<CSSValue> value = nullptr;
if (parser.parseGeneratedImage(parser.m_valueList.get(), value))
@@ -7102,7 +7110,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
if (arg->unit != CSSPrimitiveValue::CSS_URI)
return nullptr;
- RefPtrWillBeRawPtr<CSSImageValue> image = CSSImageValue::create(arg->string, completeURL(arg->string));
+ RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg->string, completeURL(arg->string));
imageSet->append(image);
arg = functionArgs->next();
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/html/HTMLBodyElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698