forked from dliw/fpCEF3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcef3api.pas
4963 lines (3893 loc) · 234 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
*
* 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 <dev.dliw@gmail.com>
* Repository: http://github.com/dliw/fpCEF3
*
*
* Based on 'Delphi Chromium Embedded' by: Henri Gourvest <hgourvest@gmail.com>
* Repository : http://code.google.com/p/delphichromiumembedded/
*
* 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 WINDOWS}Windows,{$ENDIF}
{$IFDEF LINUX}Dynlibs,{$ENDIF}
sysutils, LCLProc, ctypes,
cef3types;
Type
PCefBase = ^TCefBase;
PCefApp = ^TCefApp;
PCefAuthCallback = ^TCefAuthCallback;
PCefBrowser = ^TCefBrowser;
PCefRunFileDialogCallback = ^TCefRunFileDialogCallback;
PCefBrowserHost = ^TCefBrowserHost;
PCefBrowserProcessHandler = ^TCefBrowserProcessHandler;
PCefCompletionHandler = ^TCefCompletionHandler;
PCefCallback = ^TCefCallback;
PCefClient = ^TCefClient;
PCefCommandLine = ^TCefCommandLine;
PCefContextMenuHandler = ^TCefContextMenuHandler;
PCefContextMenuParams = ^TCefContextMenuParams;
PCefCookieManager = ^TCefCookieManager;
PCefCookieVisitor = ^TCefCookieVisitor;
PCefFileDialogCallback = ^TCefFileDialogCallback;
PCefDialogHandler = ^TCefDialogHandler;
PCefDisplayHandler = ^TCefDisplayHandler;
PCefDomVisitor = ^TCefDomVisitor;
PCefDomDocument = ^TCefDomDocument;
PCefDomNode = ^TCefDomNode;
PCefDomEvent = ^TCefDomEvent;
PCefDomEventListener = ^TCefDomEventListener;
PCefBeforeDownloadCallback = ^TCefBeforeDownloadCallback;
PCefDownloadItemCallback = ^TCefDownloadItemCallback;
PCefDownloadHandler = ^TCefDownloadHandler;
PCefDownloadItem = ^TCefDownloadItem;
PCefDragData = ^TCefDragData;
PCefDragHandler = ^TCefDragHandler;
PCefFocusHandler = ^TCefFocusHandler;
PCefFrame = ^TCefFrame;
PCefGetGeolocationCallback = ^TCefGetGeolocationCallback;
PCefGeolocationCallback = ^TCefGeolocationCallback;
PCefGeolocationHandler = ^TCefGeolocationHandler;
PCefJsDialogCallback = ^TCefJsDialogCallback;
PCefJsDialogHandler = ^TCefJsDialogHandler;
PCefKeyboardHandler = ^TCefKeyboardHandler;
PCefLifeSpanHandler = ^TCefLifeSpanHandler;
PCefLoadHandler = ^TCefLoadHandler;
PCefMenuModel = ^TCefMenuModel;
PCefProcessMessage = ^TCefProcessMessage;
PCefRenderHandler = ^TCefRenderHandler;
PCefRenderProcessHandler = ^TCefRenderProcessHandler;
PCefRequest = ^TCefRequest;
PCefPostData = ^TCefPostData;
PCefPostDataElementArray = ^TCefPostDataElementArray;
PCefPostDataElement = ^TCefPostDataElement;
PCefRequestContext = ^TCefRequestContext;
PCefRequestContextHandler = ^TCefRequestContextHandler;
PCefQuotaCallback = ^TCefQuotaCallback;
PCefAllowCertificateErrorCallback = ^TCefAllowCertificateErrorCallback;
PCefRequestHandler = ^TCefRequestHandler;
PCefResourceBundleHandler = ^TCefResourceBundleHandler;
PCefResourceHandler = ^TCefResourceHandler;
PCefResponse = ^TCefResponse;
PCefSchemeRegistrar = ^TCefSchemeRegistrar;
PCefSchemeHandlerFactory = ^TCefSchemeHandlerFactory;
PCefReadHandler = ^TCefReadHandler;
PCefStreamReader = ^TCefStreamReader;
PCefWriteHandler = ^TCefWriteHandler;
PCefStreamWriter = ^TCefStreamWriter;
PCefStringVisitor = ^TCefStringVisitor;
PCefTask = ^TCefTask;
PCefTaskRunner = ^TCefTaskRunner;
PCefTraceClient = ^TCefTraceClient;
PCefUrlRequest = ^TCefUrlRequest;
PCefUrlRequestClient = ^TCefUrlRequestClient;
PCefV8Context = ^TCefV8Context;
PCefV8Handler = ^TCefV8Handler;
PCefV8Accessor = ^TCefV8Accessor;
PCefV8Exception = ^TCefV8Exception;
PPCefV8Value = ^PCefV8ValueArray;
PCefV8Value = ^TCefV8Value;
PCefV8StackTrace = ^TCefV8StackTrace;
PCefV8StackFrame = ^TCefV8StackFrame;
PCefBinaryValue = ^TCefBinaryValue;
PCefDictionaryValue = ^TCefDictionaryValue;
PCefListValue = ^TCefListValue;
PCefWebPluginInfo = ^TCefWebPluginInfo;
PCefWebPluginInfoVisitor = ^TCefWebPluginInfoVisitor;
PCefWebPluginUnstableCallback = ^TCefWebPluginUnstableCallback;
PCefXMLReader = ^TCefXMLReader;
PCefZipReader = ^TCefZipReader;
{ *** cef_base_capi.h *** }
// Structure defining the reference count implementation functions. All
// framework structures must include the cef_base_t structure first.
TCefBase = record
// Size of the data structure.
size: csize_t;
// Increment the reference count.
add_ref: function(self: PCefBase): Integer; cconv;
// Decrement the reference count. Delete this object when no references
// remain.
release: function(self: PCefBase): Integer; cconv;
// Returns the current number of references.
get_refct: function(self: PCefBase): Integer; 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: TCefBase;
// 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: TCefBase;
// 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: TCefBase;
// 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: TCefBase;
// Called asynchronously after the file dialog is dismissed. If the selection
// was successful |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.
cont: procedure(self: PCefRunFileDialogCallback; browser_host: PCefBrowserHost;
file_paths: TCefStringList); 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: TCefBase;
// Returns the hosted browser object.
get_browser: function(self : PCefBrowserHost) : PCefBrowser; cconv;
// Call this function before destroying a contained browser window. This
// function performs any internal cleanup that may be needed before the
// browser window is destroyed. See cef_life_span_handler_t::do_close()
// documentation for additional usage information.
parent_window_will_close: procedure(self: PCefBrowserHost); 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;
// Set focus for the browser window. If |enable| is true (1) focus will be set
// to the window. Otherwise, focus will be removed.
set_focus: procedure(self : PCefBrowserHost; enable : Integer); cconv;
// Retrieve the window handle for this browser.
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. This function can be used in combination
// with custom handling of modal windows.
get_opener_window_handle: function(self: PCefBrowserHost): TCefWindowHandle; 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;
// Returns the DevTools URL for this browser. If |http_scheme| is true (1) the
// returned URL will use the http scheme instead of the chrome-devtools
// scheme. Remote debugging can be enabled by specifying the "remote-
// debugging-port" command-line flag or by setting the
// CefSettings.remote_debugging_port value. If remote debugging is not enabled
// this function will return an NULL string.
///
// The resulting string must be freed by calling cef_string_userfree_free().
get_dev_tools_url: function(self: PCefBrowserHost; http_scheme: Integer): PCefStringUserFree; 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_name|
// is the default file name to select in the dialog. |accept_types| is a list
// of valid lower-cased MIME types or file extensions specified in an input
// element and is used to restrict selectable files to such types. |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_name: PCefString; accept_types: TCefStringList;
callback: PCefRunFileDialogCallback); cconv;
// Download the file at |url| using cef_download_handler_t.
start_download: procedure(self: PCefBrowserHost; const url: PCefString); cconv;
// Print the current browser contents.
print: procedure(self: PCefBrowserHost); cconv;
// Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |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.
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;
// 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;
// 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 |dirtyRect| region of the view. The browser will call
// cef_render_handler_t::OnPaint asynchronously with the updated regions. This
// function is only used when window rendering is disabled.
invalidate: procedure(self: PCefBrowserHost; const dirtyRect: PCefRect; 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;
// Get the NSTextInputContext implementation for enabling IME on Mac when
// window rendering is disabled.
get_nstext_input_context: function(self : PCefBrowserHost) : TCefTextInputContext; cconv;
// Handles a keyDown event prior to passing it through the NSTextInputClient
// machinery.
handle_key_event_before_text_input_client: procedure(self : PCefBrowserHost; keyEvent : TCefEventHandle); cconv;
// Performs any additional actions after NSTextInputClient handles the event.
handle_key_event_after_text_input_client: procedure(self : PCefBrowserHost; keyEvent : TCefEventHandle); 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: TCefBase;
// 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;
end;
{ *** cef_callback_capi.h *** }
// Generic callback structure used for asynchronous continuation.
TCefCallback = record
// Base structure.
base: TCefBase;
// Continue processing.
cont: procedure(self: PCefCallback); cconv;
// Cancel processing.
cancel: procedure(self: PCefCallback); cconv;
end;
// Generic callback structure used for asynchronous completion.
TCefCompletionHandler = record
// Base structure.
base: TCefBase;
// Method that will be called once the task is complete.
on_complete: procedure(self: PCefCompletionHandler); cconv;
end;
{ *** cef_client_capi.h *** }
// Implement this structure to provide handler implementations.
TCefClient = record
// Base structure.
base: TCefBase;
// 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 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: TCefBase;
// 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 *** }
// 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: TCefBase;
// Called before a context menu is displayed. |params| provides information
// about the context menu state. |model| initially contains the default
// context menu. The |model| can be cleared to show no context menu or
// modified to show a custom menu. Do not keep references to |params| or
// |model| outside of this callback.
on_before_context_menu: procedure(self: PCefContextMenuHandler;
browser: PCefBrowser; frame: PCefFrame; params: PCefContextMenuParams;
model: PCefMenuModel); cconv;
// Called to execute a command selected from the context menu. Return true (1)
// if the command was handled or false (0) for the default implementation. See
// cef_menu_id_t for the command ids that have default implementations. All
// user-defined command ids should be between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST. |params| will have the same values as what was passed to
// on_before_context_menu(). Do not keep a reference to |params| outside of
// this callback.
on_context_menu_command: function(self: PCefContextMenuHandler;
browser: PCefBrowser; frame: PCefFrame; params: PCefContextMenuParams;
command_id: Integer; event_flags: TCefEventFlags): Integer; cconv;
// Called when the context menu is dismissed irregardless of whether the menu
// was NULL or a command was selected.
on_context_menu_dismissed: procedure(self: PCefContextMenuHandler;
browser: PCefBrowser; frame: PCefFrame); cconv;
end;
// Provides information about the context menu state. The methods of this
// structure can only be accessed on browser process the UI thread.
TCefContextMenuParams = record
// Base structure.
base: TCefBase;
// Returns the X coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
get_xcoord: function(self: PCefContextMenuParams): Integer; cconv;
// Returns the Y coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
get_ycoord: function(self: PCefContextMenuParams): Integer; cconv;
// Returns flags representing the type of node that the context menu was
// invoked on.
//get_type_flags: function(self: PCefContextMenuParams): Integer; cconv;
get_type_flags: function(self: PCefContextMenuParams): TCefContextMenuTypeFlags; cconv;
// Returns the URL of the link, if any, that encloses the node that the
// context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_link_url: function(self: PCefContextMenuParams): PCefStringUserFree; cconv;
// Returns the link URL, if any, to be used ONLY for "copy link address". We
// don't validate this field in the frontend process.
get_unfiltered_link_url: function(self: PCefContextMenuParams): PCefStringUserFree; cconv;
// Returns the source URL, if any, for the element that the context menu was
// invoked on. Example of elements with source URLs are img, audio, and video.
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_source_url: function(self: PCefContextMenuParams): PCefStringUserFree; cconv;
// Returns true (1) if the context menu was invoked on an image which has non-
// NULL contents.
has_image_contents: function(self: PCefContextMenuParams): Integer; cconv;
// Returns the URL of the top level page that the context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_page_url: function(self: PCefContextMenuParams): PCefStringUserFree; cconv;
// Returns the URL of the subframe that the context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_frame_url: function(self: PCefContextMenuParams): PCefStringUserFree; cconv;
// Returns the character encoding of the subframe that the context menu was
// invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_frame_charset: function(self: PCefContextMenuParams): PCefStringUserFree; cconv;
// Returns the type of context node that the context menu was invoked on.
get_media_type: function(self: PCefContextMenuParams): TCefContextMenuMediaType; cconv;
// Returns flags representing the actions supported by the media element, if
// any, that the context menu was invoked on.
get_media_state_flags: function(self: PCefContextMenuParams): TCefContextMenuMediaStateFlags; cconv;
// Returns the text of the selection, if any, that the context menu was
// invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
get_selection_text: function(self: PCefContextMenuParams): PCefStringUserFree; cconv;
// Returns true (1) if the context menu was invoked on an editable node.
is_editable: function(self: PCefContextMenuParams): Integer; cconv;
// Returns true (1) if the context menu was invoked on an editable node where
// speech-input is enabled.
is_speech_input_enabled: function(self: PCefContextMenuParams): Integer; cconv;
// Returns flags representing the actions supported by the editable node, if
// any, that the context menu was invoked on.
//get_edit_state_flags: function(self: PCefContextMenuParams): Integer; cconv;
get_edit_state_flags: function(self: PCefContextMenuParams): TCefContextMenuEditStateFlags; cconv;
end;
{ *** cef_cookie_capi.h *** }
// Structure used for managing cookies. The functions of this structure may be
// called on any thread unless otherwise indicated.
TCefCookieManager = record
// Base structure.
base: TCefBase;
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. Must be called before any cookies are
// accessed.
set_supported_schemes: procedure(self: PCefCookieManager; schemes: TCefStringList); cconv;
// Visit all cookies. The returned cookies are ordered by longest path, then
// by earliest creation date. Returns false (0) if cookies cannot be accessed.
visit_all_cookies: function(self: PCefCookieManager; visitor: PCefCookieVisitor): Integer; cconv;
// Visit a subset of cookies. The results are filtered by the given url
// scheme, host, domain and path. If |includeHttpOnly| is true (1) HTTP-only
// cookies will also be included in the results. The returned cookies are
// ordered by longest path, then by earliest creation date. Returns false (0)
// if cookies cannot be accessed.
visit_url_cookies: function(self: PCefCookieManager; const url: PCefString;
includeHttpOnly: Integer; visitor: PCefCookieVisitor): Integer; cconv;
// Sets a cookie given a valid URL and explicit user-provided cookie
// attributes. This function expects each attribute to be well-formed. It will
// check for disallowed characters (e.g. the ';' character is disallowed
// within the cookie value attribute) and will return false (0) without
// setting the cookie if such characters are found. This function must be
// called on the IO thread.
set_cookie: function(self: PCefCookieManager; const url: PCefString; const cookie: PCefCookie): Integer; cconv;
// Delete all cookies that match the specified parameters. If both |url| and
// values |cookie_name| are specified all host and domain cookies matching
// both will be deleted. If only |url| is specified all host cookies (but not
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
// cookies for all hosts and domains will be deleted. Returns false (0) if a
// non- NULL invalid URL is specified or if cookies cannot be accessed. This
// function must be called on the IO thread.
delete_cookies: function(self: PCefCookieManager;
const url, cookie_name: PCefString): Integer; cconv;
// Sets the directory path that will be used for storing cookie data. If
// |path| is NULL data will be stored in memory only. Otherwise, data will be
// stored at the specified |path|. To persist session cookies (cookies without
// an expiry date or validity interval) set |persist_session_cookies| to true
// (1). Session cookies are generally intended to be transient and most Web
// browsers do not persist them. Returns false (0) if cookies cannot be
// accessed.
set_storage_path: function(self: PCefCookieManager; const path: PCefString;
persist_session_cookies: Integer): Integer; cconv;
// Flush the backing store (if any) to disk and execute the specified
// |handler| on the IO thread when done. Returns false (0) if cookies cannot
// be accessed.
flush_store: function(self: PCefCookieManager; handler: PCefCompletionHandler): Integer; cconv;
end;
// Structure to implement for visiting cookie values. The functions of this
// structure will always be called on the IO thread.
TCefCookieVisitor = record
// Base structure.
base: TCefBase;
// Method that will be called once for each cookie. |count| is the 0-based
// index for the current cookie. |total| is the total number of cookies. Set
// |deleteCookie| to true (1) to delete the cookie currently being visited.
// Return false (0) to stop visiting cookies. This function may never be
// called if no cookies are found.
visit: function(self: PCefCookieVisitor; const cookie: PCefCookie;
count, total: Integer; deleteCookie: PInteger): Integer; cconv;
end;
{ *** cef_dialog_handler_capi.h *** }
// Callback structure for asynchronous continuation of file dialog requests.
TCefFileDialogCallback = record
// Base structure.
base: TCefBase;
// Continue the file selection with the specified |file_paths|. This may be a
// single value or a list of values depending on the dialog mode. An NULL
// value is treated the same as calling cancel().
cont: procedure(self: PCefFileDialogCallback; file_paths: TCefStringList); cconv;
// Cancel the file selection.
cancel: procedure(self: PCefFileDialogCallback); cconv;
end;
// Implement this structure to handle dialog events. The functions of this
// structure will be called on the browser process UI thread.
TCefDialogHandler = record
// Base structure.
base: TCefBase;
// Called to run a file chooser dialog. |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_name| is the default file name to select in the dialog.
// |accept_types| is a list of valid lower-cased MIME types or file extensions
// specified in an input element and is used to restrict selectable files to
// such types. To display a custom dialog return true (1) and execute
// |callback| either inline or at a later time. To display the default dialog
// return false (0).
on_file_dialog: function(self: PCefDialogHandler; browser: PCefBrowser;
mode: TCefFileDialogMode; const title, default_file_name: PCefString;
accept_types: TCefStringList; callback: PCefFileDialogCallback): Integer; cconv;
end;
{ *** cef_display_handler_capi.h *** }
// Implement this structure to handle events related to browser display state.
// The functions of this structure will be called on the UI thread.
TCefDisplayHandler = record
// Base structure.
base: TCefBase;
// Called when a frame's address has changed.
on_address_change: procedure(self: PCefDisplayHandler;
browser: PCefBrowser; frame: PCefFrame; const url: PCefString); cconv;
// Called when the page title changes.
on_title_change: procedure(self: PCefDisplayHandler;
browser: PCefBrowser; const title: PCefString); cconv;
// Called when the browser is about to display a tooltip. |text| contains the
// text that will be displayed in the tooltip. To handle the display of the
// tooltip yourself return true (1). Otherwise, you can optionally modify
// |text| and then return false (0) to allow the browser to display the
// tooltip. When window rendering is disabled the application is responsible
// for drawing tooltips and the return value is ignored.
on_tooltip: function(self: PCefDisplayHandler;
browser: PCefBrowser; text: PCefString): Integer; cconv;
// Called when the browser receives a status message. |text| contains the text
// that will be displayed in the status message and |type| indicates the
// status message type.
on_status_message: procedure(self: PCefDisplayHandler;
browser: PCefBrowser; const value: PCefString); cconv;
// Called to display a console message. Return true (1) to stop the message
// from being output to the console.
on_console_message: function(self: PCefDisplayHandler;
browser: PCefBrowser; const message, source: PCefString; line: Integer): Integer; cconv;
end;
{ *** cef_dom_capi.h *** }
// Structure to implement for visiting the DOM. The functions of this structure
// will be called on the render process main thread.
TCefDomVisitor = record
// Base structure.
base: TCefBase;
// Method executed for visiting the DOM. The document object passed to this
// function represents a snapshot of the DOM at the time this function is
// executed. DOM objects are only valid for the scope of this function. Do not
// keep references to or attempt to access any DOM objects outside the scope
// of this function.
visit: procedure(self: PCefDomVisitor; document: PCefDomDocument); cconv;
end;
// Structure used to represent a DOM document. The functions of this structure
// should only be called on the render process main thread thread.
TCefDomDocument = record
// Base structure.
base: TCefBase;
// Returns the document type.
get_type: function(self: PCefDomDocument): TCefDomDocumentType; cconv;
// Returns the root document node.
get_document: function(self: PCefDomDocument): PCefDomNode; cconv;
// Returns the BODY node of an HTML document.
get_body: function(self: PCefDomDocument): PCefDomNode; cconv;
// Returns the HEAD node of an HTML document.