Exemple #1
0
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            base.OnBeforeCommandLineProcessing(processType, commandLine);

            Console.WriteLine("ChromiumWebBrowser_OnBeforeCommandLineProcessing");
            Console.WriteLine(commandLine.CommandLineString);

            //commandLine.AppendSwitchWithValue("proxy-server", "127.0.0.1:8888");


            commandLine.AppendSwitchWithValue("remote-debugging-port", "9222");

            //enable-devtools-experiments
            commandLine.AppendSwitch("enable-devtools-experiments");

            //e.CommandLine.AppendSwitchWithValue("user-agent", "Mozilla/5.0 (Windows 10.0) WebKa/" + DateTime.UtcNow.Ticks);

            //("force-device-scale-factor", "1");

            //commandLine.AppendSwitch("disable-gpu");
            //commandLine.AppendSwitch("disable-gpu-compositing");
            //commandLine.AppendSwitch("disable-gpu-vsync");

            commandLine.AppendSwitch("enable-begin-frame-scheduling");
            commandLine.AppendSwitch("enable-media-stream");

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                commandLine.AppendSwitch("no-zygote");
                commandLine.AppendSwitch("no-sandbox");
            }
        }
Exemple #2
0
        /// <summary>
        /// The on before command line processing.
        /// </summary>
        /// <param name="processType">
        /// The process type.
        /// </param>
        /// <param name="commandLine">
        /// The command line.
        /// </param>
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            if (_subprocessParams != null && _subprocessParams.CommandLineArgs != null && _subprocessParams.CommandLineArgs.Any())
            {
                foreach (var item in _subprocessParams.CommandLineArgs)
                {
                    if (item.Item3 && !string.IsNullOrWhiteSpace(item.Item1))
                    {
                        commandLine.AppendSwitch(item.Item1, item.Item2);
                    }
                    else if (!string.IsNullOrWhiteSpace(item.Item2))
                    {
                        commandLine.AppendSwitch(item.Item2);
                    }
                }
            }

            // Currently on linux platform location of locales and pack files are determined
            // incorrectly (relative to main module instead of libcef.so module).
            // Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved
            // this code can be removed.
            if (CefRuntime.Platform == CefRuntimePlatform.Linux)
            {
                var path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

                commandLine.AppendSwitch("resources-dir-path", path);
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
            }
        }
        /// <summary>
        /// The on before command line processing.
        /// </summary>
        /// <param name="processType">
        /// The process type.
        /// </param>
        /// <param name="commandLine">
        /// The command line.
        /// </param>
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            // Get all custom command line argument switches
            if (_hostConfig?.CommandLineArgs != null)
            {
                foreach (var commandArg in _hostConfig.CommandLineArgs)
                {
                    if (commandArg.Item3)
                    {
                        commandLine.AppendSwitch(commandArg.Item1 ?? string.Empty, commandArg.Item2);
                    }
                    else
                    {
                        commandLine.AppendSwitch(commandArg.Item2 ?? string.Empty);
                    }
                }
            }

            // Currently on linux platform location of locales and pack files are determined
            // incorrectly (relative to main module instead of libcef.so module).
            // Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved
            // this code can be removed.
            if (CefRuntime.Platform == CefRuntimePlatform.Linux)
            {
                var path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

                commandLine.AppendSwitch("resources-dir-path", path);
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
            }
        }
Exemple #4
0
 protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
 {
     if (string.IsNullOrEmpty(processType))
     {
         commandLine.AppendSwitch("disable-gpu");
         commandLine.AppendSwitch("disable-gpu-compositing");
         commandLine.AppendSwitch("enable-begin-frame-scheduling");
         commandLine.AppendSwitch("disable-smooth-scrolling");
     }
 }
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            if (CefRuntime.Platform == CefRuntimePlatform.Linux)
            {
                var path = new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath;
                path = Path.GetDirectoryName(path);

                commandLine.AppendSwitch("resources-dir-path", path);
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
            }
        }
Exemple #6
0
 protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
 {
     //禁止使用gpu 加速 在headless 模式下  gpu 有问题
     //参考 http://www.cnblogs.com/koangel/p/5396975.html
     //https://bitbucket.org/xilium/xilium.cefglue/commits/4146c2b46923593f55d28c7435f017631f86dca0
     //commandLine.AppendSwitch("renderer-process-limit", "1");//限制render process 的数目
     //commandLine.AppendSwitch("process-per-tab");
     commandLine.AppendSwitch("disable-gpu");
     commandLine.AppendSwitch("disable-gpu-compositing");
     commandLine.AppendSwitch("enable-begin-frame-scheduling");
     commandLine.AppendSwitch("disable-smooth-scrolling");
 }
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            if (commandLine.HasSwitch(CmdAssemblySearchPathSwitch))
            {
                var searchPath = commandLine.GetSwitchValue(CmdAssemblySearchPathSwitch);
                AppDomain.CurrentDomain.AssemblyResolve += (sender, resolveEventArgs) =>
                {
                    var assemblyName     = new AssemblyName(resolveEventArgs.Name);
                    var assemblyFileName = assemblyName.Name + ".dll";
                    var assemblyLocation = Path.Combine(searchPath, assemblyFileName);
                    if (File.Exists(assemblyLocation))
                    {
                        return(Assembly.LoadFrom(assemblyLocation));
                    }
                    return(null);
                };
            }
            if (string.IsNullOrEmpty(processType))
            {
                // Taken from: https://bitbucket.org/chromiumembedded/cef/commits/e3c1d8632eb43c1c2793d71639f3f5695696a5e8
                // If the PDF extension is enabled then cc Surfaces must be disabled for
                // PDFs to render correctly.
                // See https://bitbucket.org/chromiumembedded/cef/issues/1689 for details.
                if (!commandLine.HasSwitch("disable-extensions") && !commandLine.HasSwitch("disable-pdf-extension"))
                {
                    commandLine.AppendSwitch("disable-surfaces");
                }

                // Use software rendering and compositing (disable GPU) for increased FPS
                // and decreased CPU usage. This will also disable WebGL so remove these
                // switches if you need that capability.
                // See https://bitbucket.org/chromiumembedded/cef/issues/1257 for details.
                if (!commandLine.HasSwitch("enable-gpu"))
                {
                    commandLine.AppendSwitch("disable-gpu");
                    commandLine.AppendSwitch("disable-gpu-compositing");
                }

                // Synchronize the frame rate between all processes. This results in
                // decreased CPU usage by avoiding the generation of extra frames that
                // would otherwise be discarded. The frame rate can be set at browser
                // creation time via CefBrowserSettings.windowless_frame_rate or changed
                // dynamically using CefBrowserHost::SetWindowlessFrameRate. In cefclient
                // it can be set via the command-line using `--off-screen-frame-rate=XX`.
                // See https://bitbucket.org/chromiumembedded/cef/issues/1368 for details.
                commandLine.AppendSwitch("enable-begin-frame-scheduling");

                //commandLine.AppendSwitch("disable-smooth-scrolling");
                commandLine.AppendSwitch("enable-system-flash");
            }
            base.OnBeforeCommandLineProcessing(processType, commandLine);
        }
            protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
            {
                // TODO: currently on linux platform location of locales and pack files are determined
                // incorrectly (relative to main module instead of libcef.so module).
                // Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved this code can be removed.
                //if (CefRuntime.Platform != CefRuntimePlatform.Linux) return;
                var path = new Uri(Application.dataPath).LocalPath;

                //path = Path.GetDirectoryName(path);

                commandLine.AppendSwitch("resources-dir-path", path);
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
                MelonModLogger.Log($"OnBeforeCommandLineProcessing: {processType} {commandLine}");
            }
        /// <summary>
        /// The on before child process launch.
        /// </summary>
        /// <param name="browser_cmd">
        /// The command line.
        /// </param>
        protected override void OnBeforeChildProcessLaunch(CefCommandLine browser_cmd)
        {
            // Disable security features
            browser_cmd.AppendSwitch("default-encoding", "utf-8");
            browser_cmd.AppendSwitch("allow-file-access-from-files");
            browser_cmd.AppendSwitch("allow-universal-access-from-files");
            browser_cmd.AppendSwitch("disable-web-security");
            browser_cmd.AppendSwitch("ignore-certificate-errors");

            if (_config.DebuggingMode)
            {
                Console.WriteLine("On CefGlue child process launch arguments:");
                Console.WriteLine(browser_cmd.ToString());
            }
        }
Exemple #10
0
            protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
            {
                Console.WriteLine("OnBeforeCommandLineProcessing: {0} {1}", processType, commandLine);

                // TODO: currently on linux platform location of locales and pack files are determined
                // incorrectly (relative to main module instead of libcef.so module).
                // Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved this code can be removed.
                if (CefRuntime.Platform == CefRuntimePlatform.Linux)
                {
                    var path = new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath;
                    path = Path.GetDirectoryName(path);

                    commandLine.AppendSwitch("resources-dir-path", path);
                    commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
                }
            }
Exemple #11
0
        /// <summary>
        /// Called before child process launch.
        /// </summary>
        /// <param name="commandLine">The command line.</param>
        protected override void OnBeforeChildProcessLaunch(CefCommandLine commandLine)
        {
            if (commandLine == null)
            {
                throw new ArgumentNullException("commandLine");
            }

            // .NET in Windows treat assemblies as native images, so no any magic required.
            // Mono on any platform usually located far away from entry assembly, so we want prepare command line to call it correctly.
            if (Type.GetType("Mono.Runtime") != null)
            {
                if (!commandLine.HasSwitch("cefglue"))
                {
                    var path = PathUtility.Application;
                    commandLine.SetProgram(path);

                    var mono = CefRuntime.Platform == CefRuntimePlatform.Linux ? "/usr/bin/mono" : @"C:\Program Files\Mono-2.10.8\bin\monow.exe";
                    commandLine.PrependArgument(mono);

                    commandLine.AppendSwitch("cefglue", "w");
                }
            }

            if (!BaseMainApplication.Current.EnableD3D11 && !commandLine.GetArguments().Contains(Argument.DisableD3D11.Value))
            {
                commandLine.AppendArgument(Argument.DisableD3D11.Value);
            }
        }
Exemple #12
0
 protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
 {
     if (Main.EnableMediaStream)
     {
         commandLine.AppendSwitch("enable-media-stream");
     }
 }
Exemple #13
0
        /// <summary>
        /// Called before command line processing.
        /// </summary>
        /// <param name="processType">Type of the process.</param>
        /// <param name="commandLine">The command line.</param>
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            if (commandLine == null)
            {
                throw new ArgumentNullException("commandLine");
            }

            if (!commandLine.HasSwitch("resources-dir-path"))
            {
                commandLine.AppendSwitch("resources-dir-path", PathUtility.WorkingDirectory);
            }

            if (!commandLine.HasSwitch("locales-dir-path"))
            {
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(PathUtility.WorkingDirectory, "locales"));
            }
        }
Exemple #14
0
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            Console.WriteLine("OnBeforeCommandLineProcessing: {0} {1}", processType, commandLine);

            // TODO: currently on linux platform location of locales and pack files are determined
            // incorrectly (relative to main module instead of libcef.so module).
            // Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved
            // this code can be removed.
            if (CefRuntime.Platform == CefRuntimePlatform.Linux)
            {
                var path = new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath;
                path = Path.GetDirectoryName(path);

                commandLine.AppendSwitch("resources-dir-path", path);
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
            }
        }
        /// <summary>
        /// The on before command line processing.
        /// </summary>
        /// <param name="processType">
        /// The process type.
        /// </param>
        /// <param name="commandLine">
        /// The command line.
        /// </param>
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            if (string.IsNullOrEmpty(processType))
            {
                commandLine.AppendSwitch("no-zygote");
            }

            commandLine.AppendSwitch("--disable-web-security");
            commandLine.AppendSwitch("--user-data-dir");
            commandLine.AppendSwitch("--allow-file-access-to-files");

            // Get all custom command line argument switches
            if (this.mHostConfig?.CommandLineArgs != null)
            {
                foreach (var commandArg in this.mHostConfig.CommandLineArgs)
                {
                    commandLine.AppendSwitch(commandArg.Key, commandArg.Value);
                }
            }

            //commandLine.AppendSwitch("high-dpi-support", "1");
            //commandLine.AppendSwitch("force-device-scale-factor", "1");

            // Currently on linux platform location of locales and pack files are determined
            // incorrectly (relative to main module instead of libcef.so module).
            // Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved
            // this code can be removed.
            if (CefRuntime.Platform == CefRuntimePlatform.Linux)
            {
                var path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

                commandLine.AppendSwitch("resources-dir-path", path);
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
            }
        }
 protected override void OnBeforeChildProcessLaunch(CefCommandLine commandLine)
 {
     if (!commandLine.HasSwitch(CmdAssemblySearchPathSwitch))
     {
         var searchPath = Path.GetDirectoryName(typeof(IPluginEvaluate).Assembly.Location);
         commandLine.AppendSwitch(CmdAssemblySearchPathSwitch, searchPath);
     }
     base.OnBeforeChildProcessLaunch(commandLine);
 }
Exemple #17
0
 protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
 {
     commandLine.AppendSwitch("disable-gpu");
     commandLine.AppendSwitch("disable-gpu-compositing");
     commandLine.AppendSwitch("enable-begin-frame-scheduling");
     commandLine.AppendSwitch("off-screen-rendering-enabled");
     commandLine.AppendSwitch("disable-gpu-sandbox");
     commandLine.AppendSwitch("off-screen-frame-rate", "60");
     commandLine.AppendSwitch("use-angle", "gles");
     commandLine.AppendSwitch("use-gl", "swiftshader");
 }
Exemple #18
0
 //GPU and others
 protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
 {
     if (string.IsNullOrEmpty(processType))
     {
         // commandLine.AppendSwitch("enable-webrtc");
         if (!_enableGPU)
         {
             commandLine.AppendSwitch("disable-gpu");
             commandLine.AppendSwitch("disable-gpu-compositing");
         }
         commandLine.AppendSwitch("enable-begin-frame-scheduling");
         commandLine.AppendSwitch("disable-smooth-scrolling");
         if (_enableWebRtc)
         {
             commandLine.AppendSwitch("enable-media-stream", "true");
         }
     }
     //commandLine.AppendArgument("--enable-media-stream");
 }
Exemple #19
0
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            // Prevent a separate gpu-process renderer process from being started.
            commandLine.AppendSwitch("in-process-gpu");

            Logger.Info("{0} process started with commandline arguments : {1}",
                        string.IsNullOrEmpty(processType) ? "Browser" : processType, commandLine.ToString());

            base.OnBeforeCommandLineProcessing(processType, commandLine);
        }
Exemple #20
0
        /// <summary>
        /// The on before command line processing.
        /// </summary>
        /// <param name="processType">
        /// The process type.
        /// </param>
        /// <param name="commandLine">
        /// The command line.
        /// </param>
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            // Get all custom command line argument switches
            if (_config?.CommandLineArgs != null)
            {
                foreach (var commandArg in _config.CommandLineArgs)
                {
                    commandLine.AppendSwitch(commandArg.Key ?? string.Empty, commandArg.Value);
                }
            }

            if (_config?.CommandLineOptions != null)
            {
                foreach (var commmandOption in _config?.CommandLineOptions)
                {
                    commandLine.AppendSwitch(commmandOption ?? string.Empty);
                }
            }
        }
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            if (noProxyServer && !commandLine.HasSwitch("--no-proxy-server"))
            {
                commandLine.AppendSwitch("--no-proxy-server");
            }

            if (mediaStreamingEnabled && !commandLine.HasSwitch("--enable-media-stream"))
            {
                commandLine.AppendSwitch("--enable-media-stream");
            }

#if LINUX
            if (!commandLine.HasSwitch("--no-zygote"))
            {
                commandLine.AppendSwitch("--no-zygote");
            }
#endif
        }
Exemple #22
0
        protected override void OnBeforeChildProcessLaunch(CefCommandLine commandLine)
        {
            commandLine.AppendSwitch("default-encoding", "utf-8");
            commandLine.AppendArgument("--allow-file-access-from-files");
            commandLine.AppendArgument("--allow-universal-access-from-files");
            commandLine.AppendArgument("--disable-web-security");
            commandLine.AppendArgument("--ignore-certificate-errors");


            WinFormium.Runtime.ChromiumEnvironment.CommandLineConfigurations?.Invoke(commandLine);

            commandLine.AppendSwitch("--libcef-dir-path", WinFormium.Runtime.ChromiumEnvironment.LibCefDir);
            commandLine.AppendSwitch("--host-process-id", System.Diagnostics.Process.GetCurrentProcess().Id.ToString());

            if (WinFormium.Runtime.IsDebuggingMode)
            {
                logger.Debug("On CefGlue child process launch arguments:");
                logger.Verbose(commandLine.ToString());
            }
        }
 protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
 {
     // only happens if configuration is bad
     if (arguments != null)
     {
         foreach (String argument in arguments)
         {
             commandLine.AppendSwitch(argument);
         }
     }
 }
Exemple #24
0
        protected override void OnBeforeChildProcessLaunch(CefCommandLine commandLine)
        {
            Console.WriteLine("AppendExtraCommandLineSwitches: {0}", commandLine);
            Console.WriteLine(" Program == {0}", commandLine.GetProgram());

            // .NET in Windows treat assemblies as native images, so no any magic required.
            // Mono on any platform usually located far away from entry assembly, so we want prepare command line to call it correctly.
            if (Type.GetType("Mono.Runtime") != null)
            {
                if (!commandLine.HasSwitch("cefglue"))
                {
                    var path = new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath;
                    commandLine.SetProgram(path);

                    var mono = CefRuntime.Platform == CefRuntimePlatform.Linux ? "/usr/bin/mono" : @"C:\Program Files\Mono-2.10.8\bin\monow.exe";
                    commandLine.PrependArgument(mono);

                    //commandLine.AppendSwitch("disable-web-security", "1");

                    //commandLine.AppendSwitch("high-dpi-support", "1");
                    //commandLine.AppendSwitch("force-device-scale-factor", "1");

                    //commandLine.AppendSwitch("no-proxy-server", "1");
                    //commandLine.AppendSwitch("no-sandbox");

                    //commandLine.AppendSwitch("disable-gpu", "1");
                    //commandLine.AppendSwitch("disable-gpu-compositing", "1");
                    //commandLine.AppendSwitch("enable-begin-frame-scheduling", "1");
                    // commandLine.AppendSwitch("disable-smooth-scrolling", "1");

                    commandLine.AppendSwitch("--disable-web-security");
                    commandLine.AppendSwitch("--user-data-dir");
                    commandLine.AppendSwitch("--allow-file-access-to-files");
                    commandLine.AppendSwitch("--enable-media-stream");
                    commandLine.AppendSwitch("cefglue", "w");
                }
            }

            Console.WriteLine("  -> {0}", commandLine);
        }
Exemple #25
0
        /// <summary>
        /// Called before command line processing.
        /// </summary>
        /// <param name="processType">Type of the process.</param>
        /// <param name="commandLine">The command line.</param>
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            if (commandLine == null)
            {
                throw new ArgumentNullException("commandLine");
            }

            if (!commandLine.HasSwitch("resources-dir-path"))
            {
                commandLine.AppendSwitch("resources-dir-path", PathUtility.WorkingDirectory);
            }

            if (!commandLine.HasSwitch("locales-dir-path"))
            {
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(PathUtility.WorkingDirectory, "locales"));
            }

            if (!BaseMainApplication.Current.EnableD3D11 && !commandLine.GetArguments().Contains(Argument.DisableD3D11.Value))
            {
                commandLine.AppendArgument(Argument.DisableD3D11.Value);
            }
        }
Exemple #26
0
 protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
 {
     if (commandLine.HasSwitch(CmdAssemblySearchPathSwitch))
     {
         var searchPath = commandLine.GetSwitchValue(CmdAssemblySearchPathSwitch);
         AppDomain.CurrentDomain.AssemblyResolve += (sender, resolveEventArgs) =>
         {
             var assemblyName     = new AssemblyName(resolveEventArgs.Name);
             var assemblyFileName = assemblyName.Name + ".dll";
             var assemblyLocation = Path.Combine(searchPath, assemblyFileName);
             if (File.Exists(assemblyLocation))
             {
                 return(Assembly.LoadFrom(assemblyLocation));
             }
             return(null);
         };
     }
     if (string.IsNullOrEmpty(processType))
     {
         commandLine.AppendSwitch("disable-smooth-scrolling");
         commandLine.AppendSwitch("enable-system-flash");
     }
     base.OnBeforeCommandLineProcessing(processType, commandLine);
 }
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            System.Console.WriteLine("Entering OnBeforeCommandLineProcessing");

            // https://simpleit.rocks/linux/ubuntu/fixing-common-google-chrome-gpu-process-error-message-in-linux/
            commandLine.AppendSwitch("headless");
            commandLine.AppendSwitch("no-sandbox");
            commandLine.AppendSwitch("single-process");
            commandLine.AppendSwitch("disable-software-rasterizer");

            commandLine.AppendSwitch("disable-gpu");
            commandLine.AppendSwitch("disable-gpu-compositing");

            commandLine.AppendSwitch("disable-extensions");
            commandLine.AppendSwitch("disable-pinch");

            System.Console.WriteLine("Entering base.OnBeforeCommandLineProcessing");
            base.OnBeforeCommandLineProcessing(processType, commandLine);
            System.Console.WriteLine("Exiting  OnBeforeCommandLineProcessing");
        }
 protected override void OnBeforeCommandLineProcessing(
     string processType,
     CefCommandLine commandLine)
 {
     if (!string.IsNullOrEmpty(processType))
     {
         return;
     }
     commandLine.AppendSwitch("disable-gpu");
     commandLine.AppendSwitch("disable-gpu-compositing");
     commandLine.AppendSwitch("disable-smooth-scrolling");
     commandLine.AppendSwitch("--enable-system-flash");
     commandLine.AppendSwitch("ppapi-flash-path", Path.Combine(RegistryManager.Instance.CefDataPath, "pepflashplayer.dll"));
     commandLine.AppendSwitch("plugin-policy", "allow");
     commandLine.AppendSwitch("enable-media-stream", "1");
     if (!this.mDevToolEnable)
     {
         return;
     }
     commandLine.AppendSwitch("enable-begin-frame-scheduling");
 }
Exemple #29
0
        /// <summary>
        /// The on before command line processing.
        /// </summary>
        /// <param name="processType">
        /// The process type.
        /// </param>
        /// <param name="commandLine">
        /// The command line.
        /// </param>
        protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
        {
            // Get all custom command line argument switches
            if (_config?.CommandLineArgs != null)
            {
                foreach (var commandArg in _config.CommandLineArgs)
                {
                    commandLine.AppendSwitch(commandArg.Item1 ?? string.Empty, commandArg.Item2);
                }
            }

            if (_config?.CommandLineOptions != null)
            {
                foreach (var commmandOption in _config?.CommandLineOptions)
                {
                    commandLine.AppendSwitch(commmandOption ?? string.Empty);
                }
            }

            // Currently on linux platform location of locales and pack files are determined
            // incorrectly (relative to main module instead of libcef.so module).
            // Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved
            // this code can be removed.
            if (CefRuntime.Platform == CefRuntimePlatform.Linux)
            {
                if (string.IsNullOrEmpty(processType) || processType.Contains("zygote"))
                {
                    commandLine.AppendSwitch("no-zygote");
                }


                commandLine.AppendArgument("--disable-gpu");
                commandLine.AppendArgument("--disable-software-rasterizer");

                commandLine.AppendSwitch("disable-gpu", "1");
                commandLine.AppendSwitch("disable-software-rasterizer", "1");

                commandLine.AppendSwitch("resources-dir-path", _config.AppExeLocation);
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(_config.AppExeLocation, "locales"));
            }
        }
        protected override void OnBeforeChildProcessLaunch(CefCommandLine commandLine)
        {
            Console.WriteLine("AppendExtraCommandLineSwitches: {0}", commandLine);
            Console.WriteLine(" Program == {0}", commandLine.GetProgram());

            // .NET in Windows treat assemblies as native images, so no any magic required.
            // Mono on any platform usually located far away from entry assembly, so we want prepare command line to call it correctly.
            if (Type.GetType("Mono.Runtime") != null)
            {
                if (!commandLine.HasSwitch("cefglue"))
                {
                    var path = new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath;
                    commandLine.SetProgram(path);

                    var mono = CefRuntime.Platform == CefRuntimePlatform.Linux ? "/usr/bin/mono" : @"C:\Program Files\Mono-2.10.8\bin\monow.exe";
                    commandLine.PrependArgument(mono);

                    commandLine.AppendSwitch("cefglue", "w");
                }
            }

            Console.WriteLine("  -> {0}", commandLine);
        }
Exemple #31
0
        /// <summary>
        /// The on before child process launch.
        /// </summary>
        /// <param name="commandLine">
        /// The command line.
        /// </param>
        protected override void OnBeforeChildProcessLaunch(CefCommandLine commandLine)
        {
            // We need to know the process Id to establish WCF communication and for monitoring of parent process exit
            commandLine.AppendSwitch(SubprocessArguments.HostProcessIdArgument, Process.GetCurrentProcess().Id.ToString());
            commandLine.AppendSwitch(SubprocessArguments.ExitIfParentProcessClosed, "1");

            var schemeHandlerObjs = IoC.GetAllInstances(typeof(ChromelySchemeHandler));

            if (schemeHandlerObjs != null)
            {
                var schemeHandlers = schemeHandlerObjs.ToList();
                var argument       = string.Empty;
                foreach (var item in schemeHandlers)
                {
                    if (item is ChromelySchemeHandler handler)
                    {
                        bool isStandardScheme = UrlScheme.IsStandardScheme(handler.SchemeName);
                        if (!isStandardScheme)
                        {
                            argument += handler.SchemeName + SubprocessArguments.Separator;
                        }
                    }
                }

                argument = argument.TrimEnd(SubprocessArguments.Separator);
                commandLine.AppendSwitch(SubprocessArguments.CustomSchemeArgument, argument);
            }

            // Get all custom command line argument switches
            if (ChromelyConfiguration.Instance.CommandLineArgs != null)
            {
                var argument = string.Empty;
                foreach (var commandArg in ChromelyConfiguration.Instance.CommandLineArgs)
                {
                    if (commandArg.Item3)
                    {
                        argument += commandArg.Item1 + SubprocessArguments.ChildSeparator + commandArg.Item2 + SubprocessArguments.ChildSeparator + "T" + SubprocessArguments.Separator;
                    }
                    else
                    {
                        argument += string.Empty + SubprocessArguments.ChildSeparator + commandArg.Item2 + SubprocessArguments.ChildSeparator + "F" + SubprocessArguments.Separator;
                    }
                }

                // Disable security features
                argument += "default-encoding" + SubprocessArguments.ChildSeparator + "utf-8" + SubprocessArguments.ChildSeparator + "T" + SubprocessArguments.Separator;
                argument += string.Empty + SubprocessArguments.ChildSeparator + "allow-file-access-from-files" + SubprocessArguments.ChildSeparator + "F" + SubprocessArguments.Separator;
                argument += string.Empty + SubprocessArguments.ChildSeparator + "allow-universal-access-from-files" + SubprocessArguments.ChildSeparator + "F" + SubprocessArguments.Separator;
                argument += string.Empty + SubprocessArguments.ChildSeparator + "disable-web-security" + SubprocessArguments.ChildSeparator + "F" + SubprocessArguments.Separator;
                argument += string.Empty + SubprocessArguments.ChildSeparator + "ignore-certificate-errors" + SubprocessArguments.ChildSeparator + "F" + SubprocessArguments.Separator;

                argument = argument.TrimEnd(SubprocessArguments.Separator);
                commandLine.AppendSwitch(SubprocessArguments.CustomCmdlineArgument, argument);
            }

            // Disable security features
            commandLine.AppendSwitch("default-encoding", "utf-8");
            commandLine.AppendSwitch("allow-file-access-from-files");
            commandLine.AppendSwitch("allow-universal-access-from-files");
            commandLine.AppendSwitch("disable-web-security");
            commandLine.AppendSwitch("ignore-certificate-errors");

            if (ChromelyConfiguration.Instance.DebuggingMode)
            {
                Console.WriteLine("On CefGlue child process launch arguments:");
                Console.WriteLine(commandLine.ToString());
            }
        }