You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Update frameworks with a Framework mode to differentiate between linking with it and copying to .app (in case of a static lib framework, or load-only dylib - Updated CEF3 to work as a normal framework (if we have a universal framework binary, it would be simpler, because LoadInMain() would work without any paths) #rb roman.dzieciol #preflight 643484117536ac6b78ae7ce3 [CL 24985043 by Josh Adams in ue5-main branch]
115 lines
2.8 KiB
C++
115 lines
2.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "WebBrowserModule.h"
|
|
#include "WebBrowserLog.h"
|
|
#include "WebBrowserSingleton.h"
|
|
#include "Misc/App.h"
|
|
#include "Misc/EngineVersion.h"
|
|
#include "Misc/Paths.h"
|
|
#if WITH_CEF3
|
|
# include "CEF3Utils.h"
|
|
# if PLATFORM_MAC
|
|
# include "include/wrapper/cef_library_loader.h"
|
|
# endif
|
|
#endif
|
|
|
|
DEFINE_LOG_CATEGORY(LogWebBrowser);
|
|
|
|
static FWebBrowserSingleton* WebBrowserSingleton = nullptr;
|
|
|
|
FWebBrowserInitSettings::FWebBrowserInitSettings()
|
|
: ProductVersion(FString::Printf(TEXT("%s/%s UnrealEngine/%s Chrome/90.0.4430.212"), FApp::GetProjectName(), FApp::GetBuildVersion(), *FEngineVersion::Current().ToString()))
|
|
{
|
|
}
|
|
|
|
class FWebBrowserModule : public IWebBrowserModule
|
|
{
|
|
private:
|
|
// IModuleInterface Interface
|
|
virtual void StartupModule() override;
|
|
virtual void ShutdownModule() override;
|
|
|
|
public:
|
|
virtual bool IsWebModuleAvailable() const override;
|
|
virtual IWebBrowserSingleton* GetSingleton() override;
|
|
virtual bool CustomInitialize(const FWebBrowserInitSettings& WebBrowserInitSettings) override;
|
|
|
|
private:
|
|
#if WITH_CEF3
|
|
bool bLoadedCEFModule = false;
|
|
#if PLATFORM_MAC
|
|
// Dynamically load the CEF framework library.
|
|
CefScopedLibraryLoader *CEFLibraryLoader = nullptr;
|
|
#endif
|
|
#endif
|
|
};
|
|
|
|
IMPLEMENT_MODULE( FWebBrowserModule, WebBrowser );
|
|
|
|
void FWebBrowserModule::StartupModule()
|
|
{
|
|
#if WITH_CEF3
|
|
if (!IsRunningCommandlet())
|
|
{
|
|
CEF3Utils::BackupCEF3Logfile(FPaths::ProjectLogDir());
|
|
}
|
|
bLoadedCEFModule = CEF3Utils::LoadCEF3Modules(true);
|
|
#if PLATFORM_MAC
|
|
// Dynamically load the CEF framework library into this dylibs memory space.
|
|
// CEF now loads function pointers at runtime so we need this to be dylib specific.
|
|
CEFLibraryLoader = new CefScopedLibraryLoader();
|
|
if (!CEFLibraryLoader->LoadInMain(TCHAR_TO_ANSI(*CEF3Utils::GetCEF3ModulePath())))
|
|
{
|
|
UE_LOG(LogWebBrowser, Error, TEXT("Chromium loader initialization failed"));
|
|
}
|
|
#endif // PLATFORM_MAC
|
|
#endif
|
|
}
|
|
|
|
void FWebBrowserModule::ShutdownModule()
|
|
{
|
|
if (WebBrowserSingleton != nullptr)
|
|
{
|
|
delete WebBrowserSingleton;
|
|
WebBrowserSingleton = nullptr;
|
|
}
|
|
|
|
#if WITH_CEF3
|
|
CEF3Utils::UnloadCEF3Modules();
|
|
#if PLATFORM_MAC
|
|
delete CEFLibraryLoader;
|
|
CEFLibraryLoader = nullptr;
|
|
#endif // PLATFORM_MAC
|
|
#endif
|
|
}
|
|
|
|
bool FWebBrowserModule::CustomInitialize(const FWebBrowserInitSettings& WebBrowserInitSettings)
|
|
{
|
|
if (WebBrowserSingleton == nullptr)
|
|
{
|
|
WebBrowserSingleton = new FWebBrowserSingleton(WebBrowserInitSettings);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
IWebBrowserSingleton* FWebBrowserModule::GetSingleton()
|
|
{
|
|
if (WebBrowserSingleton == nullptr)
|
|
{
|
|
WebBrowserSingleton = new FWebBrowserSingleton(FWebBrowserInitSettings());
|
|
}
|
|
return WebBrowserSingleton;
|
|
}
|
|
|
|
|
|
bool FWebBrowserModule::IsWebModuleAvailable() const
|
|
{
|
|
#if WITH_CEF3
|
|
return bLoadedCEFModule;
|
|
#else
|
|
return true;
|
|
#endif
|
|
}
|
|
|