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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
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/fetch/ResourceFetcher.h" |
29 #include "core/loader/MixedContentChecker.h" | 30 #include "core/loader/MixedContentChecker.h" |
30 #include "core/style/StyleFetchedImage.h" | 31 #include "core/style/StyleFetchedImage.h" |
| 32 #include "platform/CrossOriginAttributeValue.h" |
31 #include "platform/weborigin/KURL.h" | 33 #include "platform/weborigin/KURL.h" |
32 #include "platform/weborigin/SecurityPolicy.h" | 34 #include "platform/weborigin/SecurityPolicy.h" |
33 | 35 |
34 namespace blink { | 36 namespace blink { |
35 | 37 |
36 CSSImageValue::CSSImageValue(const AtomicString& rawValue, const KURL& url, Styl
eFetchedImage* image) | 38 CSSImageValue::CSSImageValue(const AtomicString& rawValue, const KURL& url, Styl
eFetchedImage* image) |
37 : CSSValue(ImageClass) | 39 : CSSValue(ImageClass) |
38 , m_relativeURL(rawValue) | 40 , m_relativeURL(rawValue) |
39 , m_absoluteURL(url.string()) | 41 , m_absoluteURL(url.string()) |
40 , m_isCachePending(!image) | 42 , m_isCachePending(!image) |
41 , m_cachedImage(image) | 43 , m_cachedImage(image) |
42 { | 44 { |
43 } | 45 } |
44 | 46 |
45 CSSImageValue::~CSSImageValue() | 47 CSSImageValue::~CSSImageValue() |
46 { | 48 { |
47 } | 49 } |
48 | 50 |
49 StyleFetchedImage* CSSImageValue::cacheImage(Document* document, const ResourceL
oaderOptions& options) | 51 StyleFetchedImage* CSSImageValue::cacheImage(Document* document, CrossOriginAttr
ibuteValue crossOrigin) |
50 { | 52 { |
51 ASSERT(document); | 53 ASSERT(document); |
52 | 54 |
53 if (m_isCachePending) { | 55 if (m_isCachePending) { |
54 m_isCachePending = false; | 56 m_isCachePending = false; |
55 | 57 |
56 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE
mpty() ? FetchInitiatorTypeNames::css : m_initiatorName, options); | 58 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)); | 59 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat
eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer)); |
58 | 60 |
59 if (options.corsEnabled == IsCORSEnabled) | 61 if (crossOrigin != CrossOriginAttributeNotSet) |
60 request.setCrossOriginAccessControl(document->securityOrigin(), opti
ons.allowCredentials, options.credentialsRequested); | 62 request.setCrossOriginAccessControl(document->securityOrigin(), cros
sOrigin); |
61 | 63 |
62 if (ResourcePtr<ImageResource> cachedImage = ImageResource::fetch(reques
t, document->fetcher())) | 64 if (ResourcePtr<ImageResource> cachedImage = ImageResource::fetch(reques
t, document->fetcher())) |
63 m_cachedImage = StyleFetchedImage::create(cachedImage.get(), documen
t, request.url()); | 65 m_cachedImage = StyleFetchedImage::create(cachedImage.get(), documen
t, request.url()); |
64 } | 66 } |
65 | 67 |
66 return m_cachedImage.get(); | 68 return m_cachedImage.get(); |
67 } | 69 } |
68 | 70 |
69 void CSSImageValue::restoreCachedResourceIfNeeded(Document& document) const | 71 void CSSImageValue::restoreCachedResourceIfNeeded(Document& document) const |
70 { | 72 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 KURL url = document.completeURL(m_relativeURL); | 120 KURL url = document.completeURL(m_relativeURL); |
119 AtomicString urlString(url.string()); | 121 AtomicString urlString(url.string()); |
120 if (urlString == m_absoluteURL) | 122 if (urlString == m_absoluteURL) |
121 return; | 123 return; |
122 m_absoluteURL = urlString; | 124 m_absoluteURL = urlString; |
123 m_isCachePending = true; | 125 m_isCachePending = true; |
124 m_cachedImage.clear(); | 126 m_cachedImage.clear(); |
125 } | 127 } |
126 | 128 |
127 } // namespace blink | 129 } // namespace blink |
OLD | NEW |