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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 ASSERT(resource->type() == Resource::Script); | 143 ASSERT(resource->type() == Resource::Script); |
144 ScriptResource* scriptResource = toScriptResource(resource); | 144 ScriptResource* scriptResource = toScriptResource(resource); |
145 String integrityAttr = m_element->fastGetAttribute(HTMLNames::integrityA ttr); | 145 String integrityAttr = m_element->fastGetAttribute(HTMLNames::integrityA ttr); |
146 | 146 |
147 // It is possible to get back a script resource with integrity metadata | 147 // It is possible to get back a script resource with integrity metadata |
148 // for a request with an empty integrity attribute. In that case, the | 148 // for a request with an empty integrity attribute. In that case, the |
149 // integrity check should be skipped, so this check ensures that the | 149 // integrity check should be skipped, so this check ensures that the |
150 // integrity attribute isn't empty in addition to checking if the | 150 // integrity attribute isn't empty in addition to checking if the |
151 // resource has empty integrity metadata. | 151 // resource has empty integrity metadata. |
152 if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isE mpty()) { | 152 if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isE mpty()) { |
153 if (!scriptResource->integrityAlreadyChecked() && resource->resource Buffer()) { | 153 ScriptIntegrityDisposition disposition = scriptResource->integrityDi sposition(); |
154 scriptResource->setIntegrityAlreadyChecked(true); | 154 if (disposition == IntegrityFailed) { |
155 // TODO(jww): This should probably also generate a console | |
156 // message identical to the one produced by | |
157 // CheckSubresourceIntegrity below. | |
158 m_integrityFailure = true; | |
159 } else if (disposition == IntegrityNotChecked && resource->resourceB uffer()) { | |
155 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceInte grity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer( )->data(), resource->resourceBuffer()->size(), resource->url(), *resource); | 160 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceInte grity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer( )->data(), resource->resourceBuffer()->size(), resource->url(), *resource); |
161 scriptResource->setIntegrityAlreadyChecked(!m_integrityFailure); | |
dcheng
2016/02/09 01:12:46
I don't think it's obvious from the callsite that
jww
2016/02/09 04:38:50
Done.
| |
156 } | 162 } |
157 } | 163 } |
158 } | 164 } |
159 | 165 |
160 if (m_streamer) | 166 if (m_streamer) |
161 m_streamer->notifyFinished(resource); | 167 m_streamer->notifyFinished(resource); |
162 } | 168 } |
163 | 169 |
164 void PendingScript::notifyAppendData(ScriptResource* resource) | 170 void PendingScript::notifyAppendData(ScriptResource* resource) |
165 { | 171 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 bool PendingScript::isReady() const | 203 bool PendingScript::isReady() const |
198 { | 204 { |
199 if (resource() && !resource()->isLoaded()) | 205 if (resource() && !resource()->isLoaded()) |
200 return false; | 206 return false; |
201 if (m_streamer && !m_streamer->isFinished()) | 207 if (m_streamer && !m_streamer->isFinished()) |
202 return false; | 208 return false; |
203 return true; | 209 return true; |
204 } | 210 } |
205 | 211 |
206 } // namespace blink | 212 } // namespace blink |
OLD | NEW |