/// <summary> /// Handle retrieval of the interceptor value identified by |name|. |object| is /// the receiver ('this' object) of the interceptor. If retrieval succeeds, set /// |retval| to the return value. If the requested value does not exist, don't /// set either |retval| or |exception|. If retrieval fails, set |exception| to /// the exception that will be thrown. If the property has an associated /// accessor, it will be called only if you don't set |retval|. Return true (1) /// if interceptor retrieval was handled, false (0) otherwise. /// </summary> protected internal unsafe virtual bool GetByName(string name, CefV8Value @object, ref CefV8Value retval, ref string exception) { return(default);
/// <summary> /// Handle execution of the function identified by |name|. |object| is the /// receiver ('this' object) of the function. |arguments| is the list of /// arguments passed to the function. If execution succeeds set |retval| to the /// function return value. If execution fails set |exception| to the exception /// that will be thrown. Return true (1) if execution was handled. /// </summary> protected internal unsafe virtual bool Execute(string name, CefV8Value @object, CefV8Value[] arguments, ref CefV8Value retval, ref string exception) { return(default);
/// <summary> /// Handle retrieval the accessor value identified by |name|. |object| is the /// receiver ('this' object) of the accessor. If retrieval succeeds set /// |retval| to the return value. If retrieval fails set |exception| to the /// exception that will be thrown. Return true (1) if accessor retrieval was /// handled. /// </summary> public unsafe virtual bool Get(string name, CefV8Value @object, ref CefV8Value retval, ref string exception) { return(default);
/// <summary> /// Execute the function using the specified V8 context. |object| is the /// receiver ('this' object) of the function. If |object| is NULL the specified /// context's global object will be used. |arguments| is the list of arguments /// that will be passed to the function. Returns the function return value on /// success. Returns NULL if this function is called incorrectly or an /// exception is thrown. /// </summary> public unsafe virtual CefV8Value ExecuteFunctionWithContext(CefV8Context context, CefV8Value @object, CefV8Value[] arguments) { cef_v8value_t **arr3 = (cef_v8value_t **)Marshal.AllocHGlobal(sizeof(cef_v8value_t *) * arguments.Length); for (int i = 0; i < arguments.Length; i++) { var e3 = arguments[i]; *(arr3 + i) = e3 != null?e3.GetNativeInstance() : null; } var rv = CefV8Value.Wrap(CefV8Value.Create, NativeInstance->ExecuteFunctionWithContext((context != null) ? context.GetNativeInstance() : null, (@object != null) ? @object.GetNativeInstance() : null, new UIntPtr((uint)arguments.Length), arr3)); Marshal.FreeHGlobal((IntPtr)arr3); GC.KeepAlive(this); return(rv); }
private static void ProcessXrayRequest(CefProcessMessageReceivedEventArgs e) { CefListValue args = e.Message.ArgumentList; CefProcessMessage message = new CefProcessMessage(XrayResponseKey); CefListValue retArgs = message.ArgumentList; retArgs.SetSize(2); retArgs.SetValue(0, args.GetValue(0)); CefValue retval = null; XrayAction queryAction = (XrayAction)args.GetInt(1); try { CefV8Context v8Context; XrayObject target = null; if (queryAction == XrayAction.GetGlobal) { v8Context = e.Frame.V8Context; } else { target = XrayHandle.FromCfxBinaryValue(args.GetBinary(2)).GetTarget(e.Frame); v8Context = target?.Context ?? e.Frame.V8Context; } if (!v8Context.IsValid) { throw new ObjectDeadException(); } if (!v8Context.Enter()) { throw new ObjectDeadException(); } try { CefV8Value rv = null; switch (queryAction) { case XrayAction.Get: long corsRid = ScriptableObjectProvider.Get(v8Context, target, args, out rv); if (corsRid != 0) { var xray = new XrayHandle(); xray.dataType = XrayDataType.CorsRedirect; xray.iRaw = corsRid; retval = new CefValue(); retval.SetBinary(xray.ToCfxBinaryValue()); retArgs.SetValue(1, retval); } break; case XrayAction.Set: ScriptableObjectProvider.Set(v8Context, target, args); break; case XrayAction.InvokeMember: rv = ScriptableObjectProvider.InvokeMember(v8Context, target, args); break; case XrayAction.Invoke: rv = ScriptableObjectProvider.Invoke(v8Context, target, args); break; case XrayAction.GetGlobal: rv = v8Context.GetGlobal(); break; default: throw new NotSupportedException(); } if (rv != null) { retval = ScriptableObjectProvider.CastCefV8ValueToCefValue(v8Context, rv, out bool isXray); if (!isXray) { rv.Dispose(); } retArgs.SetValue(1, retval); } } finally { v8Context.Exit(); } } catch (AccessViolationException) { throw; } catch (OutOfMemoryException) { throw; } catch (Exception ex) { //File.AppendAllText("G:\\outlog.txt", ex.GetType().Name + ": " + ex.Message + "\r\n" + ex.StackTrace + "\r\n"); retArgs.SetSize(4); retArgs.SetString(1, ex.Message); retArgs.SetString(2, ex.GetType().FullName); retArgs.SetString(3, ex.StackTrace); } //CfxValueType t = e.Message.ArgumentList.GetType(0); e.Frame.SendProcessMessage(CefProcessId.Browser, message); message.Dispose(); retval?.Dispose(); e.Handled = true; }
/// <summary> /// Returns the value with the specified identifier on success. Returns NULL if /// this function is called incorrectly or an exception is thrown. /// </summary> public unsafe virtual CefV8Value GetValueByIndex(int index) { return(SafeCall(CefV8Value.Wrap(CefV8Value.Create, NativeInstance->GetValueByIndex(index)))); }
/// <summary> /// Associates a value with the specified identifier and returns true (1) on /// success. Returns false (0) if this function is called incorrectly or an /// exception is thrown. For read-only values this function will return true /// (1) even though assignment failed. /// </summary> public unsafe virtual bool SetValueByIndex(int index, CefV8Value value) { return(SafeCall(NativeInstance->SetValueByIndex(index, (value != null) ? value.GetNativeInstance() : null) != 0)); }
/// <summary> /// Returns true (1) if this object is pointing to the same handle as |that| /// object. /// </summary> public unsafe virtual bool IsSame(CefV8Value that) { return(SafeCall(NativeInstance->IsSame((that != null) ? that.GetNativeInstance() : null) != 0)); }
/// <summary> /// Returns a wrapper for the specified pointer to <see cref="cef_v8value_t"/> instance. /// </summary> /// <param name="create">Represents a method that create a new wrapper.</param> /// <param name="instance">The pointer to <see cref="cef_v8value_t"/> object.</param> /// <returns>Returns an existing or new wrapper of type <see cref="CefV8Value"/>.</returns> public unsafe static CefV8Value Wrap(Func <IntPtr, CefV8Value> create, cef_v8value_t *instance) { if (instance == null) return(null); }
/// <summary> /// Execute the function without arguments using the current V8 context.<para/> /// This function should only be called from within the scope of a <see cref="CefV8Handler"/> /// or <see cref="CefV8Accessor"/> callback, or in combination with calling /// <see cref="CefV8Context.Enter"/> and <see cref="CefV8Context.Enter"/> /// on a stored <see cref="CefV8Context"/> reference. /// </summary> /// <param name="thisArg"> /// The receiver ('this' object) of the function. If <paramref name="thisArg"/> /// is null the current context's global objectwill be used. /// </param> /// <returns> /// Returns the function return value on success, or null if this function /// is called incorrectly or an exception is thrown. /// </returns> public unsafe virtual CefV8Value ExecuteFunction(CefV8Value thisArg) { return(SafeCall(CefV8Value.Wrap(CefV8Value.Create, NativeInstance->ExecuteFunction(thisArg != null ? thisArg.GetNativeInstance() : null, new UIntPtr(), null)))); }
public bool SetValue(int index, CefV8Value value) { return(SetValueByIndex(index, value)); }
public bool SetValue(string key, CefV8Value value, CefV8PropertyAttribute attributes) { return(SetValueByKey(key, value, attributes)); }