public static void Init(bool osr) { // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys // Environment.SetEnvironmentVariable("GOOGLE_API_KEY", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_SECRET", ""); //Chromium Command Line args //http://peter.sh/experiments/chromium-command-line-switches/ //NOTE: Not all relevant in relation to `CefSharp`, use for reference purposes only. var settings = new CefSettings(); 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 //settings.CefCommandLineArgs.Add("renderer-process-limit", "1"); //settings.CefCommandLineArgs.Add("renderer-startup-dialog", "1"); //settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC //settings.CefCommandLineArgs.Add("no-proxy-server", "1"); //Don't use a proxy server, always make direct connections. Overrides any other proxy server flags that are passed. //settings.CefCommandLineArgs.Add("debug-plugin-loading", "1"); //Dumps extra logging about plugin loading to the log file. //settings.CefCommandLineArgs.Add("disable-plugins-discovery", "1"); //Disable discovering third-party plugins. Effectively loading only ones shipped with the browser plus third-party ones as specified by --extra-plugin-dir and --load-plugin switches //settings.CefCommandLineArgs.Add("enable-system-flash", "1"); //Automatically discovered and load a system-wide installation of Pepper Flash. //settings.CefCommandLineArgs.Add("ppapi-flash-path", @"C:\WINDOWS\SysWOW64\Macromed\Flash\pepflashplayer32_18_0_0_209.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) //NOTE: For OSR best performance you should run with GPU disabled: // `--disable-gpu --disable-gpu-compositing --enable-begin-frame-scheduling` // (you'll loose WebGL support but gain increased FPS and reduced CPU usage). // http://magpcss.org/ceforum/viewtopic.php?f=6&t=13271#p27075 //https://bitbucket.org/chromiumembedded/cef/commits/e3c1d8632eb43c1c2793d71639f3f5695696a5e8 //NOTE: The following function will set all three params //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 //Disables the DirectWrite font rendering system on windows. //Possibly useful when experiencing blury fonts. //settings.CefCommandLineArgs.Add("disable-direct-write", "1"); // Off Screen rendering (WPF/Offscreen) if(osr) { settings.WindowlessRenderingEnabled = true; // Disable Surfaces so internal PDF viewer works for OSR // https://bitbucket.org/chromiumembedded/cef/issues/1689 //settings.CefCommandLineArgs.Add("disable-surfaces", "1"); settings.EnableInternalPdfViewerOffScreen(); settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "1"); } var proxy = ProxyConfig.GetProxyInformation(); switch (proxy.AccessType) { case InternetOpenType.Direct: { //Don't use a proxy server, always make direct connections. settings.CefCommandLineArgs.Add("no-proxy-server", "1"); break; } case InternetOpenType.Proxy: { settings.CefCommandLineArgs.Add("proxy-server", proxy.ProxyAddress); break; } case InternetOpenType.PreConfig: { settings.CefCommandLineArgs.Add("proxy-auto-detect", "1"); break; } } settings.LogSeverity = LogSeverity.Verbose; if (DebuggingSubProcess) { var architecture = Environment.Is64BitProcess ? "x64" : "x86"; settings.BrowserSubprocessPath = "..\\..\\..\\..\\CefSharp.BrowserSubprocess\\bin\\" + architecture + "\\Debug\\CefSharp.BrowserSubprocess.exe"; } settings.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeName, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() }); settings.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeNameTest, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() }); settings.RegisterExtension(new CefExtension("cefsharp/example", Resources.extension)); Cef.OnContextInitialized = delegate { var cookieManager = Cef.GetGlobalCookieManager(); cookieManager.SetStoragePath("cookies", true); cookieManager.SetSupportedSchemes("custom"); }; if (!Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: !DebuggingSubProcess)) { throw new Exception("Unable to Initialize Cef"); } }
public App() { //Perform dependency check to make sure all relevant resources are in our output directory. var settings = new CefSettings(); settings.EnableInternalPdfViewerOffScreen(); Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: true); }
public static void Main() { // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys // This will enable microphone and webcam to work. See https://console.cloud.google.com/iam-admin/serviceaccounts/project?project=flash-crawler-138718 Environment.SetEnvironmentVariable("GOOGLE_API_KEY", google_api_key); Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", google_default_client_id); Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_SECRET", google_default_client_secret); var settings = new CefSettings(); settings.EnableInternalPdfViewerOffScreen(); settings.WindowlessRenderingEnabled = true; var osVersion = Environment.OSVersion; settings.CachePath = "cache"; // ENABLE Microphone, video, flash //settings.CefCommandLineArgs.Add("enable-system-flash", "1"); settings.CefCommandLineArgs.Add("enable-media-stream", "1"); settings.CefCommandLineArgs.Add("enable-speech-input", "1"); // settings.CefCommandLineArgs.Add("ppapi-flash-path", "1"); //settings.CefCommandLineArgs.Add("enable-npapi", "1"); //settings.CefCommandLineArgs.Add("disable-bundled-ppapi-flash", "1"); //Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(settings, shutdownOnProcessExit: false, performDependencyCheck: true); var browser = new BrowserForm(); Application.Run(browser); }
public App() { var settings = new CefSettings(); settings.EnableInternalPdfViewerOffScreen(); settings.CefCommandLineArgs.Add("disable-gpu", "1"); Cef.Initialize(settings, shutdownOnProcessExit: false, performDependencyCheck: false); }
public App() { //Perform dependency check to make sure all relevant resources are in our output directory. var settings = new CefSettings(); settings.EnableInternalPdfViewerOffScreen(); var osVersion = Environment.OSVersion; //Disable GPU for Windows 7 if (osVersion.Version.Major == 6 && osVersion.Version.Minor == 1) { // Disable GPU in WPF and Offscreen examples until #1634 has been resolved settings.CefCommandLineArgs.Add("disable-gpu", "1"); } Cef.Initialize(settings, shutdownOnProcessExit: false, performDependencyCheck: true); }
private void LoadSettings() { string path = Assembly.GetExecutingAssembly().Location; string targetDirectory = Path.GetDirectoryName(path); string exePath = Path.Combine(targetDirectory, "CefSharp.BrowserSubprocess.exe"); CefSettings settings = new CefSettings(); settings.EnableInternalPdfViewerOffScreen(); settings.BrowserSubprocessPath = exePath; OperatingSystem osVersion = Environment.OSVersion; // Disable GPU for Windows 7, in case someone is still using Windows 7 if (osVersion.Version.Major == 6 && osVersion.Version.Minor == 1) { // Disable GPU in WPF and Offscreen examples until #1634 has been resolved settings.CefCommandLineArgs.Add("disable-gpu", "1"); } Cef.Initialize(settings, shutdownOnProcessExit: false, performDependencyCheck: true); }
public static void Init(bool osr, bool multiThreadedMessageLoop) { // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys // Environment.SetEnvironmentVariable("GOOGLE_API_KEY", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_SECRET", ""); //Chromium Command Line args //http://peter.sh/experiments/chromium-command-line-switches/ //NOTE: Not all relevant in relation to `CefSharp`, use for reference purposes only. var settings = new CefSettings(); 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 //settings.CefCommandLineArgs.Add("renderer-process-limit", "1"); //settings.CefCommandLineArgs.Add("renderer-startup-dialog", "1"); //settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC //settings.CefCommandLineArgs.Add("no-proxy-server", "1"); //Don't use a proxy server, always make direct connections. Overrides any other proxy server flags that are passed. //settings.CefCommandLineArgs.Add("debug-plugin-loading", "1"); //Dumps extra logging about plugin loading to the log file. //settings.CefCommandLineArgs.Add("disable-plugins-discovery", "1"); //Disable discovering third-party plugins. Effectively loading only ones shipped with the browser plus third-party ones as specified by --extra-plugin-dir and --load-plugin switches //settings.CefCommandLineArgs.Add("enable-system-flash", "1"); //Automatically discovered and load a system-wide installation of Pepper Flash. //settings.CefCommandLineArgs.Add("allow-running-insecure-content", "1"); //By default, an https page cannot run JavaScript, CSS or plugins from http URLs. This provides an override to get the old insecure behavior. Only available in 47 and above. //settings.CefCommandLineArgs.Add("enable-logging", "1"); //Enable Logging for the Renderer process (will open with a cmd prompt and output debug messages - use in conjunction with setting LogSeverity = LogSeverity.Verbose;) //settings.LogSeverity = LogSeverity.Verbose; // Needed for enable-logging to output messages //settings.CefCommandLineArgs.Add("disable-extensions", "1"); //Extension support can be disabled //settings.CefCommandLineArgs.Add("disable-pdf-extension", "1"); //The PDF extension specifically can be disabled //Load the pepper flash player that comes with Google Chrome - may be possible to load these values from the registry and query the dll for it's version info (Step 2 not strictly required it seems) //settings.CefCommandLineArgs.Add("ppapi-flash-path", @"C:\Program Files (x86)\Google\Chrome\Application\47.0.2526.106\PepperFlash\pepflashplayer.dll"); //Load a specific pepper flash version (Step 1 of 2) //settings.CefCommandLineArgs.Add("ppapi-flash-version", "20.0.0.228"); //Load a specific pepper flash version (Step 2 of 2) //NOTE: For OSR best performance you should run with GPU disabled: // `--disable-gpu --disable-gpu-compositing --enable-begin-frame-scheduling` // (you'll loose WebGL support but gain increased FPS and reduced CPU usage). // http://magpcss.org/ceforum/viewtopic.php?f=6&t=13271#p27075 //https://bitbucket.org/chromiumembedded/cef/commits/e3c1d8632eb43c1c2793d71639f3f5695696a5e8 //NOTE: The following function will set all three params //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 //Disables the DirectWrite font rendering system on windows. //Possibly useful when experiencing blury fonts. //settings.CefCommandLineArgs.Add("disable-direct-write", "1"); settings.MultiThreadedMessageLoop = multiThreadedMessageLoop; // Off Screen rendering (WPF/Offscreen) if (osr) { settings.WindowlessRenderingEnabled = true; // Disable Surfaces so internal PDF viewer works for OSR // https://bitbucket.org/chromiumembedded/cef/issues/1689 //settings.CefCommandLineArgs.Add("disable-surfaces", "1"); settings.EnableInternalPdfViewerOffScreen(); // DevTools doesn't seem to be working when this is enabled // http://magpcss.org/ceforum/viewtopic.php?f=6&t=14095 //settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "1"); } var proxy = ProxyConfig.GetProxyInformation(); switch (proxy.AccessType) { case InternetOpenType.Direct: { //Don't use a proxy server, always make direct connections. settings.CefCommandLineArgs.Add("no-proxy-server", "1"); break; } case InternetOpenType.Proxy: { settings.CefCommandLineArgs.Add("proxy-server", proxy.ProxyAddress); break; } case InternetOpenType.PreConfig: { settings.CefCommandLineArgs.Add("proxy-auto-detect", "1"); break; } } //settings.LogSeverity = LogSeverity.Verbose; if (DebuggingSubProcess) { var architecture = Environment.Is64BitProcess ? "x64" : "x86"; settings.BrowserSubprocessPath = "..\\..\\..\\..\\CefSharp.BrowserSubprocess\\bin\\" + architecture + "\\Debug\\CefSharp.BrowserSubprocess.exe"; } settings.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeName, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() //SchemeHandlerFactory = new InMemorySchemeAndResourceHandlerFactory() }); settings.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeNameTest, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() }); settings.RegisterExtension(new CefExtension("cefsharp/example", Resources.extension)); settings.FocusedNodeChangedEnabled = true; //The Request Context has been initialized, you can now set preferences, like proxy server settings Cef.OnContextInitialized = delegate { var cookieManager = Cef.GetGlobalCookieManager(); cookieManager.SetStoragePath("cookies", true); cookieManager.SetSupportedSchemes("custom"); //Dispose of context when finished - preferable not to keep a reference if possible. using (var context = Cef.GetGlobalRequestContext()) { string errorMessage; //You can set most preferences using a `.` notation rather than having to create a complex set of dictionaries. //The default is true, you can change to false to disable context.SetPreference("webkit.webprefs.plugins_enabled", true, out errorMessage); } }; if (!Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: !DebuggingSubProcess)) { throw new Exception("Unable to Initialize Cef"); } }
public static void Init(bool osr, bool multiThreadedMessageLoop) { // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys // Environment.SetEnvironmentVariable("GOOGLE_API_KEY", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_SECRET", ""); //Chromium Command Line args //http://peter.sh/experiments/chromium-command-line-switches/ //NOTE: Not all relevant in relation to `CefSharp`, use for reference purposes only. var settings = new CefSettings(); 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 //settings.CefCommandLineArgs.Add("renderer-process-limit", "1"); //settings.CefCommandLineArgs.Add("renderer-startup-dialog", "1"); //settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC //settings.CefCommandLineArgs.Add("no-proxy-server", "1"); //Don't use a proxy server, always make direct connections. Overrides any other proxy server flags that are passed. //settings.CefCommandLineArgs.Add("debug-plugin-loading", "1"); //Dumps extra logging about plugin loading to the log file. //settings.CefCommandLineArgs.Add("disable-plugins-discovery", "1"); //Disable discovering third-party plugins. Effectively loading only ones shipped with the browser plus third-party ones as specified by --extra-plugin-dir and --load-plugin switches //settings.CefCommandLineArgs.Add("enable-system-flash", "1"); //Automatically discovered and load a system-wide installation of Pepper Flash. //settings.CefCommandLineArgs.Add("ppapi-flash-path", @"C:\WINDOWS\SysWOW64\Macromed\Flash\pepflashplayer32_18_0_0_209.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) //NOTE: For OSR best performance you should run with GPU disabled: // `--disable-gpu --disable-gpu-compositing --enable-begin-frame-scheduling` // (you'll loose WebGL support but gain increased FPS and reduced CPU usage). // http://magpcss.org/ceforum/viewtopic.php?f=6&t=13271#p27075 //https://bitbucket.org/chromiumembedded/cef/commits/e3c1d8632eb43c1c2793d71639f3f5695696a5e8 //NOTE: The following function will set all three params //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 //Disables the DirectWrite font rendering system on windows. //Possibly useful when experiencing blury fonts. //settings.CefCommandLineArgs.Add("disable-direct-write", "1"); settings.MultiThreadedMessageLoop = multiThreadedMessageLoop; // Off Screen rendering (WPF/Offscreen) if (osr) { settings.WindowlessRenderingEnabled = true; // Disable Surfaces so internal PDF viewer works for OSR // https://bitbucket.org/chromiumembedded/cef/issues/1689 //settings.CefCommandLineArgs.Add("disable-surfaces", "1"); settings.EnableInternalPdfViewerOffScreen(); settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "1"); } var proxy = ProxyConfig.GetProxyInformation(); switch (proxy.AccessType) { case InternetOpenType.Direct: { //Don't use a proxy server, always make direct connections. settings.CefCommandLineArgs.Add("no-proxy-server", "1"); break; } case InternetOpenType.Proxy: { settings.CefCommandLineArgs.Add("proxy-server", proxy.ProxyAddress); break; } case InternetOpenType.PreConfig: { settings.CefCommandLineArgs.Add("proxy-auto-detect", "1"); break; } } settings.LogSeverity = LogSeverity.Verbose; if (DebuggingSubProcess) { var architecture = Environment.Is64BitProcess ? "x64" : "x86"; settings.BrowserSubprocessPath = "..\\..\\..\\..\\CefSharp.BrowserSubprocess\\bin\\" + architecture + "\\Debug\\CefSharp.BrowserSubprocess.exe"; } settings.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeName, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() }); settings.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeNameTest, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() }); settings.RegisterExtension(new CefExtension("cefsharp/example", Resources.extension)); settings.FocusedNodeChangedEnabled = true; Cef.OnContextInitialized = delegate { var cookieManager = Cef.GetGlobalCookieManager(); cookieManager.SetStoragePath("cookies", true); cookieManager.SetSupportedSchemes("custom"); }; if (!Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: !DebuggingSubProcess)) { throw new Exception("Unable to Initialize Cef"); } }
public static void Init(bool osr, bool multiThreadedMessageLoop) { // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys // Environment.SetEnvironmentVariable("GOOGLE_API_KEY", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_SECRET", ""); //Chromium Command Line args //http://peter.sh/experiments/chromium-command-line-switches/ //NOTE: Not all relevant in relation to `CefSharp`, use for reference purposes only. var settings = new CefSettings(); 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 //settings.CefCommandLineArgs.Add("renderer-process-limit", "1"); //settings.CefCommandLineArgs.Add("renderer-startup-dialog", "1"); //settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC //settings.CefCommandLineArgs.Add("no-proxy-server", "1"); //Don't use a proxy server, always make direct connections. Overrides any other proxy server flags that are passed. //settings.CefCommandLineArgs.Add("debug-plugin-loading", "1"); //Dumps extra logging about plugin loading to the log file. //settings.CefCommandLineArgs.Add("disable-plugins-discovery", "1"); //Disable discovering third-party plugins. Effectively loading only ones shipped with the browser plus third-party ones as specified by --extra-plugin-dir and --load-plugin switches //settings.CefCommandLineArgs.Add("enable-system-flash", "1"); //Automatically discovered and load a system-wide installation of Pepper Flash. //settings.CefCommandLineArgs.Add("allow-running-insecure-content", "1"); //By default, an https page cannot run JavaScript, CSS or plugins from http URLs. This provides an override to get the old insecure behavior. Only available in 47 and above. //settings.CefCommandLineArgs.Add("disable-extensions", "1"); //Extension support can be disabled //settings.CefCommandLineArgs.Add("disable-pdf-extension", "1"); //The PDF extension specifically can be disabled //Load the pepper flash player that comes with Google Chrome - may be possible to load these values from the registry and query the dll for it's version info (Step 2 not strictly required it seems) //settings.CefCommandLineArgs.Add("ppapi-flash-path", @"C:\Program Files (x86)\Google\Chrome\Application\47.0.2526.106\PepperFlash\pepflashplayer.dll"); //Load a specific pepper flash version (Step 1 of 2) //settings.CefCommandLineArgs.Add("ppapi-flash-version", "20.0.0.228"); //Load a specific pepper flash version (Step 2 of 2) //NOTE: For OSR best performance you should run with GPU disabled: // `--disable-gpu --disable-gpu-compositing --enable-begin-frame-scheduling` // (you'll loose WebGL support but gain increased FPS and reduced CPU usage). // http://magpcss.org/ceforum/viewtopic.php?f=6&t=13271#p27075 //https://bitbucket.org/chromiumembedded/cef/commits/e3c1d8632eb43c1c2793d71639f3f5695696a5e8 //NOTE: The following function will set all three params //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 //Disables the DirectWrite font rendering system on windows. //Possibly useful when experiencing blury fonts. //settings.CefCommandLineArgs.Add("disable-direct-write", "1"); settings.MultiThreadedMessageLoop = multiThreadedMessageLoop; // Off Screen rendering (WPF/Offscreen) if(osr) { settings.WindowlessRenderingEnabled = true; // Disable Surfaces so internal PDF viewer works for OSR // https://bitbucket.org/chromiumembedded/cef/issues/1689 //settings.CefCommandLineArgs.Add("disable-surfaces", "1"); settings.EnableInternalPdfViewerOffScreen(); settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "1"); // Disable GPU in WPF and Offscreen examples until #1634 has been resolved settings.CefCommandLineArgs.Add("disable-gpu", "1"); } var proxy = ProxyConfig.GetProxyInformation(); switch (proxy.AccessType) { case InternetOpenType.Direct: { //Don't use a proxy server, always make direct connections. settings.CefCommandLineArgs.Add("no-proxy-server", "1"); break; } case InternetOpenType.Proxy: { settings.CefCommandLineArgs.Add("proxy-server", proxy.ProxyAddress); break; } case InternetOpenType.PreConfig: { settings.CefCommandLineArgs.Add("proxy-auto-detect", "1"); break; } } //settings.LogSeverity = LogSeverity.Verbose; if (DebuggingSubProcess) { var architecture = Environment.Is64BitProcess ? "x64" : "x86"; settings.BrowserSubprocessPath = "..\\..\\..\\..\\CefSharp.BrowserSubprocess\\bin\\" + architecture + "\\Debug\\CefSharp.BrowserSubprocess.exe"; } settings.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeName, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() }); settings.RegisterScheme(new CefCustomScheme { SchemeName = CefSharpSchemeHandlerFactory.SchemeNameTest, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() }); settings.RegisterExtension(new CefExtension("cefsharp/example", Resources.extension)); settings.FocusedNodeChangedEnabled = true; //The Request Context has been initialized, you can now set preferences, like proxy server settings Cef.OnContextInitialized = delegate { var cookieManager = Cef.GetGlobalCookieManager(); cookieManager.SetStoragePath("cookies", true); cookieManager.SetSupportedSchemes("custom"); //Dispose of context when finished - preferable not to keep a reference if possible. using (var context = Cef.GetGlobalRequestContext()) { string errorMessage; //You can set most preferences using a `.` notation rather than having to create a complex set of dictionaries. //The default is true, you can change to false to disable context.SetPreference("webkit.webprefs.plugins_enabled", true, out errorMessage); } }; if (!Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: !DebuggingSubProcess)) { throw new Exception("Unable to Initialize Cef"); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); log4net.Config.XmlConfigurator.Configure(); m_Log = LogManager.GetLogger(this.GetType()); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var tmpFolder = System.IO.Path.GetTempPath() + "CotgBrowser_Cache"; if (CotGBrowser.Properties.Settings.Default.ClearCache) { var dirInfo = new System.IO.DirectoryInfo(tmpFolder); foreach (System.IO.FileInfo file in dirInfo.GetFiles()) { file.Delete(); } CotGBrowser.Properties.Settings.Default.ClearCache = false; CotGBrowser.Properties.Settings.Default.Save(); } var settings = new CefSettings(); settings.CachePath = tmpFolder; //settings.CefCommandLineArgs.Clear(); settings.RemoteDebuggingPort = 8088; settings.CefCommandLineArgs.Add("enable-crash-reporter", "1"); settings.CefCommandLineArgs.Add("proxy-auto-detect", "1"); //single_process //settings.CefCommandLineArgs.Add("single_process", "1"); //settings.CefCommandLineArgs.Add("renderer-process-limit", "1"); //WPF opt settings.WindowlessRenderingEnabled = true; settings.EnableInternalPdfViewerOffScreen(); //settings.CefCommandLineArgs.Add("disable-gpu", "1"); settings.CefCommandLineArgs.Add("disable-gpu-compositing", "1"); //settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "1"); //settings.CefCommandLineArgs.Add("enable-logging", "v=1"); //settings.CefCommandLineArgs.Add("js-flags", "--max-old-space-size=2000"); //settings.CefCommandLineArgs.Add("renderer-startup-dialog", "1"); //settings.CefCommandLineArgs.Add("disable-gpu-vsync", "1"); //settings.CefCommandLineArgs.Add("disable-canvas-aa", "1"); //settings.CefCommandLineArgs.Add("disable-gpu-rasterization", "1"); settings.MultiThreadedMessageLoop = true; settings.FocusedNodeChangedEnabled = true; settings.LogSeverity = LogSeverity.Error; Cef.OnContextInitialized = delegate { var cookieManager = Cef.GetGlobalCookieManager(); cookieManager.SetStoragePath("cookies", true); //Dispose of context when finished - preferable not to keep a reference if possible. using (var context = Cef.GetGlobalRequestContext()) { string errorMessage; //You can set most preferences using a `.` notation rather than having to create a complex set of dictionaries. //The default is true, you can change to false to disable context.SetPreference("webkit.webprefs.plugins_enabled", true, out errorMessage); } }; if (!Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: false)) { throw new Exception("Unable to Initialize Cef"); } /* * Task.Run(() => * { * while (true) * { * try * { * //Application.Current.Dispatcher.Invoke(new Action( * // () => Cef.DoMessageLoopWork())); * Cef.DoMessageLoopWork(); * System.Threading.Thread.Sleep(100); * } * catch (Exception eml) * { * m_Log.Error(eml.Message, eml); * } * } * }); */ //konf. fabryki IoCHelper.GetIoC(); Mapper.Initialize(cfg => { cfg.AddProfile <GotGLib.NH.Schema.MapperProfile>(); }); Mapper.AssertConfigurationIsValid(); m_Log.Info("Application started."); Application.Current.MainWindow = IoCHelper.GetIoC().Resolve <Views.MainWindow>(); Application.Current.MainWindow.Show(); Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; CotGNotifyIcon notify = new CotGNotifyIcon(); IoCHelper.GetIoC().RegisterInstance <CotGNotifyIcon>(notify, new ContainerControlledLifetimeManager()); notify.AppStarted(); }
public static void Init(CefSettings settings, string Language = "zh-cn") { // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys // Environment.SetEnvironmentVariable("GOOGLE_API_KEY", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", ""); // Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_SECRET", ""); // Widevine CDM registration - pass in directory where Widevine CDM binaries and manifest.json are located. // For more information on support for DRM content with Widevine see: https://github.com/cefsharp/CefSharp/issues/1934 //Cef.RegisterWidevineCdm(@".\WidevineCdm"); //Chromium Command Line args //http://peter.sh/experiments/chromium-command-line-switches/ //NOTE: Not all relevant in relation to `CefSharp`, use for reference purposes only. 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"; if (!string.IsNullOrEmpty(Language)) { Language = "zh-cn"; settings.Locale = Language; settings.AcceptLanguageList = Language; } //settings.UserAgent = "CefSharp Browser" + Cef.CefSharpVersion; // Example User Agent //settings.CefCommandLineArgs.Add("renderer-process-limit", "1"); //settings.CefCommandLineArgs.Add("renderer-startup-dialog", "1"); //settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC //settings.CefCommandLineArgs.Add("no-proxy-server", "1"); //Don't use a proxy server, always make direct connections. Overrides any other proxy server flags that are passed. //settings.CefCommandLineArgs.Add("debug-plugin-loading", "1"); //Dumps extra logging about plugin loading to the log file. //settings.CefCommandLineArgs.Add("disable-plugins-discovery", "1"); //Disable discovering third-party plugins. Effectively loading only ones shipped with the browser plus third-party ones as specified by --extra-plugin-dir and --load-plugin switches //settings.CefCommandLineArgs.Add("enable-system-flash", "1"); //Automatically discovered and load a system-wide installation of Pepper Flash. //settings.CefCommandLineArgs.Add("allow-running-insecure-content", "1"); //By default, an https page cannot run JavaScript, CSS or plugins from http URLs. This provides an override to get the old insecure behavior. Only available in 47 and above. //settings.CefCommandLineArgs.Add("enable-logging", "1"); //Enable Logging for the Renderer process (will open with a cmd prompt and output debug messages - use in conjunction with setting LogSeverity = LogSeverity.Verbose;) //settings.LogSeverity = LogSeverity.Verbose; // Needed for enable-logging to output messages //settings.CefCommandLineArgs.Add("disable-extensions", "1"); //Extension support can be disabled //settings.CefCommandLineArgs.Add("disable-pdf-extension", "1"); //The PDF extension specifically can be disabled //Load the pepper flash player that comes with Google Chrome - may be possible to load these values from the registry and query the dll for it's version info (Step 2 not strictly required it seems) //settings.CefCommandLineArgs.Add("ppapi-flash-path", @"C:\Program Files (x86)\Google\Chrome\Application\47.0.2526.106\PepperFlash\pepflashplayer.dll"); //Load a specific pepper flash version (Step 1 of 2) //settings.CefCommandLineArgs.Add("ppapi-flash-version", "20.0.0.228"); //Load a specific pepper flash version (Step 2 of 2) //NOTE: For OSR best performance you should run with GPU disabled: // `--disable-gpu --disable-gpu-compositing --enable-begin-frame-scheduling` // (you'll loose WebGL support but gain increased FPS and reduced CPU usage). // http://magpcss.org/ceforum/viewtopic.php?f=6&t=13271#p27075 //https://bitbucket.org/chromiumembedded/cef/commits/e3c1d8632eb43c1c2793d71639f3f5695696a5e8 //NOTE: The following function will set all three params //settings.SetOffScreenRenderingBestPerformanceArgs(); //var osVersion = Environment.OSVersion; //if (osVersion.Version.Major == 6 && osVersion.Version.Minor == 1) //{ //settings.WindowlessRenderingEnabled = true; //settings.CefCommandLineArgs.Add("disable-gpu", "1"); //settings.MultiThreadedMessageLoop = true; //} //settings.CefCommandLineArgs.Add("disable-gpu-compositing", "1"); // settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "0"); //settings.CefCommandLineArgs.Add("disable-gpu-vsync", "1"); //Disable Vsync //Disables the DirectWrite font rendering system on windows. //Possibly useful when experiencing blury fonts. //settings.CefCommandLineArgs.Add("disable-direct-write", "1"); // The following options control accessibility state for all frames. // These options only take effect if accessibility state is not set by IBrowserHost.SetAccessibilityState call. // --force-renderer-accessibility enables browser accessibility. // --disable-renderer-accessibility completely disables browser accessibility. //settings.CefCommandLineArgs.Add("force-renderer-accessibility", "1"); //settings.CefCommandLineArgs.Add("disable-renderer-accessibility", "1"); //Enables Uncaught exception handler settings.UncaughtExceptionStackSize = 20; settings.WindowlessRenderingEnabled = true; // Off Screen rendering (WPF/Offscreen) if (settings.WindowlessRenderingEnabled) { //Disable Direct Composition to test https://github.com/cefsharp/CefSharp/issues/1634 //settings.CefCommandLineArgs.Add("disable-direct-composition", "1"); settings.EnableInternalPdfViewerOffScreen(); settings.CefCommandLineArgs.Add("disable-gpu", "1"); // DevTools doesn't seem to be working when this is enabled // http://magpcss.org/ceforum/viewtopic.php?f=6&t=14095 //settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling", "1"); } var proxy = ProxyConfig.GetProxyInformation(); switch (proxy.AccessType) { case InternetOpenType.Direct: { //Don't use a proxy server, always make direct connections. settings.CefCommandLineArgs.Add("no-proxy-server", "1"); break; } case InternetOpenType.Proxy: { settings.CefCommandLineArgs.Add("proxy-server", proxy.ProxyAddress); break; } case InternetOpenType.PreConfig: { settings.CefCommandLineArgs.Add("proxy-auto-detect", "1"); break; } } // settings.LogSeverity = LogSeverity.Verbose; if (DebuggingSubProcess) { var architecture = Environment.Is64BitProcess ? "x64" : "x86"; //settings.BrowserSubprocessPath = "..\\..\\..\\..\\CefSharp.BrowserSubprocess\\bin\\" + architecture + "\\Debug\\CefSharp.BrowserSubprocess.exe"; settings.BrowserSubprocessPath = AppDomain.CurrentDomain.BaseDirectory + "CefSharp.BrowserSubprocess.exe"; } //settings.RegisterScheme(new CefCustomScheme //{ // SchemeName = CefSharpSchemeHandlerFactory.SchemeName, // SchemeHandlerFactory = new CefSharpSchemeHandlerFactory(), // IsSecure = true //treated with the same security rules as those applied to "https" URLs // //SchemeHandlerFactory = new InMemorySchemeAndResourceHandlerFactory() //}); //settings.RegisterScheme(new CefCustomScheme //{ // SchemeName = CefSharpSchemeHandlerFactory.SchemeNameTest, // SchemeHandlerFactory = new CefSharpSchemeHandlerFactory(), // IsSecure = true //treated with the same security rules as those applied to "https" URLs //}); ////You can use the http/https schemes - best to register for a specific domain //settings.RegisterScheme(new CefCustomScheme //{ // SchemeName = "https", // SchemeHandlerFactory = new CefSharpSchemeHandlerFactory(), // DomainName = "cefsharp.com", // IsSecure = true //treated with the same security rules as those applied to "https" URLs //}); //settings.RegisterScheme(new CefCustomScheme //{ // SchemeName = "localfolder", // SchemeHandlerFactory = new FolderSchemeHandlerFactory(rootFolder: @"..\..\..\..\CefSharp.Example\Resources", // schemeName: "localfolder", //Optional param no schemename checking if null // hostName: "cefsharp", //Optional param no hostname checking if null // defaultPage: "home.html") //Optional param will default to index.html //}); //dsafpbrowsercommon //settings.RegisterExtension(new CefExtension("cefsharp/example", Resources.ds_afp_browser_common)); settings.RegisterExtension(new CefExtension("dsafpbrowsercommon", Resources.ds_afp_browser_common)); //This must be set before Cef.Initialized is called settings.FocusedNodeChangedEnabled = true; //Experimental option where bound async methods are queued on TaskScheduler.Default. //CefSharpSettings.ConcurrentTaskExecution = true; //Legacy Binding Behaviour doesn't work for cross-site navigation (navigating to a different domain) //See issue https://github.com/cefsharp/CefSharp/issues/1203 for details //CefSharpSettings.LegacyJavascriptBindingEnabled = true; //Exit the subprocess if the parent process happens to close //This is optional at the moment //https://github.com/cefsharp/CefSharp/pull/2375/ //CefSharpSettings.SubprocessExitIfParentProcessClosed = true; //NOTE: Set this before any calls to Cef.Initialize to specify a proxy with username and password //One set this cannot be changed at runtime. If you need to change the proxy at runtime (dynamically) then //see https://github.com/cefsharp/CefSharp/wiki/General-Usage#proxy-resolution //CefSharpSettings.Proxy = new ProxyOptions(ip: "127.0.0.1", port: "8080", username: "******", password: "******"); if (!Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: !DebuggingSubProcess)) { throw new Exception("Unable to Initialize Cef"); } //Cef.AddCrossOriginWhitelistEntry(BaseUrl, "https", "cefsharp.com", false); }