You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
========================== MAJOR FEATURES + CHANGES ========================== Change 2911743 on 2016/03/16 by Allan.Bentham Fix broken tonemapper when using 32bpp encoded HDR. Fixes UE-28359 Cleaned up some ronin integration hacks from ronin. Change 2912053 on 2016/03/16 by Peter.Sauerbrei disable Vulkan in Win32 builds for now #codereview rolando.caloca #jira UE-28465 Change 2914512 on 2016/03/18 by Dmitriy.Dyomin Fixed crash on Nexus5 with Android 4.4.2 when TonemapperFilm is enabled Change 2914944 on 2016/03/18 by Allan.Bentham Fix es2 tonemap flip. Fixes UE-25148 Change 2915248 on 2016/03/18 by Chris.Babcock Updates to support NDK r11 #jira UE-28529 #ue4 #android Change 2919192 on 2016/03/22 by Chris.Babcock NDK level set above 19 forces minSdkVersion to 21 or above to prevent installing on unsupported devices #jira UE-28408 #ue4 #android #codereview Jack.Porter Change 2919591 on 2016/03/23 by Allan.Bentham Merge ronin's Gaussian DoF to 4.11's dof changes. Gaussian DoF will use a single recombine pass with ES31 devices or if no separate translucency is used on SM4+. Added permutation to exclude separate translucency from Gaussian recombine shader when not in use. #codereview martin.mittring Change 2920758 on 2016/03/24 by Dmitriy.Dyomin Fixed: shifting lighting samples octree https://udn.unrealengine.com/questions/276026/lighting-samples-visualization-not-working-with-le.html Change 2920793 on 2016/03/24 by Dmitriy.Dyomin Fixed: When sub-level set to be unloaded but with visbility state set to true, ULevelStreaming::IsStreamingStatePending returns wrong value #jira UE-26426 Change 2920981 on 2016/03/24 by Dmitriy.Dyomin GPU particles support for iOS Metal (A8+ only) #jira UE-11067 #jira UE-28514 #codereview Jack.Porter Change 2921383 on 2016/03/24 by Allan.Bentham Fix inverted image on device when framebuffer fetch/bViewRectSource is not used. #codereview jack.porter Change 2925694 on 2016/03/29 by Dmitriy.Dyomin Fixed: GPU particles and bloom on S7 Mali Change 2927065 on 2016/03/29 by Chris.Babcock Set the DT_SONAME field in linker (stops warning toast) #ue4 #android #codereview Jack.Porter Change 2927375 on 2016/03/30 by Jack.Porter Fixed localization for placement mode Cube, Sphere, Cylinder and Cone Change 2928643 on 2016/03/30 by Jack.Porter Fixed bug introdued by Ronin merge with DepthOfFieldScale setting being locked for BokehDOF #code_review: allan.bentham Change 2932773 on 2016/04/04 by Jack.Porter Reapply android Vulkan version fixes Change 2932853 on 2016/04/05 by Jack.Porter Enable VULKAN_CLEAR_SURFACE_ON_CREATE on Android to prevent assertion Change 2932998 on 2016/04/05 by Jack.Porter Native web browser widget on iOS #jira UEMOB-20 Change 2933420 on 2016/04/05 by Chris.Babcock Removed hard-coded bUseUnityBuild in UBT for Android (contributed by kosz78) #jira UE-29066 #pr #2236 #ue4 #android Change 2934315 on 2016/04/05 by Chris.Babcock Allow Android to act as server with OnlineSubsystemNull (contributed by psychogony) #jira UE-23937 #PR #1820 #ue4 #android #codereview Ryan.Gerleve Change 2935038 on 2016/04/06 by Chris.Babcock Fix OpenGLES31 compile error #ue4 #android #codereview Jack.Porter Change 2936288 on 2016/04/07 by Allan.Bentham Planar reflection captures for mobile. (UE-27426) Added mobile planar reflection flag to material. #codereview jack.porter, daniel.wright Change 2936297 on 2016/04/07 by Allan.Bentham Missed file. Planar reflection captures for mobile. (UE-27426) #codereview jack.porter, daniel.wright Change2937763on 2016/04/08 by Dmitriy.Dyomin Fix InstancedStaticMesh batches for ES2 (contributed by Grimmick) GitHub #2031 #jira UE-26576 #codereview Jack.Porter Change 2937863 on 2016/04/08 by Jack.Porter Merged Ronin CLs 2840392, 2860028 Allow vertex texture fetches on ES2 (requires absolute mip level) Change 2938461 on 2016/04/08 by Chris.Babcock Write Android uninstall batch files #ue4 #android Change 2939679 on 2016/04/11 by Allan.Bentham Remove bStationaryLightUsesCSMForMovableShadows from light component's UI. renamed proxy equivalent and infer its state from Inset Shadows For Movable Objects #codereview jack.porter, daniel.wright Change 2939887 on 2016/04/11 by Chris.Babcock Android ARM64 libraries #jira UEPLAT-1268 #ue4 #android Change 2940125 on 2016/04/11 by Chris.Babcock Added requirements to Arm64 and x86_64 tooltips Change 2941051 on 2016/04/12 by Allan.Bentham Fix for inverted RG channels when using filmic tonemapper with ES2. #codereview jack.porter Change 2942523 on 2016/04/13 by Chris.Babcock Add cxa_demangle build.cs instead of hiding dependency in UEBuildAndroid.cs #ue4 #android #codereview Josh.Adams Change 2942578 on 2016/04/13 by Chris.Babcock Add cxademangle dependency to Core for Android #ue4 #android #codereview Josh.Adams Change 2942997 on 2016/04/13 by Chris.Babcock Run Ant with -quiet first and run again without if there is an error for the log #ue4 #android #codereview Josh.Adams Change 2943320 on 2016/04/14 by Jack.Porter Fixed planar reflection merge errors Change 2943352 on 2016/04/14 by Jack.Porter Fix NAME_VULKAN_ES3_1_ANDROID shader format name #codereview: Rolando.Coloca Change 2943367 on 2016/04/14 by Dmitriy.Dyomin Added cvars to add or strip specific GL extensions from a driver reported extensions string #jira UE-29467 Change 2943425 on 2016/04/14 by Dmitriy.Dyomin Better logging of MobileHDR mode Change 2943461 on 2016/04/14 by Dmitriy.Dyomin Fixing HDR rendering and bloom on Galaxy S7 Change 2943493 on 2016/04/14 by Dmitriy.Dyomin Better HDR fix for devices with ES3 support Change 2943855 on 2016/04/14 by Allan.Bentham Mobile planar reflections. - currently only supports opaque materials #codereview jack.porter Change 2944721 on 2016/04/14 by Chris.Babcock Allow Vulkan-only Android builds #ue4 #android #codereview Allan.Bentham,Jack.Porter Change 2944771 on 2016/04/14 by Dmitriy.Dyomin Fixed: mesh particles crash in ES2 Change 2944827 on 2016/04/15 by Dmitriy.Dyomin Fixed: GPU particles not working on S6 with Android 6.0.1 Change 2944836 on 2016/04/15 by Jack.Porter Disable FX system calls in forward renderer when particles showflag is off Change 2944840 on 2016/04/15 by Jack.Porter Re-enabled non-radial TDeferredLightVS on ES2 for planar and put #if FEATURE_LEVEL >= FEATURE_LEVEL_SM4 around the radial shader code which was tripping up ES2. #codereview: Allan.Bentham, Chris.Babcock, Daniel.Wright Change 2944914 on 2016/04/15 by Jack.Porter Device profiles to detect Galaxy S7 Mali and Adreno variants in Vulkan mode Change 2945020 on 2016/04/15 by Gareth.Martin Cloning changes across from Dev-Landscape to Dev-Mobile due to feature deadline for 4.12. Change 2943560 on 2016/04/14 by Gareth.Martin Added ability to expand landscape bounds #jira UE-28928 #jira UE-25230 Change 2943538 on 2016/04/14 by Gareth.Martin Fix a crash with saving a level >2GB in size. There may still be other crashes with >2GB levels. Change 2943477 on 2016/04/14 by Gareth.Martin Fixed LODFalloff setting on landscape getting reset when using the "Change Landscape Component Size" tool Also moved all the LOD settings together in LandscapeProxy.h because it was messy Change 2942113 on 2016/04/13 by Gareth.Martin Updating comment to clarify behaviour of Foliage Align-To-Normal when Random-Yaw is disabled. Change 2941030 on 2016/04/12 by Gareth.Martin Cleanup and commenting Change 2940994 on 2016/04/12 by Gareth.Martin Implement random scale option for Landscape Grass. #jira UE-25743 Change 2940993 on 2016/04/12 by Gareth.Martin Remove unused BuildFlatTree function from HierarchicalInstancedStaticMeshComponent Change 2940150 on 2016/04/11 by Gareth.Martin Harden UHierarchicalInstancedStaticMeshComponent::UpdateInstanceTransform Change 2940101 on 2016/04/11 by Gareth.Martin Additional checks for bad static mesh when building the HISMC tree Change2945560on 2016/04/15 by Rolando.Caloca DM - Fix for newer Vulkan sdks Change 2945638 on 2016/04/15 by Chris.Babcock Fix permissions on uninstall script on Mac #jira UE-29236 #ue4 #android #lockdown Jack.Porter Change 2945856 on 2016/04/15 by Rolando.Caloca DM - vk - Fix mapped allocations on mobile #lockdown nick.penwarden [CL 2945995 by Chris Babcock in Main branch]
435 lines
14 KiB
C++
435 lines
14 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "WebBrowserPrivatePCH.h"
|
|
#include "SlateCore.h"
|
|
#include "WebBrowserSingleton.h"
|
|
#include "WebBrowserApp.h"
|
|
#include "WebBrowserHandler.h"
|
|
#include "WebBrowserWindow.h"
|
|
#include "IPlatformTextField.h"
|
|
#include "IVirtualKeyboardEntry.h"
|
|
#include "SlateApplication.h"
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
|
|
#if WITH_CEF3
|
|
# if PLATFORM_WINDOWS
|
|
# include "AllowWindowsPlatformTypes.h"
|
|
# endif
|
|
# pragma push_macro("OVERRIDE")
|
|
# undef OVERRIDE // cef headers provide their own OVERRIDE macro
|
|
# include "include/cef_app.h"
|
|
# pragma pop_macro("OVERRIDE")
|
|
# if PLATFORM_WINDOWS
|
|
# include "HideWindowsPlatformTypes.h"
|
|
# endif
|
|
#endif
|
|
|
|
#if PLATFORM_MAC || PLATFORM_LINUX
|
|
# include <pthread.h>
|
|
#endif
|
|
|
|
#if PLATFORM_ANDROID
|
|
# include <Android/AndroidPlatformWebBrowser.h>
|
|
#elif PLATFORM_IOS
|
|
# include <IOS/IOSPlatformWebBrowser.h>
|
|
#endif
|
|
|
|
// Define some platform-dependent file locations
|
|
#if WITH_CEF3
|
|
# define CEF3_BIN_DIR TEXT("Binaries/ThirdParty/CEF3")
|
|
# if PLATFORM_WINDOWS && PLATFORM_64BITS
|
|
# define CEF3_RESOURCES_DIR CEF3_BIN_DIR TEXT("/Win64/Resources")
|
|
# define CEF3_SUBPROCES_EXE TEXT("Binaries/Win64/UnrealCEFSubProcess.exe")
|
|
# elif PLATFORM_WINDOWS && PLATFORM_32BITS
|
|
# define CEF3_RESOURCES_DIR CEF3_BIN_DIR TEXT("/Win32/Resources")
|
|
# define CEF3_SUBPROCES_EXE TEXT("Binaries/Win32/UnrealCEFSubProcess.exe")
|
|
# elif PLATFORM_MAC
|
|
# define CEF3_FRAMEWORK_DIR CEF3_BIN_DIR TEXT("/Mac/Chromium Embedded Framework.framework")
|
|
# define CEF3_RESOURCES_DIR CEF3_FRAMEWORK_DIR TEXT("/Resources")
|
|
# define CEF3_SUBPROCES_EXE TEXT("Binaries/Mac/UnrealCEFSubProcess.app/Contents/MacOS/UnrealCEFSubProcess")
|
|
# elif PLATFORM_LINUX // @todo Linux
|
|
# define CEF3_RESOURCES_DIR CEF3_BIN_DIR TEXT("/Linux/Resources")
|
|
# define CEF3_SUBPROCES_EXE TEXT("Binaries/Linux/UnrealCEFSubProcess")
|
|
# endif
|
|
#endif
|
|
|
|
namespace {
|
|
|
|
/**
|
|
* Helper function to set the current thread name, visible by the debugger.
|
|
* @param ThreadName Name to set
|
|
*/
|
|
void SetCurrentThreadName(char* ThreadName)
|
|
{
|
|
#if PLATFORM_MAC
|
|
pthread_setname_np(ThreadName);
|
|
#elif PLATFORM_LINUX
|
|
pthread_setname_np(pthread_self(), ThreadName);
|
|
#elif PLATFORM_WINDOWS && !PLATFORM_SEH_EXCEPTIONS_DISABLED
|
|
/**
|
|
* Code setting the thread name for use in the debugger.
|
|
* Copied implementation from WindowsRunnableThread as it is private.
|
|
*
|
|
* http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
|
|
*/
|
|
const uint32 MS_VC_EXCEPTION=0x406D1388;
|
|
|
|
struct THREADNAME_INFO
|
|
{
|
|
uint32 dwType; // Must be 0x1000.
|
|
LPCSTR szName; // Pointer to name (in user addr space).
|
|
uint32 dwThreadID; // Thread ID (-1=caller thread).
|
|
uint32 dwFlags; // Reserved for future use, must be zero.
|
|
};
|
|
|
|
THREADNAME_INFO ThreadNameInfo = {0x1000, ThreadName, -1, 0};
|
|
|
|
__try
|
|
{
|
|
RaiseException( MS_VC_EXCEPTION, 0, sizeof(ThreadNameInfo)/sizeof(ULONG_PTR), (ULONG_PTR*)&ThreadNameInfo );
|
|
}
|
|
__except( EXCEPTION_EXECUTE_HANDLER )
|
|
CA_SUPPRESS(6322)
|
|
{
|
|
}
|
|
#endif
|
|
}
|
|
|
|
#if PLATFORM_MAC
|
|
// OSX wants caches in a separate location from other app data
|
|
const TCHAR* ApplicationCacheDir()
|
|
{
|
|
static TCHAR Result[MAX_PATH] = TEXT("");
|
|
if (!Result[0])
|
|
{
|
|
SCOPED_AUTORELEASE_POOL;
|
|
NSString *CacheBaseDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex: 0];
|
|
NSString* BundleID = [[NSBundle mainBundle] bundleIdentifier];
|
|
if(!BundleID)
|
|
{
|
|
BundleID = [[NSProcessInfo processInfo] processName];
|
|
}
|
|
check(BundleID);
|
|
|
|
NSString* AppCacheDir = [CacheBaseDir stringByAppendingPathComponent: BundleID];
|
|
FPlatformString::CFStringToTCHAR((CFStringRef)AppCacheDir, Result);
|
|
}
|
|
return Result;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
FWebBrowserSingleton::FWebBrowserSingleton()
|
|
: bDevToolsShortcutEnabled(UE_BUILD_DEBUG)
|
|
{
|
|
#if WITH_CEF3
|
|
// The FWebBrowserSingleton must be initialized on the game thread
|
|
check(IsInGameThread());
|
|
|
|
// Provide CEF with command-line arguments.
|
|
#if PLATFORM_WINDOWS
|
|
CefMainArgs MainArgs(hInstance);
|
|
#else
|
|
CefMainArgs MainArgs;
|
|
#endif
|
|
|
|
bool bVerboseLogging = FParse::Param(FCommandLine::Get(), TEXT("cefverbose")) || FParse::Param(FCommandLine::Get(), TEXT("debuglog"));
|
|
// WebBrowserApp implements application-level callbacks.
|
|
WebBrowserApp = new FWebBrowserApp;
|
|
WebBrowserApp->OnRenderProcessThreadCreated().BindRaw(this, &FWebBrowserSingleton::HandleRenderProcessCreated);
|
|
|
|
// Specify CEF global settings here.
|
|
CefSettings Settings;
|
|
Settings.no_sandbox = true;
|
|
Settings.command_line_args_disabled = true;
|
|
|
|
FString CefLogFile(FPaths::Combine(*FPaths::GameLogDir(), TEXT("cef3.log")));
|
|
CefLogFile = FPaths::ConvertRelativePathToFull(CefLogFile);
|
|
CefString(&Settings.log_file) = *CefLogFile;
|
|
Settings.log_severity = bVerboseLogging ? LOGSEVERITY_VERBOSE : LOGSEVERITY_WARNING;
|
|
|
|
// Specify locale from our settings
|
|
FString LocaleCode = GetCurrentLocaleCode();
|
|
CefString(&Settings.locale) = *LocaleCode;
|
|
|
|
// Append engine version to the user agent string.
|
|
FString ProductVersion = FString::Printf( TEXT("%s UnrealEngine/%s"), FApp::GetGameName(), ENGINE_VERSION_STRING);
|
|
CefString(&Settings.product_version) = *ProductVersion;
|
|
|
|
// Enable on disk cache
|
|
#if PLATFORM_MAC
|
|
// OSX wants cache files in a special location
|
|
FString CachePath(FPaths::Combine(ApplicationCacheDir(), TEXT("webcache")));
|
|
#else
|
|
FString CachePath(FPaths::Combine(*FPaths::GameSavedDir(), TEXT("webcache")));
|
|
#endif
|
|
CachePath = FPaths::ConvertRelativePathToFull(CachePath);
|
|
CefString(&Settings.cache_path) = *CachePath;
|
|
|
|
// Specify path to resources
|
|
FString ResourcesPath(FPaths::Combine(*FPaths::EngineDir(), CEF3_RESOURCES_DIR));
|
|
ResourcesPath = FPaths::ConvertRelativePathToFull(ResourcesPath);
|
|
if (!FPaths::DirectoryExists(ResourcesPath))
|
|
{
|
|
UE_LOG(LogWebBrowser, Error, TEXT("Chromium Resources information not found at: %s."), *ResourcesPath);
|
|
}
|
|
CefString(&Settings.resources_dir_path) = *ResourcesPath;
|
|
|
|
#if !PLATFORM_MAC
|
|
// On Mac Chromium ignores custom locales dir. Files need to be stored in Resources folder in the app bundle
|
|
FString LocalesPath(FPaths::Combine(*ResourcesPath, TEXT("locales")));
|
|
LocalesPath = FPaths::ConvertRelativePathToFull(LocalesPath);
|
|
if (!FPaths::DirectoryExists(LocalesPath))
|
|
{
|
|
UE_LOG(LogWebBrowser, Error, TEXT("Chromium Locales information not found at: %s."), *LocalesPath);
|
|
}
|
|
CefString(&Settings.locales_dir_path) = *LocalesPath;
|
|
#endif
|
|
|
|
// Specify path to sub process exe
|
|
FString SubProcessPath(FPaths::Combine(*FPaths::EngineDir(), CEF3_SUBPROCES_EXE));
|
|
SubProcessPath = FPaths::ConvertRelativePathToFull(SubProcessPath);
|
|
if (!FPaths::FileExists(SubProcessPath))
|
|
{
|
|
UE_LOG(LogWebBrowser, Error, TEXT("UnrealCEFSubProcess.exe not found, check that this program has been built and is placed in: %s."), *SubProcessPath);
|
|
}
|
|
CefString(&Settings.browser_subprocess_path) = *SubProcessPath;
|
|
|
|
// Initialize CEF.
|
|
bool bSuccess = CefInitialize(MainArgs, Settings, WebBrowserApp.get(), nullptr);
|
|
check(bSuccess);
|
|
|
|
// Set the thread name back to GameThread.
|
|
SetCurrentThreadName(TCHAR_TO_ANSI( *(FName( NAME_GameThread ).GetPlainNameString()) ));
|
|
#endif
|
|
}
|
|
|
|
#if WITH_CEF3
|
|
void FWebBrowserSingleton::HandleRenderProcessCreated(CefRefPtr<CefListValue> ExtraInfo)
|
|
{
|
|
for (int32 Index = WindowInterfaces.Num() - 1; Index >= 0; --Index)
|
|
{
|
|
TSharedPtr<FWebBrowserWindow> BrowserWindow = WindowInterfaces[Index].Pin();
|
|
if (BrowserWindow.IsValid())
|
|
{
|
|
CefRefPtr<CefDictionaryValue> Bindings = BrowserWindow->GetProcessInfo();
|
|
if (Bindings.get())
|
|
{
|
|
ExtraInfo->SetDictionary(ExtraInfo->GetSize(), Bindings);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
FWebBrowserSingleton::~FWebBrowserSingleton()
|
|
{
|
|
#if WITH_CEF3
|
|
// Force all existing browsers to close in case any haven't been deleted
|
|
for (int32 Index = 0; Index < WindowInterfaces.Num(); ++Index)
|
|
{
|
|
auto BrowserWindow = WindowInterfaces[Index].Pin();
|
|
if (BrowserWindow.IsValid() && BrowserWindow->IsValid())
|
|
{
|
|
// Call CloseBrowser directly on the Host object as FWebBrowserWindow::CloseBrowser is delayed
|
|
BrowserWindow->InternalCefBrowser->GetHost()->CloseBrowser(true);
|
|
}
|
|
}
|
|
|
|
// Just in case, although we deallocate WebBrowserApp right after this.
|
|
WebBrowserApp->OnRenderProcessThreadCreated().Unbind();
|
|
// CefRefPtr takes care of delete
|
|
WebBrowserApp = nullptr;
|
|
// Shut down CEF.
|
|
CefShutdown();
|
|
|
|
#endif
|
|
}
|
|
|
|
TSharedPtr<IWebBrowserWindow> FWebBrowserSingleton::CreateBrowserWindow(
|
|
TSharedPtr<FWebBrowserWindow>& BrowserWindowParent,
|
|
TSharedPtr<FWebBrowserWindowInfo>& BrowserWindowInfo
|
|
)
|
|
{
|
|
#if WITH_CEF3
|
|
|
|
TOptional<FString> ContentsToLoad;
|
|
|
|
bool bShowErrorMessage = BrowserWindowParent->IsShowingErrorMessages();
|
|
bool bThumbMouseButtonNavigation = BrowserWindowParent->IsThumbMouseButtonNavigationEnabled();
|
|
bool bUseTransparency = BrowserWindowParent->UseTransparency();
|
|
FString InitialURL = BrowserWindowInfo->Browser->GetMainFrame()->GetURL().ToWString().c_str();
|
|
TSharedPtr<FWebBrowserWindow> NewBrowserWindow(new FWebBrowserWindow(BrowserWindowInfo->Browser, BrowserWindowInfo->Handler, InitialURL, ContentsToLoad, bShowErrorMessage, bThumbMouseButtonNavigation, bUseTransparency));
|
|
BrowserWindowInfo->Handler->SetBrowserWindow(NewBrowserWindow);
|
|
|
|
WindowInterfaces.Add(NewBrowserWindow);
|
|
return NewBrowserWindow;
|
|
#endif
|
|
return nullptr;
|
|
}
|
|
|
|
TSharedPtr<IWebBrowserWindow> FWebBrowserSingleton::CreateBrowserWindow(
|
|
void* OSWindowHandle,
|
|
FString InitialURL,
|
|
bool bUseTransparency,
|
|
bool bThumbMouseButtonNavigation,
|
|
TOptional<FString> ContentsToLoad,
|
|
bool ShowErrorMessage,
|
|
FColor BackgroundColor)
|
|
{
|
|
#if WITH_CEF3
|
|
static bool AllowCEF = !FParse::Param(FCommandLine::Get(), TEXT("nocef"));
|
|
if (AllowCEF)
|
|
{
|
|
// Information used when creating the native window.
|
|
CefWindowInfo WindowInfo;
|
|
|
|
// Specify CEF browser settings here.
|
|
CefBrowserSettings BrowserSettings;
|
|
|
|
// Set max framerate to maximum supported.
|
|
BrowserSettings.background_color = CefColorSetARGB(BackgroundColor.A, BackgroundColor.R, BackgroundColor.G, BackgroundColor.B);
|
|
|
|
// Disable plugins
|
|
BrowserSettings.plugins = STATE_DISABLED;
|
|
|
|
|
|
#if PLATFORM_WINDOWS
|
|
// Create the widget as a child window on whindows when passing in a parent window
|
|
if (OSWindowHandle != nullptr)
|
|
{
|
|
RECT ClientRect = { 0, 0, 0, 0 };
|
|
WindowInfo.SetAsChild((CefWindowHandle)OSWindowHandle, ClientRect);
|
|
}
|
|
else
|
|
#endif
|
|
{
|
|
// Use off screen rendering so we can integrate with our windows
|
|
WindowInfo.SetAsWindowless(nullptr, bUseTransparency);
|
|
BrowserSettings.windowless_frame_rate = 24;
|
|
}
|
|
|
|
|
|
// WebBrowserHandler implements browser-level callbacks.
|
|
CefRefPtr<FWebBrowserHandler> NewHandler(new FWebBrowserHandler(bUseTransparency));
|
|
|
|
// Create the CEF browser window.
|
|
CefRefPtr<CefBrowser> Browser = CefBrowserHost::CreateBrowserSync(WindowInfo, NewHandler.get(), *InitialURL, BrowserSettings, nullptr);
|
|
if (Browser.get())
|
|
{
|
|
// Create new window
|
|
TSharedPtr<FWebBrowserWindow> NewBrowserWindow(new FWebBrowserWindow(Browser, NewHandler, InitialURL, ContentsToLoad, ShowErrorMessage, bThumbMouseButtonNavigation, bUseTransparency));
|
|
NewHandler->SetBrowserWindow(NewBrowserWindow);
|
|
|
|
WindowInterfaces.Add(NewBrowserWindow);
|
|
return NewBrowserWindow;
|
|
}
|
|
}
|
|
#elif PLATFORM_ANDROID || PLATFORM_IOS
|
|
// Create new window
|
|
TSharedPtr<FWebBrowserWindow> NewBrowserWindow = MakeShareable(new FWebBrowserWindow(InitialURL, ContentsToLoad, ShowErrorMessage, bThumbMouseButtonNavigation, bUseTransparency));
|
|
|
|
//WindowInterfaces.Add(NewBrowserWindow);
|
|
return NewBrowserWindow;
|
|
#endif
|
|
return nullptr;
|
|
}
|
|
|
|
bool FWebBrowserSingleton::Tick(float DeltaTime)
|
|
{
|
|
#if WITH_CEF3
|
|
bool bIsSlateAwake = !FSlateApplication::Get().IsSlateAsleep();
|
|
// Remove any windows that have been deleted and check wether it's currently visible
|
|
for (int32 Index = WindowInterfaces.Num() - 1; Index >= 0; --Index)
|
|
{
|
|
if (!WindowInterfaces[Index].IsValid())
|
|
{
|
|
WindowInterfaces.RemoveAt(Index);
|
|
}
|
|
else if (bIsSlateAwake) // only check for Tick activity if Slate is currently ticking
|
|
{
|
|
TSharedPtr<FWebBrowserWindow> BrowserWindow = WindowInterfaces[Index].Pin();
|
|
if(BrowserWindow.IsValid())
|
|
{
|
|
// Test if we've ticked recently. If not assume the browser window has become hidden.
|
|
BrowserWindow->CheckTickActivity();
|
|
}
|
|
}
|
|
}
|
|
CefDoMessageLoopWork();
|
|
#endif
|
|
return true;
|
|
}
|
|
|
|
FString FWebBrowserSingleton::GetCurrentLocaleCode()
|
|
{
|
|
FCultureRef Culture = FInternationalization::Get().GetCurrentCulture();
|
|
FString LocaleCode = Culture->GetTwoLetterISOLanguageName();
|
|
FString Country = Culture->GetRegion();
|
|
if (!Country.IsEmpty())
|
|
{
|
|
LocaleCode = LocaleCode + TEXT("-") + Country;
|
|
}
|
|
return LocaleCode;
|
|
}
|
|
|
|
#if WITH_CEF3
|
|
namespace
|
|
{
|
|
// Task for executing a callback on a given thread.
|
|
class FDeleteCookiesNotificationTask
|
|
: public CefTask
|
|
{
|
|
TFunction<void (int)> Callback;
|
|
int Value;
|
|
public:
|
|
FDeleteCookiesNotificationTask(const TFunction<void (int)>& InCallback, int InValue)
|
|
: Callback(InCallback)
|
|
, Value(InValue)
|
|
{}
|
|
|
|
virtual void Execute() override
|
|
{
|
|
Callback(Value);
|
|
}
|
|
|
|
IMPLEMENT_REFCOUNTING(FDeleteCookiesNotificationTask);
|
|
|
|
};
|
|
|
|
// Callback that will invoke the callback with the result on the UI thread.
|
|
class FDeleteCookiesFunctionCallback
|
|
: public CefDeleteCookiesCallback
|
|
{
|
|
TFunction<void (int)> Callback;
|
|
public:
|
|
FDeleteCookiesFunctionCallback(const TFunction<void (int)>& InCallback)
|
|
: Callback(InCallback)
|
|
{}
|
|
|
|
virtual void OnComplete(int NumDeleted) override
|
|
{
|
|
// We're on the IO thread, so we'll have to schedule the callback on the main thread
|
|
CefPostTask(TID_UI, new FDeleteCookiesNotificationTask(Callback, NumDeleted));
|
|
}
|
|
|
|
IMPLEMENT_REFCOUNTING(FDeleteCookiesFunctionCallback);
|
|
};
|
|
}
|
|
#endif
|
|
|
|
void FWebBrowserSingleton::DeleteBrowserCookies(FString URL, FString CookieName, TFunction<void (int)> Completed)
|
|
{
|
|
#if WITH_CEF3
|
|
CefRefPtr<FDeleteCookiesFunctionCallback> Callback = Completed ? new FDeleteCookiesFunctionCallback(Completed) : nullptr;
|
|
CefCookieManager::GetGlobalManager(nullptr)->DeleteCookies(*URL, *CookieName, Callback);
|
|
#endif
|
|
}
|
|
|
|
|
|
// Cleanup macros to avoid having them leak outside this source file
|
|
#undef CEF3_BIN_DIR
|
|
#undef CEF3_FRAMEWORK_DIR
|
|
#undef CEF3_RESOURCES_DIR
|
|
#undef CEF3_SUBPROCES_EXE
|