-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathcef3api.pas
7226 lines (5749 loc) · 354 KB
/
cef3api.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
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Author: dev.dliw@gmail.com
* Repository: https://github.com/dliw/fpCEF3
*
*
* Originally based on 'Delphi Chromium Embedded 3' by Henri Gourvest
* <hgourvest@gmail.com>
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
Unit cef3api;
{$MODE objfpc}{$H+}
{$I cef.inc}
Interface
Uses
{$IFDEF LINUX}xlib,{$ENDIF}
sysutils, ctypes, dynlibs, {$IFDEF DEBUG}LCLProc,{$ENDIF}
cef3types;
Type
PCefBaseRefCounted = ^TCefBaseRefCounted;
PCefBaseScoped = ^TCefBaseScoped;
PCefApp = ^TCefApp;
PCefAuthCallback = ^TCefAuthCallback;
PCefBrowser = ^TCefBrowser;
PCefRunFileDialogCallback = ^TCefRunFileDialogCallback;
PCefNavigationEntryVisitor = ^TCefNavigationEntryVisitor;
PCefPdfPrintCallback = ^TCefPdfPrintCallback;
PCefDownloadImageCallback = ^TCefDownloadImageCallback;
PCefBrowserHost = ^TCefBrowserHost;
PCefBrowserProcessHandler = ^TCefBrowserProcessHandler;
PCefCompletionCallback = ^TCefCompletionCallback;
PCefCallback = ^TCefCallback;
PCefClient = ^TCefClient;
PCefCommandLine = ^TCefCommandLine;
PCefRunContextMenuCallback = ^TCefRunContextMenuCallback;
PCefContextMenuHandler = ^TCefContextMenuHandler;
PCefContextMenuParams = ^TCefContextMenuParams;
PCefCookieManager = ^TCefCookieManager;
PCefCookieVisitor = ^TCefCookieVisitor;
PCefSetCookieCallback = ^TCefSetCookieCallback;
PCefDeleteCookiesCallback = ^TCefDeleteCookiesCallback;
PCefFileDialogCallback = ^TCefFileDialogCallback;
PCefDialogHandler = ^TCefDialogHandler;
PCefDisplayHandler = ^TCefDisplayHandler;
PCefDomVisitor = ^TCefDomVisitor;
PCefDomDocument = ^TCefDomDocument;
PCefDomNode = ^TCefDomNode;
PCefBeforeDownloadCallback = ^TCefBeforeDownloadCallback;
PCefDownloadItemCallback = ^TCefDownloadItemCallback;
PCefDownloadHandler = ^TCefDownloadHandler;
PCefDownloadItem = ^TCefDownloadItem;
PCefDragData = ^TCefDragData;
PCefDragHandler = ^TCefDragHandler;
PCefFindHandler = ^TCefFindHandler;
PCefFocusHandler = ^TCefFocusHandler;
PCefFrame = ^TCefFrame;
PCefGetGeolocationCallback = ^TCefGetGeolocationCallback;
PCefGeolocationCallback = ^TCefGeolocationCallback;
PCefGeolocationHandler = ^TCefGeolocationHandler;
PCefImage = ^TCefImage;
PCefJsDialogCallback = ^TCefJsDialogCallback;
PCefJsDialogHandler = ^TCefJsDialogHandler;
PCefKeyboardHandler = ^TCefKeyboardHandler;
PCefLifeSpanHandler = ^TCefLifeSpanHandler;
PCefLoadHandler = ^TCefLoadHandler;
PCefMenuModel = ^TCefMenuModel;
PCefMenuModelDelegate = ^TCefMenuModelDelegate;
PCefNavigationEntry = ^TCefNavigationEntry;
PCefPrintDialogCallback = ^TCefPrintDialogCallback;
PCefPrintJobCallback = ^TCefPrintJobCallback;
PCefPrintHandler = ^TCefPrintHandler;
PCefPrintSettings = ^TCefPrintSettings;
PCefProcessMessage = ^TCefProcessMessage;
PCefRenderHandler = ^TCefRenderHandler;
PCefRenderProcessHandler = ^TCefRenderProcessHandler;
PCefRequest = ^TCefRequest;
PCefPostData = ^TCefPostData;
PCefPostDataElement = ^TCefPostDataElement;
TCefPostDataElementArray = array[0..(High(Integer) div SizeOf(PCefPostDataElement)) - 1] of PCefPostDataElement;
PCefPostDataElementArray = ^TCefPostDataElementArray;
PCefResolveCallback = ^TCefResolveCallback;
PCefRequestContext = ^TCefRequestContext;
PCefRequestContextHandler = ^TCefRequestContextHandler;
PCefRequestCallback = ^TCefRequestCallback;
PCefSelectClientCertificateCallback = ^TCefSelectClientCertificateCallback;
PCefRequestHandler = ^TCefRequestHandler;
PCefResourceBundle = ^TCefResourceBundle;
PCefResourceBundleHandler = ^TCefResourceBundleHandler;
PCefResourceHandler = ^TCefResourceHandler;
PCefResponse = ^TCefResponse;
PCefResponseFilter = ^TCefResponseFilter;
PCefSchemeRegistrar = ^TCefSchemeRegistrar;
PCefSchemeHandlerFactory = ^TCefSchemeHandlerFactory;
PCefSslinfo = ^TCefSslinfo;
PCefSslstatus = ^TCefSslstatus;
PCefReadHandler = ^TCefReadHandler;
PCefStreamReader = ^TCefStreamReader;
PCefWriteHandler = ^TCefWriteHandler;
PCefStreamWriter = ^TCefStreamWriter;
PCefStringVisitor = ^TCefStringVisitor;
PCefTask = ^TCefTask;
PCefTaskRunner = ^TCefTaskRunner;
PCefThread = ^TCefThread;
PCefEndTracingCallback = ^TCefEndTracingCallback;
PCefUrlRequest = ^TCefUrlRequest;
PCefUrlRequestClient = ^TCefUrlRequestClient;
PCefV8Context = ^TCefV8Context;
PCefV8Handler = ^TCefV8Handler;
PCefV8Accessor = ^TCefV8Accessor;
PCefV8Interceptor = ^TCefV8Interceptor;
PCefV8Exception = ^TCefV8Exception;
PCefV8Value = ^TCefV8Value;
TCefV8ValueArray = array[0..(High(Integer) div SizeOf(PCefV8Value)) - 1] of PCefV8Value;
PCefV8ValueArray = ^TCefV8ValueArray;
PCefV8StackTrace = ^TCefV8StackTrace;
PCefV8StackFrame = ^TCefV8StackFrame;
PCefValue = ^TCefValue;
PCefBinaryValue = ^TCefBinaryValue;
TCefBinaryValueArray = array[0..(High(Integer) div SizeOf(PCefBinaryValue)) - 1] of PCefBinaryValue;
PCefBinaryValueArray = ^TCefBinaryValueArray;
PCefDictionaryValue = ^TCefDictionaryValue;
PCefListValue = ^TCefListValue;
PCefWaitableEvent = ^TCefWaitableEvent;
PCefWebPluginInfo = ^TCefWebPluginInfo;
PCefWebPluginInfoVisitor = ^TCefWebPluginInfoVisitor;
PCefWebPluginUnstableCallback = ^TCefWebPluginUnstableCallback;
PCefRegisterCdmCallback = ^TCefRegisterCdmCallback;
PCefX509certPrincipal = ^TCefX509certPrincipal;
PCefX509certificate = ^TCefX509certificate;
TCefX509certificateArray = array[0..(High(Integer) div SizeOf(PCefX509certificate)) - 1] of PCefX509certificate;
PCefX509certificateArray = ^TCefX509certificateArray;
PCefXmlReader = ^TCefXmlReader;
PCefZipReader = ^TCefZipReader;
{ *** cef_base_capi.h *** }
// All ref-counted framework structures must include this structure first.
TCefBaseRefCounted = record
// Size of the data structure.
size: csize_t;
// Called to increment the reference count for the object. Should be called
// for every new copy of a pointer to a given object.
add_ref: procedure(self: PCefBaseRefCounted); cconv;
// Called to decrement the reference count for the object. If the reference
// count falls to 0 the object should self-delete. Returns true (1) if the
// resulting reference count is 0.
release: function(self: PCefBaseRefCounted): Integer; cconv;
// Returns true (1) if the current reference count is 1.
has_one_ref: function(self: PCefBaseRefCounted): Integer; cconv;
end;
// All scoped framework structures must include this structure first.
TCefBaseScoped = record
// Size of the data structure.
size: csize_t;
// Called to delete this object. May be NULL if the object is not owned.
del: procedure(self: PCefBaseScoped); cconv;
end;
{ *** cef_app_capi.h *** }
// Implement this structure to provide handler implementations. Methods will be
// called by the process and/or thread indicated.
TCefApp = record
// Base structure.
base: TCefBaseRefCounted;
// Provides an opportunity to view and/or modify command-line arguments before
// processing by CEF and Chromium. The |process_type| value will be NULL for
// the browser process. Do not keep a reference to the cef_command_line_t
// object passed to this function. The CefSettings.command_line_args_disabled
// value can be used to start with an NULL command-line object. Any values
// specified in CefSettings that equate to command-line arguments will be set
// before this function is called. Be cautious when using this function to
// modify command-line arguments for non-browser processes as this may result
// in undefined behavior including crashes.
on_before_command_line_processing: procedure(self: PCefApp; const process_type: PCefString; command_line: PCefCommandLine); cconv;
// Provides an opportunity to register custom schemes. Do not keep a reference
// to the |registrar| object. This function is called on the main thread for
// each process and the registered schemes should be the same across all
// processes.
on_register_custom_schemes: procedure(self: PCefApp; registrar: PCefSchemeRegistrar); cconv;
// Return the handler for resource bundle events. If
// CefSettings.pack_loading_disabled is true (1) a handler must be returned.
// If no handler is returned resources will be loaded from pack files. This
// function is called by the browser and render processes on multiple threads.
get_resource_bundle_handler: function(self: PCefApp): PCefResourceBundleHandler; cconv;
// Return the handler for functionality specific to the browser process. This
// function is called on multiple threads in the browser process.
get_browser_process_handler: function(self: PCefApp): PCefBrowserProcessHandler; cconv;
// Return the handler for functionality specific to the render process. This
// function is called on the render process main thread.
get_render_process_handler: function(self: PCefApp): PCefRenderProcessHandler; cconv;
end;
{ *** cef_auth_callback_capi.h *** }
// Callback structure used for asynchronous continuation of authentication
// requests.
TCefAuthCallback = record
// Base structure.
base: TCefBaseRefCounted;
// Continue the authentication request.
cont: procedure(self: PCefAuthCallback; const username, password: PCefString); cconv;
// Cancel the authentication request.
cancel: procedure(self: PCefAuthCallback); cconv;
end;
{ *** cef_browser_capi.h *** }
// Structure used to represent a browser window. When used in the browser
// process the functions of this structure may be called on any thread unless
// otherwise indicated in the comments. When used in the render process the
// functions of this structure may only be called on the main thread.
TCefBrowser = record
// Base structure.
base: TCefBaseRefCounted;
// Returns the browser host object. This function can only be called in the
// browser process.
get_host: function(self: PCefBrowser): PCefBrowserHost; cconv;
// Returns true (1) if the browser can navigate backwards.
can_go_back: function(self: PCefBrowser): Integer; cconv;
// Navigate backwards.
go_back: procedure(self: PCefBrowser); cconv;
// Returns true (1) if the browser can navigate forwards.
can_go_forward: function(self: PCefBrowser): Integer; cconv;
// Navigate forwards.
go_forward: procedure(self: PCefBrowser); cconv;
// Returns true (1) if the browser is currently loading.
is_loading: function(self: PCefBrowser): Integer; cconv;
// Reload the current page.
reload: procedure(self: PCefBrowser); cconv;
// Reload the current page ignoring any cached data.
reload_ignore_cache: procedure(self: PCefBrowser); cconv;
// Stop loading the page.
stop_load: procedure(self: PCefBrowser); cconv;
// Returns the globally unique identifier for this browser.
get_identifier: function(self: PCefBrowser): Integer; cconv;
// Returns true (1) if this object is pointing to the same handle as |that|
// object.
is_same: function(self, that: PCefBrowser): Integer; cconv;
// Returns true (1) if the window is a popup window.
is_popup: function(self: PCefBrowser): Integer; cconv;
// Returns true (1) if a document has been loaded in the browser.
has_document: function(self: PCefBrowser): Integer; cconv;
// Returns the main (top-level) frame for the browser window.
get_main_frame: function(self: PCefBrowser): PCefFrame; cconv;
// Returns the focused frame for the browser window.
get_focused_frame: function(self: PCefBrowser): PCefFrame; cconv;
// Returns the frame with the specified identifier, or NULL if not found.
get_frame_byident: function(self: PCefBrowser; identifier: Int64): PCefFrame; cconv;
// Returns the frame with the specified name, or NULL if not found.
get_frame: function(self: PCefBrowser; const name: PCefString): PCefFrame; cconv;
// Returns the number of frames that currently exist.
get_frame_count: function(self: PCefBrowser): csize_t; cconv;
// Returns the identifiers of all existing frames.
get_frame_identifiers: procedure(self: PCefBrowser; identifiersCount: pcsize_t; identifiers: PInt64); cconv;
// Returns the names of all existing frames.
get_frame_names: procedure(self: PCefBrowser; names: TCefStringList); cconv;
// Send a message to the specified |target_process|. Returns true (1) if the
// message was sent successfully.
send_process_message: function(self: PCefBrowser; target_process: TCefProcessId;
message: PCefProcessMessage): Integer; cconv;
end;
// Callback structure for cef_browser_host_t::RunFileDialog. The functions of
// this structure will be called on the browser process UI thread.
TCefRunFileDialogCallback = record
// Base structure.
base: TCefBaseRefCounted;
// Called asynchronously after the file dialog is dismissed.
// |selected_accept_filter| is the 0-based index of the value selected from
// the accept filters array passed to cef_browser_host_t::RunFileDialog.
// |file_paths| will be a single value or a list of values depending on the
// dialog mode. If the selection was cancelled |file_paths| will be NULL.
on_file_dialog_dismissed: procedure(self: PCefRunFileDialogCallback; selected_accept_filter: Integer;
file_paths: TCefStringList); cconv;
end;
// Callback structure for cef_browser_host_t::GetNavigationEntries. The
// functions of this structure will be called on the browser process UI thread.
TCefNavigationEntryVisitor = record
// Base structure.
base: TCefBaseRefCounted;
// Method that will be executed. Do not keep a reference to |entry| outside of
// this callback. Return true (1) to continue visiting entries or false (0) to
// stop. |current| is true (1) if this entry is the currently loaded
// navigation entry. |index| is the 0-based index of this entry and |total| is
// the total number of entries.
visit: function(self: PCefNavigationEntryVisitor; entry: PCefNavigationEntry; current, index, total: Integer): Integer; cconv;
end;
// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this
// structure will be called on the browser process UI thread.
TCefPdfPrintCallback = record
// Base structure.
base: TCefBaseRefCounted;
// Method that will be executed when the PDF printing has completed. |path| is
// the output path. |ok| will be true (1) if the printing completed
// successfully or false (0) otherwise.
on_pdf_print_finished: procedure(self: PCefPdfPrintCallback; const path: PCefString; ok: Integer); cconv;
end;
// Callback structure for cef_browser_host_t::DownloadImage. The functions of
// this structure will be called on the browser process UI thread.
TCefDownloadImageCallback = record
// Base structure.
base: TCefBaseRefCounted;
// Method that will be executed when the image download has completed.
// |image_url| is the URL that was downloaded and |http_status_code| is the
// resulting HTTP status code. |image| is the resulting image, possibly at
// multiple scale factors, or NULL if the download failed.
on_download_image_finished: procedure(self: PCefDownloadImageCallback;
const image_url: PCefString; http_status_code: Integer; image: PCefImage); cconv;
end;
// Structure used to represent the browser process aspects of a browser window.
// The functions of this structure can only be called in the browser process.
// They may be called on any thread in that process unless otherwise indicated
// in the comments.
TCefBrowserHost = record
// Base structure.
base: TCefBaseRefCounted;
// Returns the hosted browser object.
get_browser: function(self: PCefBrowserHost): PCefBrowser; cconv;
// Request that the browser close. The JavaScript 'onbeforeunload' event will
// be fired. If |force_close| is false (0) the event handler, if any, will be
// allowed to prompt the user and the user can optionally cancel the close. If
// |force_close| is true (1) the prompt will not be displayed and the close
// will proceed. Results in a call to cef_life_span_handler_t::do_close() if
// the event handler allows the close or if |force_close| is true (1). See
// cef_life_span_handler_t::do_close() documentation for additional usage
// information.
close_browser: procedure(self: PCefBrowserHost; force_close: Integer); cconv;
// Helper for closing a browser. Call this function from the top-level window
// close handler. Internally this calls CloseBrowser(false (0)) if the close
// has not yet been initiated. This function returns false (0) while the close
// is pending and true (1) after the close has completed. See close_browser()
// and cef_life_span_handler_t::do_close() documentation for additional usage
// information. This function must be called on the browser process UI thread.
try_close_browser: function(self: PCefBrowserHost): Integer; cconv;
// Set whether the browser is focused.
set_focus: procedure(self: PCefBrowserHost; focus: Integer); cconv;
// Retrieve the window handle for this browser. If this browser is wrapped in
// a cef_browser_view_t this function should be called on the browser process
// UI thread and it will return the handle for the top-level native window.
get_window_handle: function(self: PCefBrowserHost): TCefWindowHandle; cconv;
// Retrieve the window handle of the browser that opened this browser. Will
// return NULL for non-popup windows or if this browser is wrapped in a
// cef_browser_view_t. This function can be used in combination with custom
// handling of modal windows.
get_opener_window_handle: function(self: PCefBrowserHost): TCefWindowHandle; cconv;
// Returns true (1) if this browser is wrapped in a cef_browser_view_t.
has_view: function(self: PCefBrowserHost): Integer; cconv;
// Returns the client for this browser.
get_client: function(self: PCefBrowserHost): PCefClient; cconv;
// Returns the request context for this browser.
get_request_context: function(self: PCefBrowserHost): PCefRequestContext; cconv;
// Get the current zoom level. The default zoom level is 0.0. This function
// can only be called on the UI thread.
get_zoom_level: function(self: PCefBrowserHost): Double; cconv;
// Change the zoom level to the specified value. Specify 0.0 to reset the zoom
// level. If called on the UI thread the change will be applied immediately.
// Otherwise, the change will be applied asynchronously on the UI thread.
set_zoom_level: procedure(self: PCefBrowserHost; zoomLevel: Double); cconv;
// Call to run a file chooser dialog. Only a single file chooser dialog may be
// pending at any given time. |mode| represents the type of dialog to display.
// |title| to the title to be used for the dialog and may be NULL to show the
// default title ("Open" or "Save" depending on the mode). |default_file_path|
// is the path with optional directory and/or file name component that will be
// initially selected in the dialog. |accept_filters| are used to restrict the
// selectable file types and may any combination of (a) valid lower-cased MIME
// types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g.
// ".txt" or ".png"), or (c) combined description and file extension delimited
// using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg").
// |selected_accept_filter| is the 0-based index of the filter that will be
// selected by default. |callback| will be executed after the dialog is
// dismissed or immediately if another dialog is already pending. The dialog
// will be initiated asynchronously on the UI thread.
run_file_dialog: procedure(self: PCefBrowserHost; mode: TCefFileDialogMode;
const title, default_file_path: PCefString; accept_filters: TCefStringList;
selected_accept_filter: Integer; callback: PCefRunFileDialogCallback); cconv;
// Download the file at |url| using cef_download_handler_t.
start_download: procedure(self: PCefBrowserHost; const url: PCefString); cconv;
// Download |image_url| and execute |callback| on completion with the images
// received from the renderer. If |is_favicon| is true (1) then cookies are
// not sent and not accepted during download. Images with density independent
// pixel (DIP) sizes larger than |max_image_size| are filtered out from the
// image results. Versions of the image at different scale factors may be
// downloaded up to the maximum scale factor supported by the system. If there
// are no image results <= |max_image_size| then the smallest image is resized
// to |max_image_size| and is the only result. A |max_image_size| of 0 means
// unlimited. If |bypass_cache| is true (1) then |image_url| is requested from
// the server even if it is present in the browser cache.
download_image: procedure(self: PCefBrowserHost; const image_url: PCefString; is_favicon: Integer;
max_image_size: cuint32; bypass_cache: Integer; callback: PCefDownloadImageCallback); cconv;
// Print the current browser contents.
print: procedure(self: PCefBrowserHost); cconv;
// Print the current browser contents to the PDF file specified by |path| and
// execute |callback| on completion. The caller is responsible for deleting
// |path| when done. For PDF printing to work on Linux you must implement the
// cef_print_handler_t::GetPdfPaperSize function.
print_to_pdf: procedure(self: PCefBrowserHost; const path: PCefString; const settings: PCefPdfPrintSettings;
callback: PCefPdfPrintCallback); cconv;
// Search for |searchText|. |identifier| must be a unique ID and these IDs
// must strictly increase so that newer requests always have greater IDs than
// older requests. If |identifier| is zero or less than the previous ID value
// then it will be automatically assigned a new valid ID. |forward| indicates
// whether to search forward or backward within the page. |matchCase|
// indicates whether the search should be case-sensitive. |findNext| indicates
// whether this is the first request or a follow-up. The cef_find_handler_t
// instance, if any, returned via cef_client_t::GetFindHandler will be called
// to report find results.
find: procedure(self: PCefBrowserHost; identifier: Integer; const searchText: PCefString;
forward_, matchCase, findNext: Integer); cconv;
// Cancel all searches that are currently going on.
stop_finding: procedure(self: PCefBrowserHost; clearSelection: Integer); cconv;
// Open developer tools (DevTools) in its own browser. The DevTools browser
// will remain associated with this browser. If the DevTools browser is
// already open then it will be focused, in which case the |windowInfo|,
// |client| and |settings| parameters will be ignored. If |inspect_element_at|
// is non-NULL then the element at the specified (x,y) location will be
// inspected. The |windowInfo| parameter will be ignored if this browser is
// wrapped in a cef_browser_view_t.
show_dev_tools: procedure(self: PCefBrowserHost; const windowInfo: PCefWindowInfo; client: PCefClient;
const settings: PCefBrowserSettings; const inspect_element_at: PCefPoint); cconv;
// Explicitly close the associated DevTools browser, if any.
close_dev_tools: procedure(self: PCefBrowserHost); cconv;
// Returns true (1) if this browser currently has an associated DevTools
// browser. Must be called on the browser process UI thread.
has_dev_tools: function(self: PCefBrowserHost): Integer; cconv;
// Retrieve a snapshot of current navigation entries as values sent to the
// specified visitor. If |current_only| is true (1) only the current
// navigation entry will be sent, otherwise all navigation entries will be
// sent.
get_navigation_entries: procedure(self: PCefBrowserHost; visitor: PCefNavigationEntryVisitor;
current_only: Integer); cconv;
// Set whether mouse cursor change is disabled.
set_mouse_cursor_change_disabled: procedure(self: PCefBrowserHost; disabled: Integer); cconv;
// Returns true (1) if mouse cursor change is disabled.
is_mouse_cursor_change_disabled: function(self: PCefBrowserHost) : Integer; cconv;
// If a misspelled word is currently selected in an editable node calling this
// function will replace it with the specified |word|.
replace_misspelling: procedure(self: PCefBrowserHost; const word: PCefString); cconv;
// Add the specified |word| to the spelling dictionary.
add_word_to_dictionary: procedure(self: PCefBrowserHost; const word: PCefString); cconv;
// Returns true (1) if window rendering is disabled.
is_window_rendering_disabled: function(self: PCefBrowserHost): Integer; cconv;
// Notify the browser that the widget has been resized. The browser will first
// call cef_render_handler_t::GetViewRect to get the new size and then call
// cef_render_handler_t::OnPaint asynchronously with the updated regions. This
// function is only used when window rendering is disabled.
was_resized: procedure(self: PCefBrowserHost); cconv;
// Notify the browser that it has been hidden or shown. Layouting and
// cef_render_handler_t::OnPaint notification will stop when the browser is
// hidden. This function is only used when window rendering is disabled.
was_hidden: procedure(self: PCefBrowserHost; hidden: Integer); cconv;
// Send a notification to the browser that the screen info has changed. The
// browser will then call cef_render_handler_t::GetScreenInfo to update the
// screen information with the new values. This simulates moving the webview
// window from one display to another, or changing the properties of the
// current display. This function is only used when window rendering is
// disabled.
notify_screen_info_changed: procedure(self: PCefBrowserHost); cconv;
// Invalidate the view. The browser will call cef_render_handler_t::OnPaint
// asynchronously. This function is only used when window rendering is
// disabled.
invalidate: procedure(self: PCefBrowserHost; type_: TCefPaintElementType); cconv;
// Send a key event to the browser.
send_key_event: procedure(self: PCefBrowserHost; const event: PCefKeyEvent); cconv;
// Send a mouse click event to the browser. The |x| and |y| coordinates are
// relative to the upper-left corner of the view.
send_mouse_click_event: procedure(self: PCefBrowserHost; const event: PCefMouseEvent; type_: TCefMouseButtonType;
mouseUp, clickCount: Integer); cconv;
// Send a mouse move event to the browser. The |x| and |y| coordinates are
// relative to the upper-left corner of the view.
send_mouse_move_event: procedure(self: PCefBrowserHost; const event: PCefMouseEvent; mouseLeave: Integer); cconv;
// Send a mouse wheel event to the browser. The |x| and |y| coordinates are
// relative to the upper-left corner of the view. The |deltaX| and |deltaY|
// values represent the movement delta in the X and Y directions respectively.
// In order to scroll inside select popups with window rendering disabled
// cef_render_handler_t::GetScreenPoint should be implemented properly.
send_mouse_wheel_event: procedure(self: PCefBrowserHost; const event: PCefMouseEvent; deltaX, deltaY: Integer); cconv;
// Send a focus event to the browser.
send_focus_event: procedure(self: PCefBrowserHost; setFocus: Integer); cconv;
// Send a capture lost event to the browser.
send_capture_lost_event: procedure(self: PCefBrowserHost); cconv;
// Notify the browser that the window hosting it is about to be moved or
// resized. This function is only used on Windows and Linux.
notify_move_or_resize_started: procedure(self: PCefBrowserHost); cconv;
// Returns the maximum rate in frames per second (fps) that
// cef_render_handler_t:: OnPaint will be called for a windowless browser. The
// actual fps may be lower if the browser cannot generate frames at the
// requested rate. The minimum value is 1 and the maximum value is 60 (default
// 30). This function can only be called on the UI thread.
get_windowless_frame_rate: function(self: PCefBrowserHost): Integer; cconv;
// Set the maximum rate in frames per second (fps) that cef_render_handler_t::
// OnPaint will be called for a windowless browser. The actual fps may be
// lower if the browser cannot generate frames at the requested rate. The
// minimum value is 1 and the maximum value is 60 (default 30). Can also be
// set at browser creation via cef_browser_tSettings.windowless_frame_rate.
set_windowless_frame_rate: procedure(self: PCefBrowserHost; frame_rate: Integer); cconv;
// Begins a new composition or updates the existing composition. Blink has a
// special node (a composition node) that allows the input function to change
// text without affecting other DOM nodes. |text| is the optional text that
// will be inserted into the composition node. |underlines| is an optional set
// of ranges that will be underlined in the resulting text.
// |replacement_range| is an optional range of the existing text that will be
// replaced. |selection_range| is an optional range of the resulting text that
// will be selected after insertion or replacement. The |replacement_range|
// value is only used on OS X.
//
// This function may be called multiple times as the composition changes. When
// the client is done making changes the composition should either be canceled
// or completed. To cancel the composition call ImeCancelComposition. To
// complete the composition call either ImeCommitText or
// ImeFinishComposingText. Completion is usually signaled when:
// A. The client receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR
// flag (on Windows), or;
// B. The client receives a "commit" signal of GtkIMContext (on Linux), or;
// C. insertText of NSTextInput is called (on Mac).
//
// This function is only used when window rendering is disabled.
ime_set_composition: procedure(self: PCefBrowserHost; const text: PCefString;
underlinesCount: csize_t; underlines: PCefCompositionUnderlineArray;
const replacement_range, selection_range: PCefRange); cconv;
// Completes the existing composition by optionally inserting the specified
// |text| into the composition node. |replacement_range| is an optional range
// of the existing text that will be replaced. |relative_cursor_pos| is where
// the cursor will be positioned relative to the current cursor position. See
// comments on ImeSetComposition for usage. The |replacement_range| and
// |relative_cursor_pos| values are only used on OS X. This function is only
// used when window rendering is disabled.
ime_commit_text: procedure(self: PCefBrowserHost; const text: PCefString;
const replacement_range: PCefRange; relative_cursor_pos: Integer); cconv;
// Completes the existing composition by applying the current composition node
// contents. If |keep_selection| is false (0) the current selection, if any,
// will be discarded. See comments on ImeSetComposition for usage. This
// function is only used when window rendering is disabled.
ime_finish_composing_text: procedure(self: PCefBrowserHost; keep_selection: Integer); cconv;
// Cancels the existing composition and discards the composition node contents
// without applying them. See comments on ImeSetComposition for usage. This
// function is only used when window rendering is disabled.
ime_cancel_composition: procedure(self: PCefBrowserHost); cconv;
// Call this function when the user drags the mouse into the web view (before
// calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). |drag_data|
// should not contain file contents as this type of data is not allowed to be
// dragged into the web view. File contents can be removed using
// cef_drag_data_t::ResetFileContents (for example, if |drag_data| comes from
// cef_render_handler_t::StartDragging). This function is only used when
// window rendering is disabled.
drag_target_drag_enter: procedure(self: PCefBrowserHost; drag_data: PCefDragData;
const event: PCefMouseEvent; allowed_ops: TCefDragOperationsMask); cconv;
// Call this function each time the mouse is moved across the web view during
// a drag operation (after calling DragTargetDragEnter and before calling
// DragTargetDragLeave/DragTargetDrop). This function is only used when window
// rendering is disabled.
drag_target_drag_over: procedure(self: PCefBrowserHost; const event: PCefMouseEvent;
alllowed_ops: TCefDragOperationsMask); cconv;
// Call this function when the user drags the mouse out of the web view (after
// calling DragTargetDragEnter). This function is only used when window
// rendering is disabled.
drag_target_drag_leave: procedure(self: PCefBrowserHost); cconv;
// Call this function when the user completes the drag operation by dropping
// the object onto the web view (after calling DragTargetDragEnter). The
// object being dropped is |drag_data|, given as an argument to the previous
// DragTargetDragEnter call. This function is only used when window rendering
// is disabled.
drag_target_drop: procedure(self: PCefBrowserHost; const event: PCefMouseEvent); cconv;
// Call this function when the drag operation started by a
// cef_render_handler_t::StartDragging call has ended either in a drop or by
// being cancelled. |x| and |y| are mouse coordinates relative to the upper-
// left corner of the view. If the web view is both the drag source and the
// drag target then all DragTarget* functions should be called before
// DragSource* mthods. This function is only used when window rendering is
// disabled.
drag_source_ended_at: procedure(self: PCefBrowserHost; x, y: Integer; op: TCefDragOperationsMask); cconv;
// Call this function when the drag operation started by a
// cef_render_handler_t::StartDragging call has completed. This function may
// be called immediately without first calling DragSourceEndedAt to cancel a
// drag operation. If the web view is both the drag source and the drag target
// then all DragTarget* functions should be called before DragSource* mthods.
// This function is only used when window rendering is disabled.
drag_source_system_drag_ended: procedure(self: PCefBrowserHost); cconv;
// Returns the current visible navigation entry for this browser. This
// function can only be called on the UI thread.
get_visible_navigation_entry: function(self: PCefBrowserHost): PCefNavigationEntry; cconv;
end;
{ *** cef_browser_process_handler.h *** }
// Structure used to implement browser process callbacks. The functions of this
// structure will be called on the browser process main thread unless otherwise
// indicated.
TCefBrowserProcessHandler = record
// Base structure.
base: TCefBaseRefCounted;
// Called on the browser process UI thread immediately after the CEF context
// has been initialized.
on_context_initialized: procedure(self: PCefBrowserProcessHandler); cconv;
// Called before a child process is launched. Will be called on the browser
// process UI thread when launching a render process and on the browser
// process IO thread when launching a GPU or plugin process. Provides an
// opportunity to modify the child process command line. Do not keep a
// reference to |command_line| outside of this function.
on_before_child_process_launch: procedure(self: PCefBrowserProcessHandler; command_line: PCefCommandLine); cconv;
// Called on the browser process IO thread after the main thread has been
// created for a new render process. Provides an opportunity to specify extra
// information that will be passed to
// cef_render_process_handler_t::on_render_thread_created() in the render
// process. Do not keep a reference to |extra_info| outside of this function.
on_render_process_thread_created: procedure(self: PCefBrowserProcessHandler; extra_info: PCefListValue); cconv;
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.
get_print_handler: function(self: PCefBrowserProcessHandler): PCefPrintHandler; cconv;
// Called from any thread when work has been scheduled for the browser process
// main (UI) thread. This callback is used in combination with CefSettings.
// external_message_pump and cef_do_message_loop_work() in cases where the CEF
// message loop must be integrated into an existing application message loop
// (see additional comments and warnings on CefDoMessageLoopWork). This
// callback should schedule a cef_do_message_loop_work() call to happen on the
// main (UI) thread. |delay_ms| is the requested delay in milliseconds. If
// |delay_ms| is <= 0 then the call should happen reasonably soon. If
// |delay_ms| is > 0 then the call should be scheduled to happen after the
// specified delay and any currently pending scheduled call should be
// cancelled.
on_schedule_message_pump_work: procedure(self: PCefBrowserProcessHandler; delay_ms: Int64); cconv;
end;
{ *** cef_callback_capi.h *** }
// Generic callback structure used for asynchronous continuation.
TCefCallback = record
// Base structure.
base: TCefBaseRefCounted;
// Continue processing.
cont: procedure(self: PCefCallback); cconv;
// Cancel processing.
cancel: procedure(self: PCefCallback); cconv;
end;
// Generic callback structure used for asynchronous completion.
TCefCompletionCallback = record
// Base structure.
base: TCefBaseRefCounted;
// Method that will be called once the task is complete.
on_complete: procedure(self: PCefCompletionCallback); cconv;
end;
{ *** cef_client_capi.h *** }
// Implement this structure to provide handler implementations.
TCefClient = record
// Base structure.
base: TCefBaseRefCounted;
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.
get_context_menu_handler: function(self: PCefClient): PCefContextMenuHandler; cconv;
// Return the handler for dialogs. If no handler is provided the default
// implementation will be used.
get_dialog_handler: function(self: PCefClient): PCefDialogHandler; cconv;
// Return the handler for browser display state events.
get_display_handler: function(self: PCefClient): PCefDisplayHandler; cconv;
// Return the handler for download events. If no handler is returned downloads
// will not be allowed.
get_download_handler: function(self: PCefClient): PCefDownloadHandler; cconv;
// Return the handler for drag events.
get_drag_handler: function(self: PCefClient): PCefDragHandler; cconv;
// Return the handler for find result events.
get_find_handler: function(self: PCefClient): PCefFindHandler; cconv;
// Return the handler for focus events.
get_focus_handler: function(self: PCefClient): PCefFocusHandler; cconv;
// Return the handler for geolocation permissions requests. If no handler is
// provided geolocation access will be denied by default.
get_geolocation_handler: function(self: PCefClient): PCefGeolocationHandler; cconv;
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
get_jsdialog_handler: function(self: PCefClient): PCefJsDialogHandler; cconv;
// Return the handler for keyboard events.
get_keyboard_handler: function(self: PCefClient): PCefKeyboardHandler; cconv;
// Return the handler for browser life span events.
get_life_span_handler: function(self: PCefClient): PCefLifeSpanHandler; cconv;
// Return the handler for browser load status events.
get_load_handler: function(self: PCefClient): PCefLoadHandler; cconv;
// Return the handler for off-screen rendering events.
get_render_handler: function(self: PCefClient): PCefRenderHandler; cconv;
// Return the handler for browser request events.
get_request_handler: function(self: PCefClient): PCefRequestHandler; cconv;
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
on_process_message_received: function(self: PCefClient; browser: PCefBrowser; source_process: TCefProcessId; message: PCefProcessMessage): Integer; cconv;
end;
{ *** cef_command_line_capi.h *** }
// Structure used to create and/or parse command line arguments. Arguments with
// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches
// will always precede any arguments without switch prefixes. Switches can
// optionally have a value specified using the '=' delimiter (e.g.
// "-switch=value"). An argument of "--" will terminate switch parsing with all
// subsequent tokens, regardless of prefix, being interpreted as non-switch
// arguments. Switch names are considered case-insensitive. This structure can
// be used before cef_initialize() is called.
TCefCommandLine = record
// Base structure.
base: TCefBaseRefCounted;
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
is_valid: function(self: PCefCommandLine): Integer; cconv;
// Returns true (1) if the values of this object are read-only. Some APIs may
// expose read-only objects.
is_read_only: function(self: PCefCommandLine): Integer; cconv;
// Returns a writable copy of this object.
copy: function(self: PCefCommandLine): PCefCommandLine; cconv;
// Initialize the command line with the specified |argc| and |argv| values.
// The first argument must be the name of the program. This function is only
// supported on non-Windows platforms.
init_from_argv: procedure(self: PCefCommandLine; argc: Integer; const argv: PPAnsiChar); cconv;
// Initialize the command line with the string returned by calling
// GetCommandLineW(). This function is only supported on Windows.
init_from_string: procedure(self: PCefCommandLine; command_line: PCefString); cconv;
// Reset the command-line switches and arguments but leave the program
// component unchanged.
reset: procedure(self: PCefCommandLine); cconv;
// Retrieve the original command line string as a vector of strings. The argv
// array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
get_argv: procedure(self: PCefCommandLine; argv: TCefStringList); cconv;
// Constructs and returns the represented command line string. Use this
// function cautiously because quoting behavior is unclear.
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_command_line_string: function(self: PCefCommandLine): PCefStringUserFree; cconv;
// Get the program part of the command line string (the first item).
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_program: function(self: PCefCommandLine): PCefStringUserFree; cconv;
// Set the program part of the command line string (the first item).
set_program: procedure(self: PCefCommandLine; const program_: PCefString); cconv;
// Returns true (1) if the command line has switches.
has_switches: function(self: PCefCommandLine): Integer; cconv;
// Returns true (1) if the command line contains the given switch.
has_switch: function(self: PCefCommandLine; const name: PCefString): Integer; cconv;
// Returns the value associated with the given switch. If the switch has no
// value or isn't present this function returns the NULL string.
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_switch_value: function(self: PCefCommandLine; const name: PCefString): PCefStringUserFree; cconv;
// Returns the map of switch names and values. If a switch has no value an
// NULL string is returned.
get_switches: procedure(self: PCefCommandLine; switches: TCefStringMap); cconv;
// Add a switch to the end of the command line. If the switch has no value
// pass an NULL value string.
append_switch: procedure(self: PCefCommandLine; const name: PCefString); cconv;
// Add a switch with the specified value to the end of the command line.
append_switch_with_value: procedure(self: PCefCommandLine; const name, value: PCefString); cconv;
// True if there are remaining command line arguments.
has_arguments: function(self: PCefCommandLine): Integer; cconv;
// Get the remaining command line arguments.
get_arguments: procedure(self: PCefCommandLine; arguments: TCefStringList); cconv;
// Add an argument to the end of the command line.
append_argument: procedure(self: PCefCommandLine; const argument: PCefString); cconv;
// Insert a command before the current command. Common for debuggers, like
// "valgrind" or "gdb --args".
prepend_wrapper: procedure(self: PCefCommandLine; const wrapper: PCefString); cconv;
end;
{ *** cef_context_menu_handler.h *** }
TCefRunContextMenuCallback = record
// Base structure.
base: TCefBaseRefCounted;
// Complete context menu display by selecting the specified |command_id| and
// |event_flags|.
cont: procedure(self: PCefRunContextMenuCallback; command_id: Integer; event_flags: TCefEventFlags); cconv;
// Cancel context menu display.
cancel: procedure(self: PCefRunContextMenuCallback); cconv;
end;
// Implement this structure to handle context menu events. The functions of this
// structure will be called on the UI thread.
TCefContextMenuHandler = record
// Base structure.
base: TCefBaseRefCounted;
// Called before a context menu is displayed. |params| provides information
// about the context menu state. |model| initially contains the default