internal static void Initialize() { if(initialized) throw new HtmlUIException("ChromiumWebBrowser library already initialized."); int retval = CfxRuntime.ExecuteProcess(); if(retval >= 0) Environment.Exit(retval); app = new CfxApp(); processHandler = new CfxBrowserProcessHandler(); app.GetBrowserProcessHandler += (s, e) => e.SetReturnValue(processHandler); app.OnBeforeCommandLineProcessing += (s, e) => HtmlUILauncher.RaiseOnBeforeCommandLineProcessing(e); app.OnRegisterCustomSchemes += (s, e) => HtmlUILauncher.RaiseOnRegisterCustomSchemes(e); var settings = new CfxSettings(); settings.MultiThreadedMessageLoop = true; settings.NoSandbox = true; HtmlUILauncher.RaiseOnBeforeCfxInitialize(settings, processHandler); if(!CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain)) throw new HtmlUIException("Failed to initialize CEF library."); initialized = true; }
private void Initialize() { CfxRuntime.LibCefDirPath = @"cef\Release"; int retval = CfxRuntime.ExecuteProcess(); var app = new CfxApp(); var processHandler = new CfxBrowserProcessHandler(); app.GetBrowserProcessHandler += (sender, e) => e.SetReturnValue(processHandler); var path = Path.Combine(GetType().Assembly.GetPath(), "ChromiumFXRenderProcess.exe"); var settings = new CfxSettings { SingleProcess = false, BrowserSubprocessPath = path, WindowlessRenderingEnabled = true, MultiThreadedMessageLoop = true, NoSandbox = true, LocalesDirPath = System.IO.Path.GetFullPath(@"cef\Resources\locales"), ResourcesDirPath = System.IO.Path.GetFullPath(@"cef\Resources") }; if (!CfxRuntime.Initialize(settings, app, RenderProcessStartup)) throw new Exception("Failed to initialize CEF library."); Thread.Sleep(200); }
/// <summary> /// This function should be called on the main application thread to initialize /// the CEF browser process. The |application| parameter may be NULL. A return /// value of true (1) indicates that it succeeded and false (0) indicates that it /// failed. /// /// The chromium sandbox is currently not supported within ChromiumFX. /// </summary> public static bool Initialize(CfxSettings settings, CfxApp application) { CfxApi.Probe(); switch (CfxApi.PlatformOS) { case CfxPlatformOS.Windows: return(InitializePrivate(null, settings, application, IntPtr.Zero)); case CfxPlatformOS.Linux: using (var mainArgs = CfxMainArgs.ForLinux()) { var retval = InitializePrivate(mainArgs, settings, application, IntPtr.Zero); mainArgs.mainArgsLinux.Free(); return(retval); } default: throw new CfxException(); } }
/// <summary> /// This function should be called on the main application thread to initialize /// the CEF browser process. The |application| parameter may be NULL. A return /// value of true (1) indicates that it succeeded and false (0) indicates that it /// failed. The |windowsSandboxInfo| parameter is only used on Windows and may /// be NULL (see cef_sandbox_win.h for details). /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_app_capi.h">cef/include/capi/cef_app_capi.h</see>. /// </remarks> private static bool InitializePrivate(CfxMainArgs args, CfxSettings settings, CfxApp application, IntPtr windowsSandboxInfo) { return(0 != CfxApi.cfx_initialize(CfxMainArgs.Unwrap(args), CfxSettings.Unwrap(settings), CfxApp.Unwrap(application), windowsSandboxInfo)); }
protected override void UpdateChromiumSettings(CfxSettings settings) { settings.RemoteDebuggingPort = 9090; }
/// <summary> /// This function should be called on the main application thread to initialize /// the CEF browser process with support for the remote interface to the render /// process. The |application| parameter may be NULL. A return value of true (1) /// indicates that it succeeded and false (0) indicates that it failed. /// /// If |renderProcessMain| is provided, then every newly created render process /// main thread will be redirected through this callback and the callee is /// responsible for calling CfrRuntime.ExecuteProcess() from within the /// scope of this callback. /// /// The chromium sandbox is currently not supported within ChromiumFX. /// </summary> public static bool Initialize(CfxSettings settings, CfxApp application, CfxRenderProcessMainDelegate renderProcessMain) { CfxApi.Probe(); Chromium.Remote.RemoteService.Initialize(renderProcessMain, ref application); return(Initialize(settings, application)); }
/// <summary> /// This function should be called on the main application thread to initialize /// the CEF browser process. The |application| parameter may be NULL. A return /// value of true (1) indicates that it succeeded and false (0) indicates that it /// failed. /// /// The chromium sandbox is currently not supported within ChromiumFX. /// </summary> public static bool Initialize(CfxSettings settings, CfxApp application) { CfxApi.Probe(); switch(CfxApi.PlatformOS) { case CfxPlatformOS.Windows: return InitializePrivate(null, settings, application, IntPtr.Zero); case CfxPlatformOS.Linux: using(var mainArgs = CfxMainArgs.ForLinux()) { var retval = InitializePrivate(mainArgs, settings, application, IntPtr.Zero); mainArgs.mainArgsLinux.Free(); return retval; } default: throw new CfxException(); } }
/// <summary> /// This function should be called on the main application thread to initialize /// the CEF browser process with support for the remote interface to the render /// process. The |application| parameter may be NULL. A return value of true (1) /// indicates that it succeeded and false (0) indicates that it failed. /// /// If |renderProcessMain| is provided, then every newly created render process /// main thread will be redirected through this callback and the callee is /// responsible for calling CfrRuntime.ExecuteProcess() from within the /// scope of this callback. /// /// The chromium sandbox is currently not supported within ChromiumFX. /// </summary> public static bool Initialize(CfxSettings settings, CfxApp application, CfxRenderProcessMainDelegate renderProcessMain) { CfxApi.Probe(); Chromium.Remote.RemoteService.Initialize(renderProcessMain, ref application); return Initialize(settings, application); }
protected virtual void UpdateChromiumSettings(CfxSettings settings) { }