| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public: | 32 public: |
| 33 // https://html.spec.whatwg.org/#creating-a-module-script | 33 // https://html.spec.whatwg.org/#creating-a-module-script |
| 34 static ModuleScript* Create(const String& source_text, | 34 static ModuleScript* Create(const String& source_text, |
| 35 Modulator*, | 35 Modulator*, |
| 36 const KURL& base_url, | 36 const KURL& base_url, |
| 37 const String& nonce, | 37 const String& nonce, |
| 38 ParserDisposition, | 38 ParserDisposition, |
| 39 WebURLRequest::FetchCredentialsMode, | 39 WebURLRequest::FetchCredentialsMode, |
| 40 AccessControlStatus); | 40 AccessControlStatus); |
| 41 | 41 |
| 42 static ModuleScript* CreateForTest( | 42 // Mostly corresponds to Create() but accepts ScriptModule as the argument |
| 43 Modulator* settings_object, | 43 // and allows null ScriptModule. |
| 44 ScriptModule record, | 44 static ModuleScript* CreateForTest(Modulator*, |
| 45 const KURL& base_url, | 45 ScriptModule, |
| 46 const String& nonce, | 46 const KURL& base_url, |
| 47 ParserDisposition parser_state, | 47 const String& nonce, |
| 48 WebURLRequest::FetchCredentialsMode credentials_mode) { | 48 ParserDisposition, |
| 49 return new ModuleScript(settings_object, record, base_url, nonce, | 49 WebURLRequest::FetchCredentialsMode); |
| 50 parser_state, credentials_mode); | 50 |
| 51 } | |
| 52 ~ModuleScript() override = default; | 51 ~ModuleScript() override = default; |
| 53 | 52 |
| 54 const ScriptModule& Record() const { return record_; } | 53 const ScriptModule& Record() const { return record_; } |
| 55 const KURL& BaseURL() const { return base_url_; } | 54 const KURL& BaseURL() const { return base_url_; } |
| 56 | 55 |
| 57 ModuleInstantiationState InstantiationState() const { | 56 ModuleInstantiationState InstantiationState() const { |
| 58 return instantiation_state_; | 57 return instantiation_state_; |
| 59 } | 58 } |
| 60 | 59 |
| 61 v8::Local<v8::Value> CreateInstantiationError(v8::Isolate* isolate) const { | 60 v8::Local<v8::Value> CreateInstantiationError(v8::Isolate* isolate) const { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 ParserDisposition parser_state, | 85 ParserDisposition parser_state, |
| 87 WebURLRequest::FetchCredentialsMode credentials_mode) | 86 WebURLRequest::FetchCredentialsMode credentials_mode) |
| 88 : settings_object_(settings_object), | 87 : settings_object_(settings_object), |
| 89 record_(record), | 88 record_(record), |
| 90 base_url_(base_url), | 89 base_url_(base_url), |
| 91 instantiation_error_(this), | 90 instantiation_error_(this), |
| 92 nonce_(nonce), | 91 nonce_(nonce), |
| 93 parser_state_(parser_state), | 92 parser_state_(parser_state), |
| 94 credentials_mode_(credentials_mode) {} | 93 credentials_mode_(credentials_mode) {} |
| 95 | 94 |
| 95 static ModuleScript* CreateInternal(Modulator*, |
| 96 ScriptModule, |
| 97 const KURL& base_url, |
| 98 const String& nonce, |
| 99 ParserDisposition, |
| 100 WebURLRequest::FetchCredentialsMode); |
| 101 |
| 96 ScriptType GetScriptType() const override { return ScriptType::kModule; } | 102 ScriptType GetScriptType() const override { return ScriptType::kModule; } |
| 97 bool IsEmpty() const override; | 103 bool IsEmpty() const override; |
| 98 bool CheckMIMETypeBeforeRunScript(Document* context_document, | 104 bool CheckMIMETypeBeforeRunScript(Document* context_document, |
| 99 const SecurityOrigin*) const override; | 105 const SecurityOrigin*) const override; |
| 100 void RunScript(LocalFrame*, const SecurityOrigin*) const override; | 106 void RunScript(LocalFrame*, const SecurityOrigin*) const override; |
| 101 String InlineSourceTextForCSP() const override; | 107 String InlineSourceTextForCSP() const override; |
| 102 | 108 |
| 103 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object | 109 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object |
| 104 Member<Modulator> settings_object_; | 110 Member<Modulator> settings_object_; |
| 105 | 111 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 129 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-parser | 135 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-parser |
| 130 const ParserDisposition parser_state_; | 136 const ParserDisposition parser_state_; |
| 131 | 137 |
| 132 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-credentials-mode | 138 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-credentials-mode |
| 133 const WebURLRequest::FetchCredentialsMode credentials_mode_; | 139 const WebURLRequest::FetchCredentialsMode credentials_mode_; |
| 134 }; | 140 }; |
| 135 | 141 |
| 136 } // namespace blink | 142 } // namespace blink |
| 137 | 143 |
| 138 #endif | 144 #endif |
| OLD | NEW |