Inject all native extensions into web worker contexts

This commit is contained in:
Corey Johnson & Nathan Sobo
2013-01-23 18:12:30 -07:00
committed by Kevin Sawicki
parent f22fedebcf
commit cab281c6db
2 changed files with 14 additions and 7 deletions

View File

@@ -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);
};

View File

@@ -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);
}