OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef ScriptController_h | 31 #ifndef ScriptController_h |
32 #define ScriptController_h | 32 #define ScriptController_h |
33 | 33 |
34 #include "bindings/core/v8/SharedPersistent.h" | 34 #include "bindings/core/v8/SharedPersistent.h" |
35 | 35 #include "bindings/core/v8/WindowProxyManager.h" |
36 #include "core/fetch/CrossOriginAccessControl.h" | 36 #include "core/fetch/CrossOriginAccessControl.h" |
| 37 #include "core/frame/LocalFrame.h" |
37 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
38 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
39 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
40 #include "wtf/text/TextPosition.h" | 41 #include "wtf/text/TextPosition.h" |
41 #include <v8.h> | 42 #include <v8.h> |
42 | 43 |
43 struct NPObject; | 44 struct NPObject; |
44 | 45 |
45 namespace blink { | 46 namespace blink { |
46 | 47 |
47 class DOMWrapperWorld; | 48 class DOMWrapperWorld; |
48 class ExecutionContext; | 49 class ExecutionContext; |
49 class HTMLDocument; | 50 class HTMLDocument; |
50 class HTMLPlugInElement; | 51 class HTMLPlugInElement; |
51 class KURL; | 52 class KURL; |
52 class LocalFrame; | |
53 class ScriptState; | 53 class ScriptState; |
54 class ScriptSourceCode; | 54 class ScriptSourceCode; |
55 class SecurityOrigin; | 55 class SecurityOrigin; |
56 class WindowProxy; | 56 class WindowProxy; |
57 class Widget; | 57 class Widget; |
58 | 58 |
59 typedef WTF::Vector<v8::Extension*> V8Extensions; | 59 typedef WTF::Vector<v8::Extension*> V8Extensions; |
60 | 60 |
61 enum ReasonForCallingCanExecuteScripts { | 61 enum ReasonForCallingCanExecuteScripts { |
62 AboutToExecuteScript, | 62 AboutToExecuteScript, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 NPObject* windowScriptNPObject(); | 143 NPObject* windowScriptNPObject(); |
144 | 144 |
145 // Registers a v8 extension to be available on webpages. Will only | 145 // Registers a v8 extension to be available on webpages. Will only |
146 // affect v8 contexts initialized after this call. Takes ownership of | 146 // affect v8 contexts initialized after this call. Takes ownership of |
147 // the v8::Extension object passed. | 147 // the v8::Extension object passed. |
148 static void registerExtensionIfNeeded(v8::Extension*); | 148 static void registerExtensionIfNeeded(v8::Extension*); |
149 static V8Extensions& registeredExtensions(); | 149 static V8Extensions& registeredExtensions(); |
150 | 150 |
151 void setWorldDebugId(int worldId, int debuggerId); | 151 void setWorldDebugId(int worldId, int debuggerId); |
152 | 152 |
153 v8::Isolate* isolate() const { return m_isolate; } | 153 v8::Isolate* isolate() const { return m_windowProxyManager->isolate(); } |
154 | 154 |
155 private: | 155 private: |
156 explicit ScriptController(LocalFrame*); | 156 explicit ScriptController(LocalFrame*); |
157 | 157 |
158 typedef WillBeHeapHashMap<int, OwnPtrWillBeMember<WindowProxy> > IsolatedWor
ldMap; | 158 LocalFrame* frame() const { return toLocalFrame(m_windowProxyManager->frame(
)); } |
| 159 |
159 typedef HashMap<Widget*, NPObject*> PluginObjectMap; | 160 typedef HashMap<Widget*, NPObject*> PluginObjectMap; |
160 | 161 |
161 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce
ssControlStatus, ExecuteScriptPolicy, double* compilationFinishTime = 0); | 162 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce
ssControlStatus, ExecuteScriptPolicy, double* compilationFinishTime = 0); |
162 | 163 |
163 RawPtrWillBeMember<LocalFrame> m_frame; | 164 OwnPtrWillBeMember<WindowProxyManager> m_windowProxyManager; |
164 const String* m_sourceURL; | 165 const String* m_sourceURL; |
165 v8::Isolate* m_isolate; | |
166 | |
167 OwnPtrWillBeMember<WindowProxy> m_windowProxy; | |
168 IsolatedWorldMap m_isolatedWorlds; | |
169 | 166 |
170 // A mapping between Widgets and their corresponding script object. | 167 // A mapping between Widgets and their corresponding script object. |
171 // This list is used so that when the plugin dies, we can immediately | 168 // This list is used so that when the plugin dies, we can immediately |
172 // invalidate all sub-objects which are associated with that plugin. | 169 // invalidate all sub-objects which are associated with that plugin. |
173 // The frame keeps a NPObject reference for each item on the list. | 170 // The frame keeps a NPObject reference for each item on the list. |
174 PluginObjectMap m_pluginObjects; | 171 PluginObjectMap m_pluginObjects; |
175 | 172 |
176 NPObject* m_windowScriptNPObject; | 173 NPObject* m_windowScriptNPObject; |
177 }; | 174 }; |
178 | 175 |
179 } // namespace blink | 176 } // namespace blink |
180 | 177 |
181 #endif // ScriptController_h | 178 #endif // ScriptController_h |
OLD | NEW |