/** * WinMain, called when the application is started */ int WINAPI WinMain( _In_ HINSTANCE hInInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR, _In_ int nCmdShow ) { #if WITH_CEF3 // Structure for passing command-line arguments. // The definition of this structure is platform-specific. CefMainArgs MainArgs(hInInstance); return RunCEFSubProcess(MainArgs); #else return 0; #endif }
FWebBrowserSingleton::FWebBrowserSingleton() { #if WITH_CEF3 // Provide CEF with command-line arguments. #if PLATFORM_WINDOWS CefMainArgs MainArgs(hInstance); #elif PLATFORM_MAC || PLATFORM_LINUX //TArray<FString> Args; //int ArgCount = GSavedCommandLine.ParseIntoArray(Args, TEXT(" "), true); CefMainArgs MainArgs(0, nullptr); #endif // 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; // Specify locale from our settings FString LocaleCode = GetCurrentLocaleCode(); CefString(&Settings.locale) = *LocaleCode; // Specify path to resources #if PLATFORM_WINDOWS #if PLATFORM_64BITS FString ResourcesPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/ThirdParty/CEF3/Win64/Resources"))); FString LocalesPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/ThirdParty/CEF3/Win64/Resources/locales"))); #else FString ResourcesPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/ThirdParty/CEF3/Win32/Resources"))); FString LocalesPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/ThirdParty/CEF3/Win32/Resources/locales"))); #endif #elif PLATFORM_MAC FString ResourcesPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/ThirdParty/CEF3/Mac/Chromium Embedded Framework.framework/Resources"))); #elif PLATFORM_LINUX // @todo Linux FString ResourcesPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/ThirdParty/CEF3/Linux/Resources"))); FString LocalesPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/ThirdParty/CEF3/Linux/Resources/locales"))); #endif #if !PLATFORM_MAC // On Mac Chromium ignores custom locales dir. Files need to be stored in Resources folder in the app bundle 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 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; // Specify path to sub process exe #if PLATFORM_WINDOWS #if PLATFORM_64BITS FString SubProcessPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/Win64/UnrealCEFSubProcess.exe"))); #else FString SubProcessPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/Win32/UnrealCEFSubProcess.exe"))); #endif #elif PLATFORM_MAC FString SubProcessPath(FPaths::Combine(*FPaths::EngineDir(), TEXT("Binaries/Mac/UnrealCEFSubProcess.app/Contents/MacOS/UnrealCEFSubProcess"))); #else // @todo Linux FString SubProcessPath(TEXT("UnrealCEFSubProcess")); #endif 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); #endif }
Args(Plugin *parent = 0, const MainArgs ma = MainArgs()) : pParentPlg(parent), margs(ma) { clog << "plg::Args(" << (int)pParentPlg << ", ...)\n" << flush; }