Commit f790abc9 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Cleanup] Avoid using deprecated V8 functions in js_extension_binding_system

BUG=v8:7287,v8:8238

Change-Id: I7dfbc89ac4ec02adf7a4275efd752cee2d142d40
Reviewed-on: https://chromium-review.googlesource.com/c/1349713Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610822}
parent 288c97fe
...@@ -44,10 +44,13 @@ v8::Local<v8::Object> GetOrCreateObject(const v8::Local<v8::Object>& object, ...@@ -44,10 +44,13 @@ v8::Local<v8::Object> GetOrCreateObject(const v8::Local<v8::Object>& object,
// If the object has a callback property, it is assumed it is an unavailable // If the object has a callback property, it is assumed it is an unavailable
// API, so it is safe to delete. This is checked before GetOrCreateObject is // API, so it is safe to delete. This is checked before GetOrCreateObject is
// called. // called.
if (object->HasRealNamedCallbackProperty(key)) { if (object->HasRealNamedCallbackProperty(context->v8_context(), key)
.FromMaybe(false)) {
object->Delete(context->v8_context(), key).ToChecked(); object->Delete(context->v8_context(), key).ToChecked();
} else if (object->HasRealNamedProperty(key)) { } else if (object->HasRealNamedProperty(context->v8_context(), key)
v8::Local<v8::Value> value = object->Get(key); .FromMaybe(false)) {
v8::Local<v8::Value> value =
object->Get(context->v8_context(), key).ToLocalChecked();
CHECK(value->IsObject()); CHECK(value->IsObject());
return v8::Local<v8::Object>::Cast(value); return v8::Local<v8::Object>::Cast(value);
} }
...@@ -67,7 +70,8 @@ v8::Local<v8::Object> GetOrCreateChrome(ScriptContext* context) { ...@@ -67,7 +70,8 @@ v8::Local<v8::Object> GetOrCreateChrome(ScriptContext* context) {
v8::NewStringType::kInternalized) v8::NewStringType::kInternalized)
.ToLocalChecked()); .ToLocalChecked());
v8::Local<v8::Object> global(context->v8_context()->Global()); v8::Local<v8::Object> global(context->v8_context()->Global());
v8::Local<v8::Value> chrome(global->Get(chrome_string)); v8::Local<v8::Value> chrome(
global->Get(context->v8_context(), chrome_string).ToLocalChecked());
if (chrome->IsUndefined()) { if (chrome->IsUndefined()) {
chrome = v8::Object::New(context->isolate()); chrome = v8::Object::New(context->isolate());
global->Set(context->v8_context(), chrome_string, chrome).ToChecked(); global->Set(context->v8_context(), chrome_string, chrome).ToChecked();
...@@ -288,7 +292,8 @@ void JsExtensionBindingsSystem::RegisterBinding( ...@@ -288,7 +292,8 @@ void JsExtensionBindingsSystem::RegisterBinding(
v8::String::NewFromUtf8(context->isolate(), bind_name.c_str(), v8::String::NewFromUtf8(context->isolate(), bind_name.c_str(),
v8::NewStringType::kInternalized) v8::NewStringType::kInternalized)
.ToLocalChecked(); .ToLocalChecked();
if (bind_object->HasRealNamedProperty(v8_bind_name)) { if (bind_object->HasRealNamedProperty(context->v8_context(), v8_bind_name)
.FromMaybe(false)) {
// The bind object may already have the property if the API has been // The bind object may already have the property if the API has been
// registered before (or if the extension has put something there already, // registered before (or if the extension has put something there already,
// but, whatevs). // but, whatevs).
...@@ -298,9 +303,13 @@ void JsExtensionBindingsSystem::RegisterBinding( ...@@ -298,9 +303,13 @@ void JsExtensionBindingsSystem::RegisterBinding(
// others so that we don't destroy state such as event listeners. // others so that we don't destroy state such as event listeners.
// //
// TODO(kalman): Only register available APIs to make this all moot. // TODO(kalman): Only register available APIs to make this all moot.
if (bind_object->HasRealNamedCallbackProperty(v8_bind_name)) if (bind_object
->HasRealNamedCallbackProperty(context->v8_context(), v8_bind_name)
.FromMaybe(false))
return; // lazy binding still there, nothing to do return; // lazy binding still there, nothing to do
if (bind_object->Get(v8_bind_name)->IsObject()) if (bind_object->Get(context->v8_context(), v8_bind_name)
.ToLocalChecked()
->IsObject())
return; // binding has already been fully installed return; // binding has already been fully installed
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment