Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: Source/core/dom/ScriptExecutionContext.h

Issue 19596004: Allow sites to enable 'window.onerror' handlers for cross-domain scripts. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: WTF::HashSet FTW! Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 virtual bool isJSExecutionForbidden() const = 0; 63 virtual bool isJSExecutionForbidden() const = 0;
64 64
65 const KURL& url() const { return virtualURL(); } 65 const KURL& url() const { return virtualURL(); }
66 KURL completeURL(const String& url) const { return virtualCompleteURL(url); } 66 KURL completeURL(const String& url) const { return virtualCompleteURL(url); }
67 67
68 virtual String userAgent(const KURL&) const = 0; 68 virtual String userAgent(const KURL&) const = 0;
69 69
70 virtual void disableEval(const String& errorMessage) = 0; 70 virtual void disableEval(const String& errorMessage) = 0;
71 71
72 bool sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnN umber, String& sourceURL, CachedScript* = 0); 72 bool sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnN umber, String& sourceURL);
73 void reportException(const String& errorMessage, int lineNumber, int columnN umber, const String& sourceURL, PassRefPtr<ScriptCallStack>, CachedScript* = 0); 73 void reportException(const String& errorMessage, int lineNumber, int columnN umber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
74 74
75 void addConsoleMessage(MessageSource, MessageLevel, const String& message, c onst String& sourceURL, unsigned lineNumber, ScriptState* = 0, unsigned long req uestIdentifier = 0); 75 void addConsoleMessage(MessageSource, MessageLevel, const String& message, c onst String& sourceURL, unsigned lineNumber, ScriptState* = 0, unsigned long req uestIdentifier = 0);
76 virtual void addConsoleMessage(MessageSource, MessageLevel, const String& me ssage, unsigned long requestIdentifier = 0) = 0; 76 virtual void addConsoleMessage(MessageSource, MessageLevel, const String& me ssage, unsigned long requestIdentifier = 0) = 0;
77 77
78 PublicURLManager& publicURLManager(); 78 PublicURLManager& publicURLManager();
79 79
80 // Active objects are not garbage collected even if inaccessible, e.g. becau se their activity may result in callbacks being invoked. 80 // Active objects are not garbage collected even if inaccessible, e.g. becau se their activity may result in callbacks being invoked.
81 bool canSuspendActiveDOMObjects(); 81 bool canSuspendActiveDOMObjects();
82 bool hasPendingActivity(); 82 bool hasPendingActivity();
83 83
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Gets the next id in a circular sequence from 1 to 2^31-1. 119 // Gets the next id in a circular sequence from 1 to 2^31-1.
120 int circularSequentialID(); 120 int circularSequentialID();
121 121
122 void didChangeTimerAlignmentInterval(); 122 void didChangeTimerAlignmentInterval();
123 virtual double timerAlignmentInterval() const; 123 virtual double timerAlignmentInterval() const;
124 124
125 virtual EventQueue* eventQueue() const = 0; 125 virtual EventQueue* eventQueue() const = 0;
126 126
127 void setDatabaseContext(DatabaseContext*); 127 void setDatabaseContext(DatabaseContext*);
128 128
129 void didLoadScriptThatPassedAccessControlCheck(const KURL&);
130 bool scriptPassedAccessControlCheck(const KURL&) const;
131
129 protected: 132 protected:
130 class AddConsoleMessageTask : public Task { 133 class AddConsoleMessageTask : public Task {
131 public: 134 public:
132 static PassOwnPtr<AddConsoleMessageTask> create(MessageSource source, Me ssageLevel level, const String& message) 135 static PassOwnPtr<AddConsoleMessageTask> create(MessageSource source, Me ssageLevel level, const String& message)
133 { 136 {
134 return adoptPtr(new AddConsoleMessageTask(source, level, message)); 137 return adoptPtr(new AddConsoleMessageTask(source, level, message));
135 } 138 }
136 virtual void performTask(ScriptExecutionContext*); 139 virtual void performTask(ScriptExecutionContext*);
137 private: 140 private:
138 AddConsoleMessageTask(MessageSource source, MessageLevel level, const St ring& message) 141 AddConsoleMessageTask(MessageSource source, MessageLevel level, const St ring& message)
(...skipping 11 matching lines...) Expand all
150 153
151 private: 154 private:
152 friend class DOMTimer; // For installNewTimeout() and removeTimeoutByID() be low. 155 friend class DOMTimer; // For installNewTimeout() and removeTimeoutByID() be low.
153 156
154 virtual const KURL& virtualURL() const = 0; 157 virtual const KURL& virtualURL() const = 0;
155 virtual KURL virtualCompleteURL(const String&) const = 0; 158 virtual KURL virtualCompleteURL(const String&) const = 0;
156 159
157 virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, Scrip tState* = 0, unsigned long requestIdentifier = 0) = 0; 160 virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, Scrip tState* = 0, unsigned long requestIdentifier = 0) = 0;
158 virtual EventTarget* errorEventTarget() = 0; 161 virtual EventTarget* errorEventTarget() = 0;
159 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) = 0; 162 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) = 0;
160 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, int colu mnNumber, const String& sourceURL, CachedScript*); 163 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, int colu mnNumber, const String& sourceURL);
161 164
162 void closeMessagePorts(); 165 void closeMessagePorts();
163 166
164 virtual void refScriptExecutionContext() = 0; 167 virtual void refScriptExecutionContext() = 0;
165 virtual void derefScriptExecutionContext() = 0; 168 virtual void derefScriptExecutionContext() = 0;
166 virtual PassOwnPtr<LifecycleNotifier> createLifecycleNotifier() OVERRIDE; 169 virtual PassOwnPtr<LifecycleNotifier> createLifecycleNotifier() OVERRIDE;
167 170
168 // Implementation details for DOMTimer. No other classes should call these f unctions. 171 // Implementation details for DOMTimer. No other classes should call these f unctions.
169 int installNewTimeout(DOMTimer::Type, PassOwnPtr<ScheduledAction>, int timeo ut); 172 int installNewTimeout(DOMTimer::Type, PassOwnPtr<ScheduledAction>, int timeo ut);
170 bool removeTimeoutByIDIfTypeMatches(DOMTimer::Type, int timeoutID); // This makes underlying DOMTimer instance destructed. Returns true if removed. 173 bool removeTimeoutByIDIfTypeMatches(DOMTimer::Type, int timeoutID); // This makes underlying DOMTimer instance destructed. Returns true if removed.
171 174
172 HashSet<MessagePort*> m_messagePorts; 175 HashSet<MessagePort*> m_messagePorts;
173 176
177 HashSet<unsigned> m_scriptsPassingAccessControlCheck;
178
174 int m_circularSequentialID; 179 int m_circularSequentialID;
175 typedef HashMap<int, OwnPtr<DOMTimer> > TimeoutMap; 180 typedef HashMap<int, OwnPtr<DOMTimer> > TimeoutMap;
176 TimeoutMap m_timeouts; 181 TimeoutMap m_timeouts;
177 182
178 bool m_inDispatchErrorEvent; 183 bool m_inDispatchErrorEvent;
179 class PendingException; 184 class PendingException;
180 OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions; 185 OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions;
181 186
182 bool m_activeDOMObjectsAreSuspended; 187 bool m_activeDOMObjectsAreSuspended;
183 ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects; 188 ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects;
184 bool m_activeDOMObjectsAreStopped; 189 bool m_activeDOMObjectsAreStopped;
185 190
186 OwnPtr<PublicURLManager> m_publicURLManager; 191 OwnPtr<PublicURLManager> m_publicURLManager;
187 192
188 RefPtr<DatabaseContext> m_databaseContext; 193 RefPtr<DatabaseContext> m_databaseContext;
189 194
190 // The location of this member is important; to make sure contextDestroyed() notification on 195 // The location of this member is important; to make sure contextDestroyed() notification on
191 // ScriptExecutionContext's members (notably m_timeouts) is called before th ey are destructed, 196 // ScriptExecutionContext's members (notably m_timeouts) is called before th ey are destructed,
192 // m_lifecycleNotifer should be placed *after* such members. 197 // m_lifecycleNotifer should be placed *after* such members.
193 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier; 198 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier;
194 }; 199 };
195 200
196 } // namespace WebCore 201 } // namespace WebCore
197 202
198 #endif // ScriptExecutionContext_h 203 #endif // ScriptExecutionContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698