OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 ASSERT(resource->type() == Resource::Script); | 158 ASSERT(resource->type() == Resource::Script); |
159 ScriptResource* scriptResource = toScriptResource(resource); | 159 ScriptResource* scriptResource = toScriptResource(resource); |
160 String integrityAttr = m_element->fastGetAttribute(HTMLNames::integrityA
ttr); | 160 String integrityAttr = m_element->fastGetAttribute(HTMLNames::integrityA
ttr); |
161 | 161 |
162 // It is possible to get back a script resource with integrity metadata | 162 // It is possible to get back a script resource with integrity metadata |
163 // for a request with an empty integrity attribute. In that case, the | 163 // for a request with an empty integrity attribute. In that case, the |
164 // integrity check should be skipped, so this check ensures that the | 164 // integrity check should be skipped, so this check ensures that the |
165 // integrity attribute isn't empty in addition to checking if the | 165 // integrity attribute isn't empty in addition to checking if the |
166 // resource has empty integrity metadata. | 166 // resource has empty integrity metadata. |
167 if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isE
mpty()) { | 167 if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isE
mpty()) { |
168 if (!scriptResource->integrityAlreadyChecked() && resource->resource
Buffer()) { | 168 ScriptIntegrityDisposition disposition = scriptResource->integrityDi
sposition(); |
169 scriptResource->setIntegrityAlreadyChecked(true); | 169 if (disposition == ScriptIntegrityDisposition::Failed) { |
| 170 // TODO(jww): This should probably also generate a console |
| 171 // message identical to the one produced by |
| 172 // CheckSubresourceIntegrity below. See https://crbug.com/585267
. |
| 173 m_integrityFailure = true; |
| 174 } else if (disposition == ScriptIntegrityDisposition::NotChecked &&
resource->resourceBuffer()) { |
170 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceInte
grity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer(
)->data(), resource->resourceBuffer()->size(), resource->url(), *resource); | 175 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceInte
grity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer(
)->data(), resource->resourceBuffer()->size(), resource->url(), *resource); |
| 176 scriptResource->setIntegrityDisposition(m_integrityFailure ? Scr
iptIntegrityDisposition::Failed : ScriptIntegrityDisposition::Passed); |
171 } | 177 } |
172 } | 178 } |
173 } | 179 } |
174 | 180 |
175 if (m_streamer) | 181 if (m_streamer) |
176 m_streamer->notifyFinished(resource); | 182 m_streamer->notifyFinished(resource); |
177 } | 183 } |
178 | 184 |
179 void PendingScript::notifyAppendData(ScriptResource* resource) | 185 void PendingScript::notifyAppendData(ScriptResource* resource) |
180 { | 186 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 bool PendingScript::isReady() const | 218 bool PendingScript::isReady() const |
213 { | 219 { |
214 if (resource() && !resource()->isLoaded()) | 220 if (resource() && !resource()->isLoaded()) |
215 return false; | 221 return false; |
216 if (m_streamer && !m_streamer->isFinished()) | 222 if (m_streamer && !m_streamer->isFinished()) |
217 return false; | 223 return false; |
218 return true; | 224 return true; |
219 } | 225 } |
220 | 226 |
221 } // namespace blink | 227 } // namespace blink |
OLD | NEW |