internal BindFunctionsTask(CfrBrowser remoteBrowser, string objName, string[] funcNames, CfrV8Handler v8Handler) { this.Execute += (s, e) => { var context = remoteBrowser.MainFrame.V8Context; context.Enter(); CfrV8Value obj = null; if (objName != null && objName != "" && !context.Global.HasValue(objName)) { obj = CfrV8Value.CreateObject(new CfrV8Accessor()); context.Global.SetValue(objName, obj, CfxV8PropertyAttribute.DontDelete | CfxV8PropertyAttribute.ReadOnly); //context.Global.DeleteValue(objName); } foreach (string name in funcNames) { // bind CfrV8Value func = CfrV8Value.CreateFunction(name, v8Handler); if (obj != null && !obj.HasValue(name)) { obj.SetValue(name, func, CfxV8PropertyAttribute.DontDelete | CfxV8PropertyAttribute.ReadOnly); } else if (!context.Global.HasValue(name)) { context.Global.SetValue(name, func, CfxV8PropertyAttribute.DontDelete | CfxV8PropertyAttribute.ReadOnly); } } context.Exit(); }; }
internal BindFunctionsTask(CfrBrowser remoteBrowser, string objName, string[] funcNames, CfrV8Handler v8Handler) { Execute += (s, e) => { var v8Context = remoteBrowser.MainFrame.V8Context; v8Context.Enter(); var cfrV8Value = (CfrV8Value)null; if (!string.IsNullOrEmpty(objName) && !v8Context.Global.HasValue(objName)) { cfrV8Value = CfrV8Value.CreateObject(new CfrV8Accessor()); v8Context.Global.SetValue(objName, cfrV8Value, CfxV8PropertyAttribute.ReadOnly | CfxV8PropertyAttribute.DontDelete); } foreach (var funcName in funcNames) { var function = CfrV8Value.CreateFunction(funcName, v8Handler); if (cfrV8Value != null && !cfrV8Value.HasValue(funcName)) { cfrV8Value.SetValue(funcName, function, CfxV8PropertyAttribute.ReadOnly | CfxV8PropertyAttribute.DontDelete); } else if (!v8Context.Global.HasValue(funcName)) { v8Context.Global.SetValue(funcName, function, CfxV8PropertyAttribute.ReadOnly | CfxV8PropertyAttribute.DontDelete); } } v8Context.Exit(); }; }
private void Bind(CfrV8Handler handler, string functionName) { lock (this) { Functions.Add(handler); var func = CfrV8Value.CreateFunction(functionName, handler); _CfrV8Value.SetValue(functionName, func, CfxV8PropertyAttribute.ReadOnly | CfxV8PropertyAttribute.DontDelete); } }
public void Bind(string functionName, IWebView context, Action <string, IJavascriptObject, IJavascriptObject[]> action) { lock (this) { var cfrV8Handler = action.Convert(functionName); Functions.Add(cfrV8Handler); var func = CfrV8Value.CreateFunction(functionName, cfrV8Handler); _CfrV8Value.SetValue(functionName, func, CfxV8PropertyAttribute.ReadOnly | CfxV8PropertyAttribute.DontDelete); } }
internal override CfrV8Value CreateV8Value() { v8Handler = new CfrV8Handler(); v8Handler.Execute += new CfrV8HandlerExecuteEventHandler(handler_Execute); return(CfrV8Value.CreateFunction(Name, v8Handler)); }
private CfrV8Value ObjectCreationCallbackFunctionCreator() { return(CfrV8Value.CreateFunction("objectCallBack", _ObjectCallback.Handler)); }