Chromium Code Reviews| 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 "core/css/CSSImageValue.h" | 21 #include "core/css/CSSImageValue.h" |
| 22 | 22 |
| 23 #include "core/css/CSSMarkup.h" | 23 #include "core/css/CSSMarkup.h" |
| 24 #include "core/dom/Document.h" | 24 #include "core/dom/Document.h" |
| 25 #include "core/frame/LocalFrame.h" | 25 #include "core/frame/LocalFrame.h" |
| 26 #include "core/frame/Settings.h" | |
|
sclittle
2017/06/21 20:46:56
nit: remove unused include
| |
| 26 #include "core/loader/resource/ImageResourceContent.h" | 27 #include "core/loader/resource/ImageResourceContent.h" |
| 27 #include "core/style/StyleFetchedImage.h" | 28 #include "core/style/StyleFetchedImage.h" |
| 28 #include "core/style/StyleInvalidImage.h" | 29 #include "core/style/StyleInvalidImage.h" |
| 29 #include "platform/CrossOriginAttributeValue.h" | 30 #include "platform/CrossOriginAttributeValue.h" |
| 30 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" | 31 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" |
| 31 #include "platform/loader/fetch/FetchParameters.h" | 32 #include "platform/loader/fetch/FetchParameters.h" |
| 32 #include "platform/loader/fetch/ResourceFetcher.h" | 33 #include "platform/loader/fetch/ResourceFetcher.h" |
| 33 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 34 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| 34 #include "platform/weborigin/KURL.h" | 35 #include "platform/weborigin/KURL.h" |
| 35 #include "platform/weborigin/SecurityPolicy.h" | 36 #include "platform/weborigin/SecurityPolicy.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 46 absolute_url_(url.GetString()), | 47 absolute_url_(url.GetString()), |
| 47 cached_image_(image) {} | 48 cached_image_(image) {} |
| 48 | 49 |
| 49 CSSImageValue::CSSImageValue(const AtomicString& absolute_url) | 50 CSSImageValue::CSSImageValue(const AtomicString& absolute_url) |
| 50 : CSSValue(kImageClass), | 51 : CSSValue(kImageClass), |
| 51 relative_url_(absolute_url), | 52 relative_url_(absolute_url), |
| 52 absolute_url_(absolute_url) {} | 53 absolute_url_(absolute_url) {} |
| 53 | 54 |
| 54 CSSImageValue::~CSSImageValue() {} | 55 CSSImageValue::~CSSImageValue() {} |
| 55 | 56 |
| 56 StyleImage* CSSImageValue::CacheImage(const Document& document, | 57 StyleImage* CSSImageValue::CacheImage( |
| 57 CrossOriginAttributeValue cross_origin) { | 58 const Document& document, |
| 59 FetchParameters::PlaceholderImageRequestType placeholder_image_request_type, | |
| 60 CrossOriginAttributeValue cross_origin) { | |
| 58 if (!cached_image_) { | 61 if (!cached_image_) { |
| 59 if (absolute_url_.IsEmpty()) | 62 if (absolute_url_.IsEmpty()) |
| 60 ReResolveURL(document); | 63 ReResolveURL(document); |
| 61 ResourceRequest resource_request(absolute_url_); | 64 ResourceRequest resource_request(absolute_url_); |
| 62 resource_request.SetHTTPReferrer(SecurityPolicy::GenerateReferrer( | 65 resource_request.SetHTTPReferrer(SecurityPolicy::GenerateReferrer( |
| 63 referrer_.referrer_policy, resource_request.Url(), referrer_.referrer)); | 66 referrer_.referrer_policy, resource_request.Url(), referrer_.referrer)); |
| 64 ResourceLoaderOptions options(kAllowStoredCredentials, | 67 ResourceLoaderOptions options(kAllowStoredCredentials, |
| 65 kClientRequestedCredentials); | 68 kClientRequestedCredentials); |
| 66 options.initiator_info.name = initiator_name_.IsEmpty() | 69 options.initiator_info.name = initiator_name_.IsEmpty() |
| 67 ? FetchInitiatorTypeNames::css | 70 ? FetchInitiatorTypeNames::css |
| 68 : initiator_name_; | 71 : initiator_name_; |
| 69 FetchParameters params(resource_request, options); | 72 FetchParameters params(resource_request, options); |
| 70 | 73 |
| 71 if (cross_origin != kCrossOriginAttributeNotSet) { | 74 if (cross_origin != kCrossOriginAttributeNotSet) { |
| 72 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), | 75 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), |
| 73 cross_origin); | 76 cross_origin); |
| 74 } | 77 } |
| 75 if (document.GetFrame()) | 78 if (document.GetFrame() && |
| 79 placeholder_image_request_type == FetchParameters::kAllowPlaceholder) | |
| 76 document.GetFrame()->MaybeAllowImagePlaceholder(params); | 80 document.GetFrame()->MaybeAllowImagePlaceholder(params); |
| 77 | 81 |
| 78 if (ImageResourceContent* cached_image = | 82 if (ImageResourceContent* cached_image = |
| 79 ImageResourceContent::Fetch(params, document.Fetcher())) { | 83 ImageResourceContent::Fetch(params, document.Fetcher())) { |
| 80 cached_image_ = | 84 cached_image_ = |
| 81 StyleFetchedImage::Create(cached_image, document, params.Url()); | 85 StyleFetchedImage::Create(cached_image, document, params.Url()); |
| 82 } else { | 86 } else { |
| 83 cached_image_ = StyleInvalidImage::Create(Url()); | 87 cached_image_ = StyleInvalidImage::Create(Url()); |
| 84 } | 88 } |
| 85 } | 89 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 void CSSImageValue::ReResolveURL(const Document& document) const { | 138 void CSSImageValue::ReResolveURL(const Document& document) const { |
| 135 KURL url = document.CompleteURL(relative_url_); | 139 KURL url = document.CompleteURL(relative_url_); |
| 136 AtomicString url_string(url.GetString()); | 140 AtomicString url_string(url.GetString()); |
| 137 if (url_string == absolute_url_) | 141 if (url_string == absolute_url_) |
| 138 return; | 142 return; |
| 139 absolute_url_ = url_string; | 143 absolute_url_ = url_string; |
| 140 cached_image_.Clear(); | 144 cached_image_.Clear(); |
| 141 } | 145 } |
| 142 | 146 |
| 143 } // namespace blink | 147 } // namespace blink |
| OLD | NEW |