mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Inject all native extensions into web worker contexts
This commit is contained in:
committed by
Kevin Sawicki
parent
f22fedebcf
commit
cab281c6db
@@ -31,6 +31,7 @@ class AtomCefRenderProcessHandler : public CefRenderProcessHandler {
|
||||
void Reload(CefRefPtr<CefBrowser> browser);
|
||||
void Shutdown(CefRefPtr<CefBrowser> browser);
|
||||
bool CallMessageReceivedHandler(CefRefPtr<CefV8Context> context, CefRefPtr<CefProcessMessage> message);
|
||||
void InjectExtensionsIntoV8Context(CefRefPtr<CefV8Context> context);
|
||||
|
||||
IMPLEMENT_REFCOUNTING(AtomCefRenderProcessHandler);
|
||||
};
|
||||
|
||||
@@ -9,19 +9,14 @@
|
||||
#import "path_watcher.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
void AtomCefRenderProcessHandler::OnWebKitInitialized() {
|
||||
}
|
||||
|
||||
void AtomCefRenderProcessHandler::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) {
|
||||
// these objects are deleted when the context removes all references to them
|
||||
(new v8_extensions::Atom())->CreateContextBinding(context);
|
||||
(new v8_extensions::Native())->CreateContextBinding(context);
|
||||
(new v8_extensions::Git())->CreateContextBinding(context);
|
||||
(new v8_extensions::OnigRegExp())->CreateContextBinding(context);
|
||||
(new v8_extensions::OnigScanner())->CreateContextBinding(context);
|
||||
(new v8_extensions::Tags())->CreateContextBinding(context);
|
||||
InjectExtensionsIntoV8Context(context);
|
||||
}
|
||||
|
||||
void AtomCefRenderProcessHandler::OnContextReleased(CefRefPtr<CefBrowser> browser,
|
||||
@@ -33,6 +28,7 @@ void AtomCefRenderProcessHandler::OnContextReleased(CefRefPtr<CefBrowser> browse
|
||||
void AtomCefRenderProcessHandler::OnWorkerContextCreated(int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) {
|
||||
InjectExtensionsIntoV8Context(context);
|
||||
}
|
||||
|
||||
void AtomCefRenderProcessHandler::OnWorkerContextReleased(int worker_id,
|
||||
@@ -122,3 +118,13 @@ bool AtomCefRenderProcessHandler::CallMessageReceivedHandler(CefRefPtr<CefV8Cont
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void AtomCefRenderProcessHandler::InjectExtensionsIntoV8Context(CefRefPtr<CefV8Context> context) {
|
||||
// these objects are deleted when the context removes all references to them
|
||||
(new v8_extensions::Atom())->CreateContextBinding(context);
|
||||
(new v8_extensions::Native())->CreateContextBinding(context);
|
||||
(new v8_extensions::Git())->CreateContextBinding(context);
|
||||
(new v8_extensions::OnigRegExp())->CreateContextBinding(context);
|
||||
(new v8_extensions::OnigScanner())->CreateContextBinding(context);
|
||||
(new v8_extensions::Tags())->CreateContextBinding(context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user