Beispiel #1
0
        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);
        }
Beispiel #2
0
        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;

            // guard if something wrong
            foreach (var arg in args) { if (arg.StartsWith("--type=")) { return -2; } }

            CefRuntime.Initialize(mainArgs, settings, app);

            // register custom scheme handler
            CefRuntime.RegisterSchemeHandlerFactory("http", DumpRequestDomain, new DemoAppSchemeHandlerFactory());
            // CefRuntime.AddCrossOriginWhitelistEntry("http://localhost", "http", "", true);

            PlatformInitialize();

            var mainMenu = CreateMainMenu();
            _mainView = CreateMainView(mainMenu);
            _mainView.NewTab(HomeUrl);

            PlatformRunMessageLoop();

            _mainView.Dispose();
            _mainView = null;

            CefRuntime.Shutdown();

            PlatformShutdown();
            return 0;
        }
Beispiel #3
0
        private int RunInternal(string[] args)
        {
            CefRuntime.Load();

            var settings = new CefSettings();
            settings.MultiThreadedMessageLoop = MultiThreadedMessageLoop = CefRuntime.Platform == CefRuntimePlatform.Windows;
            settings.SingleProcess = false;
            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;

            // guard if something wrong
            foreach (var arg in args) { if (arg.StartsWith("--type=")) { return -2; } }

            CefRuntime.Initialize(mainArgs, settings, app);

            RegisterSchemes();
            RegisterMessageRouter();

            PlatformInitialize();

            var mainMenu = CreateMainMenu();
            _mainView = CreateMainView(mainMenu);
            _mainView.NewTab(HomeUrl);

            PlatformRunMessageLoop();

            _mainView.Dispose();
            _mainView = null;

            CefRuntime.Shutdown();

            PlatformShutdown();
            return 0;
        }
        private int RunInternal(string[] args)
        {
            CefRuntime.Load();

            var settings = new CefSettings();

            //settings.WindowlessRenderingEnabled = true;

            settings.MultiThreadedMessageLoop = MultiThreadedMessageLoop = CefRuntime.Platform == CefRuntimePlatform.Windows;
            settings.SingleProcess            = false;
            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;
            settings.NoSandbox           = true;

            settings.BrowserSubprocessPath = "cefclient.exe";
            //settings.RemoteDebuggingPort = 8088;
            //The location where cache data will be stored on disk. If empty an in-memory cache will be used for some features and a temporary disk cache for others.
            //HTML5 databases such as localStorage will only persist across sessions if a cache path is specified.
            settings.CachePath = "cache";
            ////settings.UserAgent = "CefSharp Browser" + Cef.CefSharpVersion; // Example User Agent


            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, IntPtr.Zero);

            Console.WriteLine("CefRuntime.ExecuteProcess() returns {0}", exitCode);
            if (exitCode != -1)
            {
                return(exitCode);
            }

            // guard if something wrong
            foreach (var arg in args)
            {
                if (arg.StartsWith("--type="))
                {
                    return(-2);
                }
            }

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

            RegisterSchemes();
            RegisterMessageRouter();

            PlatformInitialize();

            var mainMenu = CreateMainMenu();

            _mainView = CreateMainView(mainMenu);
            _mainView.NewTab(HomeUrl);

            PlatformRunMessageLoop();

            _mainView.Dispose();
            _mainView = null;

            CefRuntime.Shutdown();

            PlatformShutdown();
            return(0);
        }
        private int RunInternal(string[] args)
        {
            CefRuntime.Load();

            var settings = new CefSettings();

            settings.MultiThreadedMessageLoop = MultiThreadedMessageLoop = CefRuntime.Platform == CefRuntimePlatform.Windows;
            settings.SingleProcess            = false;
            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;
            settings.NoSandbox           = true;

            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, IntPtr.Zero);

            Console.WriteLine("CefRuntime.ExecuteProcess() returns {0}", exitCode);
            if (exitCode != -1)
            {
                return(exitCode);
            }

            // guard if something wrong
            foreach (var arg in args)
            {
                if (arg.StartsWith("--type="))
                {
                    return(-2);
                }
            }

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

            RegisterSchemes();
            RegisterMessageRouter();

            PlatformInitialize();

            var mainMenu = CreateMainMenu();

            _mainView = CreateMainView(mainMenu);
            _mainView.NewTab(HomeUrl);

            PlatformRunMessageLoop();

            _mainView.Dispose();
            _mainView = null;

            CefRuntime.Shutdown();

            PlatformShutdown();
            return(0);
        }
Beispiel #6
0
        /// <summary>
        /// 主RUN函数
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public int Run(string[] args)
        {
            //1.加载运行时
            CefRuntime.Load();
            //2.设置
            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;
            //D:\01 project\3 FastQQ\xl\xilium-xilium.cefglue-820e4919a0f1\CefGlue.Client\bin\Debug\cache
            string cacahePath =
                @"D:\01 project\3 FastQQ\xl\xilium-xilium.cefglue-820e4919a0f1\CefGlue.Client\bin\Debug\cache";

            //  string cacahePath2 = Application.StartupPath+"\\cache";
            settings.CachePath = cacahePath;
            // settings.

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

            // guard if something wrong
            foreach (var arg in args)
            {
                if (arg.StartsWith("--type="))
                {
                    return(-2);
                }
            }

            CefRuntime.Initialize(mainArgs, settings, app);

            // register custom scheme handler
            CefRuntime.RegisterSchemeHandlerFactory("http", DumpRequestDomain, new DemoAppSchemeHandlerFactory());
            //  CefRuntime.RegisterSchemeHandlerFactory("http", Js2CsharpRequestDomain, new DemoAppSchemeHandlerFactory());
            //AddCrossOriginWhitelistEntry 似乎没有用
            //CefRuntime.AddCrossOriginWhitelistEntry(
            //   "http://trade.taobao.com", "http", "https://tbapi.alipay.com", true);
            //CefRuntime.AddCrossOriginWhitelistEntry(
            //   "http://trade.taobao.com", "https", "https://tbapi.alipay.com", true);
            //CefRuntime.AddCrossOriginWhitelistEntry(
            //  string.Format("{0}", "tbapi.alipay.com"), "https", "", true);
            //alipay.com
            PlatformInitialize();

            var mainMenu = CreateMainMenu();

            _mainView = CreateMainView(mainMenu);
            _mainView.NewTab(HomeUrl);

            PlatformRunMessageLoop();

            _mainView.Dispose();
            _mainView = null;

            CefRuntime.Shutdown();

            PlatformShutdown();
            return(0);
        }