-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuCefUiBrowserProcessMessageReceiverCommon.pas
79 lines (69 loc) · 2.21 KB
/
uCefUiBrowserProcessMessageReceiverCommon.pas
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
unit uCefUIBrowserProcessMessageReceiverCommon;
interface
uses
System.SysUtils, System.Generics.Collections, System.Classes,
//
uCEFApplication, uCefTypes, uCefInterfaces, uCefChromium,
//
uCefUIBrowserProcessMessageReceiver
;
type
TCefUIBrowserProcessMessageReceiverCommon = class(TCefUIBrowserProcessMessageReceiver)
protected
procedure Receive(Sender: TObject; const ABrowser: ICefBrowser;
ASourceProcess: TCefProcessId; const AMessage: ICefProcessMessage;
out AResult: Boolean); override;
public
constructor Create;
end;
implementation
uses
uCEFProcessMessage, uCEFMiscFunctions,
//
uCefUtilConst, uCefWaitEventList, uCefUtilFunc, uCefUIFunc;
{ TCefUIBrowserProcessMessageReceiverCommon }
constructor TCefUIBrowserProcessMessageReceiverCommon.Create;
begin
inherited Create(MYAPP_CEF_MESSAGE_NAME)
end;
procedure TCefUIBrowserProcessMessageReceiverCommon.Receive(Sender: TObject;
const ABrowser: ICefBrowser; ASourceProcess: TCefProcessId;
const AMessage: ICefProcessMessage; out AResult: Boolean);
var
arg: ICefListValue;
event: TCefWaitEventItem;
eventId: Integer;
z: string;
begin
AResult := False;
arg := AMessage.ArgumentList;
if arg.GetType(IDX_TYPE) = VTYPE_INT then
begin
AResult := True;
case arg.GetInt(IDX_TYPE) of
VAL_CLICK_XY: CefUIFocusClickAndCallbackAsync(False, ABrowser, arg);
VAL_FOCUSCLICK_XY: CefUIFocusClickAndCallbackAsync(True, ABrowser, arg);
VAL_KEY_PRESS: CefUIKeyPressAsync(ABrowser, arg);
else
AResult := False;
end;
end
else
begin
z := 'msgRecv:' + AMessage.Name + ' ';
eventId := arg.GetInt(IDX_EVENT);
z := z + 'bid:' + ABrowser.Identifier.ToString + ' eid:' + IntToStr(eventId) + ' ';
event := CefWaitEventGet(eventId);
if Assigned(event) then
begin
z := z + 'tick:' + IntToStr(event.TickDif()) + ' res:' + CefListValueToJsonStr(arg);
event.Res := arg.Copy();
event.Event.SetEvent();
AResult := True;
end;
CefLog('frame', 138, 1, z);
end;
end;
initialization
CefUIBrowserProcessMessageReceiverAdd(TCefUIBrowserProcessMessageReceiverCommon.Create())
end.