forked from bkeiren/AwesomiumUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAwesomiumUnityWebSession.cs
More file actions
79 lines (63 loc) · 3.11 KB
/
Copy pathAwesomiumUnityWebSession.cs
File metadata and controls
79 lines (63 loc) · 3.11 KB
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
74
75
76
77
78
79
using UnityEngine;
using System.Runtime.InteropServices; // For DllImport.
public class SessionPreferences
{
static public string InMemoryWebSessionPath = string.Empty;
public string WebSessionPath = InMemoryWebSessionPath;
public string PluginPath = Application.dataPath + "\\awe_plugins\\";
public bool GPUAcceleration = true;
public bool WebGL = true;
public bool JavaScript = true;
public bool Plugins = true;
public bool WebAudio = true;
public bool RemoteFonts = true;
public bool AppCache = true;
public bool Dart = true;
public bool HTML5LocalStorage = true;
public bool SmoothScrolling = true;
public bool WebSecurity = true;
public override string ToString()
{
return string.Format("Session Path: {0} | Plugin Path: {1} | GPU Accel: {2} | WebGL: {3} | JavaScript: {4} | Plugins: {5} | Web Audio: {6} | Remote Fonts: {7} | App Cache: {8} | Dart: {9} | HTML5 Local Storage: {10} | Smooth Scrolling: {11} | Web Security: {12}", WebSessionPath, PluginPath, GPUAcceleration, WebGL, JavaScript, Plugins, WebAudio, RemoteFonts, AppCache, Dart, HTML5LocalStorage, SmoothScrolling, WebSecurity);
}
}
public class AwesomiumUnityWebSession
{
internal const string DllName = "AwesomiumUnity";
/// DLL Imported functions.
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
extern static private void awe_websession_clear_cache();
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
extern static private void awe_websession_clear_cookies();
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
extern static private bool awe_websession_isondisk();
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
extern static private void awe_websession_setcookie([MarshalAs(UnmanagedType.LPWStr)]string _URL, [MarshalAs(UnmanagedType.LPWStr)]string _CookieString, bool _IsHTTPOnly, bool _ForceSessionCookie);
// NOTE: Due to the way Awesomium internally uses the cache there is a specific set of steps that need to be done in order
// before you can clear the cache. These steps are:
// 1) Dispose (close/destroy) all WebViews.
// 2) Update WebCore.
// 3) Delete cache.
public static void ClearCache()
{
awe_websession_clear_cache();
}
public static void ClearCookies()
{
awe_websession_clear_cookies();
}
public static bool IsOnDisk()
{
return awe_websession_isondisk();
}
public static void SetCookie(string _URL, string _CookieString, bool _IsHTTPOnly, bool _ForceSessionCookie)
{
awe_websession_setcookie(_URL, _CookieString, _IsHTTPOnly, _ForceSessionCookie);
}
// These are the settings that are used during WebCore initialization.
// You can customize these settings by changing the initializer list of this object here.
public static SessionPreferences Preferences = new SessionPreferences
{
WebSessionPath = SessionPreferences.InMemoryWebSessionPath // Examples paths: "C:\\MyCache", "MyCache" (will be relative to executable). An empty string signifies an in-memory session.
};
}