예제 #1
0
        public static void Init(bool osr, bool multiThreadedMessageLoop)
        {
            var settings = new CefSettings();

            settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;

            if (osr)
            {
                settings.WindowlessRenderingEnabled = true;
            }
            settings.LogSeverity = LogSeverity.Verbose;
            settings.SetOffScreenRenderingBestPerformanceArgs();
            settings.BrowserSubprocessPath = AppDomain.CurrentDomain.BaseDirectory + "\\CefSharp.BrowserSubprocess.exe";
            //settings.EnableFocusedNodeChanged = true;
            settings.CachePath = "cache";
            settings.CefCommandLineArgs.Add("ppapi-flash-path",
                                            AppDomain.CurrentDomain.BaseDirectory + "\\Plugins\\pepflash\\pepflashplayer.dll");
            //Load a specific pepper flash version (Step 1 of 2)
            //settings.CefCommandLineArgs.Add("ppapi-flash-version", "18.0.0.209"); //Load a specific pepper flash version (Step 2 of 2)

            Cef.OnContextInitialized = delegate
            {
                _cookieManager = Cef.GetGlobalCookieManager();
                _cookieManager.SetStoragePath("cache", true);
            };
            if (!Cef.Initialize(settings, true, true))
            {
                throw new Exception("Unable to Initialize Cef");
            }
        }
예제 #2
0
        private void InitializeBrowser()
        {
            var settings = new CefSettings();

            settings.SetOffScreenRenderingBestPerformanceArgs();

            Cef.Initialize(settings);

            var startPage = String.Format(@"{0}\web\index.html", Application.StartupPath);

            _browser = new ChromiumWebBrowser("about:blank")
            {
                Dock            = DockStyle.Fill,
                BrowserSettings = new BrowserSettings()
                {
                    OffScreenTransparentBackground = false
                }
            };

            cefHost.Controls.Add(_browser);

            var bridge = new CustomerServiceBridge(_customerService, _browser);

            bridge.ItemSelected += BridgeOnItemSelected;

            _browser.Load(startPage);
        }
예제 #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            if (!Directory.Exists(Webexpresspath))
            {
                Directory.CreateDirectory(Webexpresspath);
                Directory.CreateDirectory(Userdatapath);
            }
            if (!Directory.Exists(Userdatapath))
            {
                Directory.CreateDirectory(Userdatapath);
            }
            if (!System.IO.Directory.Exists("Extensions"))
            {
                System.IO.Directory.CreateDirectory("Extensions");
            }
            var cefSettings = new CefSettings();
            cefSettings.CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WebExpress\\user data\\Cache");
            cefSettings.SetOffScreenRenderingBestPerformanceArgs();
            cefSettings.UserDataPath = Userdatapath;
            cefSettings.BrowserSubprocessPath = "WebExpress.exe";
            cefSettings.PersistSessionCookies = true;

            //Make sure all dependencies are present when the application runs, may wish to include a nicer error message
            Cef.Initialize(cefSettings, shutdownOnProcessExit:true, performDependencyCheck:true);
        }
예제 #4
0
    protected override void OnStartup(StartupEventArgs e)
    {
        var cefSettings = new CefSettings();

        cefSettings.SetOffScreenRenderingBestPerformanceArgs();
        Cef.Initialize(cefSettings);
    }
예제 #5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            if (!Directory.Exists(Webexpresspath))
            {
                Directory.CreateDirectory(Webexpresspath);
                Directory.CreateDirectory(Userdatapath);
            }
            if (!Directory.Exists(Userdatapath))
            {
                Directory.CreateDirectory(Userdatapath);
            }
            if (!System.IO.Directory.Exists("Extensions"))
            {
                System.IO.Directory.CreateDirectory("Extensions");
            }
            var cefSettings = new CefSettings();

            cefSettings.CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WebExpress\\user data\\Cache");
            cefSettings.SetOffScreenRenderingBestPerformanceArgs();
            cefSettings.UserDataPath          = Userdatapath;
            cefSettings.BrowserSubprocessPath = "WebExpress.exe";
            cefSettings.PersistSessionCookies = true;

            //Make sure all dependencies are present when the application runs, may wish to include a nicer error message
            Cef.Initialize(cefSettings, shutdownOnProcessExit: true, performDependencyCheck: true);
        }
예제 #6
0
        private void InitialzeBrowser()
        {
            //Load App.cofig and Filter.config
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();

            fileMap.ExeConfigFilename = Application.StartupPath + @"\Config\Filter.config";
            Filter        = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            DefaultEngine = Properties.Settings.Default.DefaultEngine;
            CefSettings setting = new CefSettings();

            setting.UserAgent = USER_AGENT;                     //改成手机端请求头,让网页响应页面
            //setting.CachePath = string.Empty; //incognito mode
            setting.SetOffScreenRenderingBestPerformanceArgs(); //设置屏幕渲染最佳性能参数,解决高DPI错位问题
            setting.Locale = "en-US";
            Cef.Initialize(setting);
            string word = DBHelper.GetTopTimesWord();

            Browser = new ChromiumWebBrowser(string.Format(DefaultEngine, word));
            Browser.FrameLoadStart += new EventHandler <FrameLoadStartEventArgs>(FramLoadStart_Event);
            this.Text = word;

            //Cef.EnableHighDPISupport(); //对高DPI的支持
            if (Properties.Settings.Default.FlowMouse)
            {
                this.FormBorderStyle = FormBorderStyle.FixedDialog;
                this.MaximizeBox     = false;
                //this.MinimizeBox = false;
            }
            this.panel1.Controls.Add(Browser);
        }
예제 #7
0
        public static void Initialize(string pluginDirectory, string appDataDirectory, bool reportErrors)
        {
            if (!initialized)
            {
                if (reportErrors)
                {
                    try
                    {
                        // Enable the Crashpad reporter. This *HAS* to happen before libcef.dll is loaded.
                        EnableErrorReports(appDataDirectory);
                    } catch (Exception e)
                    {
                        // TODO: Log this exception.
                    }
                }

                var lang    = System.Globalization.CultureInfo.CurrentCulture.Name;
                var langPak = Path.Combine(appDataDirectory, "OverlayPluginCef", Environment.Is64BitProcess ? "x64" : "x86",
                                           "locales", lang + ".pak");

                // Fall back to en-US if we can't find the current locale.
                if (!File.Exists(langPak))
                {
                    lang = "en-US";
                }

                var cefSettings = new CefSettings
                {
                    WindowlessRenderingEnabled = true,
                    Locale    = lang,
                    CachePath = Path.Combine(appDataDirectory, "OverlayPluginCache"),
                    MultiThreadedMessageLoop = true,
                    LogFile = Path.Combine(appDataDirectory, "OverlayPluginCEF.log"),
#if DEBUG
                    LogSeverity = LogSeverity.Info,
#else
                    LogSeverity = LogSeverity.Error,
#endif
                    BrowserSubprocessPath = Path.Combine(appDataDirectory,
                                                         "OverlayPluginCef",
                                                         Environment.Is64BitProcess ? "x64" : "x86",
                                                         "CefSharp.BrowserSubprocess.exe"),
                };

                // Necessary to avoid input lag with a framerate limit below 60.
                cefSettings.CefCommandLineArgs["enable-begin-frame-scheduling"] = "1";

                // Allow websites to play sound even if the user never interacted with that site (pretty common for our overlays)
                cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required";

                cefSettings.EnableAudio();

                // Enables software compositing instead of GPU compositing -> less CPU load but no WebGL
                cefSettings.SetOffScreenRenderingBestPerformanceArgs();

                Cef.Initialize(cefSettings, performDependencyCheck: true, browserProcessHandler: null);

                initialized = true;
            }
        }
예제 #8
0
        public App()
        {
#if !NETCOREAPP
            var settings = new CefSettings()
            {
                //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
                CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache")
            };
            settings.SetOffScreenRenderingBestPerformanceArgs();
            settings.MultiThreadedMessageLoop = true;

            //Example of setting a command line argument
            //Enables WebRTC
            settings.CefCommandLineArgs.Add("enable-media-stream", "1");

            settings.RegisterScheme(new CefCustomScheme
            {
                SchemeName           = "ecb",
                SchemeHandlerFactory = new ECBSchemeHandlerFactory()
            });

            //Perform dependency check to make sure all relevant resources are in our output directory.
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

            Cef.AddCrossOriginWhitelistEntry("ecb://web", "http", string.Empty, true);
            Cef.AddCrossOriginWhitelistEntry("ecb://web", "https", string.Empty, true);
#endif
        }
예제 #9
0
        public void Initialize()
        {
            CefSettings cefSettings = new CefSettings
            {
                LogSeverity = LogSeverity.Disable,
                //LogFile = "",

                /*
                 *  Custom flags used when initializing V8.
                 *  See https://github.com/v8/v8/blob/master/src/flag-definitions.h
                 */
                //JavascriptFlags = "",
                UserAgent = CrawlDescription.UserAgent
            };

            cefSettings.CefCommandLineArgs.Add("proxy-server", $"{CrawlDescription.IP}:{CrawlDescription.Port}");

            // Disable WebGL
            //cefSettings.DisableGpuAcceleration();

            // This will also diable WebGL and perform
            // some magic to optimize performance.
            cefSettings.SetOffScreenRenderingBestPerformanceArgs();

            if (!Cef.Initialize(cefSettings, performDependencyCheck: true, browserProcessHandler: null))
            {
                throw new Exception("Unable to Start CEF");
            }
        }
예제 #10
0
        public App()
        {
            var settings = new CefSettings();

            settings.SetOffScreenRenderingBestPerformanceArgs();
            Cef.Initialize(settings);
        }
예제 #11
0
        // construction
        public MainWindow()
        {
            InitializeComponent();
            WebCommunications.AuthKey = ConfigurationManager.AppSettings["WebCommunicationsAuthKey"];
            m_dPageStack       = new Dictionary <string, Page>();      // collection of pages with their associated query strings
            m_dPageStackLabels = new Dictionary <string, Border>();    // collection of the sidebar page labels with associated query strings

            // make rendering not suck
            CefSettings pSettings = new CefSettings();

            pSettings.SetOffScreenRenderingBestPerformanceArgs();
            Cef.Initialize(pSettings);

            Master.AssignMainWindow(this);

            //this.ShowPage("Genetic_Algorithm");

            /*this.ShowPage("Test");
             *
             * BitmapImage pOrigImage = new BitmapImage(new Uri(@"pack://application:,,,/Logo_256.png"));
             * m_pStartupImage = new Image();
             *
             * m_pStartupImage.Source = pOrigImage;
             * m_pStartupImage.Width = 256;
             * m_pStartupImage.Height = 256;
             *
             *
             * cnvsMain.Children.Add(m_pStartupImage);
             * Canvas.SetLeft(m_pStartupImage, (this.ActualWidth-250) / 2);
             * Canvas.SetTop(m_pStartupImage, cnvsMain.ActualHeight / 2);*/
        }
예제 #12
0
파일: TDC.cs 프로젝트: Timoms/TDC
        public TDC()
        {
            InitializeComponent();
            Size = new Size(Threema_Desktop_Client.Properties.Settings.Default.width, Threema_Desktop_Client.Properties.Settings.Default.height);
            CenterToScreen();

            CefSettings s = new CefSettings()
            {
                Locale = "de"
            };


            s.SetOffScreenRenderingBestPerformanceArgs();
            s.CachePath           = "cache";
            s.RemoteDebuggingPort = 8088;


            if (!Cef.IsInitialized)
            {
                Cef.Initialize(s);
            }



            browser = new ChromiumWebBrowser("https://web.threema.ch/")
            {
                Dock = DockStyle.Fill,
            };



            browser.RenderProcessMessageHandler = new RenderHandler();
            browser.RequestHandler  = new RequestHandle(this);
            browser.LifeSpanHandler = new LifeSpanHandler(this);


            browser.TitleChanged += OnBrowserTitleChanged;

            browser.FrameLoadEnd += (sender, args) =>
            {
                if (args.Url.StartsWith("https://web.threema.ch/"))
                {
                    if (args.Frame.IsMain)
                    {
                        if (!(Properties.Settings.Default.password.Length == 0) && Properties.Settings.Default.autologin != false)
                        {
                            args.Frame.ExecuteJavaScriptAsync((Properties.Resources.Threema.Replace("password_", Properties.Settings.Default.password)));
                        }
                    }
                }
            };
            splitContainer1.Panel1.Controls.Add(browser);
            splitContainer1.SplitterDistance = splitContainer1.Width;

            //Controls.Add(browser);
        }
예제 #13
0
 public App()
 {
     using (var settings = new CefSettings())
     {
         settings.SetOffScreenRenderingBestPerformanceArgs();
         settings.DisableGpuAcceleration();
         settings.Locale = CultureInfo.CurrentCulture.Name;
         Cef.Initialize(settings);
     }
 }
예제 #14
0
        private void DefaultCefSettings(CefSettings settings)
        {
            settings.WindowlessRenderingEnabled = true;
            settings.MultiThreadedMessageLoop   = true;
            settings.FocusedNodeChangedEnabled  = true;

            settings.CefCommandLineArgs.Add("disable-plugins-discovery", "1");

            settings.SetOffScreenRenderingBestPerformanceArgs();
        }
예제 #15
0
        private void InitializeChromium()
        {
            CefSettings settings = new CefSettings();

            settings.SetOffScreenRenderingBestPerformanceArgs();
            DoubleBuffered = true;

            // Note that if you get an error or a white screen, you may be doing something wrong !
            // Try to load a local file that you're sure that exists and give the complete path instead to test
            // for example, replace page with a direct path instead :
            // String page = @"C:\Users\SDkCarlos\Desktop\afolder\index.html";

            string page = string.Format($"{ Application.StartupPath}\\view\\index.html");

            //String page = @"C:\Users\SDkCarlos\Desktop\artyom-HOMEPAGE\index.html";

            if (!File.Exists(page))
            {
                MessageBox.Show(@"Error The html file doesn't exists : " + page);
            }

            // Initialize cef with the provided settings
            Cef.Initialize(settings);
            // Create a browser component
            _chromeBrowser = new ChromiumWebBrowser(page)
            {
                RequestContext = new RequestContext()
            };

            // Add it to the form and fill it to the form window.
            Panel.Controls.Add(_chromeBrowser);
            _chromeBrowser.Dock = DockStyle.Fill;

            // Allow the use of local resources in the browser
            BrowserSettings browserSettings = new BrowserSettings
            {
                FileAccessFromFileUrls      = CefState.Enabled,
                UniversalAccessFromFileUrls = CefState.Enabled
            };

            _chromeBrowser.BrowserSettings = browserSettings;
            _chromeBrowser.DownloadHandler = new DownloadHandler();

            //			var server_start = new CefCustomObject(_chromeBrowser, this);

            _chromeBrowser.RegisterAsyncJsObject("serverStart", new CefCustomObject(_chromeBrowser, this), BindingOptions.DefaultBinder);

            _chromeBrowser.IsBrowserInitializedChanged += (sender, args) =>
            {
                if (_chromeBrowser.IsBrowserInitialized)
                {
                    _chromeBrowser.ShowDevTools();
                }
            };
        }
예제 #16
0
파일: Program.cs 프로젝트: maihcx/IDesign
        static void Main(string[] args)
        {
            //Properties.Settings.Default.FUser = "";
            //Properties.Settings.Default.FUser = "";
            //Properties.Settings.Default.FIsFirsStart = false;
            //Properties.Settings.Default.Save();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
            Cef.EnableHighDPISupport();
            var settings = new CefSettings()
            {
                CachePath = Path
                            .Combine(Environment
                                     .GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MessengerFB\\Cache")
            };

            settings.CefCommandLineArgs.Add("debug-plugin-loading", "1");
            settings.CefCommandLineArgs.Add("allow-outdated-plugins", "1");
            settings.CefCommandLineArgs.Add("always-authorize-plugins", "1");
            settings.CefCommandLineArgs.Add("disable-web-security", "1");
            settings.CefCommandLineArgs.Add("enable-npapi", "1");
            settings.CefCommandLineArgs.Add("enable-media-stream", "1");
            settings.CefCommandLineArgs.Add("enable_spellchecking", "0");
            settings.WindowlessRenderingEnabled = true;
            //settings.EnableNetSecurityExpiration = true;
            settings.BackgroundColor = Cef.ColorSetARGB(255, 85, 85, 85);
            if (Properties.Settings.Default.FStopGPU)
            {
                settings.SetOffScreenRenderingBestPerformanceArgs();
                settings.DisableGpuAcceleration();
            }
            settings.Locale             = "vi";
            settings.AcceptLanguageList = "en_US";
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

            //Application.Run(new frmMain());

            if (Properties.Settings.Default.FIsFirsStart)
            {
                frm = new frmMain();
                SingleInstanceApplication.Run(frm, NewInstanceHandler);
            }
            else
            {
                frm = new frmLogin();
                SingleInstanceApplication.Run(frm, NewInstanceHandler);
            }

            //frm1 = new frmIconTray();
            //SingleInstanceApplication.Run(frm1, NewInstanceHandlerNone);
            //Application.Run(new frmIconTray());
        }
예제 #17
0
        protected override void OnStartup(StartupEventArgs e)
        {
#if DEBUG
            MessageBox.Show("WAITING IN DEBUG MODE");
#endif
            base.OnStartup(e);


            var settings = new CefSettings();
            settings.SetOffScreenRenderingBestPerformanceArgs();
            Cef.Initialize(settings);
        }
        public static void InitializeCef()
        {
            if (Cef.IsInitialized)
            {
                return;
            }
            var set = new CefSettings();

            set.SetOffScreenRenderingBestPerformanceArgs();
            set.BackgroundColor = Cef.ColorSetARGB(0, 255, 255, 255);
            Cef.Initialize(set, performDependencyCheck: true, browserProcessHandler: null);
        }
예제 #19
0
        private void FillYoutube(string url)
        {
            CefSettings s = new CefSettings();

            s.SetOffScreenRenderingBestPerformanceArgs();
            Cef.Initialize(s);
            ChromiumWebBrowser wbMain = new ChromiumWebBrowser();

            //wbMain.Address = "https://www.youtube.com/embed/videoseries?list=PLjkUDT6hWqyrotJAOd5JAdF_63LFku36i;autoplay=1";
            wbMain.Address = "https://www.youtube.com/embed/DnDFThL1qlI?autoplay=1;loop=1";
            grMain.Children.Add(wbMain);
        }
예제 #20
0
        static void Main()
        {
            try
            {
                // Directories
                //currentDir = System.Environment.CurrentDirectory;
                currentDir   = AppDomain.CurrentDomain.BaseDirectory;
                tempDir      = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                minerstatDir = tempDir + "/minerstat";

                // Assigning file paths to varialbles
                lib     = Program.currentDir + @"resources\libcef.dll";
                browser = Program.currentDir + @"resources\CefSharp.BrowserSubprocess.exe";
                locales = Program.currentDir + @"resources\locales\";
                //res = Program.currentDir + @"resources\";

                var  libraryLoader = new CefLibraryHandle(lib);
                bool isValid       = !libraryLoader.IsInvalid;
                libraryLoader.Dispose();

                var settings = new CefSettings();
                settings.BrowserSubprocessPath = browser;
                settings.LocalesDirPath        = locales;
                settings.ResourcesDirPath      = res;
                settings.SetOffScreenRenderingBestPerformanceArgs();
                settings.WindowlessRenderingEnabled = true;
                Cef.Initialize(settings);

                if (File.Exists(Program.currentDir + "/benchmark.txt"))
                {
                    File.Delete(Program.currentDir + "/benchmark.txt");
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new LauncherForm());
            }
            catch (Exception err)
            {
                Console.WriteLine("ERROR => " + err.ToString());
                try
                {
                    reStart();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ERROR => " + ex.ToString());
                }
            }
        }
예제 #21
0
        public void InitializeChromium()
        {
            CefSettings settings = new CefSettings();

            settings.CachePath = "";

            settings.SetOffScreenRenderingBestPerformanceArgs();
            //settings.CefCommandLineArgs.Add("disable-gpu", "1");
            //settings.CefCommandLineArgs.Add("disable-gpu-compositing", "1");
            //settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "1");
            //settings.CefCommandLineArgs.Add("disable-gpu-vsync", "1"); //Disable Vsync

            // Initialize cef with the provided settings
            Cef.Initialize(settings);
        }
예제 #22
0
        public static void InitializeCefSharp()
        {
            var location = Path.GetDirectoryName(typeof(BardWebClient).Assembly.Location);
            var settings = new CefSettings();

            settings.SetOffScreenRenderingBestPerformanceArgs();

            // Set BrowserSubProcessPath based on app bitness at runtime
            settings.BrowserSubprocessPath = Path.Combine(location,
                                                          Environment.Is64BitProcess ? "x64" : "x86",
                                                          "CefSharp.BrowserSubprocess.exe");

            // Make sure you set performDependencyCheck false
            Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
        }
예제 #23
0
        public static void CefSettings()
        {
            #region CEF settings
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/StreamerPlusApp/";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            if (!Directory.Exists(path + "userData/"))
            {
                Directory.CreateDirectory(path + "userData/");
            }

            using (CefSettings settings = new CefSettings
            {
                LogSeverity = LogSeverity.Disable,
                WindowlessRenderingEnabled = true,
                BrowserSubprocessPath = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Environment.Is64BitProcess ? "x64" : "x86", "CefSharp.BrowserSubprocess.exe"),
                BackgroundColor = Util.ColorToUInt(System.Drawing.Color.FromArgb(255, 56, 56, 56)),
                CachePath = path,
                UserDataPath = path + "userData/",
                Locale = "he",
                RemoteDebuggingPort = 6968,
                PersistSessionCookies = true,
                UserAgent = BrowserFlow.UA,
            })
            {
                settings.CefCommandLineArgs.Add("--js-flags", "--max_old_space_size=500");
                settings.CefCommandLineArgs.Add("--multi-threaded-message-loop", "1");
                settings.CefCommandLineArgs.Remove("process-per-tab");
                settings.CefCommandLineArgs.Add("enable-media-stream", "0");
                settings.CefCommandLineArgs.Add("disable-gpu-vsync", "1");
                settings.CefCommandLineArgs.Add("mute-audio", "true");
                settings.CefCommandLineArgs.Add("disable-3d-apis", "1");
                settings.CefCommandLineArgs.Add("renderer-process-limit", "10");
                settings.SetOffScreenRenderingBestPerformanceArgs();
                CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
                CefSharpSettings.ShutdownOnExit = true;
                Rectangle resolution = Screen.PrimaryScreen.Bounds;
                if (resolution.Width >= 1440 || resolution.Height >= 1440)
                {
                    Cef.EnableHighDPISupport();
                }
                Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
            }
            #endregion
        }
예제 #24
0
        public static void Initialise(string cefAssemblyPath, string cefCacheDir)
        {
            var settings = new CefSettings()
            {
                BrowserSubprocessPath = Path.Combine(cefAssemblyPath, "CefSharp.BrowserSubprocess.exe"),
                CachePath             = cefCacheDir,
#if !DEBUG
                LogSeverity = LogSeverity.Fatal,
#endif
            };

            settings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required";
            settings.EnableAudio();
            settings.SetOffScreenRenderingBestPerformanceArgs();

            Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
        }
예제 #25
0
        private static void InitializeCefSharp()
        {
            //var settings = new CefSettings();
            var setting = new CefSettings()
            {
                CachePath = Directory.GetCurrentDirectory() + @"\Cache",
            };

            //setting.RemoteDebuggingPort = 8088;
            setting.Locale = "zh-CN";
            //setting.UserAgent = "Mozilla/6.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2228.0 Safari/537.36";

            //代理设置
            setting.CefCommandLineArgs.Add("enable-npapi", "1");
            setting.CefCommandLineArgs.Add("--proxy-server", $"http://127.0.0.1:{TitaniumWebProxy.localProxyProt}");
            //setting.CefCommandLineArgs.Add("--no-proxy-server", "1");

            //硬件加速设置
            setting.CefCommandLineArgs.Add("--enable-media-stream", "1");
            //setting.CefCommandLineArgs.Add("disable-gpu", "0");
            setting.SetOffScreenRenderingBestPerformanceArgs();
            //setting.CefCommandLineArgs.Add("disable-gpu", "1");
            //setting.CefCommandLineArgs.Add("disable-gpu-compositing", "1");
            //setting.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "1");
            setting.CefCommandLineArgs.Add("enable-media-stream", "1");

            //Flash设置
            setting.CefCommandLineArgs["enable-system-flash"] = "0";
            //setting.CefCommandLineArgs.Add("enable-system-flash", "0"); //Automatically discovered and load a system-wide installation of Pepper Flash.
            setting.CefCommandLineArgs.Add("ppapi-flash-path", @".\plugins\pepflashplayer64_23_0_0_162.dll"); //Load a specific pepper flash version (Step 1 of 2)
            setting.CefCommandLineArgs.Add("ppapi-flash-version", "23.0.0.162");                              //Load a specific pepper flash version (Step 2 of 2)



            // Set BrowserSubProcessPath based on app bitness at runtime
            setting.BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                                                         Environment.Is64BitProcess ? "x64" : "x86",
                                                         "CefSharp.BrowserSubprocess.exe");

            if (!Cef.Initialize(setting, performDependencyCheck: false, browserProcessHandler: null))
            {
                throw new Exception("Unable to Initialize Cef");
            }

            CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
        }
예제 #26
0
        public LibraryView(LibraryViewModel viewModel)
        {
            this.DataContext = viewModel;

            if (!Cef.IsInitialized)
            {
                var settings = new CefSettings {
                    RemoteDebuggingPort = 8088
                };
                //to fix Fickering set disable-gpu to true
                settings.SetOffScreenRenderingBestPerformanceArgs();
                Cef.Initialize(settings, true, false);
            }

            InitializeComponent();

            this.Browser.MenuHandler = new LibraryViewContextMenuHandler();
        }
예제 #27
0
        internal void Init()
        {
            AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);

            var cefSettings = new CefSettings
            {
                CachePath                  = Path.Combine(Program.BaseDirectory, "cache"),
                UserDataPath               = Path.Combine(Program.BaseDirectory, "userdata"),
                IgnoreCertificateErrors    = true,
                LogSeverity                = LogSeverity.Disable,
                WindowlessRenderingEnabled = true,
                PersistSessionCookies      = true,
                PersistUserPreferences     = true
            };

            /*cefSettings.RegisterScheme(new CefCustomScheme
             * {
             *  SchemeName = "vrcx",
             *  DomainName = "app",
             *  SchemeHandlerFactory = new FolderSchemeHandlerFactory(Application.StartupPath + "/../../../html")
             * });*/

            cefSettings.CefCommandLineArgs.Add("disable-threaded-scrolling");
            cefSettings.CefCommandLineArgs.Add("ignore-certificate-errors");
            cefSettings.CefCommandLineArgs.Add("disable-plugins");
            cefSettings.CefCommandLineArgs.Add("disable-spell-checking");
            cefSettings.CefCommandLineArgs.Add("disable-pdf-extension");
            cefSettings.CefCommandLineArgs.Add("disable-extensions");
            cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required";
            // cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
            // cefSettings.CefCommandLineArgs.Add("disable-web-security");
            cefSettings.SetOffScreenRenderingBestPerformanceArgs();

            CefSharpSettings.WcfEnabled     = true; // TOOD: REMOVE THIS LINE YO
            CefSharpSettings.ShutdownOnExit = false;

            // Enable High-DPI support on Windows 7 or newer
            Cef.EnableHighDPISupport();

            if (Cef.Initialize(cefSettings) == false)
            {
                throw new Exception("Cef.Initialize()");
            }
        }
예제 #28
0
        public DetailsView(DetailsViewModel viewModel, Grid parent)
        {
            this.DataContext = viewModel;
            this.parentGrid  = parent;

            if (!Cef.IsInitialized)
            {
                var settings = new CefSettings {
                    RemoteDebuggingPort = 8088
                };
                //to fix Fickering set disable-gpu to true
                settings.SetOffScreenRenderingBestPerformanceArgs();
                Cef.Initialize(settings);
            }

            InitializeComponent();

            this.IsVisibleChanged += OnVisibilityChange;
        }
예제 #29
0
        private void InitializeChromium()
        {
            string      exeLocation = AppDomain.CurrentDomain.BaseDirectory;
            CefSettings cfsettings  = new CefSettings
            {
                //UserAgent = "Mozilla/5..0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko",
                UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
                CachePath = exeLocation + CACHE_PATH,
            };

            cfsettings.SetOffScreenRenderingBestPerformanceArgs();

            cfsettings.CefCommandLineArgs.Add("disable-web-security", "true");


            if (!Cef.IsInitialized)
            {
                Cef.Initialize(cfsettings);
            }
        }
        /// <summary>
        /// The Initialize.
        /// </summary>
        public static void Initialize()
        {
            if (!Cef.IsInitialized)
            {
                System.AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);
                const bool multiThreadedMessageLoop = true;
                var        browserProcessHandler    = new BrowserProcessHandler();
                var        settings = new CefSettings
                {
                    //UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0",
                    MultiThreadedMessageLoop = multiThreadedMessageLoop,
                    ExternalMessagePump      = !multiThreadedMessageLoop
                };

                settings.PersistSessionCookies = true;
                settings.SetOffScreenRenderingBestPerformanceArgs();
                settings.CefCommandLineArgs.Remove("disable-gpu-compositing");
                CefConfig.Init(settings, browserProcessHandler: browserProcessHandler);
            }
        }
예제 #31
0
        public MainWindow()
        {
            if (!Cef.IsInitialized)
            {
                var settings = new CefSettings();
                settings.LogSeverity = LogSeverity.Verbose;
                settings.CachePath   = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Octant\\CefSharp\\Cache");
                settings.SetOffScreenRenderingBestPerformanceArgs();
                Cef.Initialize(settings);
            }

            this.DataContext = this;

            InitializeComponent();



            WebBrowser.MenuHandler = new WebBrowserMenuHandler();

            this.SourceInitialized += new EventHandler(win_SourceInitialized);
        }