OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2012 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 kNotAboutToExecuteScript | 61 kNotAboutToExecuteScript |
62 }; | 62 }; |
63 | 63 |
64 class CORE_EXPORT ExecutionContext : public ContextLifecycleNotifier, | 64 class CORE_EXPORT ExecutionContext : public ContextLifecycleNotifier, |
65 public Supplementable<ExecutionContext> { | 65 public Supplementable<ExecutionContext> { |
66 WTF_MAKE_NONCOPYABLE(ExecutionContext); | 66 WTF_MAKE_NONCOPYABLE(ExecutionContext); |
67 | 67 |
68 public: | 68 public: |
69 DECLARE_VIRTUAL_TRACE(); | 69 DECLARE_VIRTUAL_TRACE(); |
70 | 70 |
71 // Used to specify whether |isSecureContext| should walk the | |
72 // ancestor tree to decide whether to restrict usage of a powerful | |
73 // feature. | |
74 enum SecureContextCheck { | |
75 kStandardSecureContextCheck, | |
76 kWebCryptoSecureContextCheck | |
77 }; | |
78 | |
79 static ExecutionContext* From(const ScriptState*); | 71 static ExecutionContext* From(const ScriptState*); |
80 | 72 |
81 virtual bool IsDocument() const { return false; } | 73 virtual bool IsDocument() const { return false; } |
82 virtual bool IsWorkerOrWorkletGlobalScope() const { return false; } | 74 virtual bool IsWorkerOrWorkletGlobalScope() const { return false; } |
83 virtual bool IsWorkerGlobalScope() const { return false; } | 75 virtual bool IsWorkerGlobalScope() const { return false; } |
84 virtual bool IsWorkletGlobalScope() const { return false; } | 76 virtual bool IsWorkletGlobalScope() const { return false; } |
85 virtual bool IsMainThreadWorkletGlobalScope() const { return false; } | 77 virtual bool IsMainThreadWorkletGlobalScope() const { return false; } |
86 virtual bool IsDedicatedWorkerGlobalScope() const { return false; } | 78 virtual bool IsDedicatedWorkerGlobalScope() const { return false; } |
87 virtual bool IsSharedWorkerGlobalScope() const { return false; } | 79 virtual bool IsSharedWorkerGlobalScope() const { return false; } |
88 virtual bool IsServiceWorkerGlobalScope() const { return false; } | 80 virtual bool IsServiceWorkerGlobalScope() const { return false; } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 virtual EventQueue* GetEventQueue() const = 0; | 157 virtual EventQueue* GetEventQueue() const = 0; |
166 | 158 |
167 // Methods related to window interaction. It should be used to manage window | 159 // Methods related to window interaction. It should be used to manage window |
168 // focusing and window creation permission for an ExecutionContext. | 160 // focusing and window creation permission for an ExecutionContext. |
169 void AllowWindowInteraction(); | 161 void AllowWindowInteraction(); |
170 void ConsumeWindowInteraction(); | 162 void ConsumeWindowInteraction(); |
171 bool IsWindowInteractionAllowed() const; | 163 bool IsWindowInteractionAllowed() const; |
172 | 164 |
173 // Decides whether this context is privileged, as described in | 165 // Decides whether this context is privileged, as described in |
174 // https://w3c.github.io/webappsec/specs/powerfulfeatures/#settings-privileged
. | 166 // https://w3c.github.io/webappsec/specs/powerfulfeatures/#settings-privileged
. |
175 virtual bool IsSecureContext( | 167 virtual bool IsSecureContext(String& error_message) const = 0; |
176 String& error_message, | 168 virtual bool IsSecureContext() const; |
177 const SecureContextCheck = kStandardSecureContextCheck) const = 0; | |
178 virtual bool IsSecureContext( | |
179 const SecureContextCheck = kStandardSecureContextCheck) const; | |
180 | 169 |
181 virtual String OutgoingReferrer() const; | 170 virtual String OutgoingReferrer() const; |
182 // Parses a comma-separated list of referrer policy tokens, and sets | 171 // Parses a comma-separated list of referrer policy tokens, and sets |
183 // the context's referrer policy to the last one that is a valid | 172 // the context's referrer policy to the last one that is a valid |
184 // policy. Logs a message to the console if none of the policy | 173 // policy. Logs a message to the console if none of the policy |
185 // tokens are valid policies. | 174 // tokens are valid policies. |
186 // | 175 // |
187 // If |supportLegacyKeywords| is true, then the legacy keywords | 176 // If |supportLegacyKeywords| is true, then the legacy keywords |
188 // "never", "default", "always", and "origin-when-crossorigin" are | 177 // "never", "default", "always", and "origin-when-crossorigin" are |
189 // parsed as valid policies. | 178 // parsed as valid policies. |
(...skipping 27 matching lines...) Expand all Loading... |
217 // |allowWindowInteraction()| and |consumeWindowInteraction()| in order to | 206 // |allowWindowInteraction()| and |consumeWindowInteraction()| in order to |
218 // increment and decrement the counter. | 207 // increment and decrement the counter. |
219 int window_interaction_tokens_; | 208 int window_interaction_tokens_; |
220 | 209 |
221 ReferrerPolicy referrer_policy_; | 210 ReferrerPolicy referrer_policy_; |
222 }; | 211 }; |
223 | 212 |
224 } // namespace blink | 213 } // namespace blink |
225 | 214 |
226 #endif // ExecutionContext_h | 215 #endif // ExecutionContext_h |
OLD | NEW |