| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 class DOMWrapperWorld; | 48 class DOMWrapperWorld; |
| 49 class Event; | 49 class Event; |
| 50 class Frame; | 50 class Frame; |
| 51 class HTMLDocument; | 51 class HTMLDocument; |
| 52 class HTMLPlugInElement; | 52 class HTMLPlugInElement; |
| 53 class KURL; | 53 class KURL; |
| 54 class ScriptSourceCode; | 54 class ScriptSourceCode; |
| 55 class ScriptState; | 55 class ScriptState; |
| 56 class SecurityOrigin; | 56 class SecurityOrigin; |
| 57 class V8DOMWindowShell; | 57 class V8WindowShell; |
| 58 class Widget; | 58 class Widget; |
| 59 | 59 |
| 60 typedef WTF::Vector<v8::Extension*> V8Extensions; | 60 typedef WTF::Vector<v8::Extension*> V8Extensions; |
| 61 | 61 |
| 62 enum ReasonForCallingCanExecuteScripts { | 62 enum ReasonForCallingCanExecuteScripts { |
| 63 AboutToExecuteScript, | 63 AboutToExecuteScript, |
| 64 NotAboutToExecuteScript | 64 NotAboutToExecuteScript |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class ScriptController { | 67 class ScriptController { |
| 68 public: | 68 public: |
| 69 ScriptController(Frame*); | 69 ScriptController(Frame*); |
| 70 ~ScriptController(); | 70 ~ScriptController(); |
| 71 | 71 |
| 72 bool initializeMainWorld(); | 72 bool initializeMainWorld(); |
| 73 V8DOMWindowShell* windowShell(DOMWrapperWorld*); | 73 V8WindowShell* windowShell(DOMWrapperWorld*); |
| 74 V8DOMWindowShell* existingWindowShell(DOMWrapperWorld*); | 74 V8WindowShell* existingWindowShell(DOMWrapperWorld*); |
| 75 | 75 |
| 76 ScriptValue executeScript(const ScriptSourceCode&); | 76 ScriptValue executeScript(const ScriptSourceCode&); |
| 77 ScriptValue executeScript(const String& script, bool forceUserGesture = fals
e); | 77 ScriptValue executeScript(const String& script, bool forceUserGesture = fals
e); |
| 78 | 78 |
| 79 // Evaluate JavaScript in the main world. | 79 // Evaluate JavaScript in the main world. |
| 80 ScriptValue executeScriptInMainWorld(const ScriptSourceCode&); | 80 ScriptValue executeScriptInMainWorld(const ScriptSourceCode&); |
| 81 | 81 |
| 82 // Executes JavaScript in an isolated world. The script gets its own global
scope, | 82 // Executes JavaScript in an isolated world. The script gets its own global
scope, |
| 83 // its own prototypes for intrinsic JavaScript objects (String, Array, and s
o-on), | 83 // its own prototypes for intrinsic JavaScript objects (String, Array, and s
o-on), |
| 84 // and its own wrappers for all DOM nodes and DOM constructors. | 84 // and its own wrappers for all DOM nodes and DOM constructors. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // Registers a v8 extension to be available on webpages. Will only | 152 // Registers a v8 extension to be available on webpages. Will only |
| 153 // affect v8 contexts initialized after this call. Takes ownership of | 153 // affect v8 contexts initialized after this call. Takes ownership of |
| 154 // the v8::Extension object passed. | 154 // the v8::Extension object passed. |
| 155 static void registerExtensionIfNeeded(v8::Extension*); | 155 static void registerExtensionIfNeeded(v8::Extension*); |
| 156 static V8Extensions& registeredExtensions(); | 156 static V8Extensions& registeredExtensions(); |
| 157 | 157 |
| 158 bool setContextDebugId(int); | 158 bool setContextDebugId(int); |
| 159 static int contextDebugId(v8::Handle<v8::Context>); | 159 static int contextDebugId(v8::Handle<v8::Context>); |
| 160 | 160 |
| 161 private: | 161 private: |
| 162 typedef HashMap<int, OwnPtr<V8DOMWindowShell> > IsolatedWorldMap; | 162 typedef HashMap<int, OwnPtr<V8WindowShell> > IsolatedWorldMap; |
| 163 | 163 |
| 164 void clearForClose(bool destroyGlobal); | 164 void clearForClose(bool destroyGlobal); |
| 165 | 165 |
| 166 Frame* m_frame; | 166 Frame* m_frame; |
| 167 const String* m_sourceURL; | 167 const String* m_sourceURL; |
| 168 v8::Isolate* m_isolate; | 168 v8::Isolate* m_isolate; |
| 169 | 169 |
| 170 OwnPtr<V8DOMWindowShell> m_windowShell; | 170 OwnPtr<V8WindowShell> m_windowShell; |
| 171 IsolatedWorldMap m_isolatedWorlds; | 171 IsolatedWorldMap m_isolatedWorlds; |
| 172 | 172 |
| 173 bool m_paused; | 173 bool m_paused; |
| 174 | 174 |
| 175 typedef HashMap<Widget*, NPObject*> PluginObjectMap; | 175 typedef HashMap<Widget*, NPObject*> PluginObjectMap; |
| 176 | 176 |
| 177 // A mapping between Widgets and their corresponding script object. | 177 // A mapping between Widgets and their corresponding script object. |
| 178 // This list is used so that when the plugin dies, we can immediately | 178 // This list is used so that when the plugin dies, we can immediately |
| 179 // invalidate all sub-objects which are associated with that plugin. | 179 // invalidate all sub-objects which are associated with that plugin. |
| 180 // The frame keeps a NPObject reference for each item on the list. | 180 // The frame keeps a NPObject reference for each item on the list. |
| 181 PluginObjectMap m_pluginObjects; | 181 PluginObjectMap m_pluginObjects; |
| 182 // The window script object can get destroyed while there are outstanding | 182 // The window script object can get destroyed while there are outstanding |
| 183 // references to it. Please refer to ScriptController::clearScriptObjects | 183 // references to it. Please refer to ScriptController::clearScriptObjects |
| 184 // for more information as to why this is necessary. To avoid crashes due | 184 // for more information as to why this is necessary. To avoid crashes due |
| 185 // to calls on the destroyed window object, we return a proxy NPObject | 185 // to calls on the destroyed window object, we return a proxy NPObject |
| 186 // which wraps the underlying window object. The wrapped window object | 186 // which wraps the underlying window object. The wrapped window object |
| 187 // pointer in this object is cleared out when the window object is | 187 // pointer in this object is cleared out when the window object is |
| 188 // destroyed. | 188 // destroyed. |
| 189 NPObject* m_wrappedWindowScriptNPObject; | 189 NPObject* m_wrappedWindowScriptNPObject; |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 } // namespace WebCore | 192 } // namespace WebCore |
| 193 | 193 |
| 194 #endif // ScriptController_h | 194 #endif // ScriptController_h |
| OLD | NEW |