-
Notifications
You must be signed in to change notification settings - Fork 78
/
unV8Extension.pas
74 lines (58 loc) · 1.87 KB
/
unV8Extension.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
unit unV8Extension;
{$I cef.inc}
interface
uses
uCEFInterfaces, uCEFProcessMessage, uCEFv8Context, uCEFTypes, unConfig,
Generics.Collections, Windows,SysUtils;
type
TV8Extension = class
// 显示窗口
class procedure show(url: string; width: Integer; height: Integer);
// modal显示窗口
class procedure showmodal(url: string; width: Integer; height: Integer);
// 关闭窗口
class procedure closeWin();
// 向其它窗口发送消息
class procedure sendMsg(aMsg,aFrameName: string);
end;
implementation
{ TV8Extension }
class procedure TV8Extension.closeWin;
var
msg: ICefProcessMessage;
begin
msg := TCefProcessMessageRef.New(YS_BROWSER_EXTENSION_CLOSEWIN);
TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg);
end;
class procedure TV8Extension.sendMsg(aMsg,aFrameName: string);
var
processIDList: TList<DWORD>;
i: Integer;
msg: ICefProcessMessage;
begin
msg := TCefProcessMessageRef.New(YS_BROWSER_EXTENSION_WINDOW_MSG);
msg.ArgumentList.SetString(0, aMsg);
msg.ArgumentList.SetString(1, aFrameName);
TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg);
end;
class procedure TV8Extension.show(url: string; width: Integer; height: Integer);
var
msg: ICefProcessMessage;
begin
msg := TCefProcessMessageRef.New(YS_BROWSER_EXTENSION_SHOW);
msg.ArgumentList.SetString(0, url);
msg.ArgumentList.SetInt(1, width);
msg.ArgumentList.SetInt(2, height);
TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg);
end;
class procedure TV8Extension.showmodal(url: string; width: Integer; height: Integer);
var
msg: ICefProcessMessage;
begin
msg := TCefProcessMessageRef.New(YS_BROWSER_EXTENSION_SHOWMODAL);
msg.ArgumentList.SetString(0, url);
msg.ArgumentList.SetInt(1, width);
msg.ArgumentList.SetInt(2, height);
TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg);
end;
end.