Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/worklet/Worklet.h" | 5 #include "modules/worklet/Worklet.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| 11 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
| 12 #include "core/inspector/InspectorInstrumentation.h" | 12 #include "core/inspector/InspectorInstrumentation.h" |
| 13 #include "core/workers/WorkletGlobalScopeProxy.h" | 13 #include "core/workers/WorkletGlobalScopeProxy.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 Worklet::Worklet(ExecutionContext* executionContext) | 17 Worklet::Worklet(ExecutionContext* executionContext) |
| 18 : ActiveDOMObject(executionContext) | 18 : ActiveDOMObject(executionContext) |
| 19 { | 19 { |
| 20 } | 20 } |
| 21 | 21 |
| 22 ScriptPromise Worklet::import(ScriptState* scriptState, const String& url) | 22 ScriptPromise Worklet::import(ScriptState* scriptState, const String& url) |
| 23 { | 23 { |
| 24 KURL scriptURL = getExecutionContext()->completeURL(url); | 24 KURL scriptURL = getExecutionContext()->completeURL(url); |
| 25 if (!scriptURL.isValid()) { | 25 if (!scriptURL.isValid()) { |
| 26 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SyntaxError, "'" + url + "' is not a valid URL.")); | 26 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SyntaxError, "'" + url + "' is not a valid URL.")); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // TODO(ikilpatrick): Perform upfront CSP checks once we decide on a | 29 if (!getExecutionContext()->securityContext().contentSecurityPolicy()->allow ScriptFromSource(scriptURL, AtomicString())) { |
| 30 // CSP-policy for worklets. | 30 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NetworkError, "Access to '" + scriptURL.elidedString() + "' is denied by document's Content Security Policies.")); |
|
Mike West
2016/07/21 07:26:48
Hrm. This seems inconsistent with the way we handl
| |
| 31 } | |
| 31 | 32 |
| 32 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | 33 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; |
| 33 m_resolvers.append(resolver); | 34 m_resolvers.append(resolver); |
| 34 | 35 |
| 35 ScriptPromise promise = resolver->promise(); | 36 ScriptPromise promise = resolver->promise(); |
| 36 | 37 |
| 37 // TODO(ikilpatrick): WorkerScriptLoader will need to be extended to allow | 38 // TODO(ikilpatrick): WorkerScriptLoader will need to be extended to allow |
| 38 // module loading support. For now just fetch a 'classic' script. | 39 // module loading support. For now just fetch a 'classic' script. |
| 39 | 40 |
| 40 // NOTE: WorkerScriptLoader may synchronously invoke its callbacks | 41 // NOTE: WorkerScriptLoader may synchronously invoke its callbacks |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 } | 85 } |
| 85 } | 86 } |
| 86 | 87 |
| 87 DEFINE_TRACE(Worklet) | 88 DEFINE_TRACE(Worklet) |
| 88 { | 89 { |
| 89 visitor->trace(m_resolvers); | 90 visitor->trace(m_resolvers); |
| 90 ActiveDOMObject::trace(visitor); | 91 ActiveDOMObject::trace(visitor); |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |