OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef ModuleScript_h | 5 #ifndef ModuleScript_h |
6 #define ModuleScript_h | 6 #define ModuleScript_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptModule.h" | 8 #include "bindings/core/v8/ScriptModule.h" |
9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
11 #include "bindings/core/v8/TraceWrapperV8Reference.h" | 11 #include "bindings/core/v8/TraceWrapperV8Reference.h" |
12 #include "core/CoreExport.h" | 12 #include "core/CoreExport.h" |
| 13 #include "core/dom/Script.h" |
13 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
14 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 15 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
15 #include "platform/weborigin/KURL.h" | 16 #include "platform/weborigin/KURL.h" |
16 #include "public/platform/WebURLRequest.h" | 17 #include "public/platform/WebURLRequest.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 | 20 |
20 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-
instantiation-state | 21 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-
instantiation-state |
21 enum class ModuleInstantiationState { | 22 enum class ModuleInstantiationState { |
22 kUninstantiated, | 23 kUninstantiated, |
23 kErrored, | 24 kErrored, |
24 kInstantiated, | 25 kInstantiated, |
25 }; | 26 }; |
26 | 27 |
27 // ModuleScript is a model object for the "module script" spec concept. | 28 // ModuleScript is a model object for the "module script" spec concept. |
28 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script | 29 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script |
29 class CORE_EXPORT ModuleScript final | 30 class CORE_EXPORT ModuleScript final : public Script { |
30 : public GarbageCollectedFinalized<ModuleScript>, | |
31 public TraceWrapperBase { | |
32 public: | 31 public: |
33 static ModuleScript* Create( | 32 static ModuleScript* Create( |
34 ScriptModule record, | 33 ScriptModule record, |
35 const KURL& base_url, | 34 const KURL& base_url, |
36 const String& nonce, | 35 const String& nonce, |
37 ParserDisposition parser_state, | 36 ParserDisposition parser_state, |
38 WebURLRequest::FetchCredentialsMode credentials_mode) { | 37 WebURLRequest::FetchCredentialsMode credentials_mode) { |
39 return new ModuleScript(record, base_url, nonce, parser_state, | 38 return new ModuleScript(record, base_url, nonce, parser_state, |
40 credentials_mode); | 39 credentials_mode); |
41 } | 40 } |
42 ~ModuleScript() = default; | 41 ~ModuleScript() override = default; |
43 | 42 |
44 ScriptModule& Record() { return record_; } | 43 ScriptModule& Record() { return record_; } |
45 void ClearRecord() { record_ = ScriptModule(); } | 44 void ClearRecord() { record_ = ScriptModule(); } |
46 const KURL& BaseURL() const { return base_url_; } | 45 const KURL& BaseURL() const { return base_url_; } |
47 | 46 |
48 ModuleInstantiationState InstantiationState() const { | 47 ModuleInstantiationState InstantiationState() const { |
49 return instantiation_state_; | 48 return instantiation_state_; |
50 } | 49 } |
51 | 50 |
52 void SetInstantiationSuccess(); | 51 void SetInstantiationSuccess(); |
(...skipping 14 matching lines...) Expand all Loading... |
67 const String& nonce, | 66 const String& nonce, |
68 ParserDisposition parser_state, | 67 ParserDisposition parser_state, |
69 WebURLRequest::FetchCredentialsMode credentials_mode) | 68 WebURLRequest::FetchCredentialsMode credentials_mode) |
70 : record_(record), | 69 : record_(record), |
71 base_url_(base_url), | 70 base_url_(base_url), |
72 instantiation_error_(this), | 71 instantiation_error_(this), |
73 nonce_(nonce), | 72 nonce_(nonce), |
74 parser_state_(parser_state), | 73 parser_state_(parser_state), |
75 credentials_mode_(credentials_mode) {} | 74 credentials_mode_(credentials_mode) {} |
76 | 75 |
| 76 ScriptType GetScriptType() const override { return ScriptType::kModule; } |
| 77 bool IsEmpty() const override; |
| 78 bool CheckMIMETypeBeforeRunScript(Document* context_document, |
| 79 const SecurityOrigin*) const override; |
| 80 void RunScript(LocalFrame*, const SecurityOrigin*) const override; |
| 81 String InlineSourceTextForCSP() const override; |
| 82 |
77 // Note: A "module script"'s "setttings object" is ommitted, as we currently | 83 // Note: A "module script"'s "setttings object" is ommitted, as we currently |
78 // always have access to the corresponding Modulator when operating on a | 84 // always have access to the corresponding Modulator when operating on a |
79 // ModuleScript instance. | 85 // ModuleScript instance. |
80 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object | 86 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object |
81 | 87 |
82 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-module-record | 88 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-module-record |
83 ScriptModule record_; | 89 ScriptModule record_; |
84 | 90 |
85 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-base-url | 91 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-base-url |
86 const KURL base_url_; | 92 const KURL base_url_; |
(...skipping 11 matching lines...) Expand all Loading... |
98 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-parser | 104 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-parser |
99 const ParserDisposition parser_state_; | 105 const ParserDisposition parser_state_; |
100 | 106 |
101 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-credentials-mode | 107 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-credentials-mode |
102 const WebURLRequest::FetchCredentialsMode credentials_mode_; | 108 const WebURLRequest::FetchCredentialsMode credentials_mode_; |
103 }; | 109 }; |
104 | 110 |
105 } // namespace blink | 111 } // namespace blink |
106 | 112 |
107 #endif | 113 #endif |
OLD | NEW |