-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuCefScriptNavBase.pas
99 lines (82 loc) · 2.04 KB
/
uCefScriptNavBase.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
unit uCefScriptNavBase;
interface
uses
System.Classes, System.SysUtils, System.SyncObjs,
//
uReLog3, uLoggerInterface,
//
uCefScriptBase, uCefWebActionBase, uCefWebAction;
const
NAV_TIMEOUT_DEF = 60;
type
TCefScriptNavBase = class abstract(TCefScriptBase)
private
protected
FSetIsNav: Boolean;
FDoStop: Boolean;
FAction: TCefWebAction;
procedure Nav(const AUrl: string);
function DoStartEvent: Boolean; override;
function DoNavEvent(const AWebAction: TCefWebAction): Boolean; virtual; abstract;
public
constructor Create(const AActionName: string; const ASetAsNav: Boolean;
const AParent: TCefScriptBase);
destructor Destroy; override;
procedure AfterConstruction; override;
function Wait:TWaitResult; override;
procedure Abort; override;
end;
implementation
uses
//
uStringUtils
;
{ TCefScriptNavBase }
constructor TCefScriptNavBase.Create(const AActionName: string; const ASetAsNav: Boolean;
const AParent: TCefScriptBase);
begin
inherited Create(AActionName, AParent);
FSetIsNav := ASetAsNav
end;
destructor TCefScriptNavBase.Destroy;
begin
FAction.Free;
inherited;
end;
procedure TCefScriptNavBase.AfterConstruction;
begin
inherited;
FAction := TCefWebAction.Create('wa', FLogger, Chromium, NAV_TIMEOUT_DEF, FAbortEvent, DoNavEvent);
end;
procedure TCefScriptNavBase.Abort;
begin
inherited;
FAction.Abort();
end;
function TCefScriptNavBase.DoStartEvent: Boolean;
begin
if FSetIsNav then
begin
FAction.IsNavigate := True;
FDoStop := True;
end;
if FDoStop then
begin
DoNavStop();
end;
Result := FAction.Start()
end;
procedure TCefScriptNavBase.Nav(const AUrl: string);
begin
LogInfo('navigate ' + AUrl);
//FAction.IsNavigate := True;
Chromium.LoadURL(AUrl);
end;
function TCefScriptNavBase.Wait: TWaitResult;
begin
Result := FAction.Wait();
FFail := FAction.IsFail;
if FAction.ErrorStr <> '' then
LogError2(FAction.ErrorStr);
end;
end.