/// <summary> /// Call from CefRenderProcessHandler::OnContextCreated. Registers the /// JavaScripts functions with the new context. /// </summary> public void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context) { Helpers.RequireRendererThread(); // Do not keep any references to CefV8Value objects, otherwise // we should release all of them in OnContextReleased method (so we // can't rely on GC for this purpose). // Register function handlers with the 'window' object. using (var window = context.GetGlobal()) { var handler = new V8HandlerImpl(this, _config); CefV8PropertyAttribute attributes = CefV8PropertyAttribute.ReadOnly | CefV8PropertyAttribute.DontEnum | CefV8PropertyAttribute.DontDelete; // Add the query function. using (var queryFunc = CefV8Value.CreateFunction(_config.JSQueryFunction, handler)) { window.SetValue(_config.JSQueryFunction, queryFunc, attributes); } // Add the cancel function. using (var cancelFunc = CefV8Value.CreateFunction(_config.JSCancelFunction, handler)) { window.SetValue(_config.JSCancelFunction, cancelFunc, attributes); } } }
/// <summary> /// Call from CefRenderProcessHandler::OnContextCreated. Registers the /// JavaScripts functions with the new context. /// </summary> public void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context) { Helpers.RequireRendererThread(); // Register function handlers with the 'window' object. var window = context.GetGlobal(); var handler = new V8HandlerImpl(this, _config); CefV8PropertyAttribute attributes = CefV8PropertyAttribute.ReadOnly | CefV8PropertyAttribute.DontEnum | CefV8PropertyAttribute.DontDelete; // Add the query function. var queryFunc = CefV8Value.CreateFunction(_config.JSQueryFunction, handler); window.SetValue(_config.JSQueryFunction, queryFunc, attributes); // Add the cancel function. var cancelFunc = CefV8Value.CreateFunction(_config.JSCancelFunction, handler); window.SetValue(_config.JSCancelFunction, cancelFunc, attributes); }