Store context that API is running in to deliver IPC events

This commit is contained in:
Kevin Sawicki 2016-12-13 14:04:17 -08:00
parent 2928fe5c43
commit 5b6397aaa6
3 changed files with 11 additions and 6 deletions

View file

@ -292,6 +292,9 @@ void AtomRendererClient::DidCreateScriptContext(
if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame))
return;
api_context_.Reset(context->GetIsolate(), context);
api_context_.SetWeak();
// Whether the node binding has been initialized.
bool first_time = node_bindings_->uv_env() == nullptr;
@ -321,10 +324,6 @@ void AtomRendererClient::DidCreateScriptContext(
}
}
v8::Local<v8::Context> AtomRendererClient::GetContext() {
return node_bindings_->uv_env()->context();
}
void AtomRendererClient::WillReleaseScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
// Only allow node integration for the main frame, unless it is a devtools
@ -367,4 +366,8 @@ void AtomRendererClient::AddSupportedKeySystems(
AddChromeKeySystems(key_systems);
}
v8::Local<v8::Context> AtomRendererClient::GetAPIContext(v8::Isolate* isolate) {
return api_context_.Get(isolate);
}
} // namespace atom