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();
        }
예제 #2
0
        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();
        }