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

Side by Side Diff: Source/core/css/CSSImageValue.cpp

Issue 239353007: Set proper referrer for css resource fetching (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add test Created 6 years, 8 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
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 55 }
56 56
57 StyleFetchedImage* CSSImageValue::cachedImage(ResourceFetcher* fetcher, const Re sourceLoaderOptions& options) 57 StyleFetchedImage* CSSImageValue::cachedImage(ResourceFetcher* fetcher, const Re sourceLoaderOptions& options)
58 { 58 {
59 ASSERT(fetcher); 59 ASSERT(fetcher);
60 60
61 if (!m_accessedImage) { 61 if (!m_accessedImage) {
62 m_accessedImage = true; 62 m_accessedImage = true;
63 63
64 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE mpty() ? FetchInitiatorTypeNames::css : m_initiatorName, options); 64 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE mpty() ? FetchInitiatorTypeNames::css : m_initiatorName, options);
65 if (!m_referrer.isEmpty())
66 request.mutableResourceRequest().setHTTPReferrer(Referrer(m_referrer , ReferrerPolicyDefault));
65 67
66 if (options.corsEnabled == IsCORSEnabled) 68 if (options.corsEnabled == IsCORSEnabled)
67 request.setCrossOriginAccessControl(fetcher->document()->securityOri gin(), options.allowCredentials, options.credentialsRequested); 69 request.setCrossOriginAccessControl(fetcher->document()->securityOri gin(), options.allowCredentials, options.credentialsRequested);
68 70
69 if (ResourcePtr<ImageResource> cachedImage = fetcher->fetchImage(request )) 71 if (ResourcePtr<ImageResource> cachedImage = fetcher->fetchImage(request ))
70 m_image = StyleFetchedImage::create(cachedImage.get()); 72 m_image = StyleFetchedImage::create(cachedImage.get());
71 } 73 }
72 74
73 return (m_image && m_image->isImageResource()) ? toStyleFetchedImage(m_image ) : 0; 75 return (m_image && m_image->isImageResource()) ? toStyleFetchedImage(m_image ) : 0;
74 } 76 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 { 116 {
115 KURL url = document.completeURL(m_relativeURL); 117 KURL url = document.completeURL(m_relativeURL);
116 if (url == m_absoluteURL) 118 if (url == m_absoluteURL)
117 return; 119 return;
118 m_absoluteURL = url.string(); 120 m_absoluteURL = url.string();
119 m_accessedImage = false; 121 m_accessedImage = false;
120 m_image.clear(); 122 m_image.clear();
121 } 123 }
122 124
123 } // namespace WebCore 125 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698