refactor: expose process.contextId directly (#29236)

This commit is contained in:
Milan Burda 2021-05-24 09:51:54 +02:00 committed by GitHub
parent 12aa6d7343
commit 8fc86517fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 23 deletions

View file

@ -146,16 +146,6 @@ RendererClientBase::~RendererClientBase() {
g_renderer_client_base = nullptr;
}
void RendererClientBase::DidCreateScriptContext(
v8::Handle<v8::Context> context,
content::RenderFrame* render_frame) {
// global.setHidden("contextId", `${processHostId}-${++next_context_id_}`)
auto context_id = base::StringPrintf(
"%s-%" PRId64, renderer_client_id_.c_str(), ++next_context_id_);
gin_helper::Dictionary global(context->GetIsolate(), context->Global());
global.SetHidden("contextId", context_id);
}
// static
RendererClientBase* RendererClientBase::Get() {
DCHECK(g_renderer_client_base);
@ -165,9 +155,13 @@ RendererClientBase* RendererClientBase::Get() {
void RendererClientBase::BindProcess(v8::Isolate* isolate,
gin_helper::Dictionary* process,
content::RenderFrame* render_frame) {
auto context_id = base::StringPrintf(
"%s-%" PRId64, renderer_client_id_.c_str(), ++next_context_id_);
process->SetReadOnly("isMainFrame", render_frame->IsMainFrame());
process->SetReadOnly("contextIsolated",
render_frame->GetBlinkPreferences().context_isolation);
process->SetReadOnly("contextId", context_id);
}
void RendererClientBase::RenderThreadStarted() {