OLD | NEW |
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 10 matching lines...) Expand all Loading... |
21 #include "config.h" | 21 #include "config.h" |
22 #include "core/css/CSSImageValue.h" | 22 #include "core/css/CSSImageValue.h" |
23 | 23 |
24 #include "core/css/CSSMarkup.h" | 24 #include "core/css/CSSMarkup.h" |
25 #include "core/dom/Document.h" | 25 #include "core/dom/Document.h" |
26 #include "core/fetch/FetchInitiatorTypeNames.h" | 26 #include "core/fetch/FetchInitiatorTypeNames.h" |
27 #include "core/fetch/FetchRequest.h" | 27 #include "core/fetch/FetchRequest.h" |
28 #include "core/fetch/ImageResource.h" | 28 #include "core/fetch/ImageResource.h" |
29 #include "core/loader/MixedContentChecker.h" | 29 #include "core/loader/MixedContentChecker.h" |
30 #include "core/style/StyleFetchedImage.h" | 30 #include "core/style/StyleFetchedImage.h" |
| 31 #include "platform/CrossOriginAttributeValue.h" |
31 #include "platform/weborigin/KURL.h" | 32 #include "platform/weborigin/KURL.h" |
32 #include "platform/weborigin/SecurityPolicy.h" | 33 #include "platform/weborigin/SecurityPolicy.h" |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 CSSImageValue::CSSImageValue(const AtomicString& rawValue, const KURL& url, Styl
eFetchedImage* image) | 37 CSSImageValue::CSSImageValue(const AtomicString& rawValue, const KURL& url, Styl
eFetchedImage* image) |
37 : CSSValue(ImageClass) | 38 : CSSValue(ImageClass) |
38 , m_relativeURL(rawValue) | 39 , m_relativeURL(rawValue) |
39 , m_absoluteURL(url.string()) | 40 , m_absoluteURL(url.string()) |
40 , m_isCachePending(!image) | 41 , m_isCachePending(!image) |
41 , m_cachedImage(image) | 42 , m_cachedImage(image) |
42 { | 43 { |
43 } | 44 } |
44 | 45 |
45 CSSImageValue::~CSSImageValue() | 46 CSSImageValue::~CSSImageValue() |
46 { | 47 { |
47 } | 48 } |
48 | 49 |
49 StyleFetchedImage* CSSImageValue::cacheImage(Document* document, const ResourceL
oaderOptions& options) | 50 StyleFetchedImage* CSSImageValue::cacheImage(Document* document, CrossOriginAttr
ibuteValue crossOrigin) |
50 { | 51 { |
51 ASSERT(document); | 52 ASSERT(document); |
52 | 53 |
53 if (m_isCachePending) { | 54 if (m_isCachePending) { |
54 m_isCachePending = false; | 55 m_isCachePending = false; |
55 | 56 |
56 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE
mpty() ? FetchInitiatorTypeNames::css : m_initiatorName, options); | 57 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE
mpty() ? FetchInitiatorTypeNames::css : m_initiatorName); |
57 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat
eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer)); | 58 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat
eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer)); |
58 | 59 |
59 if (options.corsEnabled == IsCORSEnabled) | 60 if (crossOrigin != CrossOriginAttributeNotSet) |
60 request.setCrossOriginAccessControl(document->securityOrigin(), opti
ons.allowCredentials, options.credentialsRequested); | 61 request.setCrossOriginAccessControl(document->securityOrigin(), cros
sOrigin); |
61 | 62 |
62 if (ResourcePtr<ImageResource> cachedImage = ImageResource::fetch(reques
t, document->fetcher())) | 63 if (ResourcePtr<ImageResource> cachedImage = ImageResource::fetch(reques
t, document->fetcher())) |
63 m_cachedImage = StyleFetchedImage::create(cachedImage.get(), documen
t, request.url()); | 64 m_cachedImage = StyleFetchedImage::create(cachedImage.get(), documen
t, request.url()); |
64 } | 65 } |
65 | 66 |
66 return m_cachedImage.get(); | 67 return m_cachedImage.get(); |
67 } | 68 } |
68 | 69 |
69 void CSSImageValue::restoreCachedResourceIfNeeded(Document& document) const | 70 void CSSImageValue::restoreCachedResourceIfNeeded(Document& document) const |
70 { | 71 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 KURL url = document.completeURL(m_relativeURL); | 119 KURL url = document.completeURL(m_relativeURL); |
119 AtomicString urlString(url.string()); | 120 AtomicString urlString(url.string()); |
120 if (urlString == m_absoluteURL) | 121 if (urlString == m_absoluteURL) |
121 return; | 122 return; |
122 m_absoluteURL = urlString; | 123 m_absoluteURL = urlString; |
123 m_isCachePending = true; | 124 m_isCachePending = true; |
124 m_cachedImage.clear(); | 125 m_cachedImage.clear(); |
125 } | 126 } |
126 | 127 |
127 } // namespace blink | 128 } // namespace blink |
OLD | NEW |