forked from vrcx-team/VRCX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCefService.cs
73 lines (64 loc) · 2.47 KB
/
CefService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.IO;
using CefSharp;
using CefSharp.SchemeHandler;
using CefSharp.WinForms;
namespace VRCX
{
public class CefService
{
public static readonly CefService Instance;
static CefService()
{
Instance = new CefService();
}
internal void Init()
{
var userDataDir = Path.Combine(Program.AppDataDirectory, "userdata");
var cefSettings = new CefSettings
{
RootCachePath = userDataDir,
CachePath = Path.Combine(userDataDir, "cache"),
LogSeverity = LogSeverity.Disable,
WindowlessRenderingEnabled = true,
PersistSessionCookies = true,
PersistUserPreferences = true,
UserAgent = Program.Version
};
cefSettings.RegisterScheme(new CefCustomScheme
{
SchemeName = "file",
DomainName = "vrcx",
SchemeHandlerFactory = new FolderSchemeHandlerFactory(
Path.Combine(Program.BaseDirectory, "html"),
"file",
defaultPage: "index.html"
),
IsLocal = true
});
// cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
// 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["autoplay-policy"] = "no-user-gesture-required";
cefSettings.CefCommandLineArgs.Add("disable-web-security");
cefSettings.SetOffScreenRenderingBestPerformanceArgs(); // causes white screen sometimes?
if (Program.LaunchDebug)
{
cefSettings.RemoteDebuggingPort = 8088;
cefSettings.CefCommandLineArgs["remote-allow-origins"] = "*";
}
CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO (needed for synchronous configRepository)
CefSharpSettings.ShutdownOnExit = false;
if (Cef.Initialize(cefSettings) == false)
{
throw new Exception("Cef.Initialize()");
}
}
internal void Exit()
{
Cef.Shutdown();
}
}
}