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:
chrome/renderer
components/contextual_search/content/renderer
content
public
renderer
docs
@ -75,7 +75,7 @@ void SandboxStatusExtension::Install() {
|
||||
v8::Context::Scope context_scope(context);
|
||||
|
||||
v8::Local<v8::Object> chrome =
|
||||
content::GetOrCreateChromeObject(isolate, context->Global());
|
||||
content::GetOrCreateChromeObject(isolate, context);
|
||||
v8::Local<v8::Function> function;
|
||||
bool success =
|
||||
gin::CreateFunctionTemplate(
|
||||
|
@ -1082,7 +1082,7 @@ void SearchBoxExtension::Install(blink::WebLocalFrame* frame) {
|
||||
return;
|
||||
|
||||
v8::Local<v8::Object> chrome =
|
||||
content::GetOrCreateChromeObject(isolate, context->Global());
|
||||
content::GetOrCreateChromeObject(isolate, context);
|
||||
v8::Local<v8::Object> embedded_search = v8::Object::New(isolate);
|
||||
embedded_search
|
||||
->Set(context, gin::StringToV8(isolate, "searchBox"),
|
||||
|
@ -52,7 +52,7 @@ void ContextualSearchWrapper::Install(content::RenderFrame* render_frame) {
|
||||
return;
|
||||
|
||||
v8::Local<v8::Object> chrome =
|
||||
content::GetOrCreateChromeObject(isolate, context->Global());
|
||||
content::GetOrCreateChromeObject(isolate, context);
|
||||
chrome->Set(gin::StringToV8(isolate, kContextualSearchObjectName),
|
||||
wrapper.ToV8());
|
||||
}
|
||||
|
@ -10,13 +10,16 @@
|
||||
namespace content {
|
||||
|
||||
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::Value> chrome_value =
|
||||
global->Get(gin::StringToV8(isolate, "chrome"));
|
||||
if (chrome_value.IsEmpty() || !chrome_value->IsObject()) {
|
||||
v8::Local<v8::Value> chrome_value;
|
||||
if (!global->Get(context, gin::StringToV8(isolate, "chrome"))
|
||||
.ToLocal(&chrome_value) ||
|
||||
!chrome_value->IsObject()) {
|
||||
chrome = v8::Object::New(isolate);
|
||||
global->Set(gin::StringToSymbol(isolate, "chrome"), chrome);
|
||||
global->Set(context, gin::StringToSymbol(isolate, "chrome"), chrome)
|
||||
.Check();
|
||||
} else {
|
||||
chrome = v8::Local<v8::Object>::Cast(chrome_value);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
namespace v8 {
|
||||
template<class T> class Local;
|
||||
class Context;
|
||||
class Object;
|
||||
class Isolate;
|
||||
} // namespace v8
|
||||
@ -17,7 +18,7 @@ namespace content {
|
||||
|
||||
CONTENT_EXPORT v8::Local<v8::Object> GetOrCreateChromeObject(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> global);
|
||||
v8::Local<v8::Context> context);
|
||||
|
||||
} // namespace content
|
||||
|
||||
|
@ -525,8 +525,7 @@ void GpuBenchmarking::Install(RenderFrameImpl* frame) {
|
||||
if (controller.IsEmpty())
|
||||
return;
|
||||
|
||||
v8::Local<v8::Object> chrome =
|
||||
GetOrCreateChromeObject(isolate, context->Global());
|
||||
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate, context);
|
||||
chrome->Set(gin::StringToV8(isolate, "gpuBenchmarking"), controller.ToV8());
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,7 @@ void SkiaBenchmarking::Install(blink::WebLocalFrame* frame) {
|
||||
if (controller.IsEmpty())
|
||||
return;
|
||||
|
||||
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate,
|
||||
context->Global());
|
||||
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate, context);
|
||||
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::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate,
|
||||
context->Global());
|
||||
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate, context);
|
||||
chrome->Set(
|
||||
gin::StringToSymbol(isolate, "send"),
|
||||
gin::CreateFunctionTemplate(isolate, base::Bind(&WebUIExtension::Send))
|
||||
|
@ -502,8 +502,7 @@ renderer:
|
||||
|
||||
```c++
|
||||
// WebUIExtension::Install():
|
||||
v8::Local<v8::Object> chrome =
|
||||
GetOrCreateChromeObject(isolate, context->Global());
|
||||
v8::Local<v8::Object> chrome = GetOrCreateChromeObject(isolate, context);
|
||||
chrome->Set(gin::StringToSymbol(isolate, "send"),
|
||||
gin::CreateFunctionTemplate(
|
||||
isolate, base::Bind(&WebUIExtension::Send))->GetFunction());
|
||||
|
Reference in New Issue
Block a user