/// <summary> /// Sets the value at the specified key as type list. Returns true (1) if the /// value was set successfully. If |value| is currently owned by another object /// then the value will be copied and the |value| reference will not change. /// Otherwise, ownership will be transferred to this object and the |value| /// reference will be invalidated. /// </summary> public unsafe virtual bool SetList(string key, CefListValue value) { fixed(char *s0 = key) { var cstr0 = new cef_string_t { Str = s0, Length = key != null ? key.Length : 0 }; return(SafeCall(NativeInstance->SetList(&cstr0, (value != null) ? value.GetNativeInstance() : null) != 0)); } }
// void (*)(_cef_browser_process_handler_t* self, _cef_list_value_t* extra_info)* private static unsafe void OnRenderProcessThreadCreatedImpl(cef_browser_process_handler_t *self, cef_list_value_t *extra_info) { var instance = GetInstance((IntPtr)self) as CefBrowserProcessHandler; if (instance == null || ((ICefBrowserProcessHandlerPrivate)instance).AvoidOnRenderProcessThreadCreated()) { ReleaseIfNonNull((cef_base_ref_counted_t *)extra_info); return; } instance.OnRenderProcessThreadCreated(CefListValue.Wrap(CefListValue.Create, extra_info)); }
/// <summary> /// Returns the value at the specified key as type list. The returned value /// will reference existing data and modifications to the value will modify /// this object. /// </summary> public unsafe virtual CefListValue GetList(string key) { fixed(char *s0 = key) { var cstr0 = new cef_string_t { Str = s0, Length = key != null ? key.Length : 0 }; return(SafeCall(CefListValue.Wrap(CefListValue.Create, NativeInstance->GetList(&cstr0)))); } }
private static bool ProcessXrayMessage(CefProcessMessage msg) { CefListValue args = msg.ArgumentList; var sqi = ScriptableRequestInfo.Get(args.GetInt(0)); if (sqi is null) { return(true); } if (args.GetSize() == 2) { sqi.Complete(args.GetValue(1)); } else { sqi.Complete(new CefNetRemoteException(args.GetString(1), args.GetString(2), args.GetString(3))); } return(true); }
/// <summary> /// Called on the browser process IO thread after the main thread has been /// created for a new render process. Provides an opportunity to specify extra /// information that will be passed to /// cef_render_process_handler_t::on_render_thread_created() in the render /// process. Do not keep a reference to |extra_info| outside of this function. /// </summary> public unsafe virtual void OnRenderProcessThreadCreated(CefListValue extraInfo) { }
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> /// Initializes a new instance of the <see cref="RenderThreadCreatedEventArgs"/> class. /// </summary> /// <param name="extraInfo">The extra information.</param> public RenderThreadCreatedEventArgs(CefListValue extraInfo) { this.ExtraInfo = extraInfo; }
/// <summary> /// Returns a writable copy of this object. /// </summary> public unsafe virtual CefListValue Copy() { return(SafeCall(CefListValue.Wrap(CefListValue.Create, NativeInstance->Copy()))); }
/// <summary> /// Returns true (1) if this object and |that| object have an equivalent /// underlying value but are not necessarily the same object. /// </summary> public unsafe virtual bool IsEqual(CefListValue that) { return(SafeCall(NativeInstance->IsEqual((that != null) ? that.GetNativeInstance() : null) != 0)); }
/// <summary> /// Sets the value at the specified index as type list. Returns true (1) if the /// value was set successfully. If |value| is currently owned by another object /// then the value will be copied and the |value| reference will not change. /// Otherwise, ownership will be transferred to this object and the |value| /// reference will be invalidated. /// </summary> public unsafe virtual bool SetList(long index, CefListValue value) { return(SafeCall(NativeInstance->SetList(new UIntPtr((ulong)index), (value != null) ? value.GetNativeInstance() : null) != 0)); }
/// <summary> /// Returns the value at the specified index as type list. The returned value /// will reference existing data and modifications to the value will modify /// this object. /// </summary> public unsafe virtual CefListValue GetList(long index) { return(SafeCall(CefListValue.Wrap(CefListValue.Create, NativeInstance->GetList(new UIntPtr((ulong)index))))); }
/// <summary> /// Called after the render process main thread has been created. |extra_info| /// is a read-only value originating from /// cef_browser_process_handler_t::on_render_process_thread_created(). Do not /// keep a reference to |extra_info| outside of this function. /// </summary> protected internal unsafe virtual void OnRenderThreadCreated(CefListValue extraInfo) { }
/// <summary> /// Sets the underlying value as type list. Returns true (1) if the value was /// set successfully. This object keeps a reference to |value| and ownership of /// the underlying data remains unchanged. /// </summary> public unsafe virtual bool SetList(CefListValue value) { return(SafeCall(NativeInstance->SetList((value != null) ? value.GetNativeInstance() : null) != 0)); }