CEFInterfaceBrowserClosureTask.h 1.2 KB
// Engine/Source/Runtime/WebBrowser/Private/CEF/CEFBrowserClosureTask.h

#pragma once

#include "CoreMinimal.h"

#if WITH_CEF3

#if PLATFORM_WINDOWS
	#include "Windows/AllowWindowsPlatformTypes.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/cef_task.h"
THIRD_PARTY_INCLUDES_END
#if PLATFORM_APPLE
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#endif
#pragma pop_macro("OVERRIDE")

#if PLATFORM_LINUX
typedef CefBase CefBaseRefCounted;
#endif

#if PLATFORM_WINDOWS
	#include "Windows/HideWindowsPlatformTypes.h"
#endif

// Helper for posting a closure as a task
class FCEFInterfaceBrowserClosureTask
	: public CefTask
{
public:
	FCEFInterfaceBrowserClosureTask(CefRefPtr<CefBaseRefCounted> InHandle, TFunction<void ()> InClosure)
		: Handle(InHandle)
		, Closure(InClosure)
	{ }

	virtual void Execute() override
	{
		Closure();
	}

private:
	CefRefPtr<CefBaseRefCounted> Handle; // Used so the handler will not go out of scope before the closure is executed.
	TFunction<void ()> Closure;
	IMPLEMENT_REFCOUNTING(FCEFInterfaceBrowserClosureTask);
};


#endif /* WITH_CEF3 */