/// <summary> /// Initializes a new instance of the <see cref="DirectoryPackage"/> /// </summary> /// <param name="directoryPath"> /// The path to the directory. /// </param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// The folder specified by <paramref name="directoryPath"/> does not exist. /// </exception> public DirectoryPackage(string directoryPath) : base(FileAccess.Read) { _directoryPath = directoryPath; CefRuntime.Load(); FilePackagePart.InitCustomContentTypes(Path.Combine(_directoryPath, "[Content_Types].xml")); }
private static bool cefruntimeLoad(out int main) { main = 0; try { CefRuntime.Load(); } catch (DllNotFoundException ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); { main = 1; return(true); } } catch (CefRuntimeException ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); { main = 2; return(true); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); { main = 3; return(true); } } return(false); }
internal int InitializeProcessOnly() { var args = Environment.GetCommandLineArgs(); if (ProcessType == CefProcessType.Browser) { Logger.Error("This process is just only run as subprocess."); return(-1); } CefRuntime.Load(ChromiumEnvironment.LibCefDir); IsRuntimeInitialized = true; if (!ChromiumEnvironment.ForceHighDpiSupportDisabled) { CefRuntime.EnableHighDpiSupport(); } ChromiumEnvironment.CefBrowserSettingConfigurations?.Invoke(WinFormium.DefaultBrowserSettings); ApplicationConfiguration.UseExtensions[(int)ExtensionExecutePosition.SubProcessStartup]?.Invoke(this, ApplicationProperties); var cefMainArgs = new CefMainArgs(args); var app = new WinFormiumApp(); var exitCode = CefRuntime.ExecuteProcess(cefMainArgs, app, IntPtr.Zero); return(exitCode); }
private static int Main(string[] args) { try { CefRuntime.Load(); } catch (DllNotFoundException ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } catch (CefRuntimeException ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(2); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(3); } var mainArgs = new CefMainArgs(args); var app = new DemoApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, app); if (exitCode != -1) { return(exitCode); } var codeBase = Assembly.GetExecutingAssembly().CodeBase; var localFolder = Path.GetDirectoryName(new Uri(codeBase).LocalPath); var browserProcessPath = CombinePaths(localFolder, "..", "..", "..", "CefGlue.Demo.WinForms", "bin", "Release", "Xilium.CefGlue.Demo.WinForms.exe"); var settings = new CefSettings { BrowserSubprocessPath = browserProcessPath, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Disable, LogFile = "CefGlue.log", }; CefRuntime.Initialize(mainArgs, settings, app); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!settings.MultiThreadedMessageLoop) { Application.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); }; } Application.Run(new MainForm()); CefRuntime.Shutdown(); return(0); }
public static void Initialize() { if (!initialized) { CefRuntime.Load(); var cefMainArgs = new CefMainArgs(new string[0]); var cefApp = new App(); if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1) { Console.Error.WriteLine("Couldn't execute secondary process."); } var cefSettings = new CefSettings { CachePath = "cache", SingleProcess = true, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Disable }; CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); initialized = true; } }
public static T ConfigureCefGlue <T>(this T builder, string[] args) where T : AppBuilderBase <T>, new() { return(builder.AfterSetup(b => { CefRuntime.Load(); var mainArgs = new CefMainArgs(args); var cefApp = new SampleCefApp(); cefApp.RegisterCustomSchemes += CefApp_RegisterCustomSchemes; cefApp.WebKitInitialized += CefApp_WebKitInitialized; var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp, IntPtr.Zero); if (exitCode != -1) { return; } var cefSettings = new CefSettings { SingleProcess = true, WindowlessRenderingEnabled = true, MultiThreadedMessageLoop = false, LogSeverity = CefLogSeverity.Disable, LogFile = "cef.log", ExternalMessagePump = true }; CefRuntime.Initialize(mainArgs, cefSettings, cefApp, IntPtr.Zero); })); }
public static int Main(string[] args) { InitLogging(args); var logger = ParagonLogManager.GetLogger(); var procId = Process.GetCurrentProcess().Id; logger.Info("Render process {0} starting", procId); try { if (!ExitWhenParentProcessExits()) { logger.Warn("Unable to monitor parent process for exit"); } CefRuntime.Load(); CefRuntime.ExecuteProcess(new CefMainArgs(args), new CefRenderApplication(), IntPtr.Zero); } catch (Exception ex) { logger.Error("Fatal error in render process {0} : {1}, StackTrace = {2}", procId, ex.Message, ex.StackTrace); return(1); } logger.Info("Render process {0} stopping.", procId); return(0); }
public static void Initialize(string cefRoot) { string environmentVariable = Environment.GetEnvironmentVariable("PATH"); if (Marshal.SizeOf(typeof(IntPtr)) == 4) { Environment.SetEnvironmentVariable("PATH", cefRoot + "\\cef_x86;" + environmentVariable); } else { Environment.SetEnvironmentVariable("PATH", cefRoot + "\\cef_x64;" + environmentVariable); } CefRuntime.Load(); CefMainArgs args2 = new CefMainArgs(new string[] {}); var cefApp = new SharpDXCefApp(); CefSettings settings = new CefSettings { SingleProcess = false, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Disable, LogFile = "Cef.log" }; try { CefRuntime.Initialize(args2, settings, cefApp); } catch (CefRuntimeException ex) { throw new Exception("Cef failed to initialize"); } }
// Main entry point when called by vvvv void IStartable.Start() { CefRuntime.Load(); var cefSettings = new CefSettings(); cefSettings.WindowlessRenderingEnabled = true; cefSettings.PackLoadingDisabled = false; cefSettings.MultiThreadedMessageLoop = true; cefSettings.BrowserSubprocessPath = Assembly.GetExecutingAssembly().Location; cefSettings.CommandLineArgsDisabled = false; cefSettings.IgnoreCertificateErrors = true; //// We do not meet the requirements - see cef_sandbox_win.h //cefSettings.NoSandbox = true; #if DEBUG cefSettings.LogSeverity = CefLogSeverity.Error; // Set to true to debug DOM / JavaScript cefSettings.SingleProcess = false; #else cefSettings.LogSeverity = CefLogSeverity.Disable; #endif var args = Environment.GetCommandLineArgs(); var mainArgs = new CefMainArgs(args); CefRuntime.Initialize(mainArgs, cefSettings, new HTMLTextureApp(), IntPtr.Zero); var schemeName = "cef"; if (!CefRuntime.RegisterSchemeHandlerFactory(SchemeHandlerFactory.SCHEME_NAME, null, new SchemeHandlerFactory())) { throw new Exception(string.Format("Couldn't register custom scheme factory for '{0}'.", schemeName)); } }
/// <summary> /// The on create. /// </summary> /// <param name="packet"> /// The packet. /// </param> /// <exception cref="Exception"> /// Rethrown exception on Cef load failure. /// </exception> protected override void OnCreate(ref CreateWindowPacket packet) { // Will throw exception if Cef load fails. CefRuntime.Load(); var mainArgs = new CefMainArgs(this.HostConfig.AppArgs); var app = new CefGlueApp(this.HostConfig); var exitCode = CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero); if (exitCode != -1) { return; } var codeBase = Assembly.GetExecutingAssembly().CodeBase; var localFolder = Path.GetDirectoryName(new Uri(codeBase).LocalPath); var localesDirPath = Path.Combine(localFolder, "locales"); var settings = new CefSettings { LocalesDirPath = localesDirPath, Locale = this.HostConfig.Locale, SingleProcess = false, MultiThreadedMessageLoop = true, LogSeverity = (CefLogSeverity)this.HostConfig.LogSeverity, LogFile = this.HostConfig.LogFile, ResourcesDirPath = Path.GetDirectoryName(new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath), NoSandbox = true }; // Update configuration settings settings.Update(this.HostConfig.CustomSettings); CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero); this.RegisterSchemeHandlers(); this.RegisterMessageRouters(); var browserConfig = new CefBrowserConfig { StartUrl = this.HostConfig.StartUrl, ParentHandle = this.Handle, AppArgs = this.HostConfig.AppArgs, CefRectangle = new CefRectangle { X = 0, Y = 0, Width = this.HostConfig.HostWidth, Height = this.HostConfig.HostHeight } }; this.mBrowser = new CefGlueBrowser(browserConfig); base.OnCreate(ref packet); Log.Info("Cef browser successfully created."); }
/// <summary> /// Initializes the cef. /// </summary> private void InitializeCef() { CefRuntime.Load(); var cefSettings = new CefSettings { MultiThreadedMessageLoop = true, SingleProcess = false, LogSeverity = CefLogSeverity.Warning, LogFile = LogsDirectoryPath + "/cef.log", CachePath = CacheDirectoryPath, ResourcesDirPath = PathUtility.WorkingDirectory, RemoteDebuggingPort = 20480, NoSandbox = true, CommandLineArgsDisabled = true }; // arguments var arguments = new List <string>(); if (!EnableD3D11 && !arguments.Contains(Argument.DisableD3D11.Value)) { arguments.Add(Argument.DisableD3D11.Value); } // initialize var mainArgs = new CefMainArgs(arguments.ToArray()); var app = new App(); CefRuntime.Initialize(mainArgs, cefSettings, app, IntPtr.Zero); }
/// <summary> /// 初始化浏览器 /// </summary> private void InitializeBrowser() { if (IsDesignMode()) { return; } CefRuntime.Load(ConfigurationManager.AppSettings["CefLibraryPath"]); var mainArgs = new CefMainArgs(new string[] { }); var cefApp = new WebApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp, IntPtr.Zero); if (exitCode != -1) { return; } var settings = new CefSettings { SingleProcess = false, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Disable, Locale = "zh-CN" }; CefRuntime.Initialize(mainArgs, settings, cefApp, IntPtr.Zero); if (!settings.MultiThreadedMessageLoop) { Application.Idle += (sender, e) => CefRuntime.DoMessageLoopWork(); } }
/// <summary> /// Creates a new <see cref="CefManager"/> instance /// </summary> /// <param name="arguments"></param> /// <param name="rawArguments"></param> /// <exception cref="DllNotFoundException"></exception> /// <exception cref="CefVersionMismatchException"></exception> /// <exception cref="Exception"></exception> public CefManager(LaunchArguments arguments, string[] rawArguments) { //Setup CEF CefRuntime.Load(); launchArguments = arguments; args = rawArguments; }
private static int Main(string[] args) { try { CefRuntime.Load(); } catch (DllNotFoundException ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } catch (CefRuntimeException ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(2); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(3); } var mainArgs = new CefMainArgs(args); var app = new DemoApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, app); if (exitCode != -1) { return(exitCode); } var settings = new CefSettings { // BrowserSubprocessPath = @"D:\fddima\Projects\Xilium\Xilium.CefGlue\CefGlue.Demo\bin\Release\Xilium.CefGlue.Demo.exe", SingleProcess = false, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Disable, LogFile = "CefGlue.log", RemoteDebuggingPort = 7777, }; CefRuntime.Initialize(mainArgs, settings, app); CefRuntime.RegisterSchemeHandlerFactory("http", "server", new MySchemeHandlerFactory()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!settings.MultiThreadedMessageLoop) { Application.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); }; } Application.Run(new MainForm()); CefRuntime.Shutdown(); return(0); }
static void Main() { vt1 = new VisualStudio2012DarkTheme(); //vt2 = new Office2013DarkTheme(); //vt3 = new VisualStudio2012LightTheme(); //vt4 = new Windows7Theme(); //vt5 = new Windows8Theme(); CefRuntime.Load(); var mainArgs = new CefMainArgs(new string[] { }); var settings = new CefSettings(); settings.MultiThreadedMessageLoop = CefRuntime.Platform == CefRuntimePlatform.Windows; settings.SingleProcess = false; settings.LogSeverity = CefLogSeverity.Verbose; settings.LogFile = "cef.log"; settings.Locale = "zh-CN"; settings.ResourcesDirPath = System.IO.Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase).LocalPath); settings.RemoteDebuggingPort = 20480; settings.NoSandbox = true; //settings.CachePath = @"E:\mine\工作相关\工作代码\Spot Trade System\UseOnlineTradingSystem\UseOnlineTradingSystem\bin\Debug"; var app = new BsCefApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero); if (exitCode != -1) { return; } CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!settings.MultiThreadedMessageLoop) { Application.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); }; } LoginFm = new FormLogin(); main = new MainForm(); //mf = new MainForm(); //Application.Run(mf); // Application.Run(LoginFm); try { Application.Run(LoginFm); } catch (Exception err) { Logger.LogError(err.ToString()); } Logger.LogInfo("退出程序!"); USeManager.Instance.Stop(); KillProcess(); //CefRuntime.Shutdown(); //Environment.Exit(0); }
public CefWebBrowser() { /* BEG: modbyme */ if (LicenseManager.UsageMode != LicenseUsageMode.Designtime) { CefRuntime.Load(); CefSettings settings = new CefSettings(); settings.CachePath = @"Cache"; //Cache Folder settings.MultiThreadedMessageLoop = false; settings.NoSandbox = true; //settings.LogSeverity = CefLogSeverity.Error; //settings.LogFile = "cef.log"; //settings.ResourcesDirPath = System.IO.Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase).LocalPath); //settings.RemoteDebuggingPort = 20480; // // settings.SingleProcess = true; CefMainArgs mainArgs = new CefMainArgs(Environment.GetCommandLineArgs()); CefWebApp app = new CefWebApp(this); if (CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero) != -1) { MessageBox.Show("ExecuteProcess failed"); } CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero); Application.Idle += (s, e) => CefRuntime.DoMessageLoopWork(); } /* END: modbyme */ SetStyle( ControlStyles.ContainerControl | ControlStyles.ResizeRedraw | ControlStyles.FixedWidth | ControlStyles.FixedHeight | ControlStyles.StandardClick | ControlStyles.UserMouse | ControlStyles.SupportsTransparentBackColor | ControlStyles.StandardDoubleClick | ControlStyles.OptimizedDoubleBuffer | ControlStyles.CacheText | ControlStyles.EnableNotifyMessage | ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UseTextForAccessibility | ControlStyles.Opaque, false); SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Selectable, true); StartUrl = "about:blank"; }
public int Run(string[] args) { CefRuntime.Load(); var settings = new CefSettings(); settings.MultiThreadedMessageLoop = CefRuntime.Platform == CefRuntimePlatform.Windows; settings.ReleaseDCheckEnabled = true; settings.LogSeverity = CefLogSeverity.Verbose; settings.LogFile = "cef.log"; settings.ResourcesDirPath = System.IO.Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase).LocalPath); settings.RemoteDebuggingPort = 20480; var argv = args; if (CefRuntime.Platform != CefRuntimePlatform.Windows) { argv = new string[args.Length + 1]; Array.Copy(args, 0, argv, 1, args.Length); argv[0] = "-"; } var mainArgs = new CefMainArgs(argv); var app = new DemoCefApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, app); Console.WriteLine("CefRuntime.ExecuteProcess() returns {0}", exitCode); if (exitCode != -1) { return(exitCode); } CefRuntime.Initialize(mainArgs, settings, app); // register custom scheme handler CefRuntime.RegisterSchemeHandlerFactory("http", DumpRequestDomain, new DemoAppSchemeHandlerFactory()); PlatformInitialize(); var mainMenu = CreateMainMenu(); _mainView = CreateMainView(mainMenu); _mainView.NewTab(HomeUrl); PlatformRunMessageLoop(); _mainView.Dispose(); _mainView = null; CefRuntime.Shutdown(); PlatformShutdown(); return(0); }
// ReSharper disable once UnusedParameter.Local private static void Main(string[] args) { Console.WriteLine("Sample showing stonehenge on Chromely"); // stonehenge backend var options = new StonehengeHostOptions { Title = "Demo" }; var provider = StonehengeResourceLoader .CreateDefaultLoader(new VueResourceProvider()); var host = new KestrelHost(provider, options); if (!host.Start(options.Title, false, "localhost", 8888)) { Console.WriteLine("Failed to start stonehenge server"); } // ensure CEF runtime files are present var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) ?? "."; Directory.SetCurrentDirectory(path); try { CefRuntime.Load(); } catch (Exception ex) { Console.WriteLine("Failed to load runtime: " + ex.Message); Console.WriteLine("Installing CEF runtime from " + CefLoader.CefBuildsDownloadUrl); CefLoader.Load(); } // chromely frontend var startUrl = host.BaseUrl; var config = ChromelyConfiguration .Create() .WithHostMode(WindowState.Normal, true) .WithHostTitle(options.Title) //.WithHostIconFile("chromely.ico") .WithAppArgs(args) .WithHostSize(1000, 600) .WithStartUrl(startUrl); using (var window = new CefGlueBrowserWindow(config)) { var exitCode = window.Run(args); if (exitCode != 0) { Console.WriteLine("Failed to start chromely frontend: code " + exitCode); } } Console.WriteLine("Demo done."); }
/// <summary> /// Run internal. /// </summary> protected override void RunInternal() { CefRuntime.Load(); var arguments = Environment.GetCommandLineArgs(); var mainArgs = new CefMainArgs(arguments.ToArray()); var app = new App(); CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero); }
/// <summary> /// 加载 Cef /// </summary> /// <returns></returns> public int RunInternal(string[] args) { try { CefRuntime.Load(); } catch (DllNotFoundException ex) { PlatformMessageBox(ex.Message); return(1); } catch (CefRuntimeException ex) { PlatformMessageBox(ex.Message); return(2); } catch (Exception ex) { PlatformMessageBox(ex.ToString()); return(3); } CefSettings settings = new CefSettings(); settings.MultiThreadedMessageLoop = MultiThreadedMessageLoop = CefRuntime.Platform == CefRuntimePlatform.Windows; //settings.MultiThreadedMessageLoop = false; settings.LogSeverity = CefLogSeverity.Error | CefLogSeverity.ErrorReport; settings.LogFile = "cef.log"; settings.ResourcesDirPath = System.IO.Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase).LocalPath); settings.RemoteDebuggingPort = 20480; settings.NoSandbox = true; settings.Locale = "zh-CN"; settings.CommandLineArgsDisabled = false; CefMainArgs mainArgs = new CefMainArgs(args); MonitorCefApp app = new MonitorCefApp(); CefMenuHandler cefMenuHandler = new CefMenuHandler(); int exitCode = CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero); if (exitCode != -1) { return(exitCode); } CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero); PlatformInitialize(); PlatformRunMessageLoop(); CefRuntime.Shutdown(); return(0); }
private void StartCef() { #if UNITY_EDITOR CefRuntime.Load(Path.Combine(Application.dataPath, "Plugins", "Cef", "Windows")); #else CefRuntime.Load(); #endif var cefMainArgs = new CefMainArgs(new string[] { }); var cefApp = new OffscreenCEFClient.OffscreenCEFApp(); // This is where the code path diverges for child processes. if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1) { Debug.LogError("Could not start the secondary process."); } var cefSettings = new CefSettings { //ExternalMessagePump = true, MultiThreadedMessageLoop = false, SingleProcess = true, LogSeverity = CefLogSeverity.Verbose, LogFile = "cef.log", WindowlessRenderingEnabled = true, NoSandbox = true }; // Start the browser process (a child process). CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); // Instruct CEF to not render to a window. CefWindowInfo cefWindowInfo = CefWindowInfo.Create(); cefWindowInfo.SetAsWindowless(IntPtr.Zero, true); // Settings for the browser window itself (e.g. enable JavaScript?). CefBrowserSettings cefBrowserSettings = new CefBrowserSettings() { }; Debug.Log("Start with window: " + this.windowWidth + ", " + this.windowHeight); // Initialize some of the custom interactions with the browser process. this.cefClient = new OffscreenCEFClient( this.windowWidth, this.windowHeight, this.hideScrollbars, this.BrowserTexture, this ); // Start up the browser instance. CefBrowserHost.CreateBrowser(cefWindowInfo, this.cefClient, cefBrowserSettings, string.IsNullOrEmpty(this.overlayUrl) ? "http://www.google.com" : this.overlayUrl); }
protected override void OnCreate(ref CreateWindowPacket packet) { try { CefRuntime.Load(); } catch (Exception ex) { throw ex; } var mainArgs = new CefMainArgs(HostConfig.CefAppArgs); var app = new CefWebApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero); if (exitCode != -1) { return; } var codeBase = Assembly.GetExecutingAssembly().CodeBase; var localFolder = Path.GetDirectoryName(new Uri(codeBase).LocalPath); var localesDirPath = Path.Combine(localFolder, "locales"); var settings = new CefSettings { LocalesDirPath = localFolder, Locale = HostConfig.CefLocale, SingleProcess = false, MultiThreadedMessageLoop = true, LogSeverity = (CefLogSeverity)HostConfig.CefLogSeverity, LogFile = HostConfig.CefLogFile }; CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero); RegisterSchemeHandlers(); RegisterMessageRouters(); CefBrowserConfig browserConfig = new CefBrowserConfig(); browserConfig.StartUrl = HostConfig.CefStartUrl; browserConfig.ParentHandle = Handle; browserConfig.AppArgs = HostConfig.CefAppArgs; browserConfig.CefRectangle = new CefRectangle { X = 0, Y = 0, Width = HostConfig.CefHostWidth, Height = HostConfig.CefHostHeight }; m_browser = new CefWebBrowser(browserConfig); base.OnCreate(ref packet); Log.Info("Cef browser successfully created."); }
private static int Main(string[] args) { try { CefRuntime.Load(); } catch (DllNotFoundException ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } catch (CefRuntimeException ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(2); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(3); } var mainArgs = new CefMainArgs(args); var app = new DemoApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero); if (exitCode != -1) { return(exitCode); } var settings = new CefSettings { MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Disable, LogFile = "CefGlue.log", NoSandbox = true }; CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); CefRuntime.Shutdown(); return(0); }
static bool CefRintimePrepare(string[] args, string temporaryDirectoryPath) { try { string path = Directory.GetCurrentDirectory(); var runtimepath = path; var clientpath = Path.Combine(runtimepath, "cefclient.exe"); Log.InfoFormat("using client path {0}", clientpath); var resourcepath = runtimepath; var localepath = Path.Combine(resourcepath, "locales"); Log.Info("===============START================"); CefRuntime.Load(runtimepath); //using native render helper Log.Info("appending disable cache keys"); CefMainArgs cefMainArgs = new CefMainArgs(args) { }; if (parametres._enableWebRTC) { Log.Info("starting with webrtc"); } var cefApp = new WorkerCefApp(parametres._enableWebRTC, parametres._enableGPU); int exit_code = CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero); if (exit_code >= 0) { Log.ErrorFormat("CefRuntime return " + exit_code); return(false); } var cefSettings = new CefSettings { SingleProcess = false, MultiThreadedMessageLoop = true, WindowlessRenderingEnabled = true, // BrowserSubprocessPath = clientpath, FrameworkDirPath = runtimepath, ResourcesDirPath = resourcepath, LocalesDirPath = localepath, LogFile = Path.Combine(Path.GetTempPath(), "cefruntime-" + Guid.NewGuid() + ".log"), Locale = "en-US", LogSeverity = CefLogSeverity.Error, //RemoteDebuggingPort = 8088, NoSandbox = true, //CachePath = temporaryDirectoryPath }; CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); ///////////// } catch (Exception ex) { Log.Info("EXCEPTION ON CEF INITIALIZATION:" + ex.Message + "\n" + ex.StackTrace); return(false); } return(true); }
private void StartCef() { #if UNITY_EDITOR CefRuntime.Load("./Assets/Plugins/x86_64"); #else CefRuntime.Load(); #endif var cefMainArgs = new CefMainArgs(new string[] { }); var cefApp = new OffscreenCEFClient.OffscreenCEFApp(); // This is where the code path diverges for child processes. if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1) { Debug.LogError("Could not start the secondary process."); } var cefSettings = new CefSettings { //ExternalMessagePump = true, MultiThreadedMessageLoop = false, SingleProcess = true, LogSeverity = CefLogSeverity.Verbose, LogFile = "cef.log", WindowlessRenderingEnabled = true, NoSandbox = true, }; // Start the browser process (a child process). CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); // Instruct CEF to not render to a window. CefWindowInfo cefWindowInfo = CefWindowInfo.Create(); cefWindowInfo.SetAsWindowless(IntPtr.Zero, false); // Settings for the browser window itself (e.g. enable JavaScript?). CefBrowserSettings cefBrowserSettings = new CefBrowserSettings() { BackgroundColor = new CefColor(255, 60, 85, 115), JavaScript = CefState.Enabled, JavaScriptAccessClipboard = CefState.Disabled, JavaScriptCloseWindows = CefState.Disabled, JavaScriptDomPaste = CefState.Disabled, JavaScriptOpenWindows = CefState.Disabled, LocalStorage = CefState.Disabled }; // Initialize some of the custom interactions with the browser process. this.cefClient = new OffscreenCEFClient(this.windowSize, this.hideScrollbars); // Start up the browser instance. CefBrowserHost.CreateBrowser(cefWindowInfo, this.cefClient, cefBrowserSettings, string.IsNullOrEmpty(this.url) ? "http://www.google.com" : this.url); }
public static T ConfigureCefGlue <T>(this T builder, string[] args) where T : AppBuilderBase <T>, new() { return(builder.AfterSetup((b) => { try { CefRuntime.Load(); } catch (DllNotFoundException ex) { } catch (CefRuntimeException ex) { } catch (Exception ex) { } var mainArgs = new CefMainArgs(args); var cefApp = new SampleCefApp(); cefApp.RegisterCustomSchemes += CefApp_RegisterCustomSchemes; cefApp.WebKitInitialized += CefApp_WebKitInitialized; var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp); if (exitCode != -1) { return; } var location = System.Reflection.Assembly.GetEntryAssembly().Location; var directory = System.IO.Path.GetDirectoryName(location); var cefSettings = new CefSettings { SingleProcess = true, WindowlessRenderingEnabled = true, MultiThreadedMessageLoop = false, LogSeverity = CefLogSeverity.Disable, LogFile = "cef.log", ExternalMessagePump = true }; try { CefRuntime.Initialize(mainArgs, cefSettings, cefApp); } catch (CefRuntimeException ex) { } })); }
static void Main(string[] args) { AppBuilder.Configure <App>() .UseSkia().UseWin32().AfterSetup((a) => { try { CefRuntime.Load(); } catch (DllNotFoundException ex) { } catch (CefRuntimeException ex) { } catch (Exception ex) { } var mainArgs = new CefMainArgs(args); var cefApp = new SampleCefApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp); if (exitCode != -1) { return; } var location = System.Reflection.Assembly.GetEntryAssembly().Location; var directory = System.IO.Path.GetDirectoryName(location); var cefSettings = new CefSettings { BrowserSubprocessPath = Path.Combine(directory, "cefclient.exe"), SingleProcess = false, WindowlessRenderingEnabled = true, MultiThreadedMessageLoop = false, LogSeverity = CefLogSeverity.Verbose, LogFile = "cef.log", ExternalMessagePump = true }; try { CefRuntime.Initialize(mainArgs, cefSettings, cefApp); } catch (CefRuntimeException ex) { } }).Start <MainWindow>(); }
public static void Initialize(string MainApplicationPath) { if (!initialized) { CefRuntime.Load(); var Cache = "Cache"; var Userdata = "UserData"; if (MainApplicationPath != "") { Cache = System.IO.Path.Combine(MainApplicationPath, "Cache"); Userdata = System.IO.Path.Combine(MainApplicationPath, "UserData"); } // for under 0.3.4.0 users if (System.IO.Directory.Exists("cache")) { try { var di = new System.IO.DirectoryInfo("cache"); di.MoveTo(Cache); } catch { Cache = "cache"; } } var cefMainArgs = new CefMainArgs(new string[0]); var cefApp = new App(); if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1) { Console.Error.WriteLine("Couldn't execute secondary process."); } var cefSettings = new CefSettings { CachePath = Cache, Locale = System.Globalization.CultureInfo.CurrentCulture.Name, UserDataPath = Userdata, SingleProcess = true, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Disable }; CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); initialized = true; } }
private void Load(string cachePath, string currentDir) { try { CefRuntime.Load(); } catch (DllNotFoundException ex) { ErrorAndExit(ex); } catch (CefRuntimeException ex) { ErrorAndExit(ex); } catch (Exception ex) { ErrorAndExit(ex); } var mainArgs = new CefMainArgs(new string[] { }); var cefApp = new AppDirectCefApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp); if (exitCode != -1) { ErrorAndExit(new Exception("CEF Failed to load")); } var cefSettings = new CefSettings { BrowserSubprocessPath = currentDir + Path.DirectorySeparatorChar + CefClientExe, SingleProcess = false, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Verbose, PersistSessionCookies = true, LogFile = "cef.log", CachePath = cachePath, IgnoreCertificateErrors = true }; try { CefRuntime.Initialize(mainArgs, cefSettings, cefApp); } catch (CefRuntimeException ex) { ErrorAndExit(ex); } }
public void Initialize() { if (_initialized) { throw new Exception("Only one runtime can be initialized."); } _initialized = true; CefRuntime.Load(); var mainArgs = new CefMainArgs(_commandLineArgs); var cefApp = new CefApp(); CefRuntime.Initialize(mainArgs, _cefSettings, cefApp, IntPtr.Zero); }