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 Script_h | 5 #ifndef Script_h |
6 #define Script_h | 6 #define Script_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
11 #include "platform/wtf/text/WTFString.h" | 11 #include "platform/wtf/text/WTFString.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class Document; | 15 class Document; |
16 class LocalFrame; | 16 class LocalFrame; |
17 class SecurityOrigin; | 17 class SecurityOrigin; |
18 | 18 |
19 enum class ScriptType { kClassic, kModule }; | 19 enum class ScriptType { kClassic, kModule }; |
20 | 20 |
21 // https://html.spec.whatwg.org/#concept-script | 21 // https://html.spec.whatwg.org/#concept-script |
22 class CORE_EXPORT Script : public GarbageCollectedFinalized<Script>, | 22 class CORE_EXPORT Script : public GarbageCollectedFinalized<Script> { |
23 public TraceWrapperBase { | |
24 public: | 23 public: |
25 DEFINE_INLINE_VIRTUAL_TRACE() {} | 24 DEFINE_INLINE_VIRTUAL_TRACE() {} |
26 DEFINE_INLINE_VIRTUAL_TRACE_WRAPPERS() {} | |
27 | 25 |
28 virtual ~Script() {} | 26 virtual ~Script() {} |
29 | 27 |
30 virtual ScriptType GetScriptType() const = 0; | 28 virtual ScriptType GetScriptType() const = 0; |
31 | 29 |
32 // Used to skip execution of the script if it is empty. | 30 // Used to skip execution of the script if it is empty. |
33 virtual bool IsEmpty() const = 0; | 31 virtual bool IsEmpty() const = 0; |
34 | 32 |
35 // Returns false if the script should not be run due to MIME type check. | 33 // Returns false if the script should not be run due to MIME type check. |
36 virtual bool CheckMIMETypeBeforeRunScript(Document* context_document, | 34 virtual bool CheckMIMETypeBeforeRunScript(Document* context_document, |
37 const SecurityOrigin*) const = 0; | 35 const SecurityOrigin*) const = 0; |
38 | 36 |
39 // https://html.spec.whatwg.org/#run-a-classic-script or | 37 // https://html.spec.whatwg.org/#run-a-classic-script or |
40 // https://html.spec.whatwg.org/#run-a-module-script, | 38 // https://html.spec.whatwg.org/#run-a-module-script, |
41 // depending on the script type. | 39 // depending on the script type. |
42 virtual void RunScript(LocalFrame*, const SecurityOrigin*) const = 0; | 40 virtual void RunScript(LocalFrame*, const SecurityOrigin*) const = 0; |
43 | 41 |
44 // For CSP check for inline scripts. | 42 // For CSP check for inline scripts. |
45 virtual String InlineSourceTextForCSP() const = 0; | 43 virtual String InlineSourceTextForCSP() const = 0; |
46 }; | 44 }; |
47 | 45 |
48 } // namespace blink | 46 } // namespace blink |
49 | 47 |
50 #endif | 48 #endif |
OLD | NEW |