2021-03-09 15:32:23 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2015-06-25 16:56:38 -04:00
|
|
|
|
2021-03-09 01:37:10 -04:00
|
|
|
#include "EpicWebHelperCallbackRegistry.h"
|
|
|
|
|
#include "EpicWebHelper.h"
|
2015-06-25 16:56:38 -04:00
|
|
|
|
2015-07-08 18:54:20 -04:00
|
|
|
#if WITH_CEF3
|
|
|
|
|
|
2021-03-09 01:37:10 -04:00
|
|
|
FGuid FEpicWebHelperCallbackRegistry::FindOrAdd(CefRefPtr<CefV8Context> Context, CefRefPtr<CefV8Value> Object, CefRefPtr<CefV8Value> Function, CefRefPtr<CefV8Value> OnError, bool bOneShot)
|
2015-06-25 16:56:38 -04:00
|
|
|
{
|
|
|
|
|
if (! bOneShot)
|
|
|
|
|
{
|
|
|
|
|
for(auto Iter = CreateIterator(); Iter; ++Iter)
|
|
|
|
|
{
|
|
|
|
|
auto Value = Iter.Value();
|
|
|
|
|
if (! Value.bOneShot
|
|
|
|
|
&& Context->IsSame(Value.Context)
|
|
|
|
|
&& Function->IsSame(Value.Function)
|
2016-11-21 20:27:58 -05:00
|
|
|
&& ( ((Object == nullptr) && (Value.Object == nullptr)) || Object->IsSame(Value.Object))
|
|
|
|
|
&& ( ((OnError == nullptr) && (Value.OnError == nullptr)) || OnError->IsSame(Value.OnError)))
|
2015-06-25 16:56:38 -04:00
|
|
|
{
|
|
|
|
|
return Iter.Key();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If not found or one-shot, add new entry to the map
|
|
|
|
|
FGuid Guid = FGuid::NewGuid();
|
2021-03-09 01:37:10 -04:00
|
|
|
Add(Guid, FEpicWebHelperCallbackRegistryEntry(Context, Object, Function, OnError, bOneShot));
|
2015-06-25 16:56:38 -04:00
|
|
|
return Guid;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-09 01:37:10 -04:00
|
|
|
void FEpicWebHelperCallbackRegistry::RemoveByContext(CefRefPtr<CefV8Context> Context)
|
2015-06-25 16:56:38 -04:00
|
|
|
{
|
|
|
|
|
for(auto Iter = CreateIterator(); Iter; ++Iter)
|
|
|
|
|
{
|
|
|
|
|
if (Context->IsSame(Iter.Value().Context))
|
|
|
|
|
{
|
|
|
|
|
Iter.RemoveCurrent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-08 18:54:20 -04:00
|
|
|
|
|
|
|
|
#endif // WITH_CEF3
|