BrowserCefApp.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections.Generic;
  2. using Xilium.CefGlue.Common.Handlers;
  3. using Xilium.CefGlue.Common.InternalHandlers;
  4. using Xilium.CefGlue.Common.Shared;
  5. namespace Xilium.CefGlue.Common
  6. {
  7. internal class BrowserCefApp : CommonCefApp
  8. {
  9. private readonly CefBrowserProcessHandler _browserProcessHandler;
  10. private readonly KeyValuePair<string, string>[] _flags;
  11. internal BrowserCefApp(CustomScheme[] customSchemes = null, KeyValuePair<string, string>[] flags = null, BrowserProcessHandler browserProcessHandler = null) :
  12. base(customSchemes)
  13. {
  14. _browserProcessHandler = new CommonBrowserProcessHandler(browserProcessHandler, customSchemes);
  15. _flags = flags;
  16. }
  17. protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
  18. {
  19. if (string.IsNullOrEmpty(processType))
  20. {
  21. if (CefRuntimeLoader.IsOSREnabled)
  22. {
  23. commandLine.AppendSwitch("disable-gpu", "1");
  24. commandLine.AppendSwitch("disable-gpu-compositing", "1");
  25. commandLine.AppendSwitch("enable-begin-frame-scheduling", "1");
  26. commandLine.AppendSwitch("disable-smooth-scrolling", "1");
  27. }
  28. if (_flags != null)
  29. {
  30. foreach (var flag in _flags)
  31. {
  32. commandLine.AppendSwitch(flag.Key, flag.Value);
  33. }
  34. }
  35. }
  36. }
  37. protected override CefBrowserProcessHandler GetBrowserProcessHandler()
  38. {
  39. return _browserProcessHandler;
  40. }
  41. }
  42. }