| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 class EventQueue; | 52 class EventQueue; |
| 53 class EventTarget; | 53 class EventTarget; |
| 54 class ExecutionContextTask; | 54 class ExecutionContextTask; |
| 55 class LocalDOMWindow; | 55 class LocalDOMWindow; |
| 56 class OriginTrialContext; | 56 class OriginTrialContext; |
| 57 class PublicURLManager; | 57 class PublicURLManager; |
| 58 class SecurityOrigin; | 58 class SecurityOrigin; |
| 59 class ScriptCallStack; | 59 class ScriptCallStack; |
| 60 | 60 |
| 61 class CORE_EXPORT ExecutionContext | 61 class CORE_EXPORT ExecutionContext |
| 62 : public ContextLifecycleNotifier, public WillBeHeapSupplementable<Execution
Context> { | 62 : public ContextLifecycleNotifier, public HeapSupplementable<ExecutionContex
t> { |
| 63 WTF_MAKE_NONCOPYABLE(ExecutionContext); | 63 WTF_MAKE_NONCOPYABLE(ExecutionContext); |
| 64 public: | 64 public: |
| 65 DECLARE_VIRTUAL_TRACE(); | 65 DECLARE_VIRTUAL_TRACE(); |
| 66 | 66 |
| 67 // Used to specify whether |isSecureContext| should walk the | 67 // Used to specify whether |isSecureContext| should walk the |
| 68 // ancestor tree to decide whether to restrict usage of a powerful | 68 // ancestor tree to decide whether to restrict usage of a powerful |
| 69 // feature. | 69 // feature. |
| 70 enum SecureContextCheck { | 70 enum SecureContextCheck { |
| 71 StandardSecureContextCheck, | 71 StandardSecureContextCheck, |
| 72 WebCryptoSecureContextCheck | 72 WebCryptoSecureContextCheck |
| (...skipping 26 matching lines...) Expand all Loading... |
| 99 // not be used after the ExecutionContext is destroyed. | 99 // not be used after the ExecutionContext is destroyed. |
| 100 virtual DOMTimerCoordinator* timers() = 0; | 100 virtual DOMTimerCoordinator* timers() = 0; |
| 101 | 101 |
| 102 virtual void reportBlockedScriptExecutionToInspector(const String& directive
Text) = 0; | 102 virtual void reportBlockedScriptExecutionToInspector(const String& directive
Text) = 0; |
| 103 | 103 |
| 104 virtual SecurityContext& securityContext() = 0; | 104 virtual SecurityContext& securityContext() = 0; |
| 105 KURL contextURL() const { return virtualURL(); } | 105 KURL contextURL() const { return virtualURL(); } |
| 106 KURL contextCompleteURL(const String& url) const { return virtualCompleteURL
(url); } | 106 KURL contextCompleteURL(const String& url) const { return virtualCompleteURL
(url); } |
| 107 | 107 |
| 108 bool shouldSanitizeScriptError(const String& sourceURL, AccessControlStatus)
; | 108 bool shouldSanitizeScriptError(const String& sourceURL, AccessControlStatus)
; |
| 109 void reportException(PassRefPtrWillBeRawPtr<ErrorEvent>, int scriptId, PassR
efPtr<ScriptCallStack>, AccessControlStatus); | 109 void reportException(RawPtr<ErrorEvent>, int scriptId, PassRefPtr<ScriptCall
Stack>, AccessControlStatus); |
| 110 | 110 |
| 111 virtual void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) = 0; | 111 virtual void addConsoleMessage(RawPtr<ConsoleMessage>) = 0; |
| 112 virtual void logExceptionToConsole(const String& errorMessage, int scriptId,
const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCal
lStack>) = 0; | 112 virtual void logExceptionToConsole(const String& errorMessage, int scriptId,
const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCal
lStack>) = 0; |
| 113 | 113 |
| 114 PublicURLManager& publicURLManager(); | 114 PublicURLManager& publicURLManager(); |
| 115 | 115 |
| 116 virtual void removeURLFromMemoryCache(const KURL&); | 116 virtual void removeURLFromMemoryCache(const KURL&); |
| 117 | 117 |
| 118 void suspendActiveDOMObjects(); | 118 void suspendActiveDOMObjects(); |
| 119 void resumeActiveDOMObjects(); | 119 void resumeActiveDOMObjects(); |
| 120 void stopActiveDOMObjects(); | 120 void stopActiveDOMObjects(); |
| 121 void postSuspendableTask(PassOwnPtr<SuspendableTask>); | 121 void postSuspendableTask(PassOwnPtr<SuspendableTask>); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 151 | 151 |
| 152 // Decides whether this context is privileged, as described in | 152 // Decides whether this context is privileged, as described in |
| 153 // https://w3c.github.io/webappsec/specs/powerfulfeatures/#settings-privileg
ed. | 153 // https://w3c.github.io/webappsec/specs/powerfulfeatures/#settings-privileg
ed. |
| 154 virtual bool isSecureContext(String& errorMessage, const SecureContextCheck
= StandardSecureContextCheck) const = 0; | 154 virtual bool isSecureContext(String& errorMessage, const SecureContextCheck
= StandardSecureContextCheck) const = 0; |
| 155 virtual bool isSecureContext(const SecureContextCheck = StandardSecureContex
tCheck) const; | 155 virtual bool isSecureContext(const SecureContextCheck = StandardSecureContex
tCheck) const; |
| 156 | 156 |
| 157 virtual void setReferrerPolicy(ReferrerPolicy); | 157 virtual void setReferrerPolicy(ReferrerPolicy); |
| 158 ReferrerPolicy getReferrerPolicy() const { return m_referrerPolicy; } | 158 ReferrerPolicy getReferrerPolicy() const { return m_referrerPolicy; } |
| 159 | 159 |
| 160 // Override to enable experimental features through origin trials | 160 // Override to enable experimental features through origin trials |
| 161 virtual PassOwnPtrWillBeRawPtr<OriginTrialContext> createOriginTrialContext(
); | 161 virtual RawPtr<OriginTrialContext> createOriginTrialContext(); |
| 162 | 162 |
| 163 protected: | 163 protected: |
| 164 ExecutionContext(); | 164 ExecutionContext(); |
| 165 virtual ~ExecutionContext(); | 165 virtual ~ExecutionContext(); |
| 166 | 166 |
| 167 virtual const KURL& virtualURL() const = 0; | 167 virtual const KURL& virtualURL() const = 0; |
| 168 virtual KURL virtualCompleteURL(const String&) const = 0; | 168 virtual KURL virtualCompleteURL(const String&) const = 0; |
| 169 | 169 |
| 170 private: | 170 private: |
| 171 bool dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent>, AccessControlSta
tus); | 171 bool dispatchErrorEvent(RawPtr<ErrorEvent>, AccessControlStatus); |
| 172 void runSuspendableTasks(); | 172 void runSuspendableTasks(); |
| 173 | 173 |
| 174 #if !ENABLE(OILPAN) | 174 #if !ENABLE(OILPAN) |
| 175 virtual void refExecutionContext() = 0; | 175 virtual void refExecutionContext() = 0; |
| 176 virtual void derefExecutionContext() = 0; | 176 virtual void derefExecutionContext() = 0; |
| 177 #endif | 177 #endif |
| 178 // LifecycleContext implementation. | 178 // LifecycleContext implementation. |
| 179 | 179 |
| 180 unsigned m_circularSequentialID; | 180 unsigned m_circularSequentialID; |
| 181 | 181 |
| 182 bool m_inDispatchErrorEvent; | 182 bool m_inDispatchErrorEvent; |
| 183 class PendingException; | 183 class PendingException; |
| 184 OwnPtr<Vector<OwnPtr<PendingException>>> m_pendingExceptions; | 184 OwnPtr<Vector<OwnPtr<PendingException>>> m_pendingExceptions; |
| 185 | 185 |
| 186 bool m_activeDOMObjectsAreSuspended; | 186 bool m_activeDOMObjectsAreSuspended; |
| 187 bool m_activeDOMObjectsAreStopped; | 187 bool m_activeDOMObjectsAreStopped; |
| 188 | 188 |
| 189 OwnPtrWillBeMember<PublicURLManager> m_publicURLManager; | 189 Member<PublicURLManager> m_publicURLManager; |
| 190 | 190 |
| 191 // Counter that keeps track of how many window interaction calls are allowed | 191 // Counter that keeps track of how many window interaction calls are allowed |
| 192 // for this ExecutionContext. Callers are expected to call | 192 // for this ExecutionContext. Callers are expected to call |
| 193 // |allowWindowInteraction()| and |consumeWindowInteraction()| in order to | 193 // |allowWindowInteraction()| and |consumeWindowInteraction()| in order to |
| 194 // increment and decrement the counter. | 194 // increment and decrement the counter. |
| 195 int m_windowInteractionTokens; | 195 int m_windowInteractionTokens; |
| 196 | 196 |
| 197 Deque<OwnPtr<SuspendableTask>> m_suspendedTasks; | 197 Deque<OwnPtr<SuspendableTask>> m_suspendedTasks; |
| 198 bool m_isRunSuspendableTasksScheduled; | 198 bool m_isRunSuspendableTasksScheduled; |
| 199 | 199 |
| 200 ReferrerPolicy m_referrerPolicy; | 200 ReferrerPolicy m_referrerPolicy; |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 } // namespace blink | 203 } // namespace blink |
| 204 | 204 |
| 205 #endif // ExecutionContext_h | 205 #endif // ExecutionContext_h |
| OLD | NEW |