Fix deprecated V8 function use in GetOrCreateChromeObject
Fixes use of deprecated Object::Get/Set V8 functions in content::GetOrCreateChromeObject by instead using the Context version and checking the return values. Bug: v8:7283, v8:8562 Change-Id: I16b147ec9f642a744b77516cf228fbd0a78f1bc3 Reviewed-on: https://chromium-review.googlesource.com/c/1447718 Reviewed-by: Jochen Eisinger <jochen@chromium.org> Commit-Queue: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#628372}
This commit is contained in:
@ -75,7 +75,7 @@ void SandboxStatusExtension::Install() {
|
|||||||
v8::Context::Scope context_scope(context);
|
v8::Context::Scope context_scope(context);
|
||||||
|
|
||||||
v8::Local<v8::Object> chrome =
|
v8::Local<v8::Object> chrome =
|
||||||
content::GetOrCreateChromeObject(isolate, context->Global());
|
content::GetOrCreateChromeObject(isolate, context);
|
||||||
v8::Local<v8::Function> function;
|
v8::Local<v8::Function> function;
|
||||||
bool success =
|
bool success =
|
||||||
gin::CreateFunctionTemplate(
|
gin::CreateFunctionTemplate(
|
||||||
|
@ -1082,7 +1082,7 @@ void SearchBoxExtension::Install(blink::WebLocalFrame* frame) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
v8::Local<v8::Object> chrome =
|
v8::Local<v8::Object> chrome =
|
||||||
content::GetOrCreateChromeObject(isolate, context->Global());
|
content::GetOrCreateChromeObject(isolate, context);
|
||||||
v8::Local<v8::Object> embedded_search = v8::Object::New(isolate);
|
v8::Local<v8::Object> embedded_search = v8::Object::New(isolate);
|
||||||
embedded_search
|
embedded_search
|
||||||
->Set(context, gin::StringToV8(isolate, "searchBox"),
|
->Set(context, gin::StringToV8(isolate, "searchBox"),
|
||||||
|
@ -52,7 +52,7 @@ void ContextualSearchWrapper::Install(content::RenderFrame* render_frame) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
v8::Local<v8::Object> chrome =
|
v8::Local<v8::Object> chrome =
|
||||||
content::GetOrCreateChromeObject(isolate, context->Global());
|
content::GetOrCreateChromeObject(isolate, context);
|
||||||
chrome->Set(gin::StringToV8(isolate, kContextualSearchObjectName),
|
chrome->Set(gin::StringToV8(isolate, kContextualSearchObjectName),
|
||||||
wrapper.ToV8());
|
wrapper.ToV8());
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,16 @@
|
|||||||
namespace content {
|
namespace content {
|
||||||
|
|
||||||
v8::Local<v8::Object> GetOrCreateChromeObject(v8::Isolate* isolate,
|
v8::Local<v8::Object> GetOrCreateChromeObject(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> global) {
|
v8::Local<v8::Context> context) {
|
||||||
|
v8::Local<v8::Object> global = context->Global();
|
||||||
v8::Local<v8::Object> chrome;
|
v8::Local<v8::Object> chrome;
|
||||||
v8::Local<v8::Value> chrome_value =
|
v8::Local<v8::Value> chrome_value;
|
||||||
global->Get(gin::StringToV8(isolate, "chrome"));
|
if (!global->Get(context, gin::StringToV8(isolate, "chrome"))
|
||||||
if (chrome_value.IsEmpty() || !chrome_value->IsObject()) {
|
.ToLocal(&chrome_value) ||
|
||||||
|
!chrome_value->IsObject()) {
|
||||||
chrome = v8::Object::New(isolate);
|
chrome = v8::Object::New(isolate);
|
||||||
global->Set(gin::StringToSymbol(isolate, "chrome"), chrome);
|
global->Set(context, gin::StringToSymbol(isolate, "chrome"), chrome)
|
||||||
|
.Check();
|
||||||
} else {
|
} else {
|
||||||
chrome = v8::Local<v8::Object>::Cast(chrome_value);
|
chrome = v8::Local<v8::Object>::Cast(chrome_value);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace v8 {
|
namespace v8 {
|
||||||
template<class T> class Local;
|
template<class T> class Local;
|
||||||
|
class Context;
|
||||||
class Object;
|
class Object;
|
||||||
class Isolate;
|
class Isolate;
|
||||||
} // namespace v8
|
} // namespace v8
|
||||||
@ -17,7 +18,7 @@ namespace content {
|
|||||||
|
|
||||||
CONTENT_EXPORT v8::Local<v8::Object> GetOrCreateChromeObject(
|
CONTENT_EXPORT v8::Local<v8::Object> GetOrCreateChromeObject(
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> global);
|
v8::Local<v8::Context> context);
|
||||||
|
|
||||||
} // namespace content
|
} // namespace content
|
||||||
|
|
||||||
|
@ -525,8 +525,7 @@ void GpuBenchmarking::Install(RenderFrameImpl* frame) {
|
|||||||
if (controller.IsEmpty())
|
if (controller.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
v8::Local<v8::Object> chrome =
|
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate, context);
|
||||||
GetOrCreateChromeObject(isolate, context->Global());
|
|
||||||
chrome->Set(gin::StringToV8(isolate, "gpuBenchmarking"), controller.ToV8());
|
chrome->Set(gin::StringToV8(isolate, "gpuBenchmarking"), controller.ToV8());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +124,7 @@ void SkiaBenchmarking::Install(blink::WebLocalFrame* frame) {
|
|||||||
if (controller.IsEmpty())
|
if (controller.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate,
|
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate, context);
|
||||||
context->Global());
|
|
||||||
chrome->Set(gin::StringToV8(isolate, "skiaBenchmarking"), controller.ToV8());
|
chrome->Set(gin::StringToV8(isolate, "skiaBenchmarking"), controller.ToV8());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,7 @@ void WebUIExtension::Install(blink::WebLocalFrame* frame) {
|
|||||||
|
|
||||||
v8::Context::Scope context_scope(context);
|
v8::Context::Scope context_scope(context);
|
||||||
|
|
||||||
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate,
|
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate, context);
|
||||||
context->Global());
|
|
||||||
chrome->Set(
|
chrome->Set(
|
||||||
gin::StringToSymbol(isolate, "send"),
|
gin::StringToSymbol(isolate, "send"),
|
||||||
gin::CreateFunctionTemplate(isolate, base::Bind(&WebUIExtension::Send))
|
gin::CreateFunctionTemplate(isolate, base::Bind(&WebUIExtension::Send))
|
||||||
|
@ -502,8 +502,7 @@ renderer:
|
|||||||
|
|
||||||
```c++
|
```c++
|
||||||
// WebUIExtension::Install():
|
// WebUIExtension::Install():
|
||||||
v8::Local<v8::Object> chrome =
|
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate, context);
|
||||||
GetOrCreateChromeObject(isolate, context->Global());
|
|
||||||
chrome->Set(gin::StringToSymbol(isolate, "send"),
|
chrome->Set(gin::StringToSymbol(isolate, "send"),
|
||||||
gin::CreateFunctionTemplate(
|
gin::CreateFunctionTemplate(
|
||||||
isolate, base::Bind(&WebUIExtension::Send))->GetFunction());
|
isolate, base::Bind(&WebUIExtension::Send))->GetFunction());
|
||||||
|
Reference in New Issue
Block a user