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

Side by Side Diff: Source/bindings/v8/ScriptController.h

Issue 24758003: ScriptController: limit script execution API to executeScript and callFunction, pass valid ScriptEx… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: w/ ScheduledAction executing in given context. Created 7 years, 2 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
« no previous file with comments | « Source/bindings/v8/ScheduledAction.cpp ('k') | Source/bindings/v8/ScriptController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScheduledAction.cpp ('k') | Source/bindings/v8/ScriptController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698