UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CEFJSScripting.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6
7#if WITH_CEF3
8#include "WebJSFunction.h"
9#include "WebJSScripting.h"
10
11#if PLATFORM_WINDOWS
14#endif
15#pragma push_macro("OVERRIDE")
16#undef OVERRIDE // cef headers provide their own OVERRIDE macro
18#if PLATFORM_APPLE
20#endif
21#include "include/cef_client.h"
22#include "include/cef_values.h"
23#if PLATFORM_APPLE
25#endif
27#pragma pop_macro("OVERRIDE")
28#if PLATFORM_WINDOWS
31#endif
32#endif
33
34class Error;
35class FWebJSScripting;
36struct FWebJSParam;
37
38#if WITH_CEF3
39
44 : public FWebJSScripting
45 , public TSharedFromThis<FCEFJSScripting>
46{
47public:
48 FCEFJSScripting(CefRefPtr<CefBrowser> Browser, bool bJSBindingToLoweringEnabled)
49 : FWebJSScripting(bJSBindingToLoweringEnabled)
51 {}
52
53 void UnbindCefBrowser();
54
55 virtual void BindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true) override;
56 virtual void UnbindUObject(const FString& Name, UObject* Object = nullptr, bool bIsPermanent = true) override;
57
67
75
76 CefRefPtr<CefDictionaryValue> ConvertStruct(UStruct* TypeInfo, const void* StructPtr);
78
79 // Works for CefListValue and CefDictionaryValues
80 template<typename ContainerType, typename KeyType>
82 {
83 switch (Param.Tag)
84 {
86 return Container->SetNull(Key);
88 return Container->SetBool(Key, Param.BoolValue);
90 return Container->SetDouble(Key, Param.DoubleValue);
92 return Container->SetInt(Key, Param.IntValue);
94 {
96 return Container->SetString(Key, ConvertedString);
97 }
99 {
100 if (Param.ObjectValue == nullptr)
101 {
102 return Container->SetNull(Key);
103 }
104 else
105 {
107 return Container->SetDictionary(Key, ConvertedObject);
108 }
109 }
111 {
113 return Container->SetDictionary(Key, ConvertedStruct);
114 }
116 {
117 CefRefPtr<CefListValue> ConvertedArray = CefListValue::Create();
118 for(int i=0; i < Param.ArrayValue->Num(); ++i)
119 {
120 SetConverted(ConvertedArray, i, (*Param.ArrayValue)[i]);
121 }
122 return Container->SetList(Key, ConvertedArray);
123 }
125 {
126 CefRefPtr<CefDictionaryValue> ConvertedMap = CefDictionaryValue::Create();
127 for(auto& Pair : *Param.MapValue)
128 {
129 SetConverted(ConvertedMap, TCHAR_TO_WCHAR(*Pair.Key), Pair.Value);
130 }
131 return Container->SetDictionary(Key, ConvertedMap);
132 }
133 default:
134 return false;
135 }
136 }
137
139
140 void InvokeJSFunction(FGuid FunctionId, int32 ArgCount, FWebJSParam Arguments[], bool bIsError=false) override;
142 void InvokeJSErrorResult(FGuid FunctionId, const FString& Error) override;
143
144private:
146
147 bool IsValid()
148 {
149 return InternalCefBrowser.get() != nullptr;
150 }
151
154 bool HandleExecuteUObjectMethodMessage(CefRefPtr<CefListValue> MessageArguments);
156
159};
160
161#endif
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define THIRD_PARTY_INCLUDES_START
Definition GenericPlatformCompilerPreSetup.h:63
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define TCHAR_TO_WCHAR(str)
Definition StringConv.h:1092
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition UnrealType.h:174
Definition WebJSScripting.h:17
virtual void InvokeJSErrorResult(FGuid FunctionId, const FString &Error)=0
virtual void InvokeJSFunction(FGuid FunctionId, int32 ArgCount, FWebJSParam Arguments[], bool bIsError=false)=0
virtual void UnbindUObject(const FString &Name, UObject *Object=nullptr, bool bIsPermanent=true)=0
virtual void BindUObject(const FString &Name, UObject *Object, bool bIsPermanent=true)=0
UE_REWRITE SizeType Num() const
Definition Array.h:1144
Definition SharedPointer.h:1640
Definition Object.h:95
Definition Class.h:480
Definition Voronoi.cpp:10
U16 Index
Definition radfft.cpp:71
Definition Guid.h:109
virtual const void * GetData()=0
virtual UStruct * GetTypeInfo()=0
Definition WebJSFunction.h:26
bool BoolValue
Definition WebJSFunction.h:118
UObject * ObjectValue
Definition WebJSFunction.h:121
IStructWrapper * StructValue
Definition WebJSFunction.h:123
int32 IntValue
Definition WebJSFunction.h:120
double DoubleValue
Definition WebJSFunction.h:119
enum FWebJSParam::@2456 Tag
const FString * StringValue
Definition WebJSFunction.h:122
TArray< FWebJSParam > * ArrayValue
Definition WebJSFunction.h:124
@ PTYPE_OBJECT
Definition WebJSFunction.h:115
@ PTYPE_MAP
Definition WebJSFunction.h:115
@ PTYPE_DOUBLE
Definition WebJSFunction.h:115
@ PTYPE_STRING
Definition WebJSFunction.h:115
@ PTYPE_BOOL
Definition WebJSFunction.h:115
@ PTYPE_STRUCT
Definition WebJSFunction.h:115
@ PTYPE_INT
Definition WebJSFunction.h:115
@ PTYPE_ARRAY
Definition WebJSFunction.h:115
@ PTYPE_NULL
Definition WebJSFunction.h:115