Support IPC messages in isolated context
This commit is contained in:
parent
073d8c2177
commit
78e0b80dc7
4 changed files with 10 additions and 1 deletions
|
@ -76,6 +76,7 @@ AtomRenderViewObserver::AtomRenderViewObserver(
|
|||
content::RenderView* render_view,
|
||||
AtomRendererClient* renderer_client)
|
||||
: content::RenderViewObserver(render_view),
|
||||
renderer_client_(renderer_client),
|
||||
document_created_(false) {
|
||||
// Initialise resource for directory listing.
|
||||
net::NetModule::SetResourceProvider(NetResourceProvider);
|
||||
|
@ -93,7 +94,7 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame,
|
|||
v8::Isolate* isolate = blink::mainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::Context> context = frame->mainWorldScriptContext();
|
||||
v8::Local<v8::Context> context = renderer_client_->GetContext();
|
||||
v8::Context::Scope context_scope(context);
|
||||
|
||||
// Only emit IPC event for context with node integration.
|
||||
|
|
|
@ -40,6 +40,8 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
|
|||
const base::string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
AtomRendererClient* renderer_client_;
|
||||
|
||||
// Whether the document object has been created.
|
||||
bool document_created_;
|
||||
|
||||
|
|
|
@ -334,6 +334,10 @@ 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
|
||||
|
|
|
@ -27,6 +27,8 @@ class AtomRendererClient : public content::ContentRendererClient {
|
|||
void WillReleaseScriptContext(
|
||||
v8::Handle<v8::Context> context, content::RenderFrame* render_frame);
|
||||
|
||||
v8::Local<v8::Context> GetContext();
|
||||
|
||||
private:
|
||||
enum NodeIntegration {
|
||||
ALL,
|
||||
|
|
Loading…
Reference in a new issue