From 7249b25868f8679dd9f85a48d8ff2bd26ce826c1 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Tue, 16 Jul 2019 04:50:38 +0200 Subject: [PATCH] refactor: replace SetHiddenValue() with mate::Dictionary::SetHidden() (#19263) --- shell/renderer/renderer_client_base.cc | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/shell/renderer/renderer_client_base.cc b/shell/renderer/renderer_client_base.cc index 40746e6593a5..b88fccf74a1a 100644 --- a/shell/renderer/renderer_client_base.cc +++ b/shell/renderer/renderer_client_base.cc @@ -73,15 +73,6 @@ std::vector ParseSchemesCLISwitch(base::CommandLine* command_line, base::SPLIT_WANT_NONEMPTY); } -void SetHiddenValue(v8::Handle context, - const base::StringPiece& key, - v8::Local value) { - v8::Isolate* isolate = context->GetIsolate(); - v8::Local privateKey = - v8::Private::ForApi(isolate, mate::StringToV8(isolate, key)); - context->Global()->SetPrivate(context, privateKey, value); -} - } // namespace RendererClientBase::RendererClientBase() { @@ -110,14 +101,13 @@ void RendererClientBase::DidCreateScriptContext( // global.setHidden("contextId", `${processHostId}-${++next_context_id_}`) auto context_id = base::StringPrintf( "%s-%" PRId64, renderer_client_id_.c_str(), ++next_context_id_); - v8::Isolate* isolate = context->GetIsolate(); - SetHiddenValue(context, "contextId", mate::ConvertToV8(isolate, context_id)); + mate::Dictionary global(context->GetIsolate(), context->Global()); + global.SetHidden("contextId", context_id); auto* command_line = base::CommandLine::ForCurrentProcess(); bool enableRemoteModule = !command_line->HasSwitch(switches::kDisableRemoteModule); - SetHiddenValue(context, "enableRemoteModule", - mate::ConvertToV8(isolate, enableRemoteModule)); + global.SetHidden("enableRemoteModule", enableRemoteModule); } void RendererClientBase::AddRenderBindings(