WebInterfaceBrowserSingleton.h
6.0 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
// Engine/Source/Runtime/WebBrowser/Private/WebBrowserSingleton.h
#pragma once
#include "CoreMinimal.h"
#include "Containers/Ticker.h"
#include "IWebInterfaceBrowserSingleton.h"
#if WITH_CEF3
#if PLATFORM_WINDOWS
#include "Windows/WindowsHWrapper.h"
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/AllowWindowsPlatformAtomics.h"
#endif
#pragma push_macro("OVERRIDE")
#undef OVERRIDE // cef headers provide their own OVERRIDE macro
THIRD_PARTY_INCLUDES_START
#if PLATFORM_APPLE
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#endif
#include "include/internal/cef_ptr.h"
#include "include/cef_request_context.h"
#if PLATFORM_APPLE
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#endif
THIRD_PARTY_INCLUDES_END
#pragma pop_macro("OVERRIDE")
#if PLATFORM_WINDOWS
#include "Windows/HideWindowsPlatformAtomics.h"
#include "Windows/HideWindowsPlatformTypes.h"
#endif
#include "CEF/CEFInterfaceSchemeHandler.h"
class CefListValue;
class FCEFInterfaceBrowserApp;
class FCEFWebInterfaceBrowserWindow;
#endif
class IWebInterfaceBrowserCookieManager;
class IWebInterfaceBrowserWindow;
struct FWebInterfaceBrowserWindowInfo;
struct FWebInterfaceBrowserInitSettings;
class UMaterialInterface;
PRAGMA_DISABLE_DEPRECATION_WARNINGS
/**
* Implementation of singleton class that takes care of general web browser tasks
*/
class FWebInterfaceBrowserSingleton
: public IWebInterfaceBrowserSingleton
, public FTickerObjectBase
{
public:
/** Constructor. */
FWebInterfaceBrowserSingleton(const FWebInterfaceBrowserInitSettings& WebBrowserInitSettings);
/** Virtual destructor. */
virtual ~FWebInterfaceBrowserSingleton();
/**
* Gets the Current Locale Code in the format CEF expects
*
* @return Locale code as either "xx" or "xx-YY"
*/
static FString GetCurrentLocaleCode();
virtual FString ApplicationCacheDir() const override;
public:
// IWebBrowserSingleton Interface
virtual TSharedRef<IWebInterfaceBrowserWindowFactory> GetWebBrowserWindowFactory() const override;
TSharedPtr<IWebInterfaceBrowserWindow> CreateBrowserWindow(
TSharedPtr<FCEFWebInterfaceBrowserWindow>& BrowserWindowParent,
TSharedPtr<FWebInterfaceBrowserWindowInfo>& BrowserWindowInfo) override;
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>()) override;
TSharedPtr<IWebInterfaceBrowserWindow> CreateBrowserWindow(const FCreateInterfaceBrowserWindowSettings& Settings) override;
#if BUILD_EMBEDDED_APP
TSharedPtr<IWebInterfaceBrowserWindow> CreateNativeBrowserProxy() override;
#endif
virtual void DeleteBrowserCookies(FString URL = TEXT(""), FString CookieName = TEXT(""), TFunction<void(int)> Completed = nullptr) override;
virtual TSharedPtr<IWebInterfaceBrowserCookieManager> GetCookieManager() const override
{
return DefaultCookieManager;
}
virtual TSharedPtr<IWebInterfaceBrowserCookieManager> GetCookieManager(TOptional<FString> ContextId) const override;
virtual bool RegisterContext(const FInterfaceBrowserContextSettings& Settings) override;
virtual bool UnregisterContext(const FString& ContextId) override;
virtual bool RegisterSchemeHandlerFactory(FString Scheme, FString Domain, IWebInterfaceBrowserSchemeHandlerFactory* WebBrowserSchemeHandlerFactory) override;
virtual bool UnregisterSchemeHandlerFactory(IWebInterfaceBrowserSchemeHandlerFactory* WebBrowserSchemeHandlerFactory) override;
virtual bool IsDevToolsShortcutEnabled() override
{
return bDevToolsShortcutEnabled;
}
virtual void SetDevToolsShortcutEnabled(bool Value) override
{
bDevToolsShortcutEnabled = Value;
}
virtual void SetJSBindingToLoweringEnabled(bool bEnabled) override
{
bJSBindingsToLoweringEnabled = bEnabled;
}
/** Set a reference to UWebBrowser's default material*/
virtual void SetDefaultMaterial(UMaterialInterface* InDefaultMaterial) override
{
DefaultMaterial = InDefaultMaterial;
}
/** Set a reference to UWebBrowser's translucent material*/
virtual void SetDefaultTranslucentMaterial(UMaterialInterface* InDefaultMaterial) override
{
DefaultTranslucentMaterial = InDefaultMaterial;
}
/** Get a reference to UWebBrowser's default material*/
virtual UMaterialInterface* GetDefaultMaterial() override
{
return DefaultMaterial;
}
/** Get a reference to UWebBrowser's translucent material*/
virtual UMaterialInterface* GetDefaultTranslucentMaterial() override
{
return DefaultTranslucentMaterial;
}
public:
// FTickerObjectBase Interface
virtual bool Tick(float DeltaTime) override;
private:
TSharedPtr<IWebInterfaceBrowserCookieManager> DefaultCookieManager;
#if WITH_CEF3
/** When new render processes are created, send all permanent variable bindings to them. */
void HandleRenderProcessCreated(CefRefPtr<CefListValue> ExtraInfo);
/** Pointer to the CEF App implementation */
CefRefPtr<FCEFInterfaceBrowserApp> CEFBrowserApp;
TMap<FString, CefRefPtr<CefRequestContext>> RequestContexts;
FCefInterfaceSchemeHandlerFactories SchemeHandlerFactories;
bool bAllowCEF;
#endif
/** List of currently existing browser windows */
#if WITH_CEF3
TArray<TWeakPtr<FCEFWebInterfaceBrowserWindow>> WindowInterfaces;
#endif
/** Critical section for thread safe modification of WindowInterfaces array. */
FCriticalSection WindowInterfacesCS;
TSharedRef<IWebInterfaceBrowserWindowFactory> WebBrowserWindowFactory;
bool bDevToolsShortcutEnabled;
bool bJSBindingsToLoweringEnabled;
/** Reference to UWebBrowser's default material*/
UMaterialInterface* DefaultMaterial;
/** Reference to UWebBrowser's translucent material*/
UMaterialInterface* DefaultTranslucentMaterial;
};
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#if WITH_CEF3
class CefCookieManager;
class FCefWebInterfaceCookieManagerFactory
{
public:
static TSharedRef<IWebInterfaceBrowserCookieManager> Create(
const CefRefPtr<CefCookieManager>& CookieManager);
};
#endif