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

Unified Diff: Source/bindings/v8/ScriptController.cpp

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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/ScriptController.h ('k') | Source/bindings/v8/ScriptFunctionCall.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptController.cpp
diff --git a/Source/bindings/v8/ScriptController.cpp b/Source/bindings/v8/ScriptController.cpp
index 73699dae57283eb9bfe7422d8a2b5f30a3932ae4..a6a9c8bb8ee34b59dabdf033ceebd7ea9535f582 100644
--- a/Source/bindings/v8/ScriptController.cpp
+++ b/Source/bindings/v8/ScriptController.cpp
@@ -150,12 +150,7 @@ v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> fun
{
// Keep Frame (and therefore ScriptController) alive.
RefPtr<Frame> protect(m_frame);
- return ScriptController::callFunctionWithInstrumentation(m_frame ? m_frame->document() : 0, function, receiver, argc, args, m_isolate);
-}
-
-ScriptValue ScriptController::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> argv[])
-{
- return ScriptValue(callFunction(function, receiver, argc, argv), m_isolate);
+ return ScriptController::callFunction(m_frame->document(), function, receiver, argc, args, m_isolate);
}
static void resourceInfo(const v8::Handle<v8::Function> function, String& resourceName, int& lineNumber)
@@ -183,7 +178,7 @@ static String resourceString(const v8::Handle<v8::Function> function)
return builder.toString();
}
-v8::Local<v8::Value> ScriptController::callFunctionWithInstrumentation(ScriptExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate)
+v8::Local<v8::Value> ScriptController::callFunction(ScriptExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate)
{
InspectorInstrumentationCookie cookie;
if (InspectorInstrumentation::timelineAgentEnabled(context)) {
@@ -199,9 +194,9 @@ v8::Local<v8::Value> ScriptController::callFunctionWithInstrumentation(ScriptExe
return result;
}
-v8::Local<v8::Value> ScriptController::compileAndRunScript(const ScriptSourceCode& source, AccessControlStatus corsStatus)
+v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Handle<v8::Context> context, const ScriptSourceCode& source, AccessControlStatus corsStatus)
{
- ASSERT(v8::Context::InContext());
+ v8::Context::Scope scope(context);
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, source.url().isNull() ? String() : source.url().string(), source.startLine());
@@ -314,9 +309,6 @@ v8::Local<v8::Context> ScriptController::currentWorldContext()
return contextForWorld(this, mainThreadNormalWorld());
Frame* frame = toFrameIfNotDetached(context);
- if (!m_frame)
- return v8::Local<v8::Context>();
-
if (m_frame == frame)
return v8::Local<v8::Context>::New(m_isolate, context);
@@ -670,9 +662,7 @@ ScriptValue ScriptController::evaluateScriptInMainWorld(const ScriptSourceCode&
OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentation::preprocess(m_frame, sourceCode);
const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *maybeProcessedSourceCode : sourceCode;
- v8::Context::Scope scope(v8Context);
- v8::Local<v8::Value> object = compileAndRunScript(sourceCodeToCompile, corsStatus);
-
+ v8::Local<v8::Value> object = executeScriptAndReturnValue(v8Context, sourceCodeToCompile, corsStatus);
m_sourceURL = savedSourceURL;
if (object.IsEmpty())
@@ -700,7 +690,7 @@ void ScriptController::executeScriptInIsolatedWorld(int worldID, const Vector<Sc
v8::Local<v8::Array> resultArray = v8::Array::New(sources.size());
for (size_t i = 0; i < sources.size(); ++i) {
- v8::Local<v8::Value> evaluationResult = compileAndRunScript(sources[i]);
+ v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(context, sources[i]);
if (evaluationResult.IsEmpty())
evaluationResult = v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
resultArray->Set(i, evaluationResult);
« no previous file with comments | « Source/bindings/v8/ScriptController.h ('k') | Source/bindings/v8/ScriptFunctionCall.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698