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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 namespace WebCore { | 56 namespace WebCore { |
57 | 57 |
58 class DOMWrapperWorld; | 58 class DOMWrapperWorld; |
59 class Event; | 59 class Event; |
60 class Frame; | 60 class Frame; |
61 class HTMLPlugInElement; | 61 class HTMLPlugInElement; |
62 class ScriptSourceCode; | 62 class ScriptSourceCode; |
63 class Widget; | 63 class Widget; |
64 | 64 |
| 65 class AbstractController : public RefCounted<AbstractController> { |
| 66 public: |
| 67 virtual ~AbstractController() {} |
| 68 |
| 69 virtual bool isScriptTypeSupported(const String& mimeType) = 0; |
| 70 virtual void evaluate(const ScriptSourceCode&) = 0; |
| 71 virtual void bindToWindowObject(Frame*, const String& key, NPObject*) = 0; |
| 72 virtual void clearWindowShell() = 0; |
| 73 }; |
| 74 |
65 class ScriptController { | 75 class ScriptController { |
66 public: | 76 public: |
67 ScriptController(Frame*); | 77 ScriptController(Frame*); |
68 ~ScriptController(); | 78 ~ScriptController(); |
69 | 79 |
70 // FIXME: V8Proxy should either be folded into ScriptController | 80 // FIXME: V8Proxy should either be folded into ScriptController |
71 // or this accessor should be made JSProxy* | 81 // or this accessor should be made JSProxy* |
72 V8Proxy* proxy() { return m_proxy.get(); } | 82 V8Proxy* proxy() { return m_proxy.get(); } |
73 | 83 |
74 ScriptValue executeScript(const ScriptSourceCode&); | 84 ScriptValue executeScript(const ScriptSourceCode&); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 #endif | 191 #endif |
182 | 192 |
183 #if PLATFORM(QT) | 193 #if PLATFORM(QT) |
184 QScriptEngine* qtScriptEngine(); | 194 QScriptEngine* qtScriptEngine(); |
185 #endif | 195 #endif |
186 | 196 |
187 // Dummy method to avoid a bunch of ifdef's in WebCore. | 197 // Dummy method to avoid a bunch of ifdef's in WebCore. |
188 void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*); | 198 void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*); |
189 static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds); | 199 static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds); |
190 | 200 |
| 201 bool isScriptTypeSupported(const String& mimeType); |
| 202 AbstractController* controller(const String& name); |
| 203 |
191 private: | 204 private: |
192 Frame* m_frame; | 205 Frame* m_frame; |
193 const String* m_sourceURL; | 206 const String* m_sourceURL; |
194 | 207 |
195 bool m_inExecuteScript; | 208 bool m_inExecuteScript; |
196 | 209 |
197 bool m_paused; | 210 bool m_paused; |
198 | 211 |
| 212 typedef HashMap<String, RefPtr<AbstractController> > ControllerMap; |
| 213 ControllerMap m_controllers; |
| 214 |
199 OwnPtr<V8Proxy> m_proxy; | 215 OwnPtr<V8Proxy> m_proxy; |
200 typedef HashMap<Widget*, NPObject*> PluginObjectMap; | 216 typedef HashMap<Widget*, NPObject*> PluginObjectMap; |
201 #if PLATFORM(QT) | 217 #if PLATFORM(QT) |
202 OwnPtr<QScriptEngine> m_qtScriptEngine; | 218 OwnPtr<QScriptEngine> m_qtScriptEngine; |
203 #endif | 219 #endif |
204 | 220 |
205 // A mapping between Widgets and their corresponding script object. | 221 // A mapping between Widgets and their corresponding script object. |
206 // This list is used so that when the plugin dies, we can immediately | 222 // This list is used so that when the plugin dies, we can immediately |
207 // invalidate all sub-objects which are associated with that plugin. | 223 // invalidate all sub-objects which are associated with that plugin. |
208 // The frame keeps a NPObject reference for each item on the list. | 224 // The frame keeps a NPObject reference for each item on the list. |
209 PluginObjectMap m_pluginObjects; | 225 PluginObjectMap m_pluginObjects; |
210 #if ENABLE(NETSCAPE_PLUGIN_API) | 226 #if ENABLE(NETSCAPE_PLUGIN_API) |
211 // The window script object can get destroyed while there are outstanding | 227 // The window script object can get destroyed while there are outstanding |
212 // references to it. Please refer to ScriptController::clearScriptObjects | 228 // references to it. Please refer to ScriptController::clearScriptObjects |
213 // for more information as to why this is necessary. To avoid crashes due | 229 // for more information as to why this is necessary. To avoid crashes due |
214 // to calls on the destroyed window object, we return a proxy NPObject | 230 // to calls on the destroyed window object, we return a proxy NPObject |
215 // which wraps the underlying window object. The wrapped window object | 231 // which wraps the underlying window object. The wrapped window object |
216 // pointer in this object is cleared out when the window object is | 232 // pointer in this object is cleared out when the window object is |
217 // destroyed. | 233 // destroyed. |
218 NPObject* m_wrappedWindowScriptNPObject; | 234 NPObject* m_wrappedWindowScriptNPObject; |
219 #endif | 235 #endif |
220 }; | 236 }; |
221 | 237 |
222 } // namespace WebCore | 238 } // namespace WebCore |
223 | 239 |
224 #endif // ScriptController_h | 240 #endif // ScriptController_h |
OLD | NEW |