CEFWebInterfaceBrowserDialog.h
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Engine/Source/Runtime/WebBrowser/Private/CEF/CEFWebBrowserDialog.h
#pragma once
#include "CoreMinimal.h"
#include "Misc/AssertionMacros.h"
#include "Internationalization/Text.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
#if PLATFORM_APPLE
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#endif
# include "include/cef_jsdialog_handler.h"
#if PLATFORM_APPLE
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#endif
#pragma pop_macro("OVERRIDE")
#if PLATFORM_WINDOWS
# include "Windows/HideWindowsPlatformTypes.h"
#endif
#include "IWebInterfaceBrowserDialog.h"
class FCEFWebInterfaceBrowserDialog
: public IWebInterfaceBrowserDialog
{
public:
virtual ~FCEFWebInterfaceBrowserDialog()
{}
// IWebBrowserDialog interface:
virtual EWebInterfaceBrowserDialogType GetType() override
{
return Type;
}
virtual const FText& GetMessageText() override
{
return MessageText;
}
virtual const FText& GetDefaultPrompt() override
{
return DefaultPrompt;
}
virtual bool IsReload() override
{
check(Type == EWebInterfaceBrowserDialogType::Unload);
return bIsReload;
}
virtual void Continue(bool Success = true, const FText& UserResponse = FText::GetEmpty()) override
{
check(Type == EWebInterfaceBrowserDialogType::Prompt || UserResponse.IsEmpty());
Callback->Continue(Success, TCHAR_TO_WCHAR(*UserResponse.ToString()));
}
private:
EWebInterfaceBrowserDialogType Type;
FText MessageText;
FText DefaultPrompt;
bool bIsReload;
CefRefPtr<CefJSDialogCallback> Callback;
// Create a dialog from OnJSDialog arguments
FCEFWebInterfaceBrowserDialog(CefJSDialogHandler::JSDialogType InDialogType, const CefString& InMessageText, const CefString& InDefaultPrompt, CefRefPtr<CefJSDialogCallback> InCallback)
: Type((EWebInterfaceBrowserDialogType)InDialogType)
, MessageText(FText::FromString(WCHAR_TO_TCHAR(InMessageText.ToWString().c_str())))
, DefaultPrompt(FText::FromString(WCHAR_TO_TCHAR(InDefaultPrompt.ToWString().c_str())))
, bIsReload(false)
, Callback(InCallback)
{}
// Create a dialog from OnBeforeUnloadDialog arguments
FCEFWebInterfaceBrowserDialog(const CefString& InMessageText, bool InIsReload, CefRefPtr<CefJSDialogCallback> InCallback)
: Type(EWebInterfaceBrowserDialogType::Unload)
, MessageText(FText::FromString(WCHAR_TO_TCHAR(InMessageText.ToWString().c_str())))
, DefaultPrompt(FText::GetEmpty())
, bIsReload(InIsReload)
, Callback(InCallback)
{};
friend class FCEFWebInterfaceBrowserWindow;
};
typedef FCEFWebInterfaceBrowserDialog FWebInterfaceBrowserDialog;
#endif