OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/frame/SubresourceIntegrity.h" | 5 #include "core/frame/SubresourceIntegrity.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
10 #include "core/fetch/Resource.h" | 10 #include "core/fetch/Resource.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (integrityParseResult != IntegrityParseValidResult) | 114 if (integrityParseResult != IntegrityParseValidResult) |
115 return true; | 115 return true; |
116 | 116 |
117 return CheckSubresourceIntegrity(metadataSet, element, content, size, resour
ceUrl, resource); | 117 return CheckSubresourceIntegrity(metadataSet, element, content, size, resour
ceUrl, resource); |
118 } | 118 } |
119 | 119 |
120 bool SubresourceIntegrity::CheckSubresourceIntegrity(const IntegrityMetadataSet&
metadataSet, const Element& element, const char* content, size_t size, const KU
RL& resourceUrl, const Resource& resource) | 120 bool SubresourceIntegrity::CheckSubresourceIntegrity(const IntegrityMetadataSet&
metadataSet, const Element& element, const char* content, size_t size, const KU
RL& resourceUrl, const Resource& resource) |
121 { | 121 { |
122 Document& document = element.document(); | 122 Document& document = element.document(); |
123 | 123 |
124 if (!resource.isEligibleForIntegrityCheck(document.securityOrigin())) { | 124 if (!resource.isEligibleForIntegrityCheck(document.getSecurityOrigin())) { |
125 UseCounter::count(document, UseCounter::SRIElementIntegrityAttributeButI
neligible); | 125 UseCounter::count(document, UseCounter::SRIElementIntegrityAttributeButI
neligible); |
126 logErrorToConsole("Subresource Integrity: The resource '" + resourceUrl.
elidedString() + "' has an integrity attribute, but the resource requires the re
quest to be CORS enabled to check the integrity, and it is not. The resource has
been blocked because the integrity cannot be enforced.", document); | 126 logErrorToConsole("Subresource Integrity: The resource '" + resourceUrl.
elidedString() + "' has an integrity attribute, but the resource requires the re
quest to be CORS enabled to check the integrity, and it is not. The resource has
been blocked because the integrity cannot be enforced.", document); |
127 return false; | 127 return false; |
128 } | 128 } |
129 | 129 |
130 String errorMessage; | 130 String errorMessage; |
131 bool result = CheckSubresourceIntegrity(metadataSet, content, size, resource
Url, document, errorMessage); | 131 bool result = CheckSubresourceIntegrity(metadataSet, content, size, resource
Url, document, errorMessage); |
132 if (!result) | 132 if (!result) |
133 logErrorToConsole(errorMessage, document); | 133 logErrorToConsole(errorMessage, document); |
134 return result; | 134 return result; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 metadataSet.add(integrityMetadata.toPair()); | 351 metadataSet.add(integrityMetadata.toPair()); |
352 } | 352 } |
353 | 353 |
354 if (metadataSet.size() == 0 && error) | 354 if (metadataSet.size() == 0 && error) |
355 return IntegrityParseNoValidResult; | 355 return IntegrityParseNoValidResult; |
356 | 356 |
357 return IntegrityParseValidResult; | 357 return IntegrityParseValidResult; |
358 } | 358 } |
359 | 359 |
360 } // namespace blink | 360 } // namespace blink |
OLD | NEW |