OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/PrivateScriptRunner.h" | 6 #include "bindings/core/v8/PrivateScriptRunner.h" |
7 | 7 |
8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 v8::Handle<v8::Object> global = isolate->GetCurrentContext()->Global(); | 52 v8::Handle<v8::Object> global = isolate->GetCurrentContext()->Global(); |
53 v8::Handle<v8::Value> privateScriptController = global->Get(v8String(isolate
, "privateScriptController")); | 53 v8::Handle<v8::Value> privateScriptController = global->Get(v8String(isolate
, "privateScriptController")); |
54 RELEASE_ASSERT(privateScriptController->IsUndefined() || privateScriptContro
ller->IsObject()); | 54 RELEASE_ASSERT(privateScriptController->IsUndefined() || privateScriptContro
ller->IsObject()); |
55 if (privateScriptController->IsObject()) { | 55 if (privateScriptController->IsObject()) { |
56 v8::Handle<v8::Object> privateScriptControllerObject = privateScriptCont
roller->ToObject(isolate); | 56 v8::Handle<v8::Object> privateScriptControllerObject = privateScriptCont
roller->ToObject(isolate); |
57 v8::Handle<v8::Value> importFunctionValue = privateScriptControllerObjec
t->Get(v8String(isolate, "import")); | 57 v8::Handle<v8::Value> importFunctionValue = privateScriptControllerObjec
t->Get(v8String(isolate, "import")); |
58 if (importFunctionValue->IsUndefined()) | 58 if (importFunctionValue->IsUndefined()) |
59 privateScriptControllerObject->Set(v8String(isolate, "import"), v8::
FunctionTemplate::New(isolate, importFunction)->GetFunction()); | 59 privateScriptControllerObject->Set(v8String(isolate, "import"), v8::
FunctionTemplate::New(isolate, importFunction)->GetFunction()); |
60 } | 60 } |
61 | 61 |
62 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(v8String(isola
te, sourceString), fileName, String(), TextPosition::minimumPosition(), isolate,
nullptr, nullptr, nullptr, NotSharableCrossOrigin); | 62 v8::Local<v8::Script> script; |
63 if (block.HasCaught()) { | 63 if (!v8Call(V8ScriptRunner::compileScript(v8String(isolate, sourceString), f
ileName, String(), TextPosition::minimumPosition(), isolate, nullptr, nullptr, n
ullptr, NotSharableCrossOrigin), script, block)) { |
64 fprintf(stderr, "Private script error: Compile failed. (Class name = %s)
\n", scriptClassName.utf8().data()); | 64 fprintf(stderr, "Private script error: Compile failed. (Class name = %s)
\n", scriptClassName.utf8().data()); |
65 dumpV8Message(block.Message()); | 65 dumpV8Message(block.Message()); |
66 RELEASE_ASSERT_NOT_REACHED(); | 66 RELEASE_ASSERT_NOT_REACHED(); |
67 } | 67 } |
68 | 68 |
69 v8::Handle<v8::Value> result = V8ScriptRunner::runCompiledInternalScript(iso
late, script); | 69 v8::Local<v8::Value> result; |
70 if (block.HasCaught()) { | 70 if (!v8Call(V8ScriptRunner::runCompiledInternalScript(isolate, script), resu
lt, block)) { |
71 fprintf(stderr, "Private script error: installClass() failed. (Class nam
e = %s)\n", scriptClassName.utf8().data()); | 71 fprintf(stderr, "Private script error: installClass() failed. (Class nam
e = %s)\n", scriptClassName.utf8().data()); |
72 dumpV8Message(block.Message()); | 72 dumpV8Message(block.Message()); |
73 RELEASE_ASSERT_NOT_REACHED(); | 73 RELEASE_ASSERT_NOT_REACHED(); |
74 } | 74 } |
75 return result; | 75 return result; |
76 } | 76 } |
77 | 77 |
78 // Private scripts can use privateScriptController.import(bundledResource, compi
leAndRunScript) to import dependent resources. | 78 // Private scripts can use privateScriptController.import(bundledResource, compi
leAndRunScript) to import dependent resources. |
79 // |bundledResource| is a string resource name. | 79 // |bundledResource| is a string resource name. |
80 // |compileAndRunScript| optional boolean representing if the javascript should
be executed. Default: true. | 80 // |compileAndRunScript| optional boolean representing if the javascript should
be executed. Default: true. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 v8::Handle<v8::Value> result = V8ScriptRunner::callFunction(v8::Handle<v8::F
unction>::Cast(method), scriptState->executionContext(), holder, argc, argv, scr
iptState->isolate()); | 332 v8::Handle<v8::Value> result = V8ScriptRunner::callFunction(v8::Handle<v8::F
unction>::Cast(method), scriptState->executionContext(), holder, argc, argv, scr
iptState->isolate()); |
333 if (block.HasCaught()) { | 333 if (block.HasCaught()) { |
334 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); | 334 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); |
335 block.ReThrow(); | 335 block.ReThrow(); |
336 return v8::Handle<v8::Value>(); | 336 return v8::Handle<v8::Value>(); |
337 } | 337 } |
338 return result; | 338 return result; |
339 } | 339 } |
340 | 340 |
341 } // namespace blink | 341 } // namespace blink |
OLD | NEW |