private static int Main(string[] args)
        {
            try
            {
                CefRuntime.Load();
            }
            catch (DllNotFoundException ex)
            {
                MessageBox.Show(ex.Message);
                return 1;
            }
            catch (CefRuntimeException ex)
            {
                MessageBox.Show(ex.Message);
                return 2;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return 3;
            }

            var mainArgs = new CefMainArgs(args);
            var app1 = new DemoApp();

            var exitCode = CefRuntime.ExecuteProcess(mainArgs, app1);
            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",
            };

            CefRuntime.Initialize(mainArgs, settings, app1);

            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);

            if (!settings.MultiThreadedMessageLoop)
            {
                //WApplication.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); };
            }

            var app = new App();
            app.InitializeComponent();
            app.Run();

            CefRuntime.Shutdown();
            return 0;
        }
        public static ICefCoreSession GetAndInitIfNeeded(IDispatcher iIUIDispatcher = null, CefSettings iCefSettings = null, params string[] args)
        {
            if (Session==null)
            {
                if (SessionFactory==null)
                    SessionFactory = new CefCoreSessionFactory(iIUIDispatcher??new NullUIDispatcher(),iCefSettings, args);

                Session = SessionFactory.GetSession();
            }

            return Session;
        }
        public static ICefCoreSession GetAndInitIfNeeded(CefSettings iCefSettings = null, params string[] args)
        {
            if (Session==null)
            {
                if (SessionFactory==null)
                    SessionFactory = new CefCoreSessionFactory(iCefSettings, args);

                Session = SessionFactory.GetSession();
            }

            return Session;
        }
Example #4
0
        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 TrackboxApp();

            var exitCode = CefRuntime.ExecuteProcess(mainArgs, app);
            if (exitCode != -1)
                return exitCode;

            var settings = new CefSettings
            {
                SingleProcess = false,
                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 CefCoreSessionFactory(CefSettings iCefSettings = null, string[] args = null)
        {
            _Args = args ?? new string[]{};

            _CefSettings = iCefSettings ?? new CefSettings
            {
                SingleProcess = true,
                WindowlessRenderingEnabled = true,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Disable,
                RemoteDebuggingPort = 8080
            };
        }
        public CefCoreSession(CefSettings iCefSettings, NeutroniumCefApp iCefApp, string[] iArgs)
        {
            _CefApp = iCefApp;
            _Args = iArgs;
            _CefSettings = iCefSettings;
            var mainArgs = new CefMainArgs(_Args);

            CefRuntime.Load();

            var exitCode = CefRuntime.ExecuteProcess(mainArgs, _CefApp, IntPtr.Zero);
            if (exitCode != -1)
                throw ExceptionHelper.Get(string.Format("Unable to execute cef process: {0}", exitCode));

            CefRuntime.Initialize(mainArgs, _CefSettings, _CefApp, IntPtr.Zero);
        }
        public static int QuickInit(string[] args)
        {
            try
            {
                CefRuntime.Load();
            }
            catch (DllNotFoundException ex)
            {
                throw new ApplicationException("ex.Message");
                return 1;
            }
            catch (CefRuntimeException ex)
            {
                throw new ApplicationException("ex.Message");
                return 2;
            }
            catch (Exception ex)
            {
                throw new ApplicationException("ex.Message");
                return 3;
            }

            var mainArgs = new CefMainArgs(args);
            var app = new MyCefApp();

            IntPtr windowsSandboxHandle = IntPtr.Zero;

            var exitCode = CefRuntime.ExecuteProcess(mainArgs, app, windowsSandboxHandle);
            if (exitCode != -1)
                return exitCode;

            var settings = new CefSettings
            {
                SingleProcess = false,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Disable,
                LogFile = "CefGlue.log",
                Locale = CultureInfo.CurrentCulture.Name,
                 
            };


            settings.RemoteDebuggingPort = 2035;

            CefRuntime.Initialize(mainArgs, settings, app, windowsSandboxHandle);

            return 0;
        }
        public CefCoreSessionFactory(IDispatcher iIUIDispatcher, CefSettings iCefSettings = null, string[] args = null)
        {
            _IUIDispatcher = iIUIDispatcher;
            _Args = args ?? new string[]{};

            _CefSettings = iCefSettings ?? new CefSettings
            {
                // BrowserSubprocessPath = browserSubprocessPath,
                SingleProcess = true,
                WindowlessRenderingEnabled = true,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Disable,
                //LogFile = "cef.log",
                RemoteDebuggingPort = 8080
            };
        }
        public MainWindow()
        {
            CefRuntime.Load();

            var settings = new CefSettings();
            settings.MultiThreadedMessageLoop = true;
            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);

            CefRuntime.Initialize(new CefMainArgs(new string[0]), settings, null);

            InitializeComponent();

            webView.NavigateTo(ConfigurationManager.ConnectionStrings["HomeUrl"].ConnectionString);
        }
Example #10
0
        static CefGlueWebViewHandler()
        {
            xc.CefRuntime.Load();

            var mainArgs = new xc.CefMainArgs(null);
            var cefApp   = new MyCefApp();

            //var exitCode = xc.CefRuntime.ExecuteProcess(mainArgs, cefApp);
            //if (exitCode != -1) { return exitCode; }

            var cefSettings = new xc.CefSettings
            {
                SingleProcess            = true,
                MultiThreadedMessageLoop = true,
                LogSeverity = xc.CefLogSeverity.Disable,
            };

            xc.CefRuntime.Initialize(mainArgs, cefSettings, cefApp);
        }
Example #11
0
        private void Form_Load(object sender, EventArgs e)
        {
            CefRuntime.Load();

            var settings = new CefSettings();
            settings.MultiThreadedMessageLoop = true;
            settings.ReleaseDCheckEnabled = true;
            settings.LogSeverity = CefLogSeverity.Warning;
            settings.LogFile = "cef.log";
            settings.ResourcesDirPath = System.IO.Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase).LocalPath);

            CefRuntime.Initialize(new CefMainArgs(new string[0]), settings, null);

            webView = new CefWebBrowser {
                StartUrl = ConfigurationManager.ConnectionStrings["HomeUrl"].ConnectionString                
            };
            webView.Dock = DockStyle.Fill;
            this.Controls.Add(webView);
        }
        /// <summary>
        /// This function should be called on the main application thread to initialize
        /// the CEF browser process. The |application| parameter may be empty. A return
        /// value of true indicates that it succeeded and false indicates that it failed.
        /// The |windows_sandbox_info| parameter is only used on Windows and may be NULL
        /// (see cef_sandbox_win.h for details).
        /// </summary>
        public static void Initialize(CefMainArgs args, CefSettings settings, CefApp application, IntPtr windowsSandboxInfo)
        {
            LoadIfNeed();

            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (_initialized)
            {
                throw ExceptionBuilder.CefRuntimeAlreadyInitialized();
            }

            var n_main_args = args != null?args.ToNative() : null;

            var n_settings = settings.ToNative();
            var n_app      = application != null?application.ToNative() : null;

            try
            {
                if (libcef.initialize(n_main_args, n_settings, n_app, (void *)windowsSandboxInfo) != 0)
                {
                    _initialized = true;
                }
                else
                {
                    throw ExceptionBuilder.CefRuntimeFailedToInitialize();
                }
            }
            finally
            {
                CefMainArgs.Free(n_main_args);
                CefSettings.Free(n_settings);
            }
        }
Example #13
0
        static int Main(string[] args)
        {
            // Do we need to initialise CEF?
            if (ApplicationSettings.Default.UseCefWebBrowser)
            {
                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 settings = new CefSettings();
                settings.MultiThreadedMessageLoop = true;
                settings.SingleProcess = false;
                settings.LogSeverity = CefLogSeverity.Disable;
                settings.LogFile = "cef.log";
                settings.ResourcesDirPath = System.IO.Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase).LocalPath);
                settings.RemoteDebuggingPort = 20480;

                CefRuntime.Initialize(new CefMainArgs(args), settings, null, IntPtr.Zero);
            }

            // Ensure our process has the highest priority
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;

            Application.SetCompatibleTextRenderingDefault(false);

            Trace.Listeners.Add(new XiboTraceListener());

            try
            {
                // Check for any passed arguments
                if (args.Length > 0)
                {
                    if (args[0].ToString() == "o")
                    {
                        RunSettings();
                    }
                    else
                    {
                        switch (args[0].ToLower().Trim().Substring(0, 2))
                        {
                            // Preview the screen saver
                            case "/p":
                                // args[1] is the handle to the preview window
                                KeyInterceptor.SetHook();
                                MouseInterceptor.SetHook();
                                RunClient(new IntPtr(long.Parse(args[1])));
                                KeyInterceptor.UnsetHook();
                                MouseInterceptor.UnsetHook();
                                break;

                            // Show the screen saver
                            case "/s":
                                KeyInterceptor.SetHook();
                                MouseInterceptor.SetHook();
                                RunClient(true);
                                KeyInterceptor.UnsetHook();
                                MouseInterceptor.UnsetHook();
                                break;

                            // Configure the screesaver's settings
                            case "/c":
                                // Show the settings form
                                RunSettings();
                                break;

                            // Show the screen saver
                            default:
                                KeyInterceptor.SetHook();
                                MouseInterceptor.SetHook();
                                RunClient(true);
                                KeyInterceptor.UnsetHook();
                                MouseInterceptor.UnsetHook();
                                break;
                        }
                    }
                }
                else
                {
                    // Add a message filter
                    Application.AddMessageFilter(KeyStore.Instance);

                    // No arguments were passed - we run the usual client
                    RunClient();
                }
            }
            catch (Exception ex)
            {
                HandleUnhandledException(ex);
            }

            // Catch unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

            // Always flush at the end
            Trace.WriteLine(new LogMessage("Main", "Application Finished"), LogType.Info.ToString());
            Trace.Flush();

            if (ApplicationSettings.Default.UseCefWebBrowser)
                CefRuntime.Shutdown();

            return 0;
        }       
Example #14
0
        private static void InitializeCefRuntime()
        {
            if( !IsSupportedByThisPlatform() )
                return;

            if( isCefRuntimeInitialized )
                throw new InvalidOperationException( "The CefRuntime is already initialized. Call ShutdownCefRuntime() before initializing it again." );

            if( PlatformInfo.Platform == PlatformInfo.Platforms.Windows )
                NativeLibraryManager.PreLoadLibrary( Path.Combine( "CefGlue", "libcef" ) );

            //delete log file
            string realLogFileName = VirtualFileSystem.GetRealPathByVirtual( "user:Logs\\WebBrowserControl_CefGlue.log" );
            try
            {
                if( File.Exists( realLogFileName ) )
                    File.Delete( realLogFileName );
            }
            catch { }

            try
            {
                CefRuntime.Load();
            }
            catch( DllNotFoundException ex )
            {
                Log.Error( "WebBrowserControl: InitializeCefRuntime: CefRuntime.Load(): " + ex.Message );
                return;
            }
            catch( CefRuntimeException ex )
            {
                Log.Error( "WebBrowserControl: InitializeCefRuntime: CefRuntime.Load(): " + ex.Message );
                return;
            }
            catch( Exception ex )
            {
                Log.Error( "WebBrowserControl: InitializeCefRuntime: CefRuntime.Load(): " + ex.Message );
                return;
            }

            var mainArgs = new CefMainArgs( null );
            var cefApp = new SimpleApp();

            var exitCode = CefRuntime.ExecuteProcess( mainArgs, cefApp, IntPtr.Zero );
            if( exitCode != -1 )
            {
                Log.Error( "WebBrowserControl: InitializeCefRuntime: CefRuntime.ExecuteProcess: Exit code: {0}", exitCode );
                return;
            }

            var cefSettings = new CefSettings
            {
                SingleProcess = true,
                WindowlessRenderingEnabled = true,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Verbose,
                LogFile = realLogFileName,
                BrowserSubprocessPath = "",
                CachePath = "",
            };

            //!!!!
            ///// <summary>
            ///// Set to <c>true</c> to disable configuration of browser process features using
            ///// standard CEF and Chromium command-line arguments. Configuration can still
            ///// be specified using CEF data structures or via the
            ///// CefApp::OnBeforeCommandLineProcessing() method.
            ///// </summary>
            //public bool CommandLineArgsDisabled { get; set; }

            //!!!!!mac
            ///// <summary>
            ///// The fully qualified path for the resources directory. If this value is
            ///// empty the cef.pak and/or devtools_resources.pak files must be located in
            ///// the module directory on Windows/Linux or the app bundle Resources directory
            ///// on Mac OS X. Also configurable using the "resources-dir-path" command-line
            ///// switch.
            ///// </summary>
            //public string ResourcesDirPath { get; set; }

            try
            {
                CefRuntime.Initialize( mainArgs, cefSettings, cefApp, IntPtr.Zero );
            }
            catch( CefRuntimeException ex )
            {
                Log.Error( "WebBrowserControl: InitializeCefRuntime: CefRuntime.Initialize: " + ex.Message );
                return;
            }

            isCefRuntimeInitialized = true;
        }
Example #15
0
        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 CefGlueWPFWebWindowFactory( CefSettings iCefSettings = null)
 {
     _ICefCoreSession = CefCoreSessionSingleton.GetAndInitIfNeeded(iCefSettings);
 }
        public void Start()
        {
            ManualResetEventSlim contextInitializedEvent =
                new ManualResetEventSlim();

            dispatcher.PostTask(new Action(() =>
            {
                CefRuntime.Load();
                CefMainArgs cefMainArgs = new CefMainArgs(IntPtr.Zero, new String[0]);
                BrowserRuntimeSettings settings = BrowserSettings.Instance.RuntimeSettings;

                isMultiThreadedMessageLoop = settings.MultiThreadedMessageLoop;
                isSingleProcess = BrowserSettings.Instance.RuntimeSettings.SingleProcess;

                string browserSubprocessPath = Path.Combine(AssemblyDirectory,
                    "CLRBrowserSourcePlugin", "CLRBrowserSourceClient.exe");

                CefSettings cefSettings = new CefSettings
                {
                    BrowserSubprocessPath = browserSubprocessPath,
                    CachePath = settings.CachePath,
                    CommandLineArgsDisabled = settings.CommandLineArgsDisabled,
                    IgnoreCertificateErrors = settings.IgnoreCertificateErrors,
                    JavaScriptFlags = settings.JavaScriptFlags,
                    Locale = settings.Locale,
                    LocalesDirPath = settings.LocalesDirPath,
                    LogFile = settings.LogFile,
                    LogSeverity = settings.LogSeverity,
                    MultiThreadedMessageLoop = settings.MultiThreadedMessageLoop,
                    NoSandbox = true,
                    PersistSessionCookies = settings.PersistSessionCookies,
                    ProductVersion = settings.ProductVersion,
                    RemoteDebuggingPort = settings.RemoteDebuggingPort,
                    ResourcesDirPath = settings.ResourcesDirPath,
                    SingleProcess = false,
                    UncaughtExceptionStackSize = settings.UncaughtExceptionStackSize,
                    WindowlessRenderingEnabled = true
                };

                string[] commandLineArgs = settings.CommandLineArgsDisabled ?
                    new String[0] : settings.CommandLineArguments;

                BrowserApp browserApp = new BrowserApp(
                    commandLineArgs, contextInitializedEvent);

                try
                {
                    CefRuntime.Initialize(cefMainArgs, cefSettings, browserApp, IntPtr.Zero);
                }
                catch (InvalidOperationException e)
                {
                    API.Instance.Log("Failed to initialize cef runtime");
                    contextInitializedEvent.Set();
                }

                CefRuntime.RegisterSchemeHandlerFactory("local", null, new AssetSchemeHandlerFactory());
                CefRuntime.RegisterSchemeHandlerFactory("http", "absolute", new AssetSchemeHandlerFactory());

                if (!settings.MultiThreadedMessageLoop)
                {
                    CefRuntime.RunMessageLoop();
                }
            }));

            contextInitializedEvent.Wait();
        }
Example #18
0
        private static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            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;
            }

            //hmm not working
            //Should maybe move to callback in render process vs can modify from browser process this way
            //Array.Resize(ref args, args.Length + 1);
            //args[args.Length - 1] = @"--log-file ""..\logs\LVCef.RenderApp.log""";
            //for (int i = 0; i < args.Length; i++)
            //    Debug.WriteLine("Render args[" + i +"]: " + args[i]);

            var mainArgs = new CefMainArgs(args);
            var exitCode = CefRuntime.ExecuteProcess(mainArgs, null, IntPtr.Zero);
            if (exitCode != -1)
                return exitCode;

            var settings = new CefSettings
            {
                //Relative path from \cef, make sure to set Working Directory to \cef, see README.md
                BrowserSubprocessPath = @"..\dotnet\LVCef.RenderApp\bin\Debug\LVCef.RenderApp.exe",
                SingleProcess = false,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Default,
                LogFile = @"..\logs\TestControlAppSimple.log",
            };

            CefRuntime.Initialize(mainArgs, settings, null, IntPtr.Zero);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!settings.MultiThreadedMessageLoop)
            {
                Application.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); };
            }

            Application.Run(new TestControlAppSimpleForm());

            CefRuntime.Shutdown();
            return 0;
        }
Example #19
0
        /// <summary>
        /// This function should be called on the main application thread to initialize
        /// the CEF browser process. The |application| parameter may be empty. A return
        /// value of true indicates that it succeeded and false indicates that it failed.
        /// </summary>
        public static void Initialize(CefMainArgs args, CefSettings settings, CefApp application)
        {
            LoadIfNeed();

            if (args == null) throw new ArgumentNullException("args");
            if (settings == null) throw new ArgumentNullException("settings");

            if (_initialized) throw ExceptionBuilder.CefRuntimeAlreadyInitialized();

            var n_main_args = args.ToNative();
            var n_settings = settings.ToNative();
            var n_app = application != null ? application.ToNative() : null;

            try
            {
                if (libcef.initialize(n_main_args, n_settings, n_app) != 0)
                {
                    _initialized = true;
                }
                else
                {
                    throw ExceptionBuilder.CefRuntimeFailedToInitialize();
                }
            }
            finally
            {
                CefMainArgs.Free(n_main_args);
                CefSettings.Free(n_settings);
            }
        }
        public int Initialize(bool isSubProcess, params string[] args)
        {
            var path = AppDomain.CurrentDomain.BaseDirectory;
            var binPath = isSubProcess ? path : Path.Combine(path, "bin");

            loggingService.Debug("[Initialize] cefPath: {0}", binPath);

            CefRuntime.Load(binPath);

            loggingService.Debug("[Initialize] Cef binaries found");

            var mainArgs = new CefMainArgs(args);

            var exitCode = CefRuntime.ExecuteProcess(mainArgs, this, IntPtr.Zero);
            loggingService.Debug("[Initialize] exitCode: " + exitCode);

            if (exitCode != -1 || isSubProcess)
            {
                // Sub-process will return here
                return exitCode;
            }
            
            var settings = new CefSettings
            {
                SingleProcess = false,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Verbose,
                WindowlessRenderingEnabled = true,
                IgnoreCertificateErrors = true,
                PersistSessionCookies = false,
                BrowserSubprocessPath = Path.Combine(binPath, "Axh.PageTracker.SubProcess.exe"),
                LocalesDirPath = Path.Combine(binPath, "locales"),
                Locale = "en-GB",
                LogFile = "C:\\Temp\\Cef.log"
            };

            CefRuntime.Initialize(mainArgs, settings, this, IntPtr.Zero);
            this.isInitialized = true;

            loggingService.Debug("[Initialize] Success");
            return 0;
        }
        public void Start()
        {
            ManualResetEventSlim disposedEvent = new ManualResetEventSlim();

            dispatcher.Invoke(new Action(() =>
            {
                CefRuntime.Load();
                CefMainArgs cefMainArgs = new CefMainArgs(IntPtr.Zero, new String[0]);
                BrowserRuntimeSettings settings = BrowserSettings.Instance.RuntimeSettings;

                isMultiThreadedMessageLoop = settings.MultiThreadedMessageLoop;

                CefSettings cefSettings = new CefSettings
                {
                    BrowserSubprocessPath = @"plugins\CLRHostPlugin\CLRBrowserSourcePlugin\CLRBrowserSourcePipe.exe",
                    CachePath = settings.CachePath,
                    CommandLineArgsDisabled = settings.CommandLineArgsDisabled,
                    IgnoreCertificateErrors = settings.IgnoreCertificateErrors,
                    JavaScriptFlags = settings.JavaScriptFlags,
                    Locale = settings.Locale,
                    LocalesDirPath = settings.LocalesDirPath,
                    LogFile = settings.LogFile,
                    LogSeverity = settings.LogSeverity,
                    MultiThreadedMessageLoop = settings.MultiThreadedMessageLoop,
                    PersistSessionCookies = settings.PersistSessionCookies,
                    ProductVersion = settings.ProductVersion,
                    ReleaseDCheckEnabled = settings.ReleaseDCheckEnabled,
                    RemoteDebuggingPort = settings.RemoteDebuggingPort,
                    ResourcesDirPath = settings.ResourcesDirPath,
                    SingleProcess = settings.SingleProcess,
                    UncaughtExceptionStackSize = settings.UncaughtExceptionStackSize
                };

                BrowserApp browserApp = new BrowserApp(settings.CommandLineArgsDisabled ? new String[0] : settings.CommandLineArguments);

                CefRuntime.ExecuteProcess(cefMainArgs, browserApp);
                CefRuntime.Initialize(cefMainArgs, cefSettings, browserApp);

                CefRuntime.RegisterSchemeHandlerFactory("local", null, new AssetSchemeHandlerFactory());
                CefRuntime.RegisterSchemeHandlerFactory("http", "absolute", new AssetSchemeHandlerFactory());
            }));

            PluginManager.Initialize();
        }
Example #22
0
 public static void Initialize(CefMainArgs args, CefSettings settings, CefApp application)
 {
     Initialize(args, settings, application, IntPtr.Zero);
 }
Example #23
0
 public static void Initialize(CefMainArgs args, CefSettings settings, CefApp application)
 {
     Initialize(args, settings, application, IntPtr.Zero);
 }
Example #24
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("Could not the secondary process.");
                }

                var cefSettings = new CefSettings
                {
                    SingleProcess = true,
                    MultiThreadedMessageLoop = true,
                    LogSeverity = CefLogSeverity.Disable
                };

                CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero);

                initialized = true;
            }
        }