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

Side by Side Diff: Source/core/css/CSSImageSetValue.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 unified diff | Download patch
« no previous file with comments | « Source/core/css/CSSImageSetValue.h ('k') | Source/core/css/CSSImageValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 { 50 {
51 if (m_imageSet && m_imageSet->isImageResourceSet()) 51 if (m_imageSet && m_imageSet->isImageResourceSet())
52 toStyleFetchedImageSet(m_imageSet)->clearImageSetValue(); 52 toStyleFetchedImageSet(m_imageSet)->clearImageSetValue();
53 } 53 }
54 54
55 void CSSImageSetValue::fillImageSet() 55 void CSSImageSetValue::fillImageSet()
56 { 56 {
57 size_t length = this->length(); 57 size_t length = this->length();
58 size_t i = 0; 58 size_t i = 0;
59 while (i < length) { 59 while (i < length) {
60 CSSValue* imageValue = item(i); 60 CSSImageValue* imageValue = toCSSImageValue(item(i));
61 String imageURL = toCSSImageValue(imageValue)->url(); 61 String imageURL = imageValue->url();
62 62
63 ++i; 63 ++i;
64 ASSERT_WITH_SECURITY_IMPLICATION(i < length); 64 ASSERT_WITH_SECURITY_IMPLICATION(i < length);
65 CSSValue* scaleFactorValue = item(i); 65 CSSValue* scaleFactorValue = item(i);
66 float scaleFactor = toCSSPrimitiveValue(scaleFactorValue)->getFloatValue (); 66 float scaleFactor = toCSSPrimitiveValue(scaleFactorValue)->getFloatValue ();
67 67
68 ImageWithScale image; 68 ImageWithScale image;
69 image.imageURL = imageURL; 69 image.imageURL = imageURL;
70 image.referrer = imageValue->referrer();
70 image.scaleFactor = scaleFactor; 71 image.scaleFactor = scaleFactor;
71 m_imagesInSet.append(image); 72 m_imagesInSet.append(image);
72 ++i; 73 ++i;
73 } 74 }
74 75
75 // Sort the images so that they are stored in order from lowest resolution t o highest. 76 // Sort the images so that they are stored in order from lowest resolution t o highest.
76 std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::comp areByScaleFactor); 77 std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::comp areByScaleFactor);
77 } 78 }
78 79
79 CSSImageSetValue::ImageWithScale CSSImageSetValue::bestImageForScaleFactor() 80 CSSImageSetValue::ImageWithScale CSSImageSetValue::bestImageForScaleFactor()
(...skipping 17 matching lines...) Expand all
97 if (!m_imagesInSet.size()) 98 if (!m_imagesInSet.size())
98 fillImageSet(); 99 fillImageSet();
99 100
100 if (!m_accessedBestFitImage) { 101 if (!m_accessedBestFitImage) {
101 // FIXME: In the future, we want to take much more than deviceScaleFacto r into acount here. 102 // FIXME: In the future, we want to take much more than deviceScaleFacto r into acount here.
102 // All forms of scale should be included: Page::pageScaleFactor(), Local Frame::pageZoomFactor(), 103 // All forms of scale should be included: Page::pageScaleFactor(), Local Frame::pageZoomFactor(),
103 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 104 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698
104 ImageWithScale image = bestImageForScaleFactor(); 105 ImageWithScale image = bestImageForScaleFactor();
105 if (Document* document = loader->document()) { 106 if (Document* document = loader->document()) {
106 FetchRequest request(ResourceRequest(document->completeURL(image.ima geURL)), FetchInitiatorTypeNames::css, options); 107 FetchRequest request(ResourceRequest(document->completeURL(image.ima geURL)), FetchInitiatorTypeNames::css, options);
108 request.mutableResourceRequest().setHTTPReferrer(image.referrer);
107 109
108 if (options.corsEnabled == IsCORSEnabled) 110 if (options.corsEnabled == IsCORSEnabled)
109 request.setCrossOriginAccessControl(loader->document()->security Origin(), options.allowCredentials, options.credentialsRequested); 111 request.setCrossOriginAccessControl(loader->document()->security Origin(), options.allowCredentials, options.credentialsRequested);
110 112
111 if (ResourcePtr<ImageResource> cachedImage = loader->fetchImage(requ est)) { 113 if (ResourcePtr<ImageResource> cachedImage = loader->fetchImage(requ est)) {
112 m_imageSet = StyleFetchedImageSet::create(cachedImage.get(), ima ge.scaleFactor, this); 114 m_imageSet = StyleFetchedImageSet::create(cachedImage.get(), ima ge.scaleFactor, this);
113 m_accessedBestFitImage = true; 115 m_accessedBestFitImage = true;
114 } 116 }
115 } 117 }
116 } 118 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 { 186 {
185 // Non-CSSValueList data is not accessible through CSS OM, no need to clone. 187 // Non-CSSValueList data is not accessible through CSS OM, no need to clone.
186 } 188 }
187 189
188 PassRefPtrWillBeRawPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const 190 PassRefPtrWillBeRawPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const
189 { 191 {
190 return adoptRefWillBeNoop(new CSSImageSetValue(*this)); 192 return adoptRefWillBeNoop(new CSSImageSetValue(*this));
191 } 193 }
192 194
193 } // namespace WebCore 195 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/CSSImageSetValue.h ('k') | Source/core/css/CSSImageValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698