Index: extensions/renderer/utils_native_handler.cc |
diff --git a/extensions/renderer/utils_native_handler.cc b/extensions/renderer/utils_native_handler.cc |
index 209069cb942d3fd74b96a63c0351b3835d5087d7..1ce01d7c3654dd02a4fb0c796e73cd809ab55292 100644 |
--- a/extensions/renderer/utils_native_handler.cc |
+++ b/extensions/renderer/utils_native_handler.cc |
@@ -6,6 +6,7 @@ |
#include "base/strings/stringprintf.h" |
#include "extensions/renderer/script_context.h" |
+#include "extensions/renderer/v8_maybe_helpers.h" |
#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
#include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
@@ -35,7 +36,7 @@ void UtilsNativeHandler::CreateClassWrapper( |
v8::HandleScope handle_scope(GetIsolate()); |
// TODO(fsamuel): Consider moving the source wrapping to ModuleSystem. |
- v8::Local<v8::String> source = v8::String::NewFromUtf8( |
+ v8::Local<v8::String> source = ToV8String( |
GetIsolate(), |
base::StringPrintf( |
"(function($Object, $Function, privates, cls, superclass) {" |
@@ -53,26 +54,31 @@ void UtilsNativeHandler::CreateClassWrapper( |
"})", |
name.c_str(), name.c_str(), name.c_str()).c_str()); |
v8::Local<v8::Value> func_as_value = context()->module_system()->RunString( |
- source, v8::String::NewFromUtf8(GetIsolate(), name.c_str())); |
+ source, ToV8String(GetIsolate(), name.c_str())); |
if (func_as_value.IsEmpty() || func_as_value->IsUndefined()) { |
args.GetReturnValue().SetUndefined(); |
return; |
} |
// TODO(fsamuel): Move privates from ModuleSystem to a shared location. |
- v8::Local<v8::Object> natives(context()->module_system()->NewInstance()); |
- CHECK(!natives.IsEmpty()); // this can happen if v8 has issues |
+ v8::Local<v8::Object> natives; |
+ if (!context()->module_system()->NewInstance().ToLocal(&natives)) |
+ NOTREACHED(); // this can happen if v8 has issues |
v8::Local<v8::Function> func = func_as_value.As<v8::Function>(); |
+ v8::Local<v8::Context> v8_context = context()->v8_context(); |
+ v8::Local<v8::Value> privates = UnsafeGet( |
+ v8_context, natives, |
+ ToV8String(GetIsolate(), "privates", v8::NewStringType::kInternalized)); |
+ |
v8::Local<v8::Value> func_args[] = { |
context()->safe_builtins()->GetObjekt(), |
context()->safe_builtins()->GetFunction(), |
- natives->Get(v8::String::NewFromUtf8(GetIsolate(), "privates", |
- v8::String::kInternalizedString)), |
+ privates, |
cls, |
superclass}; |
v8::Local<v8::Value> result; |
{ |
- v8::TryCatch try_catch; |
+ v8::TryCatch try_catch(GetIsolate()); |
try_catch.SetCaptureMessage(true); |
result = context()->CallFunction(func, arraysize(func_args), func_args); |
if (try_catch.HasCaught()) { |