refactor: replace SetHiddenValue() with mate::Dictionary::SetHidden() (#19263)

This commit is contained in:
Milan Burda 2019-07-16 04:50:38 +02:00 committed by Cheng Zhao
parent aa211c6c50
commit 7249b25868

View file

@ -73,15 +73,6 @@ std::vector<std::string> ParseSchemesCLISwitch(base::CommandLine* command_line,
base::SPLIT_WANT_NONEMPTY); base::SPLIT_WANT_NONEMPTY);
} }
void SetHiddenValue(v8::Handle<v8::Context> context,
const base::StringPiece& key,
v8::Local<v8::Value> value) {
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Private> privateKey =
v8::Private::ForApi(isolate, mate::StringToV8(isolate, key));
context->Global()->SetPrivate(context, privateKey, value);
}
} // namespace } // namespace
RendererClientBase::RendererClientBase() { RendererClientBase::RendererClientBase() {
@ -110,14 +101,13 @@ void RendererClientBase::DidCreateScriptContext(
// global.setHidden("contextId", `${processHostId}-${++next_context_id_}`) // global.setHidden("contextId", `${processHostId}-${++next_context_id_}`)
auto context_id = base::StringPrintf( auto context_id = base::StringPrintf(
"%s-%" PRId64, renderer_client_id_.c_str(), ++next_context_id_); "%s-%" PRId64, renderer_client_id_.c_str(), ++next_context_id_);
v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary global(context->GetIsolate(), context->Global());
SetHiddenValue(context, "contextId", mate::ConvertToV8(isolate, context_id)); global.SetHidden("contextId", context_id);
auto* command_line = base::CommandLine::ForCurrentProcess(); auto* command_line = base::CommandLine::ForCurrentProcess();
bool enableRemoteModule = bool enableRemoteModule =
!command_line->HasSwitch(switches::kDisableRemoteModule); !command_line->HasSwitch(switches::kDisableRemoteModule);
SetHiddenValue(context, "enableRemoteModule", global.SetHidden("enableRemoteModule", enableRemoteModule);
mate::ConvertToV8(isolate, enableRemoteModule));
} }
void RendererClientBase::AddRenderBindings( void RendererClientBase::AddRenderBindings(