forked from dliw/fpCEF3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cef3ref.pas
4611 lines (3900 loc) · 135 KB
/
cef3ref.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*
* Free Pascal Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Author: d.l.i.w <[email protected]>
* Repository: http://github.com/dliw/fpCEF3
*
*
* Based on 'Delphi Chromium Embedded' by: Henri Gourvest <[email protected]>
* Repository : http://code.google.com/p/delphichromiumembedded/
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
Unit cef3ref;
{$MODE objfpc}{$H+}
{$I cef.inc}
Interface
Uses
Classes, SysUtils,
{$IFDEF DEBUG}LCLProc,{$ENDIF}
cef3api, cef3types, cef3intf, cef3own;
Type
{ TCefBaseRef }
TCefBaseRef = class(TInterfacedObject, ICefBase)
private
FData: Pointer;
public
constructor Create(data: Pointer); virtual;
destructor Destroy; override;
function Wrap: Pointer;
class function UnWrap(data: Pointer): ICefBase;
end;
{ TCefBrowserRef }
TCefBrowserRef = class(TCefBaseRef, ICefBrowser)
protected
function GetHost: ICefBrowserHost;
function CanGoBack: Boolean;
procedure GoBack;
function CanGoForward: Boolean;
procedure GoForward;
function IsLoading: Boolean;
procedure Reload;
procedure ReloadIgnoreCache;
procedure StopLoad;
function GetIdentifier: Integer;
function IsSame(const that: ICefBrowser): Boolean;
function IsPopup: Boolean;
function HasDocument: Boolean;
function GetMainFrame: ICefFrame;
function GetFocusedFrame: ICefFrame;
function GetFrameByident(identifier: Int64): ICefFrame;
function GetFrame(const name: ustring): ICefFrame;
function GetFrameCount: TSize;
procedure GetFrameIdentifiers(count: PSize; identifiers: PInt64);
procedure GetFrameNames(names: TStrings);
function SendProcessMessage(targetProcess: TCefProcessId; message: ICefProcessMessage): Boolean;
public
class function UnWrap(data: Pointer): ICefBrowser;
end;
TCefBrowserHostRef = class(TCefBaseRef, ICefBrowserHost)
function GetBrowser: ICefBrowser;
procedure ParentWindowWillClose;
procedure CloseBrowser(aForceClose: Boolean);
procedure SetFocus(focus: Boolean);
procedure SetWindowVisibility(visible: Boolean);
function GetWindowHandle: TCefWindowHandle;
function GetOpenerWindowHandle: TCefWindowHandle;
function GetClient: ICefClient;
function GetRequestContext: ICefRequestContext;
function GetZoomLevel: Double;
procedure SetZoomLevel(zoomLevel: Double);
procedure StartDownload(const url: ustring);
procedure Print;
procedure Find(identifier: Integer; const searchText: ustring; forward_, matchCase, findNext: Boolean);
procedure StopFinding(clearSelection: Boolean);
procedure ShowDevTools(var windowInfo: TCefWindowInfo; client: ICefClient; var settings: TCefBrowserSettings);
procedure CloseDevTools;
procedure SetMouseCursorChangeDisabled(disabled: Boolean);
function GetIsMouseCursorChangeDisabled: Boolean;
function GetIsWindowRenderingDisabled: Boolean;
procedure WasResized;
procedure WasHidden(hidden: Boolean);
procedure NotifyScreenInfoChanged;
procedure Invalidate(const dirtyRect: PCefRect; const aType: TCefPaintElementType);
procedure SendKeyEvent(const event:TCefKeyEvent);
procedure SendMouseClickEvent(const event: TCefMouseEvent; aType: TCefMouseButtonType;
mouseUp: Boolean; clickCount: Integer);
procedure SendMouseMoveEvent(event:TCefMouseEvent; mouseLeave:boolean);
procedure SendMouseWheelEvent(const event:TCefMouseEvent; deltaX, deltaY: Integer);
procedure SendFocusEvent(dosetFocus: Integer);
procedure SendCaptureLostEvent;
procedure RunFileDialog(mode: TCefFileDialogMode;
const title, defaultFileName: ustring; acceptTypes: TStrings;
const callback: ICefRunFileDialogCallback);
procedure RunFileDialogProc(mode: TCefFileDialogMode;
const title, defaultFileName: ustring; acceptTypes: TStrings;
const callback: TCefRunFileDialogCallbackProc);
{ MACOS
function GetNstextInputContext: ICefTextInputContext;
procedure HandleKeyEventBeforeTextInputClient(event: TCefEventHandle);
procedure HandleKeyAfterBeforeTextInputClient(event: TCefEventHandle);
}
public
class function UnWrap(data: Pointer): ICefBrowserHost;
end;
TCefCallbackRef = class(TCefBaseRef, ICefCallback)
protected
procedure Cont;
procedure Cancel;
public
class function UnWrap(data: Pointer): ICefCallback;
end;
TCefCommandLineRef = class(TCefBaseRef, ICefCommandLine)
protected
function IsValid: Boolean;
function IsReadOnly: Boolean;
function Copy: ICefCommandLine;
procedure InitFromArgv(argc: Integer; const argv: PPAnsiChar);
procedure InitFromString(const commandLine: ustring);
procedure Reset;
procedure GetArgv(argv: TStrings);
function GetCommandLineString: ustring;
function GetProgram: ustring;
procedure SetProgram(const program_: ustring);
function HasSwitches: Boolean;
function HasSwitch(const name: ustring): Boolean;
function GetSwitchValue(const name: ustring): ustring;
procedure GetSwitches(switches: ICefStringMap);
procedure AppendSwitch(const name: ustring);
procedure AppendSwitchWithValue(const name, value: ustring);
function HasArguments: Boolean;
procedure GetArguments(arguments: TStrings);
procedure AppendArgument(const argument: ustring);
procedure PrependWrapper(const wrapper: ustring);
public
class function UnWrap(data: Pointer): ICefCommandLine;
class function New: ICefCommandLine;
class function Global: ICefCommandLine;
end;
TCefContextMenuParamsRef = class(TCefBaseRef, ICefContextMenuParams)
protected
function GetXCoord: Integer;
function GetYCoord: Integer;
function GetTypeFlags: TCefContextMenuTypeFlags;
function GetLinkUrl: ustring;
function GetUnfilteredLinkUrl: ustring;
function GetSourceUrl: ustring;
function HasImageContents: Boolean;
function GetPageUrl: ustring;
function GetFrameUrl: ustring;
function GetFrameCharset: ustring;
function GetMediaType: TCefContextMenuMediaType;
function GetMediaStateFlags: TCefContextMenuMediaStateFlags;
function GetSelectionText: ustring;
function IsEditable: Boolean;
function IsSpeechInputEnabled: Boolean;
function GetEditStateFlags: TCefContextMenuEditStateFlags;
public
class function UnWrap(data: Pointer): ICefContextMenuParams;
end;
TCefCookieManagerRef = class(TCefBaseRef, ICefCookieManager)
protected
procedure SetSupportedSchemes(schemes: TStrings);
function VisitAllCookies(const visitor: ICefCookieVisitor): Boolean;
function VisitAllCookiesProc(const visitor: TCefCookieVisitorProc): Boolean;
function VisitUrlCookies(const url: ustring;
includeHttpOnly: Boolean; const visitor: ICefCookieVisitor): Boolean;
function VisitUrlCookiesProc(const url: ustring;
includeHttpOnly: Boolean; const visitor: TCefCookieVisitorProc): Boolean;
function SetCookie(const url: ustring; const name, value, domain, path: ustring; secure, httponly,
hasExpires: Boolean; const creation, lastAccess, expires: TDateTime): Boolean;
function DeleteCookies(const url, cookieName: ustring): Boolean;
function SetStoragePath(const path: ustring; PersistSessionCookies:boolean): Boolean;
function FlushStore(handler:ICefCompletionHandler):boolean;
public
class function UnWrap(data: Pointer): ICefCookieManager;
class function Global: ICefCookieManager;
class function New(const path: ustring; persistSessionCookies: Boolean): ICefCookieManager;
end;
TCefFileDialogCallbackRef = class(TCefBaseRef, ICefFileDialogCallback)
protected
procedure Cont(filePaths: TStrings);
procedure Cancel;
public
class function UnWrap(data: Pointer): ICefFileDialogCallback;
end;
TCefDomDocumentRef = class(TCefBaseRef, ICefDomDocument)
protected
function GetType: TCefDomDocumentType;
function GetDocument: ICefDomNode;
function GetBody: ICefDomNode;
function GetHead: ICefDomNode;
function GetTitle: ustring;
function GetElementById(const id: ustring): ICefDomNode;
function GetFocusedNode: ICefDomNode;
function HasSelection: Boolean;
function GetSelectionStartNode: ICefDomNode;
function GetSelectionStartOffset: Integer;
function GetSelectionEndNode: ICefDomNode;
function GetSelectionEndOffset: Integer;
function GetSelectionAsMarkup: ustring;
function GetSelectionAsText: ustring;
function GetBaseUrl: ustring;
function GetCompleteUrl(const partialURL: ustring): ustring;
public
class function UnWrap(data: Pointer): ICefDomDocument;
end;
TCefDomNodeRef = class(TCefBaseRef, ICefDomNode)
protected
function GetType: TCefDomNodeType;
function IsText: Boolean;
function IsElement: Boolean;
function IsEditable: Boolean;
function IsFormControlElement: Boolean;
function GetFormControlElementType: ustring;
function IsSame(const that: ICefDomNode): Boolean;
function GetName: ustring;
function GetValue: ustring;
function SetValue(const value: ustring): Boolean;
function GetAsMarkup: ustring;
function GetDocument: ICefDomDocument;
function GetParent: ICefDomNode;
function GetPreviousSibling: ICefDomNode;
function GetNextSibling: ICefDomNode;
function HasChildren: Boolean;
function GetFirstChild: ICefDomNode;
function GetLastChild: ICefDomNode;
procedure AddEventListener(const eventType: ustring;
useCapture: Boolean; const listener: ICefDomEventListener);
procedure AddEventListenerProc(const eventType: ustring; useCapture: Boolean;
const proc: TCefDomEventListenerProc);
function GetElementTagName: ustring;
function HasElementAttributes: Boolean;
function HasElementAttribute(const attrName: ustring): Boolean;
function GetElementAttribute(const attrName: ustring): ustring;
procedure GetElementAttributes(const attrMap: ICefStringMap);
function SetElementAttribute(const attrName, value: ustring): Boolean;
function GetElementInnerText: ustring;
public
class function UnWrap(data: Pointer): ICefDomNode;
end;
TCefDomEventRef = class(TCefBaseRef, ICefDomEvent)
protected
function GetType: ustring;
function GetCategory: TCefDomEventCategory;
function GetPhase: TCefDomEventPhase;
function CanBubble: Boolean;
function CanCancel: Boolean;
function GetDocument: ICefDomDocument;
function GetTarget: ICefDomNode;
function GetCurrentTarget: ICefDomNode;
public
class function UnWrap(data: Pointer): ICefDomEvent;
end;
TCefBeforeDownloadCallbackRef = class(TCefBaseRef, ICefBeforeDownloadCallback)
protected
procedure Cont(const downloadPath: ustring; showDialog: Boolean);
public
class function UnWrap(data: Pointer): ICefBeforeDownloadCallback;
end;
TCefDownloadItemCallbackRef = class(TCefBaseRef, ICefDownloadItemCallback)
protected
procedure Cancel;
public
class function UnWrap(data: Pointer): ICefDownloadItemCallback;
end;
TCefDownloadItemRef = class(TCefBaseRef, ICefDownloadItem)
protected
function IsValid: Boolean;
function IsInProgress: Boolean;
function IsComplete: Boolean;
function IsCanceled: Boolean;
function GetCurrentSpeed: Int64;
function GetPercentComplete: Integer;
function GetTotalBytes: Int64;
function GetReceivedBytes: Int64;
function GetStartTime: TDateTime;
function GetEndTime: TDateTime;
function GetFullPath: ustring;
function GetId: UInt32;
function GetUrl: ustring;
function GetSuggestedFileName: ustring;
function GetContentDisposition: ustring;
function GetMimeType: ustring;
public
class function UnWrap(data: Pointer): ICefDownLoadItem;
end;
TCefDragDataRef = class(TCefBaseRef, ICefDragData)
protected
function IsLink: Boolean;
function IsFragment: Boolean;
function IsFile: Boolean;
function GetLinkUrl: ustring;
function GetLinkTitle: ustring;
function GetLinkMetadata: ustring;
function GetFragmentText: ustring;
function GetFragmentHTML: ustring;
function GetFragmentBaseURL: ustring;
function GetFileName: ustring;
function GetFileNames(names: TStrings): Boolean;
public
class function UnWrap(data: Pointer): ICefDragData;
end;
TCefFrameRef = class(TCefBaseRef, ICefFrame)
protected
function IsValid: Boolean;
procedure Undo;
procedure Redo;
procedure Cut;
procedure Copy;
procedure Paste;
procedure Del;
procedure SelectAll;
procedure ViewSource;
procedure GetSource(const visitor: ICefStringVisitor);
procedure GetSourceProc(const proc: TCefStringVisitorProc);
procedure GetText(const visitor: ICefStringVisitor);
procedure GetTextProc(const proc: TCefStringVisitorProc);
procedure LoadRequest(const request: ICefRequest);
procedure LoadUrl(const url: ustring);
procedure LoadString(const str, url: ustring);
procedure ExecuteJavaScript(const code, scriptUrl: ustring; startLine: Integer);
function IsMain: Boolean;
function IsFocused: Boolean;
function GetName: ustring;
function GetIdentifier: Int64;
function GetParent: ICefFrame;
function GetUrl: ustring;
function GetBrowser: ICefBrowser;
function GetV8Context: ICefv8Context;
procedure VisitDom(const visitor: ICefDomVisitor);
procedure VisitDomProc(const proc: TCefDomVisitorProc);
public
class function UnWrap(data: Pointer): ICefFrame;
end;
TCefGeolocationCallbackRef = class(TCefBaseRef, ICefGeolocationCallback)
protected
procedure Cont(allow: Boolean);
public
class function UnWrap(data: Pointer): ICefGeolocationCallback;
end;
TCefJsDialogCallbackRef = class(TCefBaseRef, ICefJsDialogCallback)
protected
procedure Cont(success: Boolean; const userInput: ustring);
public
class function UnWrap(data: Pointer): ICefJsDialogCallback;
end;
TCefMenuModelRef = class(TCefBaseRef, ICefMenuModel)
protected
function Clear: Boolean;
function GetCount: Integer;
function AddSeparator: Boolean;
function AddItem(commandId: Integer; const text: ustring): Boolean;
function AddCheckItem(commandId: Integer; const text: ustring): Boolean;
function AddRadioItem(commandId: Integer; const text: ustring; groupId: Integer): Boolean;
function AddSubMenu(commandId: Integer; const text: ustring): ICefMenuModel;
function InsertSeparatorAt(index: Integer): Boolean;
function InsertItemAt(index, commandId: Integer; const text: ustring): Boolean;
function InsertCheckItemAt(index, commandId: Integer; const text: ustring): Boolean;
function InsertRadioItemAt(index, commandId: Integer; const text: ustring; groupId: Integer): Boolean;
function InsertSubMenuAt(index, commandId: Integer; const text: ustring): ICefMenuModel;
function Remove(commandId: Integer): Boolean;
function RemoveAt(index: Integer): Boolean;
function GetIndexOf(commandId: Integer): Integer;
function GetCommandIdAt(index: Integer): Integer;
function SetCommandIdAt(index, commandId: Integer): Boolean;
function GetLabel(commandId: Integer): ustring;
function GetLabelAt(index: Integer): ustring;
function SetLabel(commandId: Integer; const text: ustring): Boolean;
function SetLabelAt(index: Integer; const text: ustring): Boolean;
function GetType(commandId: Integer): TCefMenuItemType;
function GetTypeAt(index: Integer): TCefMenuItemType;
function GetGroupId(commandId: Integer): Integer;
function GetGroupIdAt(index: Integer): Integer;
function SetGroupId(commandId, groupId: Integer): Boolean;
function SetGroupIdAt(index, groupId: Integer): Boolean;
function GetSubMenu(commandId: Integer): ICefMenuModel;
function GetSubMenuAt(index: Integer): ICefMenuModel;
function IsVisible(commandId: Integer): Boolean;
function isVisibleAt(index: Integer): Boolean;
function SetVisible(commandId: Integer; visible: Boolean): Boolean;
function SetVisibleAt(index: Integer; visible: Boolean): Boolean;
function IsEnabled(commandId: Integer): Boolean;
function IsEnabledAt(index: Integer): Boolean;
function SetEnabled(commandId: Integer; enabled: Boolean): Boolean;
function SetEnabledAt(index: Integer; enabled: Boolean): Boolean;
function IsChecked(commandId: Integer): Boolean;
function IsCheckedAt(index: Integer): Boolean;
function setChecked(commandId: Integer; checked: Boolean): Boolean;
function setCheckedAt(index: Integer; checked: Boolean): Boolean;
function HasAccelerator(commandId: Integer): Boolean;
function HasAcceleratorAt(index: Integer): Boolean;
function SetAccelerator(commandId, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
function SetAcceleratorAt(index, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
function RemoveAccelerator(commandId: Integer): Boolean;
function RemoveAcceleratorAt(index: Integer): Boolean;
function GetAccelerator(commandId: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
function GetAcceleratorAt(index: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
public
class function UnWrap(data: Pointer): ICefMenuModel;
end;
TCefProcessMessageRef = class(TCefBaseRef, ICefProcessMessage)
protected
function IsValid: Boolean;
function IsReadOnly: Boolean;
function Copy: ICefProcessMessage;
function GetName: ustring;
function GetArgumentList: ICefListValue;
public
class function UnWrap(data: Pointer): ICefProcessMessage;
class function New(const name: ustring): ICefProcessMessage;
end;
TCefRequestRef = class(TCefBaseRef, ICefRequest)
protected
function IsReadOnly: Boolean;
function GetUrl: ustring;
function GetMethod: ustring;
function GetPostData: ICefPostData;
procedure GetHeaderMap(const HeaderMap: ICefStringMultimap);
procedure SetUrl(const value: ustring);
procedure SetMethod(const value: ustring);
procedure SetPostData(const value: ICefPostData);
procedure SetHeaderMap(const HeaderMap: ICefStringMultimap);
function GetFlags: TCefUrlRequestFlags;
procedure SetFlags(flags: TCefUrlRequestFlags);
function GetFirstPartyForCookies: ustring;
procedure SetFirstPartyForCookies(const url: ustring);
function GetResourceType: TCefResourceType;
function GetTransitionType: TCefTransitionType;
procedure Assign(const url, method: ustring;
const postData: ICefPostData; const headerMap: ICefStringMultimap);
public
class function UnWrap(data: Pointer): ICefRequest;
class function New: ICefRequest;
end;
TCefPostDataRef = class(TCefBaseRef, ICefPostData)
protected
function IsReadOnly: Boolean;
function GetElementCount: TSize;
function GetElements(Count: TSize): IInterfaceList; // ICefPostDataElement
function RemoveElement(const element: ICefPostDataElement): Integer;
function AddElement(const element: ICefPostDataElement): Integer;
procedure RemoveElements;
public
class function UnWrap(data: Pointer): ICefPostData;
class function New: ICefPostData;
end;
TCefPostDataElementRef = class(TCefBaseRef, ICefPostDataElement)
protected
function IsReadOnly: Boolean;
procedure SetToEmpty;
procedure SetToFile(const fileName: ustring);
procedure SetToBytes(size: TSize; const bytes: Pointer);
function GetType: TCefPostDataElementType;
function GetFile: ustring;
function GetBytesCount: TSize;
function GetBytes(size: TSize; bytes: Pointer): TSize;
public
class function UnWrap(data: Pointer): ICefPostDataElement;
class function New: ICefPostDataElement;
end;
TCefRequestContextRef = class(TCefBaseRef, ICefRequestContext)
protected
function IsSame(other: ICefRequestContext): Boolean;
function IsGlobal: Boolean;
function GetHandler: ICefRequestContextHandler;
public
class function UnWrap(data: Pointer): ICefRequestContext;
end;
TCefRequestContextHandlerRef = class(TCefBaseRef, ICefRequestContextHandler)
protected
function GetCookieManager: ICefCookieManager;
public
class function UnWrap(data: Pointer): ICefRequestContextHandler;
end;
TCefAuthCallbackRef = class(TCefBaseRef, ICefAuthCallback)
protected
procedure Cont(const username, password: ustring);
procedure Cancel;
public
class function UnWrap(data: Pointer): ICefAuthCallback;
end;
TCefQuotaCallbackRef = class(TCefBaseRef, ICefQuotaCallback)
protected
procedure Cont(allow: Boolean);
procedure Cancel;
public
class function UnWrap(data: Pointer): ICefQuotaCallback;
end;
TCefAllowCertificateErrorCallbackRef = class(TCefBaseRef, ICefAllowCertificateErrorCallback)
protected
procedure Cont(allow: Boolean);
public
class function UnWrap(data: Pointer): ICefAllowCertificateErrorCallback;
end;
TCefResponseRef = class(TCefBaseRef, ICefResponse)
protected
function IsReadOnly: Boolean;
function GetStatus: Integer;
procedure SetStatus(status: Integer);
function GetStatusText: ustring;
procedure SetStatusText(const StatusText: ustring);
function GetMimeType: ustring;
procedure SetMimeType(const mimetype: ustring);
function GetHeader(const name: ustring): ustring;
procedure GetHeaderMap(const headerMap: ICefStringMultimap);
procedure SetHeaderMap(const headerMap: ICefStringMultimap);
public
class function UnWrap(data: Pointer): ICefResponse;
class function New: ICefResponse;
end;
TCefSchemeRegistrarRef = class(TCefBaseRef, ICefSchemeRegistrar)
protected
function AddCustomScheme(const schemeName: ustring; IsStandard, IsLocal,
IsDisplayIsolated: Boolean): Boolean; cconv;
public
class function UnWrap(data: Pointer): ICefSchemeRegistrar;
end;
TCefStreamReaderRef = class(TCefBaseRef, ICefStreamReader)
protected
function Read(ptr: Pointer; size, n: TSize): TSize;
function Seek(offset: Int64; whence: Integer): Integer;
function Tell: Int64;
function Eof: Boolean;
function MayBlock: Boolean;
public
class function UnWrap(data: Pointer): ICefStreamReader;
class function CreateForFile(const filename: ustring): ICefStreamReader;
class function CreateForCustomStream(const stream: ICefCustomStreamReader): ICefStreamReader;
class function CreateForStream(const stream: TSTream; owned: Boolean): ICefStreamReader;
class function CreateForData(data: Pointer; size: Cardinal): ICefStreamReader;
end;
TCefTaskRef = class(TCefBaseRef, ICefTask)
protected
procedure Execute; virtual;
public
class function UnWrap(data: Pointer): ICefTask;
end;
TCefTaskRunnerRef = class(TCefBaseRef, ICefTaskRunner)
protected
function IsSame(that:ICefTaskRunner):boolean;
function BelongsToCurrentThread:boolean;
function BelongsToThread(ThreadID:TCefThreadID):boolean;
function PostTask(task:ICefTask):integer;
function PostDelayedTask(task:ICefTask; delay_ms:Int64):integer;
public
class function UnWrap(data: Pointer): ICefTaskRunner;
class function GetForThread(const ThreadID:TCefThreadID): ICefTaskRunner;
class function GetForCurrentThread: ICefTaskRunner;
end;
TCefUrlRequestRef = class(TCefBaseRef, ICefUrlRequest)
protected
function GetRequest: ICefRequest;
function GetClient: ICefUrlRequestClient;
function GetRequestStatus: TCefUrlRequestStatus;
function GetRequestError: TCefErrorcode;
function GetResponse: ICefResponse;
procedure Cancel;
public
class function UnWrap(data: Pointer): ICefUrlRequest;
class function New(const request: ICefRequest; const client: ICefUrlRequestClient): ICefUrlRequest;
end;
TCefUrlRequestClientRef = class(TCefBaseRef, ICefUrlRequestClient)
protected
procedure OnRequestComplete(const request: ICefUrlRequest);
procedure OnUploadProgress(const request: ICefUrlRequest; current, total: UInt64);
procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: UInt64);
procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: TSize);
function GetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer;
const realm, scheme: ustring; callback: ICefAuthCallback): Boolean;
public
class function UnWrap(data: Pointer): ICefUrlRequestClient;
end;
TCefv8ContextRef = class(TCefBaseRef, ICefv8Context)
protected
function GetTaskRunner:ICefTaskRunner;
function IsValid:boolean;
function GetBrowser: ICefBrowser;
function GetFrame: ICefFrame;
function GetGlobal: ICefv8Value;
function Enter: Boolean;
function Exit: Boolean;
function IsSame(const that: ICefv8Context): Boolean;
function Eval(const code: ustring; var retval: ICefv8Value; var exception: ICefV8Exception): Boolean;
public
class function UnWrap(data: Pointer): ICefv8Context;
class function Current: ICefv8Context;
class function Entered: ICefv8Context;
end;
TCefv8HandlerRef = class(TCefBaseRef, ICefv8Handler)
protected
function Execute(const name: ustring; const obj: ICefv8Value;
const arguments: TCefv8ValueArray; var retval: ICefv8Value;
var exception: ustring): Boolean;
public
class function UnWrap(data: Pointer): ICefv8Handler;
end;
TCefFastV8Accessor = class(TCefV8AccessorOwn)
private
FGetter: TCefV8AccessorGetterProc;
FSetter: TCefV8AccessorSetterProc;
protected
function Get(const name: ustring; const obj: ICefv8Value;
out value: ICefv8Value; const exception: string): Boolean; override;
function Put(const name: ustring; const obj, value: ICefv8Value;
const exception: string): Boolean; override;
public
constructor Create(const getter: TCefV8AccessorGetterProc;
const setter: TCefV8AccessorSetterProc); reintroduce;
end;
TCefV8ExceptionRef = class(TCefBaseRef, ICefV8Exception)
protected
function GetMessage: ustring;
function GetSourceLine: ustring;
function GetScriptResourceName: ustring;
function GetLineNumber: Integer;
function GetStartPosition: Integer;
function GetEndPosition: Integer;
function GetStartColumn: Integer;
function GetEndColumn: Integer;
public
class function UnWrap(data: Pointer): ICefV8Exception;
end;
TCefv8ValueRef = class(TCefBaseRef, ICefv8Value)
protected
function IsValid:boolean;
function IsUndefined: Boolean;
function IsNull: Boolean;
function IsBool: Boolean;
function IsInt: Boolean;
function IsUInt: Boolean;
function IsDouble: Boolean;
function IsDate: Boolean;
function IsString: Boolean;
function IsObject: Boolean;
function IsArray: Boolean;
function IsFunction: Boolean;
function IsSame(const that: ICefv8Value): Boolean;
function GetBoolValue: Boolean;
function GetIntValue: Integer;
function GetUIntValue: Cardinal;
function GetDoubleValue: Double;
function GetDateValue: TDateTime;
function GetStringValue: ustring;
function IsUserCreated: Boolean;
function HasException: Boolean;
function GetException: ICefV8Exception;
function ClearException: Boolean;
function WillRethrowExceptions: Boolean;
function SetRethrowExceptions(rethrow: Boolean): Boolean;
function HasValueByKey(const key: ustring): Boolean;
function HasValueByIndex(index: Integer): Boolean;
function DeleteValueByKey(const key: ustring): Boolean;
function DeleteValueByIndex(index: Integer): Boolean;
function GetValueByKey(const key: ustring): ICefv8Value;
function GetValueByIndex(index: Integer): ICefv8Value;
function SetValueByKey(const key: ustring; const value: ICefv8Value;
attribute: TCefV8PropertyAttribute): Boolean;
function SetValueByIndex(index: Integer; const value: ICefv8Value): Boolean;
function SetValueByAccessor(const key: ustring; settings: TCefV8AccessControl;
attribute: TCefV8PropertyAttribute): Boolean;
function GetKeys(const keys: TStrings): Integer;
function SetUserData(const data: ICefv8Value): Boolean;
function GetUserData: ICefv8Value;
function GetExternallyAllocatedMemory: Integer;
function AdjustExternallyAllocatedMemory(changeInBytes: Integer): Integer;
function GetArrayLength: Integer;
function GetFunctionName: ustring;
function GetFunctionHandler: ICefv8Handler;
function ExecuteFunction(const obj: ICefv8Value;
const arguments: TCefv8ValueArray): ICefv8Value;
function ExecuteFunctionWithContext(const context: ICefv8Context;
const obj: ICefv8Value; const arguments: TCefv8ValueArray): ICefv8Value;
public
class function UnWrap(data: Pointer): ICefv8Value;
class function NewUndefined: ICefv8Value;
class function NewNull: ICefv8Value;
class function NewBool(value: Boolean): ICefv8Value;
class function NewInt(value: Integer): ICefv8Value;
class function NewUInt(value: Cardinal): ICefv8Value;
class function NewDouble(value: Double): ICefv8Value;
class function NewDate(value: TDateTime): ICefv8Value;
class function NewString(const str: ustring): ICefv8Value;
class function NewObject(const Accessor: ICefV8Accessor): ICefv8Value;
class function NewObjectProc(const getter: TCefV8AccessorGetterProc;
const setter: TCefV8AccessorSetterProc): ICefv8Value;
class function NewArray(len: Integer): ICefv8Value;
class function NewFunction(const name: ustring; const handler: ICefv8Handler): ICefv8Value;
end;
TCefV8StackTraceRef = class(TCefBaseRef, ICefV8StackTrace)
protected
function IsValid:boolean;
function GetFrameCount: Integer;
function GetFrame(index: Integer): ICefV8StackFrame;
public
class function UnWrap(data: Pointer): ICefV8StackTrace;
class function Current(frameLimit: Integer): ICefV8StackTrace;
end;
TCefV8StackFrameRef = class(TCefBaseRef, ICefV8StackFrame)
protected
function IsValid: Boolean;
function GetScriptName: ustring;
function GetScriptNameOrSourceUrl: ustring;
function GetFunctionName: ustring;
function GetLineNumber: Integer;
function GetColumn: Integer;
function IsEval: Boolean;
function IsConstructor: Boolean;
public
class function UnWrap(data: Pointer): ICefV8StackFrame;
end;
TCefBinaryValueRef = class(TCefBaseRef, ICefBinaryValue)
protected
function IsValid: Boolean;
function IsOwned: Boolean;
function Copy: ICefBinaryValue;
function GetSize: TSize;
function GetData(buffer: Pointer; bufferSize, dataOffset: TSize): TSize;
public
class function UnWrap(data: Pointer): ICefBinaryValue;
class function New(const data: Pointer; dataSize: Cardinal): ICefBinaryValue;
end;
TCefDictionaryValueRef = class(TCefBaseRef, ICefDictionaryValue)
protected
function IsValid: Boolean;
function isOwned: Boolean;
function IsReadOnly: Boolean;
function Copy(excludeEmptyChildren: Boolean): ICefDictionaryValue;
function GetSize: TSize;
function Clear: Boolean;
function HasKey(const key: ustring): Boolean;
function GetKeys(const keys: TStrings): Boolean;
function Remove(const key: ustring): Boolean;
function GetType(const key: ustring): TCefValueType;
function GetBool(const key: ustring): Boolean;
function GetInt(const key: ustring): Integer;
function GetDouble(const key: ustring): Double;
function GetString(const key: ustring): ustring;
function GetBinary(const key: ustring): ICefBinaryValue;
function GetDictionary(const key: ustring): ICefDictionaryValue;
function GetList(const key: ustring): ICefListValue;
function SetNull(const key: ustring): Boolean;
function SetBool(const key: ustring; value: Boolean): Boolean;
function SetInt(const key: ustring; value: Integer): Boolean;
function SetDouble(const key: ustring; value: Double): Boolean;
function SetString(const key, value: ustring): Boolean;
function SetBinary(const key: ustring; const value: ICefBinaryValue): Boolean;
function SetDictionary(const key: ustring; const value: ICefDictionaryValue): Boolean;
function SetList(const key: ustring; const value: ICefListValue): Boolean;
public
class function UnWrap(data: Pointer): ICefDictionaryValue;
class function New: ICefDictionaryValue;
end;
TCefListValueRef = class(TCefBaseRef, ICefListValue)
protected
function IsValid: Boolean;
function IsOwned: Boolean;
function IsReadOnly: Boolean;
function Copy: ICefListValue;
function SetSize(size: TSize): Boolean;
function GetSize: TSize;
function Clear: Boolean;
function Remove(index: Integer): Boolean;
function GetType(index: Integer): TCefValueType;
function GetBool(index: Integer): Boolean;
function GetInt(index: Integer): Integer;
function GetDouble(index: Integer): Double;
function GetString(index: Integer): ustring;
function GetBinary(index: Integer): ICefBinaryValue;
function GetDictionary(index: Integer): ICefDictionaryValue;
function GetList(index: Integer): ICefListValue;
function SetNull(index: Integer): Boolean;
function SetBool(index: Integer; value: Boolean): Boolean;
function SetInt(index, value: Integer): Boolean;
function SetDouble(index: Integer; value: Double): Boolean;
function SetString(index: Integer; const value: ustring): Boolean;
function SetBinary(index: Integer; const value: ICefBinaryValue): Boolean;
function SetDictionary(index: Integer; const value: ICefDictionaryValue): Boolean;
function SetList(index: Integer; const value: ICefListValue): Boolean;
public
class function UnWrap(data: Pointer): ICefListValue;
class function New: ICefListValue;
end;
TCefWebPluginInfoRef = class(TCefBaseRef, ICefWebPluginInfo)
protected
function GetName: ustring;
function GetPath: ustring;
function GetVersion: ustring;
function GetDescription: ustring;
public
class function UnWrap(data: Pointer): ICefWebPluginInfo;
end;
TCefXmlReaderRef = class(TCefBaseRef, ICefXmlReader)
protected
function MoveToNextNode: Boolean;
function Close: Boolean;
function HasError: Boolean;
function GetError: ustring;
function GetType: TCefXmlNodeType;
function GetDepth: Integer;
function GetLocalName: ustring;
function GetPrefix: ustring;
function GetQualifiedName: ustring;
function GetNamespaceUri: ustring;
function GetBaseUri: ustring;
function GetXmlLang: ustring;
function IsEmptyElement: Boolean;
function HasValue: Boolean;
function GetValue: ustring;
function HasAttributes: Boolean;
function GetAttributeCount: TSize;
function GetAttributeByIndex(index: Integer): ustring;
function GetAttributeByQName(const qualifiedName: ustring): ustring;
function GetAttributeByLName(const localName, namespaceURI: ustring): ustring;
function GetInnerXml: ustring;
function GetOuterXml: ustring;
function GetLineNumber: Integer;
function MoveToAttributeByIndex(index: Integer): Boolean;
function MoveToAttributeByQName(const qualifiedName: ustring): Boolean;
function MoveToAttributeByLName(const localName, namespaceURI: ustring): Boolean;
function MoveToFirstAttribute: Boolean;
function MoveToNextAttribute: Boolean;
function MoveToCarryingElement: Boolean;
public
class function UnWrap(data: Pointer): ICefXmlReader;
class function New(const stream: ICefStreamReader;
encodingType: TCefXmlEncodingType; const URI: ustring): ICefXmlReader;
end;
TCefZipReaderRef = class(TCefBaseRef, ICefZipReader)
protected
function MoveToFirstFile: Boolean;
function MoveToNextFile: Boolean;
function MoveToFile(const fileName: ustring; caseSensitive: Boolean): Boolean;
function Close: Boolean;
function GetFileName: ustring;
function GetFileSize: Int64;
function GetFileLastModified: LongInt;
function OpenFile(const password: ustring): Boolean;
function CloseFile: Boolean;
function ReadFile(buffer: Pointer; bufferSize: TSize): Integer;
function Tell: Int64;
function Eof: Boolean;
public
class function UnWrap(data: Pointer): ICefZipReader;
class function New(const stream: ICefStreamReader): ICefZipReader;
end;
Implementation
Uses cef3lib;
{ TCefAllowCertificateErrorCallbackRef }
procedure TCefAllowCertificateErrorCallbackRef.Cont(allow : Boolean);
begin
PCefAllowCertificateErrorCallback(FData)^.cont(FData, Ord(allow));
end;
class function TCefAllowCertificateErrorCallbackRef.UnWrap(data : Pointer) : ICefAllowCertificateErrorCallback;
begin
If data <> nil then Result := Create(data) as ICefAllowCertificateErrorCallback
Else Result := nil;
end;
{ TCefBaseRef }
constructor TCefBaseRef.Create(data : Pointer);
begin
Assert(data <> nil);
FData := Data;
end;
destructor TCefBaseRef.Destroy;
begin
If Assigned(PCefBase(FData)^.release) then PCefBase(FData)^.release(FData);
inherited;
end;
function TCefBaseRef.Wrap : Pointer;
begin
Result := FData;
If Assigned(PCefBase(FData)^.add_ref) then PCefBase(FData)^.add_ref(FData);
end;
class function TCefBaseRef.UnWrap(data : Pointer) : ICefBase;
begin
If data <> nil then Result := Create(data) as ICefBase
Else Result := nil;
end;
{ TCefBrowserRef }
function TCefBrowserRef.GetHost : ICefBrowserHost;
begin
Result := TCefBrowserHostRef.UnWrap(PCefBrowser(FData)^.get_host(FData));
end;
function TCefBrowserRef.CanGoBack : Boolean;
begin
Result := PCefBrowser(FData)^.can_go_back(FData) <> 0;
end;
procedure TCefBrowserRef.GoBack;
begin
PCefBrowser(FData)^.go_back(FData);
end;
function TCefBrowserRef.CanGoForward : Boolean;
begin
Result := PCefBrowser(FData)^.can_go_forward(FData) <> 0;
end;
procedure TCefBrowserRef.GoForward;
begin
PCefBrowser(FData)^.go_forward(FData);
end;
function TCefBrowserRef.IsLoading : Boolean;
begin
Result := PCefBrowser(FData)^.is_loading(FData) <> 0;
end;
procedure TCefBrowserRef.Reload;
begin
PCefBrowser(FData)^.reload(FData);
end;
procedure TCefBrowserRef.ReloadIgnoreCache;
begin
PCefBrowser(FData)^.reload_ignore_cache(FData);
end;
procedure TCefBrowserRef.StopLoad;
begin
PCefBrowser(FData)^.stop_load(FData);
end;