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 "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // and allows null ScriptModule. | 46 // and allows null ScriptModule. |
47 static ModuleScript* CreateForTest(Modulator*, | 47 static ModuleScript* CreateForTest(Modulator*, |
48 ScriptModule, | 48 ScriptModule, |
49 const KURL& base_url, | 49 const KURL& base_url, |
50 const String& nonce, | 50 const String& nonce, |
51 ParserDisposition, | 51 ParserDisposition, |
52 WebURLRequest::FetchCredentialsMode); | 52 WebURLRequest::FetchCredentialsMode); |
53 | 53 |
54 ~ModuleScript() override = default; | 54 ~ModuleScript() override = default; |
55 | 55 |
56 const ScriptModule& Record() const { return record_; } | 56 ScriptModule Record() const; |
57 const KURL& BaseURL() const { return base_url_; } | 57 const KURL& BaseURL() const { return base_url_; } |
58 | 58 |
59 ModuleInstantiationState InstantiationState() const { | 59 ModuleInstantiationState InstantiationState() const { |
60 return instantiation_state_; | 60 return instantiation_state_; |
61 } | 61 } |
62 | 62 |
63 // Implements Step 7.1 of: | 63 // Implements Step 7.1 of: |
64 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri
pt-graph-fetching-procedure | 64 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri
pt-graph-fetching-procedure |
65 void SetInstantiationErrorAndClearRecord(ScriptValue error); | 65 void SetInstantiationErrorAndClearRecord(ScriptValue error); |
66 // Implements Step 7.2 of: | 66 // Implements Step 7.2 of: |
(...skipping 13 matching lines...) Expand all Loading... |
80 DECLARE_TRACE(); | 80 DECLARE_TRACE(); |
81 DECLARE_TRACE_WRAPPERS(); | 81 DECLARE_TRACE_WRAPPERS(); |
82 | 82 |
83 private: | 83 private: |
84 ModuleScript(Modulator* settings_object, | 84 ModuleScript(Modulator* settings_object, |
85 ScriptModule record, | 85 ScriptModule record, |
86 const KURL& base_url, | 86 const KURL& base_url, |
87 const String& nonce, | 87 const String& nonce, |
88 ParserDisposition parser_state, | 88 ParserDisposition parser_state, |
89 WebURLRequest::FetchCredentialsMode credentials_mode, | 89 WebURLRequest::FetchCredentialsMode credentials_mode, |
90 const String& source_text) | 90 const String& source_text); |
91 : settings_object_(settings_object), | |
92 record_(record), | |
93 base_url_(base_url), | |
94 instantiation_error_(this), | |
95 nonce_(nonce), | |
96 parser_state_(parser_state), | |
97 credentials_mode_(credentials_mode), | |
98 source_text_(source_text) {} | |
99 | 91 |
100 static ModuleScript* CreateInternal(const String& source_text, | 92 static ModuleScript* CreateInternal(const String& source_text, |
101 Modulator*, | 93 Modulator*, |
102 ScriptModule, | 94 ScriptModule, |
103 const KURL& base_url, | 95 const KURL& base_url, |
104 const String& nonce, | 96 const String& nonce, |
105 ParserDisposition, | 97 ParserDisposition, |
106 WebURLRequest::FetchCredentialsMode); | 98 WebURLRequest::FetchCredentialsMode); |
107 | 99 |
108 ScriptType GetScriptType() const override { return ScriptType::kModule; } | 100 ScriptType GetScriptType() const override { return ScriptType::kModule; } |
109 bool IsEmpty() const override; | 101 bool IsEmpty() const override; |
110 bool CheckMIMETypeBeforeRunScript(Document* context_document, | 102 bool CheckMIMETypeBeforeRunScript(Document* context_document, |
111 const SecurityOrigin*) const override; | 103 const SecurityOrigin*) const override; |
112 void RunScript(LocalFrame*, const SecurityOrigin*) const override; | 104 void RunScript(LocalFrame*, const SecurityOrigin*) const override; |
113 String InlineSourceTextForCSP() const override; | 105 String InlineSourceTextForCSP() const override; |
114 | 106 |
115 friend class ModulatorImpl; | 107 friend class ModulatorImpl; |
116 friend class ModuleTreeLinkerTestModulator; | 108 friend class ModuleTreeLinkerTestModulator; |
117 // Access this func only via ModulatorImpl::GetInstantiationError(), | 109 // Access this func only via ModulatorImpl::GetInstantiationError(), |
118 // or via Modulator mocks for unit tests. | 110 // or via Modulator mocks for unit tests. |
119 v8::Local<v8::Value> CreateInstantiationErrorInternal( | 111 v8::Local<v8::Value> CreateInstantiationErrorInternal( |
120 v8::Isolate* isolate) const { | 112 v8::Isolate* isolate) const { |
121 return instantiation_error_.NewLocal(isolate); | 113 return instantiation_error_.NewLocal(isolate); |
122 } | 114 } |
123 | 115 |
124 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object | 116 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object |
125 Member<Modulator> settings_object_; | 117 Member<Modulator> settings_object_; |
126 | 118 |
127 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-module-record | 119 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-module-record |
128 ScriptModule record_; | 120 TraceWrapperV8Reference<v8::Module> record_; |
129 | 121 |
130 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-base-url | 122 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-base-url |
131 const KURL base_url_; | 123 const KURL base_url_; |
132 | 124 |
133 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-instantiation-state | 125 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-instantiation-state |
134 ModuleInstantiationState instantiation_state_ = | 126 ModuleInstantiationState instantiation_state_ = |
135 ModuleInstantiationState::kUninstantiated; | 127 ModuleInstantiationState::kUninstantiated; |
136 | 128 |
137 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-instantiation-error | 129 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-instantiation-error |
138 // | 130 // |
(...skipping 14 matching lines...) Expand all Loading... |
153 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-credentials-mode | 145 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-credentials-mode |
154 const WebURLRequest::FetchCredentialsMode credentials_mode_; | 146 const WebURLRequest::FetchCredentialsMode credentials_mode_; |
155 | 147 |
156 // For CSP check. | 148 // For CSP check. |
157 const String source_text_; | 149 const String source_text_; |
158 }; | 150 }; |
159 | 151 |
160 } // namespace blink | 152 } // namespace blink |
161 | 153 |
162 #endif | 154 #endif |
OLD | NEW |