IWebInterfaceBrowserSingleton.h
8.7 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// Engine/Source/Runtime/WebBrowser/Public/IWebBrowserSingleton.h
#pragma once
#include "CoreMinimal.h"
#include "Rendering/SlateRenderer.h"
class FCEFWebInterfaceBrowserWindow;
class IWebInterfaceBrowserCookieManager;
class IWebInterfaceBrowserWindow;
class IWebInterfaceBrowserSchemeHandlerFactory;
class UMaterialInterface;
struct FWebInterfaceBrowserWindowInfo;
class IWebInterfaceBrowserWindowFactory
{
public:
virtual TSharedPtr<IWebInterfaceBrowserWindow> Create(
TSharedPtr<FCEFWebInterfaceBrowserWindow>& BrowserWindowParent,
TSharedPtr<FWebInterfaceBrowserWindowInfo>& BrowserWindowInfo) = 0;
virtual TSharedPtr<IWebInterfaceBrowserWindow> Create(
void* OSWindowHandle,
FString InitialURL,
bool bUseTransparency,
bool bThumbMouseButtonNavigation,
TOptional<FString> ContentsToLoad = TOptional<FString>(),
bool ShowErrorMessage = true,
FColor BackgroundColor = FColor(255, 255, 255, 255)) = 0;
};
struct WEBBROWSERUI_API FInterfaceBrowserContextSettings
{
FInterfaceBrowserContextSettings(const FString& InId)
: Id(InId)
, AcceptLanguageList()
, CookieStorageLocation()
, bPersistSessionCookies(false)
, bIgnoreCertificateErrors(false)
, bEnableNetSecurityExpiration(true)
{ }
FString Id;
FString AcceptLanguageList;
FString CookieStorageLocation;
bool bPersistSessionCookies;
bool bIgnoreCertificateErrors;
bool bEnableNetSecurityExpiration;
};
struct WEBBROWSERUI_API FCreateInterfaceBrowserWindowSettings
{
FCreateInterfaceBrowserWindowSettings()
: OSWindowHandle(nullptr)
, InitialURL()
, bUseTransparency(false)
, bUseNativeCursors(false)
, bThumbMouseButtonNavigation(false)
, ContentsToLoad()
, bShowErrorMessage(true)
, BackgroundColor(FColor(255, 255, 255, 255))
, BrowserFrameRate(60)
, Context()
, AltRetryDomains()
{ }
void* OSWindowHandle;
FString InitialURL;
bool bUseTransparency;
bool bUseNativeCursors;
bool bThumbMouseButtonNavigation;
TOptional<FString> ContentsToLoad;
bool bShowErrorMessage;
FColor BackgroundColor;
int BrowserFrameRate;
TOptional<FInterfaceBrowserContextSettings> Context;
TArray<FString> AltRetryDomains;
};
/**
* A singleton class that takes care of general web browser tasks
*/
class WEBBROWSERUI_API IWebInterfaceBrowserSingleton
{
public:
/**
* Virtual Destructor
*/
virtual ~IWebInterfaceBrowserSingleton() {};
/** @return A factory object that can be used to construct additional WebBrowserWindows on demand. */
virtual TSharedRef<IWebInterfaceBrowserWindowFactory> GetWebBrowserWindowFactory() const = 0;
/**
* Create a new web browser window
*
* @param BrowserWindowParent The parent browser window
* @param BrowserWindowInfo Info for setting up the new browser window
* @return New Web Browser Window Interface (may be null if not supported)
*/
virtual TSharedPtr<IWebInterfaceBrowserWindow> CreateBrowserWindow(
TSharedPtr<FCEFWebInterfaceBrowserWindow>& BrowserWindowParent,
TSharedPtr<FWebInterfaceBrowserWindowInfo>& BrowserWindowInfo
) = 0;
/**
* Create a new web browser window
*
* @param OSWindowHandle Handle of OS Window that the browser will be displayed in (can be null)
* @param InitialURL URL that the browser should initially navigate to
* @param bUseTransparency Whether to allow transparent rendering of pages
* @param ContentsToLoad Optional string to load as a web page
* @param ShowErrorMessage Whether to show an error message in case of loading errors.
* @param BackgroundColor Opaque background color used before a document is loaded and when no document color is specified.
* @param BrowserFrameRate The framerate of the browser in FPS
* @return New Web Browser Window Interface (may be null if not supported)
*/
UE_DEPRECATED(4.11, "Please use the new overload that takes a settings struct.")
virtual TSharedPtr<IWebInterfaceBrowserWindow> CreateBrowserWindow(
void* OSWindowHandle,
FString InitialURL,
bool bUseTransparency,
bool bThumbMouseButtonNavigation,
TOptional<FString> ContentsToLoad = TOptional<FString>(),
bool ShowErrorMessage = true,
FColor BackgroundColor = FColor(255, 255, 255, 255),
int BrowserFrameRate = 60,
const TArray<FString>& AltRetryDomains = TArray<FString>()) = 0;
virtual TSharedPtr<IWebInterfaceBrowserWindow> CreateBrowserWindow(const FCreateInterfaceBrowserWindowSettings& Settings) = 0;
#if BUILD_EMBEDDED_APP
virtual TSharedPtr<IWebInterfaceBrowserWindow> CreateNativeBrowserProxy() = 0;
#endif
/**
* Delete all browser cookies.
*
* Removes all matching cookies. Leave both URL and CookieName blank to delete the entire cookie database.
* The actual deletion will be scheduled on the browser IO thread, so the operation may not have completed when the function returns.
*
* @param URL The base URL to match when searching for cookies to remove. Use blank to match all URLs.
* @param CookieName The name of the cookie to delete. If left unspecified, all cookies will be removed.
* @param Completed A callback function that will be invoked asynchronously on the game thread when the deletion is complete passing in the number of deleted objects.
*/
UE_DEPRECATED(4.11, "Please use the CookieManager instead via GetCookieManager().")
virtual void DeleteBrowserCookies(FString URL = TEXT(""), FString CookieName = TEXT(""), TFunction<void(int)> Completed = nullptr) = 0;
virtual TSharedPtr<class IWebInterfaceBrowserCookieManager> GetCookieManager() const = 0;
virtual TSharedPtr<class IWebInterfaceBrowserCookieManager> GetCookieManager(TOptional<FString> ContextId) const = 0;
virtual bool RegisterContext(const FInterfaceBrowserContextSettings& Settings) = 0;
virtual bool UnregisterContext(const FString& ContextId) = 0;
// @return the application cache dir where the cookies are stored
virtual FString ApplicationCacheDir() const = 0;
/**
* Registers a custom scheme handler factory, for a given scheme and domain. The domain is ignored if the scheme is not a browser built in scheme
* and all requests will go through this factory.
* @param Scheme The scheme name to handle.
* @param Domain The domain name to handle.
* @param WebBrowserSchemeHandlerFactory The factory implementation for creating request handlers for this scheme.
*/
virtual bool RegisterSchemeHandlerFactory(FString Scheme, FString Domain, IWebInterfaceBrowserSchemeHandlerFactory* WebBrowserSchemeHandlerFactory) = 0;
/**
* Unregister a custom scheme handler factory. The factory may still be used by existing open browser windows, but will no longer be provided for new ones.
* @param WebBrowserSchemeHandlerFactory The factory implementation to remove.
*/
virtual bool UnregisterSchemeHandlerFactory(IWebInterfaceBrowserSchemeHandlerFactory* WebBrowserSchemeHandlerFactory) = 0;
/**
* Enable or disable CTRL/CMD-SHIFT-I shortcut to show the Chromium Dev tools window.
* The value defaults to true on debug builds, otherwise false.
*
* The relevant handlers for spawning new browser windows have to be set up correctly in addition to this flag being true before anything is shown.
*
* @param Value a boolean value to enable or disable the keyboard shortcut.
*/
virtual void SetDevToolsShortcutEnabled(bool Value) = 0;
/**
* Returns whether the CTRL/CMD-SHIFT-I shortcut to show the Chromium Dev tools window is enabled.
*
* The relevant handlers for spawning new browser windows have to be set up correctly in addition to this flag being true before anything is shown.
*
* @return a boolean value indicating whether the keyboard shortcut is enabled or not.
*/
virtual bool IsDevToolsShortcutEnabled() = 0;
/**
* Enable or disable to-lowering of JavaScript object member bindings.
*
* Due to how JavaScript to UObject bridges require the use of FNames for building up the JS API objects, it is possible for case-sensitivity issues
* to develop if an FName has been previously created with differing case to your function or property names. To-lowering the member names allows
* a guaranteed casing for the web page's JS to reference.
*
* Default behavior is enabled, so that all JS side objects have only lowercase members.
*
* @param bEnabled a boolean value to enable or disable the to-lowering.
*/
virtual void SetJSBindingToLoweringEnabled(bool bEnabled) = 0;
/** Set a reference to UWebBrowser's default material*/
virtual void SetDefaultMaterial(UMaterialInterface* InDefaultMaterial) = 0;
/** Set a reference to UWebBrowser's translucent material*/
virtual void SetDefaultTranslucentMaterial(UMaterialInterface* InDefaultMaterial) = 0;
/** Get a reference to UWebBrowser's default material*/
virtual UMaterialInterface* GetDefaultMaterial() = 0;
/** Get a reference to UWebBrowser's transparent material*/
virtual UMaterialInterface* GetDefaultTranslucentMaterial() = 0;
};