| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 ~ScriptController(); | 76 ~ScriptController(); |
| 77 | 77 |
| 78 bool initializeMainWorld(); | 78 bool initializeMainWorld(); |
| 79 V8WindowShell* windowShell(DOMWrapperWorld*); | 79 V8WindowShell* windowShell(DOMWrapperWorld*); |
| 80 V8WindowShell* existingWindowShell(DOMWrapperWorld*); | 80 V8WindowShell* existingWindowShell(DOMWrapperWorld*); |
| 81 | 81 |
| 82 // Evaluate JavaScript in the main world. | 82 // Evaluate JavaScript in the main world. |
| 83 void executeScriptInMainWorld(const String&, ExecuteScriptPolicy = DoNotExec
uteScriptWhenScriptsDisabled); | 83 void executeScriptInMainWorld(const String&, ExecuteScriptPolicy = DoNotExec
uteScriptWhenScriptsDisabled); |
| 84 void executeScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus =
NotSharableCrossOrigin); | 84 void executeScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus =
NotSharableCrossOrigin); |
| 85 ScriptValue executeScriptInMainWorldAndReturnValue(const ScriptSourceCode&); | 85 ScriptValue executeScriptInMainWorldAndReturnValue(const ScriptSourceCode&); |
| 86 v8::Local<v8::Value> executeScriptAndReturnValue(v8::Handle<v8::Context>, co
nst ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin); |
| 86 | 87 |
| 87 // Executes JavaScript in an isolated world. The script gets its own global
scope, | 88 // Executes JavaScript in an isolated world. The script gets its own global
scope, |
| 88 // its own prototypes for intrinsic JavaScript objects (String, Array, and s
o-on), | 89 // its own prototypes for intrinsic JavaScript objects (String, Array, and s
o-on), |
| 89 // and its own wrappers for all DOM nodes and DOM constructors. | 90 // and its own wrappers for all DOM nodes and DOM constructors. |
| 90 // | 91 // |
| 91 // If an isolated world with the specified ID already exists, it is reused. | 92 // If an isolated world with the specified ID already exists, it is reused. |
| 92 // Otherwise, a new world is created. | 93 // Otherwise, a new world is created. |
| 93 // | 94 // |
| 94 // FIXME: Get rid of extensionGroup here. | 95 // FIXME: Get rid of extensionGroup here. |
| 95 void executeScriptInIsolatedWorld(int worldID, const Vector<ScriptSourceCode
>& sources, int extensionGroup, Vector<ScriptValue>* results); | 96 void executeScriptInIsolatedWorld(int worldID, const Vector<ScriptSourceCode
>& sources, int extensionGroup, Vector<ScriptValue>* results); |
| 96 | 97 |
| 97 // Returns true if argument is a JavaScript URL. | 98 // Returns true if argument is a JavaScript URL. |
| 98 bool executeScriptIfJavaScriptURL(const KURL&); | 99 bool executeScriptIfJavaScriptURL(const KURL&); |
| 99 | 100 |
| 100 v8::Local<v8::Value> compileAndRunScript(const ScriptSourceCode&, AccessCont
rolStatus = NotSharableCrossOrigin); | |
| 101 | |
| 102 v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::O
bject>, int argc, v8::Handle<v8::Value> argv[]); | 101 v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::O
bject>, int argc, v8::Handle<v8::Value> argv[]); |
| 103 ScriptValue callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function>, v8::H
andle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]); | 102 static v8::Local<v8::Value> callFunction(ScriptExecutionContext*, v8::Handle
<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value>
args[], v8::Isolate*); |
| 104 static v8::Local<v8::Value> callFunctionWithInstrumentation(ScriptExecutionC
ontext*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8
::Handle<v8::Value> args[], v8::Isolate*); | |
| 105 | 103 |
| 106 // Returns true if the current world is isolated, and has its own Content | 104 // Returns true if the current world is isolated, and has its own Content |
| 107 // Security Policy. In this case, the policy of the main world should be | 105 // Security Policy. In this case, the policy of the main world should be |
| 108 // ignored when evaluating resources injected into the DOM. | 106 // ignored when evaluating resources injected into the DOM. |
| 109 bool shouldBypassMainWorldContentSecurityPolicy(); | 107 bool shouldBypassMainWorldContentSecurityPolicy(); |
| 110 | 108 |
| 111 // Creates a property of the global object of a frame. | 109 // Creates a property of the global object of a frame. |
| 112 void bindToWindowObject(Frame*, const String& key, NPObject*); | 110 void bindToWindowObject(Frame*, const String& key, NPObject*); |
| 113 | 111 |
| 114 PassScriptInstance createScriptInstanceForWidget(Widget*); | 112 PassScriptInstance createScriptInstanceForWidget(Widget*); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 bool setContextDebugId(int); | 156 bool setContextDebugId(int); |
| 159 static int contextDebugId(v8::Handle<v8::Context>); | 157 static int contextDebugId(v8::Handle<v8::Context>); |
| 160 | 158 |
| 161 v8::Isolate* isolate() const { return m_isolate; } | 159 v8::Isolate* isolate() const { return m_isolate; } |
| 162 | 160 |
| 163 private: | 161 private: |
| 164 typedef HashMap<int, OwnPtr<V8WindowShell> > IsolatedWorldMap; | 162 typedef HashMap<int, OwnPtr<V8WindowShell> > IsolatedWorldMap; |
| 165 typedef HashMap<Widget*, NPObject*> PluginObjectMap; | 163 typedef HashMap<Widget*, NPObject*> PluginObjectMap; |
| 166 | 164 |
| 167 ScriptValue evaluateScriptInMainWorld(const ScriptSourceCode&, AccessControl
Status, ExecuteScriptPolicy); | 165 ScriptValue evaluateScriptInMainWorld(const ScriptSourceCode&, AccessControl
Status, ExecuteScriptPolicy); |
| 168 | |
| 169 void clearForClose(bool destroyGlobal); | 166 void clearForClose(bool destroyGlobal); |
| 170 | 167 |
| 171 Frame* m_frame; | 168 Frame* m_frame; |
| 172 const String* m_sourceURL; | 169 const String* m_sourceURL; |
| 173 v8::Isolate* m_isolate; | 170 v8::Isolate* m_isolate; |
| 174 | 171 |
| 175 OwnPtr<V8WindowShell> m_windowShell; | 172 OwnPtr<V8WindowShell> m_windowShell; |
| 176 IsolatedWorldMap m_isolatedWorlds; | 173 IsolatedWorldMap m_isolatedWorlds; |
| 177 | 174 |
| 178 // A mapping between Widgets and their corresponding script object. | 175 // A mapping between Widgets and their corresponding script object. |
| 179 // This list is used so that when the plugin dies, we can immediately | 176 // This list is used so that when the plugin dies, we can immediately |
| 180 // invalidate all sub-objects which are associated with that plugin. | 177 // invalidate all sub-objects which are associated with that plugin. |
| 181 // The frame keeps a NPObject reference for each item on the list. | 178 // The frame keeps a NPObject reference for each item on the list. |
| 182 PluginObjectMap m_pluginObjects; | 179 PluginObjectMap m_pluginObjects; |
| 183 | 180 |
| 184 NPObject* m_windowScriptNPObject; | 181 NPObject* m_windowScriptNPObject; |
| 185 }; | 182 }; |
| 186 | 183 |
| 187 } // namespace WebCore | 184 } // namespace WebCore |
| 188 | 185 |
| 189 #endif // ScriptController_h | 186 #endif // ScriptController_h |
| OLD | NEW |