Пример #1
0
        private ChromiumFxSession(Action <CfxSettings> settingsBuilder, Action <CfxBrowserSettings> browserSettingsUpdater, Action <CfxOnBeforeCommandLineProcessingEventArgs> commandLineHandler, IWebSessionLogger webSessionLogger)
        {
            _CurrentDirectory        = this.GetType().Assembly.GetPath();
            _SettingsBuilder         = settingsBuilder;
            _CommandLineHandler      = commandLineHandler;
            CfxRuntime.LibCefDirPath = GetPath($@"{CefRepo}\Release");

            ChromiumWebBrowser.OnBeforeCfxInitialize         += ChromiumWebBrowser_OnBeforeCfxInitialize;
            ChromiumWebBrowser.OnBeforeCommandLineProcessing += ChromiumWebBrowser_OnBeforeCommandLineProcessing;

            int value = CfxRuntime.ExecuteProcess();

            if (value >= 0)
            {
                Environment.Exit(value);
            }
            CfxRuntime.EnableHighDpiSupport();
            ChromiumWebBrowser.Initialize();

            browserSettingsUpdater?.Invoke(NeutroniumSettings.NeutroniumBrowserSettings);

            _NeutroniumSchemeHandlerFactory = new NeutroniumSchemeHandlerFactory(webSessionLogger);
            //need this to make request interception work
            CfxRuntime.RegisterSchemeHandlerFactory("https", "application", _NeutroniumSchemeHandlerFactory);
        }
Пример #2
0
 public static void RegisterCustomScheme(string schemeName, string doamin, CfxSchemeHandlerFactory factory)
 {
     if (string.IsNullOrEmpty(schemeName))
     {
         throw new ArgumentNullException("schemeName", "必须为scheme指定名称。");
     }
     var result = CfxRuntime.RegisterSchemeHandlerFactory(schemeName, doamin, factory);
 }
        public static void RegisterScheme(string schemeName, string domain, CfxSchemeHandlerFactory factory)
        {
            var gchandle = GCHandle.Alloc(factory);

            SchemeHandlerGCHandles.Add(gchandle);

            if (string.IsNullOrEmpty(schemeName))
            {
                throw new ArgumentNullException("schemeName", "must set up the schema name.");
            }

            CfxRuntime.RegisterSchemeHandlerFactory(schemeName, domain, factory);
        }
        private ChromiumFxSession(Action <CfxSettings> settingsBuilder, Action <CfxOnBeforeCommandLineProcessingEventArgs> commadLineHandler, IWebSessionLogger webSessionLogger)
        {
            _CurrentDirectory        = this.GetType().Assembly.GetPath();
            _SettingsBuilder         = settingsBuilder;
            _CommandLineHandler      = commadLineHandler;
            CfxRuntime.LibCefDirPath = GetPath(@"cef\Release");

            ChromiumWebBrowser.OnBeforeCfxInitialize         += ChromiumWebBrowser_OnBeforeCfxInitialize;
            ChromiumWebBrowser.OnBeforeCommandLineProcessing += ChromiumWebBrowser_OnBeforeCommandLineProcessing;
            ChromiumWebBrowser.Initialize();

            //need this to make request interception work
            CfxRuntime.RegisterSchemeHandlerFactory("pack", null, new PackUriSchemeHandlerFactory(webSessionLogger));
        }
Пример #5
0
        public void MainThread(object coreInst)
        {
            core           = (Core)coreInst;
            additionalPath = Path.Combine(core.RootPath, "./Resources/ArkDesktop.Cfx/");
            if (CheckLibs() == false)
            {
                return;
            }
            int exitCode = CfxRuntime.ExecuteProcess(null);

            using (var settings = new CfxSettings())
            {
                settings.MultiThreadedMessageLoop   = true;
                settings.WindowlessRenderingEnabled = true;
                settings.NoSandbox             = true;
                settings.ResourcesDirPath      = Path.Combine(additionalPath, "cef", "Resources");
                settings.LocalesDirPath        = Path.Combine(additionalPath, "cef", "Resources", "locales");
                settings.BrowserSubprocessPath = Path.Combine(additionalPath, "ArkDesktopCfxSubProcess.exe");
                settings.LogFile = "C:/Users/z1223/Desktop/log.txt";

                var app = new CfxApp();
                app.OnBeforeCommandLineProcessing += (s, e) =>
                {
                    // optimizations following recommendations from issue #84
                    e.CommandLine.AppendSwitch("disable-gpu");
                    e.CommandLine.AppendSwitch("disable-gpu-compositing");
                    e.CommandLine.AppendSwitch("disable-gpu-vsync");
                };
                app.OnRegisterCustomSchemes += App_OnRegisterCustomSchemes;
                if (!CfxRuntime.Initialize(settings, app))
                {
                    return;
                }
                CfxRuntime.RegisterSchemeHandlerFactory("akd", "test", new ResourceManager.SchemeHandlerFactory(Path.Combine(core.RootPath, "Resources\\")));
            }
            CreateThreads();
            manager = new ArkDesktopBrowserControl(window);
            while (!disposed)
            {
                CfxRuntime.DoMessageLoopWork();
            }
        }