diff --git a/uCEFDeleteCookiesCallback.pas b/uCEFDeleteCookiesCallback.pas new file mode 100644 index 00000000..f033ed2f --- /dev/null +++ b/uCEFDeleteCookiesCallback.pas @@ -0,0 +1,127 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDeleteCookiesCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDeleteCookiesCallbackOwn = class(TCefBaseOwn, ICefDeleteCookiesCallback) + protected + procedure OnComplete(numDeleted: Integer); virtual; abstract; + + public + constructor Create; virtual; + end; + + TCefFastDeleteCookiesCallback = class(TCefDeleteCookiesCallbackOwn) + protected + FCallback: TCefDeleteCookiesCallbackProc; + + procedure OnComplete(numDeleted: Integer); override; + + public + constructor Create(const callback: TCefDeleteCookiesCallbackProc); reintroduce; + end; + + TCefCustomDeleteCookiesCallback = class(TCefDeleteCookiesCallbackOwn) + protected + FChromiumBrowser : TObject; + + procedure OnComplete(numDeleted: Integer); override; + + public + constructor Create(const aChromiumBrowser : TObject); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFChromium; + +procedure cef_delete_cookie_callback_on_complete(self: PCefDeleteCookiesCallback; num_deleted: Integer); stdcall; +begin + with TCefDeleteCookiesCallbackOwn(CefGetObject(self)) do OnComplete(num_deleted); +end; + +// TCefDeleteCookiesCallbackOwn + +constructor TCefDeleteCookiesCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefDeleteCookiesCallback)); + + with PCefDeleteCookiesCallback(FData)^ do on_complete := cef_delete_cookie_callback_on_complete; +end; + +// TCefFastDeleteCookiesCallback + +constructor TCefFastDeleteCookiesCallback.Create(const callback: TCefDeleteCookiesCallbackProc); +begin + inherited Create; + + FCallback := callback; +end; + +procedure TCefFastDeleteCookiesCallback.OnComplete(numDeleted: Integer); +begin + FCallback(numDeleted) +end; + +// TCefCustomDeleteCookiesCallback + +constructor TCefCustomDeleteCookiesCallback.Create(const aChromiumBrowser : TObject); +begin + inherited Create; + + FChromiumBrowser := aChromiumBrowser; +end; + +procedure TCefCustomDeleteCookiesCallback.OnComplete(numDeleted: Integer); +begin + if (FChromiumBrowser <> nil) and (FChromiumBrowser is TChromium) then + TChromium(FChromiumBrowser).CookiesDeleted(numDeleted); +end; + +end. diff --git a/uCEFDialogHandler.pas b/uCEFDialogHandler.pas new file mode 100644 index 00000000..f6186bc5 --- /dev/null +++ b/uCEFDialogHandler.pas @@ -0,0 +1,130 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDialogHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDialogHandlerOwn = class(TCefBaseOwn, ICefDialogHandler) + protected + function OnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; virtual; + + public + constructor Create; virtual; + end; + + TCustomDialogHandler = class(TCefDialogHandlerOwn) + protected + FEvent: IChromiumEvents; + + function OnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title: ustring; const defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFileDialogCallback; + +function cef_dialog_handler_on_file_dialog(self: PCefDialogHandler; browser: PCefBrowser; + mode: TCefFileDialogMode; const title, default_file_path: PCefString; + accept_filters: TCefStringList; selected_accept_filter: Integer; + callback: PCefFileDialogCallback): Integer; stdcall; +var + list: TStringList; + i: Integer; + str: TCefString; +begin + list := TStringList.Create; + try + for i := 0 to cef_string_list_size(accept_filters) - 1 do + begin + FillChar(str, SizeOf(str), 0); + cef_string_list_value(accept_filters, i, @str); + list.Add(CefStringClearAndGet(str)); + end; + + with TCefDialogHandlerOwn(CefGetObject(self)) do + Result := Ord(OnFileDialog(TCefBrowserRef.UnWrap(browser), mode, CefString(title), + CefString(default_file_path), list, selected_accept_filter, + TCefFileDialogCallbackRef.UnWrap(callback))); + finally + list.Free; + end; +end; + +constructor TCefDialogHandlerOwn.Create; +begin + CreateData(SizeOf(TCefDialogHandler)); + + with PCefDialogHandler(FData)^ do + on_file_dialog := cef_dialog_handler_on_file_dialog; +end; + +function TCefDialogHandlerOwn.OnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; +begin + Result := False; +end; + +// TCustomDialogHandler + +constructor TCustomDialogHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + + FEvent := events; +end; + +function TCustomDialogHandler.OnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; +begin + Result := FEvent.doOnFileDialog(browser, mode, title, defaultFilePath, acceptFilters, selectedAcceptFilter, callback); +end; + +end. + diff --git a/uCEFDictionaryValue.pas b/uCEFDictionaryValue.pas new file mode 100644 index 00000000..976c0037 --- /dev/null +++ b/uCEFDictionaryValue.pas @@ -0,0 +1,340 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDictionaryValue; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDictionaryValueRef = class(TCefBaseRef, ICefDictionaryValue) + protected + function IsValid: Boolean; + function isOwned: Boolean; + function IsReadOnly: Boolean; + function IsSame(const that: ICefDictionaryValue): Boolean; + function IsEqual(const that: ICefDictionaryValue): Boolean; + function Copy(excludeEmptyChildren: Boolean): ICefDictionaryValue; + function GetSize: NativeUInt; + function Clear: Boolean; + function HasKey(const key: ustring): Boolean; + function GetKeys(const keys: TStrings): Boolean; + function Remove(const key: ustring): Boolean; + function GetType(const key: ustring): TCefValueType; + function GetValue(const key: ustring): ICefValue; + function GetBool(const key: ustring): Boolean; + function GetInt(const key: ustring): Integer; + function GetDouble(const key: ustring): Double; + function GetString(const key: ustring): ustring; + function GetBinary(const key: ustring): ICefBinaryValue; + function GetDictionary(const key: ustring): ICefDictionaryValue; + function GetList(const key: ustring): ICefListValue; + function SetValue(const key: ustring; const value: ICefValue): Boolean; + function SetNull(const key: ustring): Boolean; + function SetBool(const key: ustring; value: Boolean): Boolean; + function SetInt(const key: ustring; value: Integer): Boolean; + function SetDouble(const key: ustring; value: Double): Boolean; + function SetString(const key, value: ustring): Boolean; + function SetBinary(const key: ustring; const value: ICefBinaryValue): Boolean; + function SetDictionary(const key: ustring; const value: ICefDictionaryValue): Boolean; + function SetList(const key: ustring; const value: ICefListValue): Boolean; + + public + class function UnWrap(data: Pointer): ICefDictionaryValue; + class function New: ICefDictionaryValue; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue, uCEFListValue, uCEFValue; + +function TCefDictionaryValueRef.Clear: Boolean; +begin + Result := PCefDictionaryValue(FData).clear(PCefDictionaryValue(FData)) <> 0; +end; + +function TCefDictionaryValueRef.Copy( + excludeEmptyChildren: Boolean): ICefDictionaryValue; +begin + Result := UnWrap(PCefDictionaryValue(FData).copy(PCefDictionaryValue(FData), Ord(excludeEmptyChildren))); +end; + +function TCefDictionaryValueRef.GetBinary(const key: ustring): ICefBinaryValue; +var + k: TCefString; +begin + k := CefString(key); + Result := TCefBinaryValueRef.UnWrap(PCefDictionaryValue(FData).get_binary(PCefDictionaryValue(FData), @k)); +end; + +function TCefDictionaryValueRef.GetBool(const key: ustring): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).get_bool(PCefDictionaryValue(FData), @k) <> 0; +end; + +function TCefDictionaryValueRef.GetDictionary( + const key: ustring): ICefDictionaryValue; +var + k: TCefString; +begin + k := CefString(key); + Result := UnWrap(PCefDictionaryValue(FData).get_dictionary(PCefDictionaryValue(FData), @k)); +end; + +function TCefDictionaryValueRef.GetDouble(const key: ustring): Double; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).get_double(PCefDictionaryValue(FData), @k); +end; + +function TCefDictionaryValueRef.GetInt(const key: ustring): Integer; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).get_int(PCefDictionaryValue(FData), @k); +end; + +function TCefDictionaryValueRef.GetKeys(const keys: TStrings): Boolean; +var + list: TCefStringList; + i: Integer; + str: TCefString; +begin + list := cef_string_list_alloc; + try + Result := PCefDictionaryValue(FData).get_keys(PCefDictionaryValue(FData), list) <> 0; + FillChar(str, SizeOf(str), 0); + for i := 0 to cef_string_list_size(list) - 1 do + begin + FillChar(str, SizeOf(str), 0); + cef_string_list_value(list, i, @str); + keys.Add(CefStringClearAndGet(str)); + end; + finally + cef_string_list_free(list); + end; +end; + +function TCefDictionaryValueRef.GetList(const key: ustring): ICefListValue; +var + k: TCefString; +begin + k := CefString(key); + Result := TCefListValueRef.UnWrap(PCefDictionaryValue(FData).get_list(PCefDictionaryValue(FData), @k)); +end; + +function TCefDictionaryValueRef.GetSize: NativeUInt; +begin + Result := PCefDictionaryValue(FData).get_size(PCefDictionaryValue(FData)); +end; + +function TCefDictionaryValueRef.GetString(const key: ustring): ustring; +var + k: TCefString; +begin + k := CefString(key); + Result := CefStringFreeAndGet(PCefDictionaryValue(FData).get_string(PCefDictionaryValue(FData), @k)); +end; + +function TCefDictionaryValueRef.GetType(const key: ustring): TCefValueType; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).get_type(PCefDictionaryValue(FData), @k); +end; + +function TCefDictionaryValueRef.GetValue(const key: ustring): ICefValue; +var + k: TCefString; +begin + k := CefString(key); + Result := TCefValueRef.UnWrap(PCefDictionaryValue(FData).get_value(PCefDictionaryValue(FData), @k)); +end; + +function TCefDictionaryValueRef.HasKey(const key: ustring): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).has_key(PCefDictionaryValue(FData), @k) <> 0; +end; + +function TCefDictionaryValueRef.IsEqual( + const that: ICefDictionaryValue): Boolean; +begin + Result := PCefDictionaryValue(FData).is_equal(PCefDictionaryValue(FData), CefGetData(that)) <> 0; +end; + +function TCefDictionaryValueRef.isOwned: Boolean; +begin + Result := PCefDictionaryValue(FData).is_owned(PCefDictionaryValue(FData)) <> 0; +end; + +function TCefDictionaryValueRef.IsReadOnly: Boolean; +begin + Result := PCefDictionaryValue(FData).is_read_only(PCefDictionaryValue(FData)) <> 0; +end; + +function TCefDictionaryValueRef.IsSame( + const that: ICefDictionaryValue): Boolean; +begin + Result := PCefDictionaryValue(FData).is_same(PCefDictionaryValue(FData), CefGetData(that)) <> 0; +end; + +function TCefDictionaryValueRef.IsValid: Boolean; +begin + Result := PCefDictionaryValue(FData).is_valid(PCefDictionaryValue(FData)) <> 0; +end; + +class function TCefDictionaryValueRef.New: ICefDictionaryValue; +begin + Result := UnWrap(cef_dictionary_value_create); +end; + +function TCefDictionaryValueRef.Remove(const key: ustring): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).remove(PCefDictionaryValue(FData), @k) <> 0; +end; + +function TCefDictionaryValueRef.SetBinary(const key: ustring; + const value: ICefBinaryValue): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).set_binary(PCefDictionaryValue(FData), @k, CefGetData(value)) <> 0; +end; + +function TCefDictionaryValueRef.SetBool(const key: ustring; + value: Boolean): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).set_bool(PCefDictionaryValue(FData), @k, Ord(value)) <> 0; +end; + +function TCefDictionaryValueRef.SetDictionary(const key: ustring; + const value: ICefDictionaryValue): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).set_dictionary(PCefDictionaryValue(FData), @k, CefGetData(value)) <> 0; +end; + +function TCefDictionaryValueRef.SetDouble(const key: ustring; + value: Double): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).set_double(PCefDictionaryValue(FData), @k, value) <> 0; +end; + +function TCefDictionaryValueRef.SetInt(const key: ustring; + value: Integer): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).set_int(PCefDictionaryValue(FData), @k, value) <> 0; +end; + +function TCefDictionaryValueRef.SetList(const key: ustring; + const value: ICefListValue): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).set_list(PCefDictionaryValue(FData), @k, CefGetData(value)) <> 0; +end; + +function TCefDictionaryValueRef.SetNull(const key: ustring): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).set_null(PCefDictionaryValue(FData), @k) <> 0; +end; + +function TCefDictionaryValueRef.SetString(const key, value: ustring): Boolean; +var + k, v: TCefString; +begin + k := CefString(key); + v := CefString(value); + Result := PCefDictionaryValue(FData).set_string(PCefDictionaryValue(FData), @k, @v) <> 0; +end; + +function TCefDictionaryValueRef.SetValue(const key: ustring; + const value: ICefValue): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefDictionaryValue(FData).set_value(PCefDictionaryValue(FData), @k, CefGetData(value)) <> 0; +end; + +class function TCefDictionaryValueRef.UnWrap( + data: Pointer): ICefDictionaryValue; +begin + if data <> nil then + Result := Create(data) as ICefDictionaryValue else + Result := nil; +end; + +end. diff --git a/uCEFDisplayHandler.pas b/uCEFDisplayHandler.pas new file mode 100644 index 00000000..6067f04b --- /dev/null +++ b/uCEFDisplayHandler.pas @@ -0,0 +1,269 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDisplayHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDisplayHandlerOwn = class(TCefBaseOwn, ICefDisplayHandler) + protected + procedure OnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); virtual; + procedure OnTitleChange(const browser: ICefBrowser; const title: ustring); virtual; + procedure OnFaviconUrlChange(const browser: ICefBrowser; iconUrls: TStrings); virtual; + procedure OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); virtual; + function OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; virtual; + procedure OnStatusMessage(const browser: ICefBrowser; const value: ustring); virtual; + function OnConsoleMessage(const browser: ICefBrowser; const message, source: ustring; line: Integer): Boolean; virtual; + public + constructor Create; virtual; + end; + + TCustomDisplayHandler = class(TCefDisplayHandlerOwn) + protected + FEvent: IChromiumEvents; + + procedure OnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); override; + procedure OnTitleChange(const browser: ICefBrowser; const title: ustring); override; + procedure OnFaviconUrlChange(const browser: ICefBrowser; iconUrls: TStrings); override; + procedure OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); override; + function OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; override; + procedure OnStatusMessage(const browser: ICefBrowser; const value: ustring); override; + function OnConsoleMessage(const browser: ICefBrowser; const message, source: ustring; line: Integer): Boolean; override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame; + + +procedure cef_display_handler_on_address_change(self: PCefDisplayHandler; + browser: PCefBrowser; frame: PCefFrame; const url: PCefString); stdcall; +begin + with TCefDisplayHandlerOwn(CefGetObject(self)) do + OnAddressChange( + TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + cefstring(url)) +end; + +procedure cef_display_handler_on_title_change(self: PCefDisplayHandler; + browser: PCefBrowser; const title: PCefString); stdcall; +begin + with TCefDisplayHandlerOwn(CefGetObject(self)) do + OnTitleChange(TCefBrowserRef.UnWrap(browser), CefString(title)); +end; + +procedure cef_display_handler_on_favicon_urlchange(self: PCefDisplayHandler; + browser: PCefBrowser; icon_urls: TCefStringList); stdcall; +var + list: TStringList; + i: Integer; + str: TCefString; +begin + list := TStringList.Create; + try + for i := 0 to cef_string_list_size(icon_urls) - 1 do + begin + FillChar(str, SizeOf(str), 0); + cef_string_list_value(icon_urls, i, @str); + list.Add(CefStringClearAndGet(str)); + end; + with TCefDisplayHandlerOwn(CefGetObject(self)) do + OnFaviconUrlChange(TCefBrowserRef.UnWrap(browser), list); + finally + list.Free; + end; +end; + +procedure cef_display_handler_on_fullscreen_mode_change(self: PCefDisplayHandler; + browser: PCefBrowser; fullscreen: Integer); stdcall; +begin + with TCefDisplayHandlerOwn(CefGetObject(self)) do + OnFullScreenModeChange(TCefBrowserRef.UnWrap(browser), fullscreen <> 0); +end; + +function cef_display_handler_on_tooltip(self: PCefDisplayHandler; + browser: PCefBrowser; text: PCefString): Integer; stdcall; +var + t: ustring; +begin + t := CefStringClearAndGet(text^); + with TCefDisplayHandlerOwn(CefGetObject(self)) do + Result := Ord(OnTooltip( + TCefBrowserRef.UnWrap(browser), t)); + text^ := CefStringAlloc(t); +end; + +procedure cef_display_handler_on_status_message(self: PCefDisplayHandler; + browser: PCefBrowser; const value: PCefString); stdcall; +begin + with TCefDisplayHandlerOwn(CefGetObject(self)) do + OnStatusMessage(TCefBrowserRef.UnWrap(browser), CefString(value)); +end; + +function cef_display_handler_on_console_message(self: PCefDisplayHandler; + browser: PCefBrowser; const message: PCefString; + const source: PCefString; line: Integer): Integer; stdcall; +begin + with TCefDisplayHandlerOwn(CefGetObject(self)) do + Result := Ord(OnConsoleMessage(TCefBrowserRef.UnWrap(browser), + CefString(message), CefString(source), line)); +end; + + +constructor TCefDisplayHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefDisplayHandler)); + with PCefDisplayHandler(FData)^ do + begin + on_address_change := cef_display_handler_on_address_change; + on_title_change := cef_display_handler_on_title_change; + on_favicon_urlchange := cef_display_handler_on_favicon_urlchange; + on_fullscreen_mode_change := cef_display_handler_on_fullscreen_mode_change; + on_tooltip := cef_display_handler_on_tooltip; + on_status_message := cef_display_handler_on_status_message; + on_console_message := cef_display_handler_on_console_message; + end; +end; + +procedure TCefDisplayHandlerOwn.OnAddressChange(const browser: ICefBrowser; + const frame: ICefFrame; const url: ustring); +begin + +end; + +function TCefDisplayHandlerOwn.OnConsoleMessage(const browser: ICefBrowser; + const message, source: ustring; line: Integer): Boolean; +begin + Result := False; +end; + +procedure TCefDisplayHandlerOwn.OnFaviconUrlChange(const browser: ICefBrowser; + iconUrls: TStrings); +begin + +end; + +procedure TCefDisplayHandlerOwn.OnFullScreenModeChange( + const browser: ICefBrowser; fullscreen: Boolean); +begin + +end; + +procedure TCefDisplayHandlerOwn.OnStatusMessage(const browser: ICefBrowser; + const value: ustring); +begin + +end; + +procedure TCefDisplayHandlerOwn.OnTitleChange(const browser: ICefBrowser; + const title: ustring); +begin + +end; + +function TCefDisplayHandlerOwn.OnTooltip(const browser: ICefBrowser; + var text: ustring): Boolean; +begin + Result := False; +end; + +// TCustomDisplayHandler + +constructor TCustomDisplayHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +procedure TCustomDisplayHandler.OnAddressChange(const browser: ICefBrowser; + const frame: ICefFrame; const url: ustring); +begin + FEvent.doOnAddressChange(browser, frame, url); +end; + +function TCustomDisplayHandler.OnConsoleMessage(const browser: ICefBrowser; + const message, source: ustring; line: Integer): Boolean; +begin + Result := FEvent.doOnConsoleMessage(browser, message, source, line); +end; + +procedure TCustomDisplayHandler.OnFaviconUrlChange(const browser: ICefBrowser; + iconUrls: TStrings); +begin + FEvent.doOnFaviconUrlChange(browser, iconUrls); +end; + +procedure TCustomDisplayHandler.OnFullScreenModeChange( + const browser: ICefBrowser; fullscreen: Boolean); +begin + FEvent.doOnFullScreenModeChange(browser, fullscreen); +end; + +procedure TCustomDisplayHandler.OnStatusMessage(const browser: ICefBrowser; + const value: ustring); +begin + FEvent.doOnStatusMessage(browser, value); +end; + +procedure TCustomDisplayHandler.OnTitleChange(const browser: ICefBrowser; + const title: ustring); +begin + FEvent.doOnTitleChange(browser, title); +end; + +function TCustomDisplayHandler.OnTooltip(const browser: ICefBrowser; + var text: ustring): Boolean; +begin + Result := FEvent.doOnTooltip(browser, text); +end; + +end. diff --git a/uCEFDomDocument.pas b/uCEFDomDocument.pas new file mode 100644 index 00000000..772dc80b --- /dev/null +++ b/uCEFDomDocument.pas @@ -0,0 +1,160 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDomDocument; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDomDocumentRef = class(TCefBaseRef, ICefDomDocument) + protected + function GetType: TCefDomDocumentType; + function GetDocument: ICefDomNode; + function GetBody: ICefDomNode; + function GetHead: ICefDomNode; + function GetTitle: ustring; + function GetElementById(const id: ustring): ICefDomNode; + function GetFocusedNode: ICefDomNode; + function HasSelection: Boolean; + function GetSelectionStartOffset: Integer; + function GetSelectionEndOffset: Integer; + function GetSelectionAsMarkup: ustring; + function GetSelectionAsText: ustring; + function GetBaseUrl: ustring; + function GetCompleteUrl(const partialURL: ustring): ustring; + + public + class function UnWrap(data: Pointer): ICefDomDocument; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFDomNode; + +function TCefDomDocumentRef.GetBaseUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefDomDocument(FData)^.get_base_url(PCefDomDocument(FData))) +end; + +function TCefDomDocumentRef.GetBody: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomDocument(FData)^.get_body(PCefDomDocument(FData))); +end; + +function TCefDomDocumentRef.GetCompleteUrl(const partialURL: ustring): ustring; +var + p: TCefString; +begin + p := CefString(partialURL); + Result := CefStringFreeAndGet(PCefDomDocument(FData)^.get_complete_url(PCefDomDocument(FData), @p)); +end; + +function TCefDomDocumentRef.GetDocument: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomDocument(FData)^.get_document(PCefDomDocument(FData))); +end; + +function TCefDomDocumentRef.GetElementById(const id: ustring): ICefDomNode; +var + i: TCefString; +begin + i := CefString(id); + Result := TCefDomNodeRef.UnWrap(PCefDomDocument(FData)^.get_element_by_id(PCefDomDocument(FData), @i)); +end; + +function TCefDomDocumentRef.GetFocusedNode: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomDocument(FData)^.get_focused_node(PCefDomDocument(FData))); +end; + +function TCefDomDocumentRef.GetHead: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomDocument(FData)^.get_head(PCefDomDocument(FData))); +end; + +function TCefDomDocumentRef.GetSelectionAsMarkup: ustring; +begin + Result := CefStringFreeAndGet(PCefDomDocument(FData)^.get_selection_as_markup(PCefDomDocument(FData))); +end; + +function TCefDomDocumentRef.GetSelectionAsText: ustring; +begin + Result := CefStringFreeAndGet(PCefDomDocument(FData)^.get_selection_as_text(PCefDomDocument(FData))); +end; + +function TCefDomDocumentRef.GetSelectionEndOffset: Integer; +begin + Result := PCefDomDocument(FData)^.get_selection_end_offset(PCefDomDocument(FData)); +end; + +function TCefDomDocumentRef.GetSelectionStartOffset: Integer; +begin + Result := PCefDomDocument(FData)^.get_selection_start_offset(PCefDomDocument(FData)); +end; + +function TCefDomDocumentRef.GetTitle: ustring; +begin + Result := CefStringFreeAndGet(PCefDomDocument(FData)^.get_title(PCefDomDocument(FData))); +end; + +function TCefDomDocumentRef.GetType: TCefDomDocumentType; +begin + Result := PCefDomDocument(FData)^.get_type(PCefDomDocument(FData)); +end; + +function TCefDomDocumentRef.HasSelection: Boolean; +begin + Result := PCefDomDocument(FData)^.has_selection(PCefDomDocument(FData)) <> 0; +end; + +class function TCefDomDocumentRef.UnWrap(data: Pointer): ICefDomDocument; +begin + if data <> nil then + Result := Create(data) as ICefDomDocument else + Result := nil; +end; + +end. diff --git a/uCEFDomNode.pas b/uCEFDomNode.pas new file mode 100644 index 00000000..b4c3de92 --- /dev/null +++ b/uCEFDomNode.pas @@ -0,0 +1,241 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDomNode; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDomNodeRef = class(TCefBaseRef, ICefDomNode) + protected + function GetType: TCefDomNodeType; + function IsText: Boolean; + function IsElement: Boolean; + function IsEditable: Boolean; + function IsFormControlElement: Boolean; + function GetFormControlElementType: ustring; + function IsSame(const that: ICefDomNode): Boolean; + function GetName: ustring; + function GetValue: ustring; + function SetValue(const value: ustring): Boolean; + function GetAsMarkup: ustring; + function GetDocument: ICefDomDocument; + function GetParent: ICefDomNode; + function GetPreviousSibling: ICefDomNode; + function GetNextSibling: ICefDomNode; + function HasChildren: Boolean; + function GetFirstChild: ICefDomNode; + function GetLastChild: ICefDomNode; + function GetElementTagName: ustring; + function HasElementAttributes: Boolean; + function HasElementAttribute(const attrName: ustring): Boolean; + function GetElementAttribute(const attrName: ustring): ustring; + procedure GetElementAttributes(const attrMap: ICefStringMap); + function SetElementAttribute(const attrName, value: ustring): Boolean; + function GetElementInnerText: ustring; + function GetElementBounds: TCefRect; + + public + class function UnWrap(data: Pointer): ICefDomNode; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFDomDocument; + +function TCefDomNodeRef.GetAsMarkup: ustring; +begin + Result := CefStringFreeAndGet(PCefDomNode(FData)^.get_as_markup(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetDocument: ICefDomDocument; +begin + Result := TCefDomDocumentRef.UnWrap(PCefDomNode(FData)^.get_document(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetElementAttribute(const attrName: ustring): ustring; +var + p: TCefString; +begin + p := CefString(attrName); + Result := CefStringFreeAndGet(PCefDomNode(FData)^.get_element_attribute(PCefDomNode(FData), @p)); +end; + +procedure TCefDomNodeRef.GetElementAttributes(const attrMap: ICefStringMap); +begin + PCefDomNode(FData)^.get_element_attributes(PCefDomNode(FData), attrMap.Handle); +end; + +function TCefDomNodeRef.GetElementInnerText: ustring; +begin + Result := CefStringFreeAndGet(PCefDomNode(FData)^.get_element_inner_text(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetElementBounds: TCefRect; +begin + Result := PCefDomNode(FData)^.get_element_bounds(PCefDomNode(FData)); +end; + +function TCefDomNodeRef.GetElementTagName: ustring; +begin + Result := CefStringFreeAndGet(PCefDomNode(FData)^.get_element_tag_name(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetFirstChild: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomNode(FData)^.get_first_child(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetFormControlElementType: ustring; +begin + Result := CefStringFreeAndGet(PCefDomNode(FData)^.get_form_control_element_type(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetLastChild: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomNode(FData)^.get_last_child(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetName: ustring; +begin + Result := CefStringFreeAndGet(PCefDomNode(FData)^.get_name(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetNextSibling: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomNode(FData)^.get_next_sibling(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetParent: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomNode(FData)^.get_parent(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetPreviousSibling: ICefDomNode; +begin + Result := TCefDomNodeRef.UnWrap(PCefDomNode(FData)^.get_previous_sibling(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.GetType: TCefDomNodeType; +begin + Result := PCefDomNode(FData)^.get_type(PCefDomNode(FData)); +end; + +function TCefDomNodeRef.GetValue: ustring; +begin + Result := CefStringFreeAndGet(PCefDomNode(FData)^.get_value(PCefDomNode(FData))); +end; + +function TCefDomNodeRef.HasChildren: Boolean; +begin + Result := PCefDomNode(FData)^.has_children(PCefDomNode(FData)) <> 0; +end; + +function TCefDomNodeRef.HasElementAttribute(const attrName: ustring): Boolean; +var + p: TCefString; +begin + p := CefString(attrName); + Result := PCefDomNode(FData)^.has_element_attribute(PCefDomNode(FData), @p) <> 0; +end; + +function TCefDomNodeRef.HasElementAttributes: Boolean; +begin + Result := PCefDomNode(FData)^.has_element_attributes(PCefDomNode(FData)) <> 0; +end; + +function TCefDomNodeRef.IsEditable: Boolean; +begin + Result := PCefDomNode(FData)^.is_editable(PCefDomNode(FData)) <> 0; +end; + +function TCefDomNodeRef.IsElement: Boolean; +begin + Result := PCefDomNode(FData)^.is_element(PCefDomNode(FData)) <> 0; +end; + +function TCefDomNodeRef.IsFormControlElement: Boolean; +begin + Result := PCefDomNode(FData)^.is_form_control_element(PCefDomNode(FData)) <> 0; +end; + +function TCefDomNodeRef.IsSame(const that: ICefDomNode): Boolean; +begin + Result := PCefDomNode(FData)^.is_same(PCefDomNode(FData), CefGetData(that)) <> 0; +end; + +function TCefDomNodeRef.IsText: Boolean; +begin + Result := PCefDomNode(FData)^.is_text(PCefDomNode(FData)) <> 0; +end; + +function TCefDomNodeRef.SetElementAttribute(const attrName, + value: ustring): Boolean; +var + p1, p2: TCefString; +begin + p1 := CefString(attrName); + p2 := CefString(value); + Result := PCefDomNode(FData)^.set_element_attribute(PCefDomNode(FData), @p1, @p2) <> 0; +end; + +function TCefDomNodeRef.SetValue(const value: ustring): Boolean; +var + p: TCefString; +begin + p := CefString(value); + Result := PCefDomNode(FData)^.set_value(PCefDomNode(FData), @p) <> 0; +end; + +class function TCefDomNodeRef.UnWrap(data: Pointer): ICefDomNode; +begin + if data <> nil then + Result := Create(data) as ICefDomNode else + Result := nil; +end; + + +end. diff --git a/uCEFDomVisitor.pas b/uCEFDomVisitor.pas new file mode 100644 index 00000000..034c30bf --- /dev/null +++ b/uCEFDomVisitor.pas @@ -0,0 +1,131 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDomVisitor; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces; + +type + TCefDomVisitorOwn = class(TCefBaseOwn, ICefDomVisitor) + protected + procedure visit(const document: ICefDomDocument); virtual; + + public + constructor Create; virtual; + end; + + TCefFastDomVisitor = class(TCefDomVisitorOwn) + protected + FProc: TCefDomVisitorProc; + + procedure visit(const document: ICefDomDocument); override; + + public + constructor Create(const proc: TCefDomVisitorProc); reintroduce; virtual; + end; + + TCustomDomVisitor = class(TCefDomVisitorOwn) + protected + FChromiumBrowser : TObject; + + procedure visit(const document: ICefDomDocument); override; + + public + constructor Create(const aChromiumBrowser : TObject); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFTypes, uCEFDomDocument, uCEFChromium; + +procedure cef_dom_visitor_visite(self: PCefDomVisitor; document: PCefDomDocument); stdcall; +begin + TCefDomVisitorOwn(CefGetObject(self)).visit(TCefDomDocumentRef.UnWrap(document)); +end; + +// TCefDomVisitorOwn + +constructor TCefDomVisitorOwn.Create; +begin + inherited CreateData(SizeOf(TCefDomVisitor)); + + with PCefDomVisitor(FData)^ do visit := cef_dom_visitor_visite; +end; + +procedure TCefDomVisitorOwn.visit(const document: ICefDomDocument); +begin + +end; + +// TCefFastDomVisitor + +constructor TCefFastDomVisitor.Create(const proc: TCefDomVisitorProc); +begin + inherited Create; + FProc := proc; +end; + +procedure TCefFastDomVisitor.visit(const document: ICefDomDocument); +begin + FProc(document); +end; + +// TCustomDomVisitor + +constructor TCustomDomVisitor.Create(const aChromiumBrowser : TObject); +begin + inherited Create; + + FChromiumBrowser := aChromiumBrowser; +end; + +procedure TCustomDomVisitor.visit(const document: ICefDomDocument); +begin + if (FChromiumBrowser <> nil) and (FChromiumBrowser is TChromium) then + TChromium(FChromiumBrowser).DOMVisitorVisit(document); +end; + +end. diff --git a/uCEFDownLoadItem.pas b/uCEFDownLoadItem.pas new file mode 100644 index 00000000..60588d29 --- /dev/null +++ b/uCEFDownLoadItem.pas @@ -0,0 +1,171 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDownLoadItem; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDownLoadItemRef = class(TCefBaseRef, ICefDownLoadItem) + protected + function IsValid: Boolean; + function IsInProgress: Boolean; + function IsComplete: Boolean; + function IsCanceled: Boolean; + function GetCurrentSpeed: Int64; + function GetPercentComplete: Integer; + function GetTotalBytes: Int64; + function GetReceivedBytes: Int64; + function GetStartTime: TDateTime; + function GetEndTime: TDateTime; + function GetFullPath: ustring; + function GetId: Cardinal; + function GetUrl: ustring; + function GetOriginalUrl: ustring; + function GetSuggestedFileName: ustring; + function GetContentDisposition: ustring; + function GetMimeType: ustring; + public + class function UnWrap(data: Pointer): ICefDownLoadItem; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +function TCefDownLoadItemRef.GetContentDisposition: ustring; +begin + Result := CefStringFreeAndGet(PCefDownloadItem(FData)^.get_content_disposition(PCefDownloadItem(FData))); +end; + +function TCefDownLoadItemRef.GetCurrentSpeed: Int64; +begin + Result := PCefDownloadItem(FData)^.get_current_speed(PCefDownloadItem(FData)); +end; + +function TCefDownLoadItemRef.GetEndTime: TDateTime; +begin + Result := CefTimeToDateTime(PCefDownloadItem(FData)^.get_end_time(PCefDownloadItem(FData))); +end; + +function TCefDownLoadItemRef.GetFullPath: ustring; +begin + Result := CefStringFreeAndGet(PCefDownloadItem(FData)^.get_full_path(PCefDownloadItem(FData))); +end; + +function TCefDownLoadItemRef.GetId: Cardinal; +begin + Result := PCefDownloadItem(FData)^.get_id(PCefDownloadItem(FData)); +end; + +function TCefDownLoadItemRef.GetMimeType: ustring; +begin + Result := CefStringFreeAndGet(PCefDownloadItem(FData)^.get_mime_type(PCefDownloadItem(FData))); +end; + +function TCefDownLoadItemRef.GetOriginalUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefDownloadItem(FData)^.get_original_url(PCefDownloadItem(FData))); +end; + +function TCefDownLoadItemRef.GetPercentComplete: Integer; +begin + Result := PCefDownloadItem(FData)^.get_percent_complete(PCefDownloadItem(FData)); +end; + +function TCefDownLoadItemRef.GetReceivedBytes: Int64; +begin + Result := PCefDownloadItem(FData)^.get_received_bytes(PCefDownloadItem(FData)); +end; + +function TCefDownLoadItemRef.GetStartTime: TDateTime; +begin + Result := CefTimeToDateTime(PCefDownloadItem(FData)^.get_start_time(PCefDownloadItem(FData))); +end; + +function TCefDownLoadItemRef.GetSuggestedFileName: ustring; +begin + Result := CefStringFreeAndGet(PCefDownloadItem(FData)^.get_suggested_file_name(PCefDownloadItem(FData))); +end; + +function TCefDownLoadItemRef.GetTotalBytes: Int64; +begin + Result := PCefDownloadItem(FData)^.get_total_bytes(PCefDownloadItem(FData)); +end; + +function TCefDownLoadItemRef.GetUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefDownloadItem(FData)^.get_url(PCefDownloadItem(FData))); +end; + +function TCefDownLoadItemRef.IsCanceled: Boolean; +begin + Result := PCefDownloadItem(FData)^.is_canceled(PCefDownloadItem(FData)) <> 0; +end; + +function TCefDownLoadItemRef.IsComplete: Boolean; +begin + Result := PCefDownloadItem(FData)^.is_complete(PCefDownloadItem(FData)) <> 0; +end; + +function TCefDownLoadItemRef.IsInProgress: Boolean; +begin + Result := PCefDownloadItem(FData)^.is_in_progress(PCefDownloadItem(FData)) <> 0; +end; + +function TCefDownLoadItemRef.IsValid: Boolean; +begin + Result := PCefDownloadItem(FData)^.is_valid(PCefDownloadItem(FData)) <> 0; +end; + +class function TCefDownLoadItemRef.UnWrap(data: Pointer): ICefDownLoadItem; +begin + if data <> nil then + Result := Create(data) as ICefDownLoadItem else + Result := nil; +end; + +end. diff --git a/uCEFDownloadHandler.pas b/uCEFDownloadHandler.pas new file mode 100644 index 00000000..b6ecb2db --- /dev/null +++ b/uCEFDownloadHandler.pas @@ -0,0 +1,142 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDownloadHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDownloadHandlerOwn = class(TCefBaseOwn, ICefDownloadHandler) + protected + procedure OnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); virtual; + procedure OnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); virtual; + + public + constructor Create; virtual; + end; + + TCustomDownloadHandler = class(TCefDownloadHandlerOwn) + protected + FEvent: IChromiumEvents; + + procedure OnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); override; + procedure OnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFDownLoadItem, uCEFBeforeDownloadCallback, + uCEFDownloadItemCallback; + +procedure cef_download_handler_on_before_download(self: PCefDownloadHandler; + browser: PCefBrowser; download_item: PCefDownloadItem; + const suggested_name: PCefString; callback: PCefBeforeDownloadCallback); stdcall; +begin + TCefDownloadHandlerOwn(CefGetObject(self)). + OnBeforeDownload(TCefBrowserRef.UnWrap(browser), + TCefDownLoadItemRef.UnWrap(download_item), CefString(suggested_name), + TCefBeforeDownloadCallbackRef.UnWrap(callback)); +end; + +procedure cef_download_handler_on_download_updated(self: PCefDownloadHandler; + browser: PCefBrowser; download_item: PCefDownloadItem; callback: PCefDownloadItemCallback); stdcall; +begin + TCefDownloadHandlerOwn(CefGetObject(self)). + OnDownloadUpdated(TCefBrowserRef.UnWrap(browser), + TCefDownLoadItemRef.UnWrap(download_item), + TCefDownloadItemCallbackRef.UnWrap(callback)); +end; + +constructor TCefDownloadHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefDownloadHandler)); + with PCefDownloadHandler(FData)^ do + begin + on_before_download := cef_download_handler_on_before_download; + on_download_updated := cef_download_handler_on_download_updated; + end; +end; + +procedure TCefDownloadHandlerOwn.OnBeforeDownload(const browser: ICefBrowser; + const downloadItem: ICefDownloadItem; const suggestedName: ustring; + const callback: ICefBeforeDownloadCallback); +begin + +end; + +procedure TCefDownloadHandlerOwn.OnDownloadUpdated(const browser: ICefBrowser; + const downloadItem: ICefDownloadItem; + const callback: ICefDownloadItemCallback); +begin + +end; + +// TCustomDownloadHandler + +constructor TCustomDownloadHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +procedure TCustomDownloadHandler.OnBeforeDownload(const browser: ICefBrowser; + const downloadItem: ICefDownloadItem; const suggestedName: ustring; + const callback: ICefBeforeDownloadCallback); +begin + FEvent.doOnBeforeDownload(browser, downloadItem, suggestedName, callback); +end; + +procedure TCustomDownloadHandler.OnDownloadUpdated(const browser: ICefBrowser; + const downloadItem: ICefDownloadItem; + const callback: ICefDownloadItemCallback); +begin + FEvent.doOnDownloadUpdated(browser, downloadItem, callback); +end; + +end. diff --git a/uCEFDownloadImageCallBack.pas b/uCEFDownloadImageCallBack.pas new file mode 100644 index 00000000..2df2783c --- /dev/null +++ b/uCEFDownloadImageCallBack.pas @@ -0,0 +1,97 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDownloadImageCallBack; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDownloadImageCallbackOwn = class(TCefBaseOwn, ICefDownloadImageCallback) + protected + procedure OnDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); virtual; abstract; + + public + constructor Create; virtual; + end; + + TCefFastDownloadImageCallback = class(TCefDownloadImageCallbackOwn) + protected + FProc: TOnDownloadImageFinishedProc; + + procedure OnDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); override; + + public + constructor Create(const proc: TOnDownloadImageFinishedProc); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFImage; + +procedure cef_download_image_callback_on_download_image_finished(self: PCefDownloadImageCallback; const image_url: PCefString; http_status_code: Integer; image: PCefImage); stdcall; +begin + with TCefDownloadImageCallbackOwn(CefGetObject(self)) do + OnDownloadImageFinished(CefString(image_url), http_status_code, TCefImageRef.UnWrap(image)); +end; + +constructor TCefDownloadImageCallbackOwn.Create; +begin + CreateData(SizeOf(TCefDownloadImageCallback), False); + + with PCefDownloadImageCallback(FData)^ do on_download_image_finished := nil; +end; + +constructor TCefFastDownloadImageCallback.Create(const proc: TOnDownloadImageFinishedProc); +begin + FProc := proc; +end; + +procedure TCefFastDownloadImageCallback.OnDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); +begin + FProc(imageUrl, httpStatusCode, image); +end; + +end. diff --git a/uCEFDownloadItemCallback.pas b/uCEFDownloadItemCallback.pas new file mode 100644 index 00000000..e3b61704 --- /dev/null +++ b/uCEFDownloadItemCallback.pas @@ -0,0 +1,87 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDownloadItemCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDownloadItemCallbackRef = class(TCefBaseRef, ICefDownloadItemCallback) + protected + procedure Cancel; + procedure Pause; + procedure Resume; + public + class function UnWrap(data: Pointer): ICefDownloadItemCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefDownloadItemCallbackRef.cancel; +begin + PCefDownloadItemCallback(FData).cancel(PCefDownloadItemCallback(FData)); +end; + +procedure TCefDownloadItemCallbackRef.Pause; +begin + PCefDownloadItemCallback(FData).pause(PCefDownloadItemCallback(FData)); +end; + +procedure TCefDownloadItemCallbackRef.Resume; +begin + PCefDownloadItemCallback(FData).resume(PCefDownloadItemCallback(FData)); +end; + +class function TCefDownloadItemCallbackRef.UnWrap(data: Pointer): ICefDownloadItemCallback; +begin + if data <> nil then + Result := Create(data) as ICefDownloadItemCallback else + Result := nil; +end; + +end. diff --git a/uCEFDragData.pas b/uCEFDragData.pas new file mode 100644 index 00000000..89e9a272 --- /dev/null +++ b/uCEFDragData.pas @@ -0,0 +1,247 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDragData; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDragDataRef = class(TCefBaseRef, ICefDragData) + protected + function Clone: ICefDragData; + function IsReadOnly: Boolean; + function IsLink: Boolean; + function IsFragment: Boolean; + function IsFile: Boolean; + function GetLinkUrl: ustring; + function GetLinkTitle: ustring; + function GetLinkMetadata: ustring; + function GetFragmentText: ustring; + function GetFragmentHtml: ustring; + function GetFragmentBaseUrl: ustring; + function GetFileName: ustring; + function GetFileContents(const writer: ICefStreamWriter): NativeUInt; + function GetFileNames(names: TStrings): Integer; + procedure SetLinkUrl(const url: ustring); + procedure SetLinkTitle(const title: ustring); + procedure SetLinkMetadata(const data: ustring); + procedure SetFragmentText(const text: ustring); + procedure SetFragmentHtml(const html: ustring); + procedure SetFragmentBaseUrl(const baseUrl: ustring); + procedure ResetFileContents; + procedure AddFile(const path, displayName: ustring); + public + class function UnWrap(data: Pointer): ICefDragData; + class function New: ICefDragData; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefDragDataRef.AddFile(const path, displayName: ustring); +var + p, d: TCefString; +begin + p := CefString(path); + d := CefString(displayName); + PCefDragData(FData).add_file(FData, @p, @d); +end; + +function TCefDragDataRef.Clone: ICefDragData; +begin + Result := UnWrap(PCefDragData(FData).clone(FData)); +end; + +function TCefDragDataRef.GetFileContents( + const writer: ICefStreamWriter): NativeUInt; +begin + Result := PCefDragData(FData).get_file_contents(FData, CefGetData(writer)) +end; + +function TCefDragDataRef.GetFileName: ustring; +begin + Result := CefStringFreeAndGet(PCefDragData(FData).get_file_name(FData)); +end; + +function TCefDragDataRef.GetFileNames(names: TStrings): Integer; +var + list: TCefStringList; + i: Integer; + str: TCefString; +begin + list := cef_string_list_alloc; + try + Result := PCefDragData(FData).get_file_names(FData, list); + for i := 0 to cef_string_list_size(list) - 1 do + begin + FillChar(str, SizeOf(str), 0); + cef_string_list_value(list, i, @str); + names.Add(CefStringClearAndGet(str)); + end; + finally + cef_string_list_free(list); + end; +end; + +function TCefDragDataRef.GetFragmentBaseUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefDragData(FData).get_fragment_base_url(FData)); +end; + +function TCefDragDataRef.GetFragmentHtml: ustring; +begin + Result := CefStringFreeAndGet(PCefDragData(FData).get_fragment_html(FData)); +end; + +function TCefDragDataRef.GetFragmentText: ustring; +begin + Result := CefStringFreeAndGet(PCefDragData(FData).get_fragment_text(FData)); +end; + +function TCefDragDataRef.GetLinkMetadata: ustring; +begin + Result := CefStringFreeAndGet(PCefDragData(FData).get_link_metadata(FData)); +end; + +function TCefDragDataRef.GetLinkTitle: ustring; +begin + Result := CefStringFreeAndGet(PCefDragData(FData).get_link_title(FData)); +end; + +function TCefDragDataRef.GetLinkUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefDragData(FData).get_link_url(FData)); +end; + +function TCefDragDataRef.IsFile: Boolean; +begin + Result := PCefDragData(FData).is_file(FData) <> 0; +end; + +function TCefDragDataRef.IsFragment: Boolean; +begin + Result := PCefDragData(FData).is_fragment(FData) <> 0; +end; + +function TCefDragDataRef.IsLink: Boolean; +begin + Result := PCefDragData(FData).is_link(FData) <> 0; +end; + +function TCefDragDataRef.IsReadOnly: Boolean; +begin + Result := PCefDragData(FData).is_read_only(FData) <> 0; +end; + +class function TCefDragDataRef.New: ICefDragData; +begin + Result := UnWrap(cef_drag_data_create()); +end; + +procedure TCefDragDataRef.ResetFileContents; +begin + PCefDragData(FData).reset_file_contents(FData); +end; + +procedure TCefDragDataRef.SetFragmentBaseUrl(const baseUrl: ustring); +var + s: TCefString; +begin + s := CefString(baseUrl); + PCefDragData(FData).set_fragment_base_url(FData, @s); +end; + +procedure TCefDragDataRef.SetFragmentHtml(const html: ustring); +var + s: TCefString; +begin + s := CefString(html); + PCefDragData(FData).set_fragment_html(FData, @s); +end; + +procedure TCefDragDataRef.SetFragmentText(const text: ustring); +var + s: TCefString; +begin + s := CefString(text); + PCefDragData(FData).set_fragment_text(FData, @s); +end; + +procedure TCefDragDataRef.SetLinkMetadata(const data: ustring); +var + s: TCefString; +begin + s := CefString(data); + PCefDragData(FData).set_link_metadata(FData, @s); +end; + +procedure TCefDragDataRef.SetLinkTitle(const title: ustring); +var + s: TCefString; +begin + s := CefString(title); + PCefDragData(FData).set_link_title(FData, @s); +end; + +procedure TCefDragDataRef.SetLinkUrl(const url: ustring); +var + s: TCefString; +begin + s := CefString(url); + PCefDragData(FData).set_link_url(FData, @s); +end; + +class function TCefDragDataRef.UnWrap(data: Pointer): ICefDragData; +begin + if data <> nil then + Result := Create(data) as ICefDragData else + Result := nil; +end; + + +end. diff --git a/uCEFDragHandler.pas b/uCEFDragHandler.pas new file mode 100644 index 00000000..e1be1017 --- /dev/null +++ b/uCEFDragHandler.pas @@ -0,0 +1,132 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDragHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefDragHandlerOwn = class(TCefBaseOwn, ICefDragHandler) + protected + function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; virtual; + procedure OnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); virtual; + + public + constructor Create; virtual; + end; + + TCustomDragHandler = class(TCefDragHandlerOwn) + protected + FEvent: IChromiumEvents; + + function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; override; + procedure OnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFDragData; + +function cef_drag_handler_on_drag_enter(self: PCefDragHandler; browser: PCefBrowser; + dragData: PCefDragData; mask: TCefDragOperations): Integer; stdcall; +begin + with TCefDragHandlerOwn(CefGetObject(self)) do + Result := Ord(OnDragEnter(TCefBrowserRef.UnWrap(browser), TCefDragDataRef.UnWrap(dragData), mask)); +end; + +procedure cef_drag_handler_on_draggable_regions_changed(self: PCefDragHandler; + browser: PCefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); stdcall; +begin + with TCefDragHandlerOwn(CefGetObject(self)) do + OnDraggableRegionsChanged(TCefBrowserRef.UnWrap(browser), regionsCount, regions); +end; + +constructor TCefDragHandlerOwn.Create; +begin + CreateData(SizeOf(TCefDragHandler), False); + with PCefDragHandler(FData)^ do + begin + on_drag_enter := cef_drag_handler_on_drag_enter; + on_draggable_regions_changed := cef_drag_handler_on_draggable_regions_changed; + end; +end; + +function TCefDragHandlerOwn.OnDragEnter(const browser: ICefBrowser; + const dragData: ICefDragData; mask: TCefDragOperations): Boolean; +begin + Result := False; +end; + +procedure TCefDragHandlerOwn.OnDraggableRegionsChanged( + const browser: ICefBrowser; regionsCount: NativeUInt; + regions: PCefDraggableRegionArray); +begin + +end; + +// TCustomDragHandler + +constructor TCustomDragHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + + FEvent := events; +end; + +function TCustomDragHandler.OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; +begin + Result := FEvent.doOnDragEnter(browser, dragData, mask); +end; + +procedure TCustomDragHandler.OnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); +begin + FEvent.doOnDraggableRegionsChanged(browser, regionsCount, regions); +end; + +end. diff --git a/uCEFEndTracingCallback.pas b/uCEFEndTracingCallback.pas new file mode 100644 index 00000000..0f17f69c --- /dev/null +++ b/uCEFEndTracingCallback.pas @@ -0,0 +1,82 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFEndTracingCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefEndTracingCallbackOwn = class(TCefBaseOwn, ICefEndTracingCallback) + protected + procedure OnEndTracingComplete(const tracingFile: ustring); virtual; + public + constructor Create; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure cef_end_tracing_callback_on_end_tracing_complete(self: PCefEndTracingCallback; const tracing_file: PCefString); stdcall; +begin + with TCefEndTracingCallbackOwn(CefGetObject(self)) do + OnEndTracingComplete(CefString(tracing_file)); +end; + +constructor TCefEndTracingCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefEndTracingCallback)); + with PCefEndTracingCallback(FData)^ do + on_end_tracing_complete := cef_end_tracing_callback_on_end_tracing_complete; +end; + +procedure TCefEndTracingCallbackOwn.OnEndTracingComplete( + const tracingFile: ustring); +begin + +end; + +end. diff --git a/uCEFFileDialogCallback.pas b/uCEFFileDialogCallback.pas new file mode 100644 index 00000000..0e069d84 --- /dev/null +++ b/uCEFFileDialogCallback.pas @@ -0,0 +1,97 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFFileDialogCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefFileDialogCallbackRef = class(TCefBaseRef, ICefFileDialogCallback) + protected + procedure Cont(selectedAcceptFilter: Integer; filePaths: TStrings); + procedure Cancel; + public + class function UnWrap(data: Pointer): ICefFileDialogCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefFileDialogCallbackRef.Cancel; +begin + PCefFileDialogCallback(FData).cancel(FData); +end; + +procedure TCefFileDialogCallbackRef.Cont(selectedAcceptFilter: Integer; filePaths: TStrings); +var + list: TCefStringList; + i: Integer; + str: TCefString; +begin + list := cef_string_list_alloc; + try + for i := 0 to filePaths.Count - 1 do + begin + str := CefString(filePaths[i]); + cef_string_list_append(list, @str); + end; + PCefFileDialogCallback(FData).cont(FData, selectedAcceptFilter, list); + finally + cef_string_list_free(list); + end; +end; + +class function TCefFileDialogCallbackRef.UnWrap( + data: Pointer): ICefFileDialogCallback; +begin + if data <> nil then + Result := Create(data) as ICefFileDialogCallback else + Result := nil; +end; + +end. diff --git a/uCEFFindHandler.pas b/uCEFFindHandler.pas new file mode 100644 index 00000000..47dabd7f --- /dev/null +++ b/uCEFFindHandler.pas @@ -0,0 +1,101 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFFindHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFTypes, uCEFInterfaces; + +type + TCefFindHandlerOwn = class(TCefBaseOwn, ICefFindHandler) + protected + procedure OnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual; abstract; + + public + constructor Create; virtual; + end; + + TCustomFindHandler = class(TCefFindHandlerOwn) + protected + FEvent: IChromiumEvents; + + procedure OnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser; + +procedure cef_find_handler_on_find_result(self: PCefFindHandler; browser: PCefBrowser; identifier, count: Integer; const selection_rect: PCefRect; active_match_ordinal, final_update: Integer); stdcall; +begin + with TCefFindHandlerOwn(CefGetObject(self)) do + OnFindResult(TCefBrowserRef.UnWrap(browser), identifier, count, selection_rect, active_match_ordinal, final_update <> 0); +end; + +constructor TCefFindHandlerOwn.Create; +begin + CreateData(SizeOf(TCefFindHandler), False); + + with PCefFindHandler(FData)^ do on_find_result := cef_find_handler_on_find_result; +end; + +// TCustomFindHandler + +constructor TCustomFindHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + + FEvent := events; +end; + +procedure TCustomFindHandler.OnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); +begin + FEvent.doOnFindResult(browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate); +end; + +end. diff --git a/uCEFFocusHandler.pas b/uCEFFocusHandler.pas new file mode 100644 index 00000000..82a8f2e5 --- /dev/null +++ b/uCEFFocusHandler.pas @@ -0,0 +1,148 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFFocusHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefFocusHandlerOwn = class(TCefBaseOwn, ICefFocusHandler) + protected + procedure OnTakeFocus(const browser: ICefBrowser; next: Boolean); virtual; + function OnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; virtual; + procedure OnGotFocus(const browser: ICefBrowser); virtual; + + public + constructor Create; virtual; + end; + + TCustomFocusHandler = class(TCefFocusHandlerOwn) + protected + FEvent: IChromiumEvents; + + procedure OnTakeFocus(const browser: ICefBrowser; next: Boolean); override; + function OnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; override; + procedure OnGotFocus(const browser: ICefBrowser); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser; + +procedure cef_focus_handler_on_take_focus(self: PCefFocusHandler; browser: PCefBrowser; next: Integer); stdcall; +begin + with TCefFocusHandlerOwn(CefGetObject(self)) do + OnTakeFocus(TCefBrowserRef.UnWrap(browser), next <> 0); +end; + +function cef_focus_handler_on_set_focus(self: PCefFocusHandler; browser: PCefBrowser; source: TCefFocusSource): Integer; stdcall; +begin + with TCefFocusHandlerOwn(CefGetObject(self)) do + Result := Ord(OnSetFocus(TCefBrowserRef.UnWrap(browser), source)) +end; + +procedure cef_focus_handler_on_got_focus(self: PCefFocusHandler; browser: PCefBrowser); stdcall; +begin + with TCefFocusHandlerOwn(CefGetObject(self)) do + OnGotFocus(TCefBrowserRef.UnWrap(browser)); +end; + +constructor TCefFocusHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefFocusHandler)); + with PCefFocusHandler(FData)^ do + begin + on_take_focus := cef_focus_handler_on_take_focus; + on_set_focus := cef_focus_handler_on_set_focus; + on_got_focus := cef_focus_handler_on_got_focus; + end; +end; + +function TCefFocusHandlerOwn.OnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; +begin + Result := False; +end; + +procedure TCefFocusHandlerOwn.OnGotFocus(const browser: ICefBrowser); +begin + // +end; + +procedure TCefFocusHandlerOwn.OnTakeFocus(const browser: ICefBrowser; next: Boolean); +begin + // +end; + +// TCustomFocusHandler + +constructor TCustomFocusHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +procedure TCustomFocusHandler.OnGotFocus(const browser: ICefBrowser); +begin + FEvent.doOnGotFocus(browser); +end; + +function TCustomFocusHandler.OnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; +begin + Result := FEvent.doOnSetFocus(browser, source); +end; + +procedure TCustomFocusHandler.OnTakeFocus(const browser: ICefBrowser; next: Boolean); +begin + FEvent.doOnTakeFocus(browser, next); +end; + + + +end. + diff --git a/uCEFFrame.pas b/uCEFFrame.pas new file mode 100644 index 00000000..e442aad9 --- /dev/null +++ b/uCEFFrame.pas @@ -0,0 +1,244 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFFrame; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBAse, uCEFInterfaces, uCEFTypes; + +type + TCefFrameRef = class(TCefBaseRef, ICefFrame) + public + function IsValid: Boolean; + procedure Undo; + procedure Redo; + procedure Cut; + procedure Copy; + procedure Paste; + procedure Del; + procedure SelectAll; + procedure ViewSource; + procedure GetSource(const visitor: ICefStringVisitor); + procedure GetSourceProc(const proc: TCefStringVisitorProc); + procedure GetText(const visitor: ICefStringVisitor); + procedure GetTextProc(const proc: TCefStringVisitorProc); + procedure LoadRequest(const request: ICefRequest); + procedure LoadUrl(const url: ustring); + procedure LoadString(const str, url: ustring); + procedure ExecuteJavaScript(const code, scriptUrl: ustring; startLine: Integer); + function IsMain: Boolean; + function IsFocused: Boolean; + function GetName: ustring; + function GetIdentifier: Int64; + function GetParent: ICefFrame; + function GetUrl: ustring; + function GetBrowser: ICefBrowser; + function GetV8Context: ICefv8Context; + procedure VisitDom(const visitor: ICefDomVisitor); + procedure VisitDomProc(const proc: TCefDomVisitorProc); + + class function UnWrap(data: Pointer): ICefFrame; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFStringVisitor, uCEFv8Context, uCEFDomVisitor; + +function TCefFrameRef.IsValid: Boolean; +begin + Result := PCefFrame(FData)^.is_valid(PCefFrame(FData)) <> 0; +end; + +procedure TCefFrameRef.Copy; +begin + PCefFrame(FData)^.copy(PCefFrame(FData)); +end; + +procedure TCefFrameRef.Cut; +begin + PCefFrame(FData)^.cut(PCefFrame(FData)); +end; + +procedure TCefFrameRef.Del; +begin + PCefFrame(FData)^.del(PCefFrame(FData)); +end; + +procedure TCefFrameRef.ExecuteJavaScript(const code, scriptUrl: ustring; + startLine: Integer); +var + j, s: TCefString; +begin + j := CefString(code); + s := CefString(scriptUrl); + PCefFrame(FData)^.execute_java_script(PCefFrame(FData), @j, @s, startline); +end; + +function TCefFrameRef.GetBrowser: ICefBrowser; +begin + Result := TCefBrowserRef.UnWrap(PCefFrame(FData)^.get_browser(PCefFrame(FData))); +end; + +function TCefFrameRef.GetIdentifier: Int64; +begin + Result := PCefFrame(FData)^.get_identifier(PCefFrame(FData)); +end; + +function TCefFrameRef.GetName: ustring; +begin + Result := CefStringFreeAndGet(PCefFrame(FData)^.get_name(PCefFrame(FData))); +end; + +function TCefFrameRef.GetParent: ICefFrame; +begin + Result := TCefFrameRef.UnWrap(PCefFrame(FData)^.get_parent(PCefFrame(FData))); +end; + +procedure TCefFrameRef.GetSource(const visitor: ICefStringVisitor); +begin + PCefFrame(FData)^.get_source(PCefFrame(FData), CefGetData(visitor)); +end; + +procedure TCefFrameRef.GetSourceProc(const proc: TCefStringVisitorProc); +begin + GetSource(TCefFastStringVisitor.Create(proc)); +end; + +procedure TCefFrameRef.getText(const visitor: ICefStringVisitor); +begin + PCefFrame(FData)^.get_text(PCefFrame(FData), CefGetData(visitor)); +end; + +procedure TCefFrameRef.GetTextProc(const proc: TCefStringVisitorProc); +begin + GetText(TCefFastStringVisitor.Create(proc)); +end; + +function TCefFrameRef.GetUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefFrame(FData)^.get_url(PCefFrame(FData))); +end; + +function TCefFrameRef.GetV8Context: ICefv8Context; +begin + Result := TCefv8ContextRef.UnWrap(PCefFrame(FData)^.get_v8context(PCefFrame(FData))); +end; + +function TCefFrameRef.IsFocused: Boolean; +begin + Result := PCefFrame(FData)^.is_focused(PCefFrame(FData)) <> 0; +end; + +function TCefFrameRef.IsMain: Boolean; +begin + Result := PCefFrame(FData)^.is_main(PCefFrame(FData)) <> 0; +end; + +procedure TCefFrameRef.LoadRequest(const request: ICefRequest); +begin + PCefFrame(FData)^.load_request(PCefFrame(FData), CefGetData(request)); +end; + +procedure TCefFrameRef.LoadString(const str, url: ustring); +var + s, u: TCefString; +begin + s := CefString(str); + u := CefString(url); + PCefFrame(FData)^.load_string(PCefFrame(FData), @s, @u); +end; + +procedure TCefFrameRef.LoadUrl(const url: ustring); +var + u: TCefString; +begin + u := CefString(url); + PCefFrame(FData)^.load_url(PCefFrame(FData), @u); + +end; + +procedure TCefFrameRef.Paste; +begin + PCefFrame(FData)^.paste(PCefFrame(FData)); +end; + +procedure TCefFrameRef.Redo; +begin + PCefFrame(FData)^.redo(PCefFrame(FData)); +end; + +procedure TCefFrameRef.SelectAll; +begin + PCefFrame(FData)^.select_all(PCefFrame(FData)); +end; + +procedure TCefFrameRef.Undo; +begin + PCefFrame(FData)^.undo(PCefFrame(FData)); +end; + +procedure TCefFrameRef.ViewSource; +begin + PCefFrame(FData)^.view_source(PCefFrame(FData)); +end; + +procedure TCefFrameRef.VisitDom(const visitor: ICefDomVisitor); +begin + PCefFrame(FData)^.visit_dom(PCefFrame(FData), CefGetData(visitor)); +end; + +procedure TCefFrameRef.VisitDomProc(const proc: TCefDomVisitorProc); +begin + VisitDom(TCefFastDomVisitor.Create(proc) as ICefDomVisitor); +end; + +class function TCefFrameRef.UnWrap(data: Pointer): ICefFrame; +begin + if data <> nil then + Result := Create(data) as ICefFrame else + Result := nil; +end; + +end. diff --git a/uCEFGeolocationCallback.pas b/uCEFGeolocationCallback.pas new file mode 100644 index 00000000..4fdd7506 --- /dev/null +++ b/uCEFGeolocationCallback.pas @@ -0,0 +1,76 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFGeolocationCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefGeolocationCallbackRef = class(TCefBaseRef, ICefGeolocationCallback) + protected + procedure Cont(allow: Boolean); + public + class function UnWrap(data: Pointer): ICefGeolocationCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefGeolocationCallbackRef.Cont(allow: Boolean); +begin + PCefGeolocationCallback(FData).cont(PCefGeolocationCallback(FData), Ord(allow)); +end; + +class function TCefGeolocationCallbackRef.UnWrap(data: Pointer): ICefGeolocationCallback; +begin + if data <> nil then + Result := Create(data) as ICefGeolocationCallback else + Result := nil; +end; + + +end. diff --git a/uCEFGeolocationHandler.pas b/uCEFGeolocationHandler.pas new file mode 100644 index 00000000..45021f19 --- /dev/null +++ b/uCEFGeolocationHandler.pas @@ -0,0 +1,138 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFGeolocationHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefGeolocationHandlerOwn = class(TCefBaseOwn, ICefGeolocationHandler) + protected + function OnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; virtual; + procedure OnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); virtual; + + public + constructor Create; virtual; + end; + + TCustomGeolocationHandler = class(TCefGeolocationHandlerOwn) + protected + FEvent: IChromiumEvents; + + function OnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; override; + procedure OnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFGeolocationCallback; + +function cef_geolocation_handler_on_request_geolocation_permission(self: PCefGeolocationHandler; + browser: PCefBrowser; const requesting_url: PCefString; request_id: Integer; + callback: PCefGeolocationCallback): Integer; stdcall; +begin + with TCefGeolocationHandlerOwn(CefGetObject(self)) do + Result := Ord(OnRequestGeolocationPermission(TCefBrowserRef.UnWrap(browser), CefString(requesting_url), + request_id, TCefGeolocationCallbackRef.UnWrap(callback))); +end; + +procedure cef_geolocation_handler_on_cancel_geolocation_permission(self: PCefGeolocationHandler; + browser: PCefBrowser; request_id: Integer); stdcall; +begin + with TCefGeolocationHandlerOwn(CefGetObject(self)) do + OnCancelGeolocationPermission(TCefBrowserRef.UnWrap(browser), request_id); +end; + +// TCefGeolocationHandlerOwn + +constructor TCefGeolocationHandlerOwn.Create; +begin + + inherited CreateData(SizeOf(TCefGeolocationHandler)); + with PCefGeolocationHandler(FData)^ do + begin + on_request_geolocation_permission := cef_geolocation_handler_on_request_geolocation_permission; + on_cancel_geolocation_permission := cef_geolocation_handler_on_cancel_geolocation_permission; + end; +end; + + +function TCefGeolocationHandlerOwn.OnRequestGeolocationPermission( + const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; + const callback: ICefGeolocationCallback): Boolean; +begin + Result := False; +end; + +procedure TCefGeolocationHandlerOwn.OnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); +begin + +end; + +// TCustomGeolocationHandler + +constructor TCustomGeolocationHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +procedure TCustomGeolocationHandler.OnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); +begin + FEvent.doOnCancelGeolocationPermission(browser, requestId); +end; + +function TCustomGeolocationHandler.OnRequestGeolocationPermission( + const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; + const callback: ICefGeolocationCallback): Boolean; +begin + Result := FEvent.doOnRequestGeolocationPermission(browser, requestingUrl, requestId, callback); +end; + +end. diff --git a/uCEFGetGeolocationCallback.pas b/uCEFGetGeolocationCallback.pas new file mode 100644 index 00000000..5895c9c5 --- /dev/null +++ b/uCEFGetGeolocationCallback.pas @@ -0,0 +1,113 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFGetGeolocationCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefGetGeolocationCallbackOwn = class(TCefBaseOwn, ICefGetGeolocationCallback) + protected + procedure OnLocationUpdate(const position: PCefGeoposition); virtual; + + public + constructor Create; virtual; + end; + + TOnLocationUpdate = reference to procedure(const position: PCefGeoposition); + + TCefFastGetGeolocationCallback = class(TCefGetGeolocationCallbackOwn) + protected + FCallback: TOnLocationUpdate; + + procedure OnLocationUpdate(const position: PCefGeoposition); override; + + public + constructor Create(const callback: TOnLocationUpdate); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure cef_get_geolocation_callback_on_location_update( + self: PCefGetGeolocationCallback; const position: PCefGeoposition); stdcall; +begin + with TCefGetGeolocationCallbackOwn(CefGetObject(self)) do + OnLocationUpdate(position); +end; + +// TCefGetGeolocationCallbackOwn + +constructor TCefGetGeolocationCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefGetGeolocationCallback)); + with PCefGetGeolocationCallback(FData)^ do + on_location_update := cef_get_geolocation_callback_on_location_update; +end; + +procedure TCefGetGeolocationCallbackOwn.OnLocationUpdate( + const position: PCefGeoposition); +begin + +end; + +// TCefFastGetGeolocationCallback + +constructor TCefFastGetGeolocationCallback.Create( + const callback: TOnLocationUpdate); +begin + inherited Create; + FCallback := callback; +end; + +procedure TCefFastGetGeolocationCallback.OnLocationUpdate( + const position: PCefGeoposition); +begin + FCallback(position); +end; + +end. diff --git a/uCEFImage.pas b/uCEFImage.pas new file mode 100644 index 00000000..fd236c7c --- /dev/null +++ b/uCEFImage.pas @@ -0,0 +1,173 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFImage; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + WinApi.Windows, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefImageRef = class(TCefBaseRef, ICefImage) + protected + function IsEmpty: Boolean; + function IsSame(const that: ICefImage): Boolean; + function AddBitmap(scaleFactor: Single; pixelWidth, pixelHeight: Integer; + colorType: TCefColorType; alphaType: TCefAlphaType; pixelData: Pointer; + pixelDataSize: NativeUInt): Boolean; + function AddPng(scaleFactor: Single; const pngData: Pointer; pngDataSize: NativeUInt): Boolean; + function AddJpeg(scaleFactor: Single; const jpegData: Pointer; jpegDataSize: NativeUInt): Boolean; + function GetWidth: NativeUInt; + function GetHeight: NativeUInt; + function HasRepresentation(scaleFactor: Single): Boolean; + function RemoveRepresentation(scaleFactor: Single): Boolean; + function GetRepresentationInfo(scaleFactor: Single; actualScaleFactor: PSingle; + pixelWidth, pixelHeight: PInteger): Boolean; + function GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; + alphaType: TCefAlphaType; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; + function GetAsPng(scaleFactor: Single; withTransparency: Boolean; + pixelWidth, pixelHeight: PInteger): ICefBinaryValue; + function GetAsJpeg(scaleFactor: Single; quality: Integer; + pixelWidth, pixelHeight: PInteger): ICefBinaryValue; + public + class function UnWrap(data: Pointer): ICefImage; + class function New: ICefImage; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue; + +function TCefImageRef.AddBitmap(scaleFactor: Single; pixelWidth, + pixelHeight: Integer; colorType: TCefColorType; alphaType: TCefAlphaType; + pixelData: Pointer; pixelDataSize: NativeUInt): Boolean; +begin + Result := PCefImage(FData).add_bitmap(FData, scaleFactor, pixelWidth, + pixelHeight, colorType, alphaType, pixelData, pixelDataSize) <> 0; +end; + +function TCefImageRef.AddJpeg(scaleFactor: Single; const jpegData: Pointer; + jpegDataSize: NativeUInt): Boolean; +begin + Result := PCefImage(FData).add_jpeg(FData, scaleFactor, jpegData, jpegDataSize) <> 0; +end; + +function TCefImageRef.AddPng(scaleFactor: Single; const pngData: Pointer; + pngDataSize: NativeUInt): Boolean; +begin + Result := PCefImage(FData).add_png(FData, scaleFactor, pngData, pngDataSize) <> 0; +end; + +function TCefImageRef.GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; + alphaType: TCefAlphaType; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; +begin + Result := TCefBinaryValueRef.UnWrap(PCefImage(FData).get_as_bitmap( + FData, scaleFactor, colorType, alphaType, pixelWidth, pixelHeight)); +end; + +function TCefImageRef.GetAsJpeg(scaleFactor: Single; quality: Integer; + pixelWidth, pixelHeight: PInteger): ICefBinaryValue; +begin + Result := TCefBinaryValueRef.UnWrap(PCefImage(FData).get_as_jpeg( + FData, scaleFactor, quality, pixelWidth, pixelHeight)); +end; + +function TCefImageRef.GetAsPng(scaleFactor: Single; withTransparency: Boolean; + pixelWidth, pixelHeight: PInteger): ICefBinaryValue; +begin + Result := TCefBinaryValueRef.UnWrap(PCefImage(FData).get_as_png( + FData, scaleFactor, Ord(withTransparency), pixelWidth, pixelHeight)); +end; + +function TCefImageRef.GetHeight: NativeUInt; +begin + Result := PCefImage(FData).get_height(FData); +end; + +function TCefImageRef.GetRepresentationInfo(scaleFactor: Single; + actualScaleFactor: PSingle; pixelWidth, pixelHeight: PInteger): Boolean; +begin + Result := PCefImage(FData).get_representation_info(FData, scaleFactor, + actualScaleFactor, pixelWidth, pixelHeight) <> 0; +end; + +function TCefImageRef.GetWidth: NativeUInt; +begin + Result := PCefImage(FData).get_width(FData); +end; + +function TCefImageRef.HasRepresentation(scaleFactor: Single): Boolean; +begin + Result := PCefImage(FData).has_representation(FData, scaleFactor) <> 0; +end; + +function TCefImageRef.IsEmpty: Boolean; +begin + Result := PCefImage(FData).is_empty(FData) <> 0; +end; + +function TCefImageRef.IsSame(const that: ICefImage): Boolean; +begin + Result := PCefImage(FData).is_same(FData, CefGetData(that)) <> 0; +end; + +class function TCefImageRef.New: ICefImage; +begin + Result := UnWrap(cef_image_create()); +end; + +function TCefImageRef.RemoveRepresentation(scaleFactor: Single): Boolean; +begin + Result := PCefImage(FData).remove_representation(FData, scaleFactor) <> 0; +end; + +class function TCefImageRef.UnWrap(data: Pointer): ICefImage; +begin + if data <> nil then + Result := Create(data) as ICefImage else + Result := nil; +end; + +end. diff --git a/uCEFInterfaces.pas b/uCEFInterfaces.pas new file mode 100644 index 00000000..2e60def1 --- /dev/null +++ b/uCEFInterfaces.pas @@ -0,0 +1,1732 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFInterfaces; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + WinApi.Windows, System.Classes, + uCEFTypes; + +type + ICefBrowser = interface; + ICefFrame = interface; + ICefRequest = interface; + ICefv8Value = interface; + ICefDomVisitor = interface; + ICefDomDocument = interface; + ICefDomNode = interface; + ICefv8Context = interface; + ICefListValue = interface; + ICefBinaryValue = interface; + ICefDictionaryValue = interface; + ICefClient = interface; + ICefUrlrequestClient = interface; + ICefBrowserHost = interface; + ICefTask = interface; + ICefTaskRunner = interface; + ICefFileDialogCallback = interface; + ICefRequestContext = interface; + ICefDragData = interface; + ICefNavigationEntry = interface; + ICefSslInfo = interface; + ICefSSLStatus = interface; + ICefImage = interface; + ICefClientHandler = interface; + IChromiumEvents = interface; + ICefThread = interface; + ICefWaitableEvent = interface; + ICefX509CertPrincipal = interface; + ICefX509Certificate = interface; + ICefSelectClientCertificateCallback = interface; + ICefSchemeRegistrar = interface; + ICefCommandLine = interface; + ICefRequestHandler = interface; + + TCefv8ValueArray = array of ICefv8Value; + TCefX509CertificateArray = array of ICefX509Certificate; + + TOnPdfPrintFinishedProc = reference to procedure(const path: ustring; ok: Boolean); + TCefDomVisitorProc = reference to procedure(const document: ICefDomDocument); + TCefStringVisitorProc = reference to procedure(const str: ustring); + TOnRegisterCustomSchemes = reference to procedure(const registrar: ICefSchemeRegistrar); + TOnBeforeCommandLineProcessing = reference to procedure(const processType: ustring; const commandLine: ICefCommandLine); + TCefCompletionCallbackProc = reference to procedure; + TCefSetCookieCallbackProc = reference to procedure(success: Boolean); + TCefDeleteCookiesCallbackProc = reference to procedure(numDeleted: Integer); + + + + ICefBase = interface + ['{1F9A7B44-DCDC-4477-9180-3ADD44BDEB7B}'] + function Wrap: Pointer; + end; + + ICefRunFileDialogCallback = interface(ICefBase) + ['{59FCECC6-E897-45BA-873B-F09586C4BE47}'] + procedure OnFileDialogDismissed(selectedAcceptFilter: Integer; filePaths: TStrings); + end; + + TCefRunFileDialogCallbackProc = reference to + procedure(selectedAcceptFilter: Integer; filePaths: TStrings); + + ICefNavigationEntryVisitor = interface(ICefBase) + ['{CC4D6BC9-0168-4C2C-98BA-45E9AA9CD619}'] + function Visit(const entry: ICefNavigationEntry; + current: Boolean; index, total: Integer): Boolean; + end; + + TCefNavigationEntryVisitorProc = reference to + function(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer): Boolean; + + ICefPdfPrintCallback = interface(ICefBase) + ['{F1CC58E9-2C30-4932-91AE-467C8D8EFB8E}'] + procedure OnPdfPrintFinished(const path: ustring; ok: Boolean); + end; + + TOnDownloadImageFinishedProc = reference to + procedure(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); + + ICefDownloadImageCallback = interface(ICefBase) + ['{0C6E9032-27DF-4584-95C6-DC3C7CB63727}'] + procedure OnDownloadImageFinished(const imageUrl: ustring; + httpStatusCode: Integer; const image: ICefImage); + end; + + ICefBrowserHost = interface(ICefBase) + ['{53AE02FF-EF5D-48C3-A43E-069DA9535424}'] + function GetBrowser: ICefBrowser; + procedure CloseBrowser(forceClose: Boolean); + function TryCloseBrowser: Boolean; + procedure SetFocus(focus: Boolean); + function GetWindowHandle: TCefWindowHandle; + function GetOpenerWindowHandle: TCefWindowHandle; + function HasView: Boolean; + function GetRequestContext: ICefRequestContext; + function GetZoomLevel: Double; + procedure SetZoomLevel(zoomLevel: Double); + procedure RunFileDialog(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefRunFileDialogCallback); + procedure RunFileDialogProc(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: TCefRunFileDialogCallbackProc); + procedure StartDownload(const url: ustring); + procedure DownloadImage(const imageUrl: ustring; isFavicon: Boolean; maxImageSize: Cardinal; bypassCache: Boolean; const callback: ICefDownloadImageCallback); + procedure Print; + procedure PrintToPdf(const path: ustring; settings: PCefPdfPrintSettings; const callback: ICefPdfPrintCallback); + procedure PrintToPdfProc(const path: ustring; settings: PCefPdfPrintSettings; const callback: TOnPdfPrintFinishedProc); + procedure Find(identifier: Integer; const searchText: ustring; forward, matchCase, findNext: Boolean); + procedure StopFinding(clearSelection: Boolean); + procedure ShowDevTools(const windowInfo: PCefWindowInfo; const client: ICefClient; const settings: PCefBrowserSettings; inspectElementAt: PCefPoint); + procedure CloseDevTools; + function HasDevTools: Boolean; + procedure GetNavigationEntries(const visitor: ICefNavigationEntryVisitor; currentOnly: Boolean); + procedure GetNavigationEntriesProc(const proc: TCefNavigationEntryVisitorProc; currentOnly: Boolean); + procedure SetMouseCursorChangeDisabled(disabled: Boolean); + function IsMouseCursorChangeDisabled: Boolean; + procedure ReplaceMisspelling(const word: ustring); + procedure AddWordToDictionary(const word: ustring); + function IsWindowRenderingDisabled: Boolean; + procedure WasResized; + procedure WasHidden(hidden: Boolean); + procedure NotifyScreenInfoChanged; + procedure Invalidate(kind: TCefPaintElementType); + procedure SendKeyEvent(const event: PCefKeyEvent); + procedure SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); + procedure SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); + procedure SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); + procedure SendFocusEvent(setFocus: Boolean); + procedure SendCaptureLostEvent; + procedure NotifyMoveOrResizeStarted; + function GetWindowlessFrameRate(): Integer; + procedure SetWindowlessFrameRate(frameRate: Integer); + procedure IMESetComposition(const text: ustring; underlinesCount : NativeUInt; const underlines : PCefCompositionUnderline; const replacement_range, selection_range : PCefRange); + procedure IMECommitText(const text: ustring; const replacement_range : PCefRange; relative_cursor_pos : integer); + procedure IMEFinishComposingText(keep_selection : boolean); + procedure IMECancelComposition; + procedure DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); + procedure DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); + procedure DragTargetDragLeave; + procedure DragTargetDrop(event: PCefMouseEvent); + procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); + procedure DragSourceSystemDragEnded; + function GetVisibleNavigationEntry : ICefNavigationEntry; + + property Browser: ICefBrowser read GetBrowser; + property WindowHandle: TCefWindowHandle read GetWindowHandle; + property OpenerWindowHandle: TCefWindowHandle read GetOpenerWindowHandle; + property ZoomLevel: Double read GetZoomLevel write SetZoomLevel; + property RequestContext: ICefRequestContext read GetRequestContext; + property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; + end; + + ICefProcessMessage = interface(ICefBase) + ['{E0B1001A-8777-425A-869B-29D40B8B93B1}'] + function IsValid: Boolean; + function IsReadOnly: Boolean; + function Copy: ICefProcessMessage; + function GetName: ustring; + function GetArgumentList: ICefListValue; + property Name: ustring read GetName; + property ArgumentList: ICefListValue read GetArgumentList; + end; + + ICefBrowser = interface(ICefBase) + ['{BA003C2E-CF15-458F-9D4A-FE3CEFCF3EEF}'] + function GetHost: ICefBrowserHost; + function CanGoBack: Boolean; + procedure GoBack; + function CanGoForward: Boolean; + procedure GoForward; + function IsLoading: Boolean; + procedure Reload; + procedure ReloadIgnoreCache; + procedure StopLoad; + function GetIdentifier: Integer; + function IsSame(const that: ICefBrowser): Boolean; + function IsPopup: Boolean; + function HasDocument: Boolean; + function GetMainFrame: ICefFrame; + function GetFocusedFrame: ICefFrame; + function GetFrameByident(identifier: Int64): ICefFrame; + function GetFrame(const name: ustring): ICefFrame; + function GetFrameCount: NativeUInt; + procedure GetFrameIdentifiers(count: PNativeUInt; identifiers: PInt64); + procedure GetFrameNames(names: TStrings); + function SendProcessMessage(targetProcess: TCefProcessId; + message: ICefProcessMessage): Boolean; + property MainFrame: ICefFrame read GetMainFrame; + property FocusedFrame: ICefFrame read GetFocusedFrame; + property FrameCount: NativeUInt read GetFrameCount; + property Host: ICefBrowserHost read GetHost; + property Identifier: Integer read GetIdentifier; + end; + + ICefPostDataElement = interface(ICefBase) + ['{3353D1B8-0300-4ADC-8D74-4FF31C77D13C}'] + function IsReadOnly: Boolean; + procedure SetToEmpty; + procedure SetToFile(const fileName: ustring); + procedure SetToBytes(size: NativeUInt; bytes: Pointer); + function GetType: TCefPostDataElementType; + function GetFile: ustring; + function GetBytesCount: NativeUInt; + function GetBytes(size: NativeUInt; bytes: Pointer): NativeUInt; + end; + + ICefPostData = interface(ICefBase) + ['{1E677630-9339-4732-BB99-D6FE4DE4AEC0}'] + function IsReadOnly: Boolean; + function HasExcludedElements: Boolean; + function GetCount: NativeUInt; + function GetElements(Count: NativeUInt): IInterfaceList; // ICefPostDataElement + function RemoveElement(const element: ICefPostDataElement): Integer; + function AddElement(const element: ICefPostDataElement): Integer; + procedure RemoveElements; + end; + + ICefStringMap = interface + ['{A33EBC01-B23A-4918-86A4-E24A243B342F}'] + function GetHandle: TCefStringMap; + function GetSize: Integer; + function Find(const Key: ustring): ustring; + function GetKey(Index: Integer): ustring; + function GetValue(Index: Integer): ustring; + procedure Append(const Key, Value: ustring); + procedure Clear; + + property Handle: TCefStringMap read GetHandle; + property Size: Integer read GetSize; + property Key[index: Integer]: ustring read GetKey; + property Value[index: Integer]: ustring read GetValue; + end; + + ICefStringMultimap = interface + ['{583ED0C2-A9D6-4034-A7C9-20EC7E47F0C7}'] + function GetHandle: TCefStringMultimap; + function GetSize: Integer; + function FindCount(const Key: ustring): Integer; + function GetEnumerate(const Key: ustring; ValueIndex: Integer): ustring; + function GetKey(Index: Integer): ustring; + function GetValue(Index: Integer): ustring; + procedure Append(const Key, Value: ustring); + procedure Clear; + + property Handle: TCefStringMap read GetHandle; + property Size: Integer read GetSize; + property Key[index: Integer]: ustring read GetKey; + property Value[index: Integer]: ustring read GetValue; + property Enumerate[const Key: ustring; ValueIndex: Integer]: ustring read GetEnumerate; + end; + + ICefRequest = interface(ICefBase) + ['{FB4718D3-7D13-4979-9F4C-D7F6C0EC592A}'] + function IsReadOnly: Boolean; + function GetUrl: ustring; + function GetMethod: ustring; + function GetPostData: ICefPostData; + procedure GetHeaderMap(const HeaderMap: ICefStringMultimap); + procedure SetUrl(const value: ustring); + procedure SetMethod(const value: ustring); + procedure SetReferrer(const referrerUrl: ustring; policy: TCefReferrerPolicy); + function GetReferrerUrl: ustring; + function GetReferrerPolicy: TCefReferrerPolicy; + procedure SetPostData(const value: ICefPostData); + procedure SetHeaderMap(const HeaderMap: ICefStringMultimap); + function GetFlags: TCefUrlRequestFlags; + procedure SetFlags(flags: TCefUrlRequestFlags); + function GetFirstPartyForCookies: ustring; + procedure SetFirstPartyForCookies(const url: ustring); + procedure Assign(const url, method: ustring; + const postData: ICefPostData; const headerMap: ICefStringMultimap); + function GetResourceType: TCefResourceType; + function GetTransitionType: TCefTransitionType; + + function GetIdentifier: UInt64; + + property Url: ustring read GetUrl write SetUrl; + property Method: ustring read GetMethod write SetMethod; + property ReferrerUrl: ustring read GetReferrerUrl; + property ReferrerPolicy: TCefReferrerPolicy read GetReferrerPolicy; + property PostData: ICefPostData read GetPostData write SetPostData; + property Flags: TCefUrlRequestFlags read GetFlags write SetFlags; + property FirstPartyForCookies: ustring read GetFirstPartyForCookies write SetFirstPartyForCookies; + property ResourceType: TCefResourceType read GetResourceType; + property TransitionType: TCefTransitionType read GetTransitionType; + property Identifier: UInt64 read GetIdentifier; + end; + + ICefStringVisitor = interface(ICefBase) + ['{63ED4D6C-2FC8-4537-964B-B84C008F6158}'] + procedure Visit(const str: ustring); + end; + + ICefFrame = interface(ICefBase) + ['{8FD3D3A6-EA3A-4A72-8501-0276BD5C3D1D}'] + function IsValid: Boolean; + procedure Undo; + procedure Redo; + procedure Cut; + procedure Copy; + procedure Paste; + procedure Del; + procedure SelectAll; + procedure ViewSource; + procedure GetSource(const visitor: ICefStringVisitor); + procedure GetSourceProc(const proc: TCefStringVisitorProc); + procedure GetText(const visitor: ICefStringVisitor); + procedure GetTextProc(const proc: TCefStringVisitorProc); + procedure LoadRequest(const request: ICefRequest); + procedure LoadUrl(const url: ustring); + procedure LoadString(const str, url: ustring); + procedure ExecuteJavaScript(const code, scriptUrl: ustring; startLine: Integer); + function IsMain: Boolean; + function IsFocused: Boolean; + function GetName: ustring; + function GetIdentifier: Int64; + function GetParent: ICefFrame; + function GetUrl: ustring; + function GetBrowser: ICefBrowser; + function GetV8Context: ICefv8Context; + procedure VisitDom(const visitor: ICefDomVisitor); + procedure VisitDomProc(const proc: TCefDomVisitorProc); + property Name: ustring read GetName; + property Url: ustring read GetUrl; + property Browser: ICefBrowser read GetBrowser; + property Parent: ICefFrame read GetParent; + end; + + + ICefCustomStreamReader = interface(ICefBase) + ['{BBCFF23A-6FE7-4C28-B13E-6D2ACA5C83B7}'] + function Read(ptr: Pointer; size, n: NativeUInt): NativeUInt; + function Seek(offset: Int64; whence: Integer): Integer; + function Tell: Int64; + function Eof: Boolean; + function MayBlock: Boolean; + end; + + ICefStreamReader = interface(ICefBase) + ['{DD5361CB-E558-49C5-A4BD-D1CE84ADB277}'] + function Read(ptr: Pointer; size, n: NativeUInt): NativeUInt; + function Seek(offset: Int64; whence: Integer): Integer; + function Tell: Int64; + function Eof: Boolean; + function MayBlock: Boolean; + end; + + ICefWriteHandler = interface(ICefBase) + ['{F2431888-4EAB-421E-9EC3-320BE695AF30}'] + function Write(const ptr: Pointer; size, n: NativeUInt): NativeUInt; + function Seek(offset: Int64; whence: Integer): Integer; + function Tell: Int64; + function Flush: Integer; + function MayBlock: Boolean; + end; + + ICefStreamWriter = interface(ICefBase) + ['{4AA6C477-7D8A-4D5A-A704-67F900A827E7}'] + function Write(const ptr: Pointer; size, n: NativeUInt): NativeUInt; + function Seek(offset: Int64; whence: Integer): Integer; + function Tell: Int64; + function Flush: Integer; + function MayBlock: Boolean; + end; + + ICefResponse = interface(ICefBase) + ['{E9C896E4-59A8-4B96-AB5E-6EA3A498B7F1}'] + function IsReadOnly: Boolean; + function GetError: TCefErrorCode; + procedure SetError(error: TCefErrorCode); + function GetStatus: Integer; + procedure SetStatus(status: Integer); + function GetStatusText: ustring; + procedure SetStatusText(const StatusText: ustring); + function GetMimeType: ustring; + procedure SetMimeType(const mimetype: ustring); + function GetHeader(const name: ustring): ustring; + procedure GetHeaderMap(const headerMap: ICefStringMultimap); + procedure SetHeaderMap(const headerMap: ICefStringMultimap); + property Status: Integer read GetStatus write SetStatus; + property StatusText: ustring read GetStatusText write SetStatusText; + property MimeType: ustring read GetMimeType write SetMimeType; + property Error: TCefErrorCode read GetError write SetError; + end; + + ICefDownloadItem = interface(ICefBase) + ['{B34BD320-A82E-4185-8E84-B98E5EEC803F}'] + function IsValid: Boolean; + function IsInProgress: Boolean; + function IsComplete: Boolean; + function IsCanceled: Boolean; + function GetCurrentSpeed: Int64; + function GetPercentComplete: Integer; + function GetTotalBytes: Int64; + function GetReceivedBytes: Int64; + function GetStartTime: TDateTime; + function GetEndTime: TDateTime; + function GetFullPath: ustring; + function GetId: Cardinal; + function GetUrl: ustring; + function GetOriginalUrl: ustring; + function GetSuggestedFileName: ustring; + function GetContentDisposition: ustring; + function GetMimeType: ustring; + + property CurrentSpeed: Int64 read GetCurrentSpeed; + property PercentComplete: Integer read GetPercentComplete; + property TotalBytes: Int64 read GetTotalBytes; + property ReceivedBytes: Int64 read GetReceivedBytes; + property StartTime: TDateTime read GetStartTime; + property EndTime: TDateTime read GetEndTime; + property FullPath: ustring read GetFullPath; + property Id: Cardinal read GetId; + property Url: ustring read GetUrl; + property OriginalUrl: ustring read GetOriginalUrl; + property SuggestedFileName: ustring read GetSuggestedFileName; + property ContentDisposition: ustring read GetContentDisposition; + property MimeType: ustring read GetMimeType; + end; + + ICefBeforeDownloadCallback = interface(ICefBase) + ['{5A81AF75-CBA2-444D-AD8E-522160F36433}'] + procedure Cont(const downloadPath: ustring; showDialog: Boolean); + end; + + ICefDownloadItemCallback = interface(ICefBase) + ['{498F103F-BE64-4D5F-86B7-B37EC69E1735}'] + procedure Cancel; + procedure Pause; + procedure Resume; + end; + + ICefDownloadHandler = interface(ICefBase) + ['{3137F90A-5DC5-43C1-858D-A269F28EF4F1}'] + procedure OnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; + const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); + procedure OnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; + const callback: ICefDownloadItemCallback); + end; + + ICefV8Exception = interface(ICefBase) + ['{7E422CF0-05AC-4A60-A029-F45105DCE6A4}'] + function GetMessage: ustring; + function GetSourceLine: ustring; + function GetScriptResourceName: ustring; + function GetLineNumber: Integer; + function GetStartPosition: Integer; + function GetEndPosition: Integer; + function GetStartColumn: Integer; + function GetEndColumn: Integer; + + property Message: ustring read GetMessage; + property SourceLine: ustring read GetSourceLine; + property ScriptResourceName: ustring read GetScriptResourceName; + property LineNumber: Integer read GetLineNumber; + property StartPosition: Integer read GetStartPosition; + property EndPosition: Integer read GetEndPosition; + property StartColumn: Integer read GetStartColumn; + property EndColumn: Integer read GetEndColumn; + end; + + ICefv8Context = interface(ICefBase) + ['{2295A11A-8773-41F2-AD42-308C215062D9}'] + function GetTaskRunner: ICefTaskRunner; + function IsValid: Boolean; + function GetBrowser: ICefBrowser; + function GetFrame: ICefFrame; + function GetGlobal: ICefv8Value; + function Enter: Boolean; + function Exit: Boolean; + function IsSame(const that: ICefv8Context): Boolean; + function Eval(const code: ustring; const script_url: ustring; start_line: integer; var retval: ICefv8Value; var exception: ICefV8Exception): Boolean; + property Browser: ICefBrowser read GetBrowser; + property Frame: ICefFrame read GetFrame; + property Global: ICefv8Value read GetGlobal; + end; + + ICefv8Handler = interface(ICefBase) + ['{F94CDC60-FDCB-422D-96D5-D2A775BD5D73}'] + function Execute(const name: ustring; const obj: ICefv8Value; + const arguments: TCefv8ValueArray; var retval: ICefv8Value; + var exception: ustring): Boolean; + end; + + ICefV8Interceptor = interface(ICefBase) + ['{B3B8FD7C-A916-4B25-93A2-2892AC324F21}'] + function GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; + function GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; + function SetByName(const name: ustring; const obj: ICefv8Value; const value: ICefv8Value; const exception: ustring): boolean; + function SetByIndex(index: integer; const obj: ICefv8Value; const value: ICefv8Value; const exception: ustring): boolean; + end; + + ICefV8Accessor = interface(ICefBase) + ['{DCA6D4A2-726A-4E24-AA64-5E8C731D868A}'] + function Get(const name: ustring; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; + function Put(const name: ustring; const obj: ICefv8Value; const value: ICefv8Value; const exception: ustring): Boolean; + end; + + ICefTask = interface(ICefBase) + ['{0D965470-4A86-47CE-BD39-A8770021AD7E}'] + procedure Execute; + end; + + ICefTaskRunner = interface(ICefBase) + ['{6A500FA3-77B7-4418-8EA8-6337EED1337B}'] + function IsSame(const that: ICefTaskRunner): Boolean; + function BelongsToCurrentThread: Boolean; + function BelongsToThread(threadId: TCefThreadId): Boolean; + function PostTask(const task: ICefTask): Boolean; stdcall; + function PostDelayedTask(const task: ICefTask; delayMs: Int64): Boolean; + end; + + ICefThread = interface(ICefBase) + ['{26B30EA5-F44A-4C40-97DF-67FD9E73A4FF}'] + function GetTaskRunner : ICefTaskRunner; + function GetPlatformThreadID : TCefPlatformThreadId; + procedure Stop; + function IsRunning : boolean; + end; + + ICefWaitableEvent = interface(ICefBase) + ['{965C90C9-3DAE-457F-AA64-E04FF508094A}'] + procedure Reset; + procedure Signal; + function IsSignaled : boolean; + procedure Wait; + function TimedWait(max_ms: int64): boolean; + end; + + ICefv8Value = interface(ICefBase) + ['{52319B8D-75A8-422C-BD4B-16FA08CC7F42}'] + function IsValid: Boolean; + function IsUndefined: Boolean; + function IsNull: Boolean; + function IsBool: Boolean; + function IsInt: Boolean; + function IsUInt: Boolean; + function IsDouble: Boolean; + function IsDate: Boolean; + function IsString: Boolean; + function IsObject: Boolean; + function IsArray: Boolean; + function IsFunction: Boolean; + function IsSame(const that: ICefv8Value): Boolean; + function GetBoolValue: Boolean; + function GetIntValue: Integer; + function GetUIntValue: Cardinal; + function GetDoubleValue: Double; + function GetDateValue: TDateTime; + function GetStringValue: ustring; + function IsUserCreated: Boolean; + function HasException: Boolean; + function GetException: ICefV8Exception; + function ClearException: Boolean; + function WillRethrowExceptions: Boolean; + function SetRethrowExceptions(rethrow: Boolean): Boolean; + function HasValueByKey(const key: ustring): Boolean; + function HasValueByIndex(index: Integer): Boolean; + function DeleteValueByKey(const key: ustring): Boolean; + function DeleteValueByIndex(index: Integer): Boolean; + function GetValueByKey(const key: ustring): ICefv8Value; + function GetValueByIndex(index: Integer): ICefv8Value; + function SetValueByKey(const key: ustring; const value: ICefv8Value; + attribute: TCefV8PropertyAttributes): Boolean; + function SetValueByIndex(index: Integer; const value: ICefv8Value): Boolean; + function SetValueByAccessor(const key: ustring; settings: TCefV8AccessControls; + attribute: TCefV8PropertyAttributes): Boolean; + function GetKeys(const keys: TStrings): Integer; + function SetUserData(const data: ICefv8Value): Boolean; + function GetUserData: ICefv8Value; + function GetExternallyAllocatedMemory: Integer; + function AdjustExternallyAllocatedMemory(changeInBytes: Integer): Integer; + function GetArrayLength: Integer; + function GetFunctionName: ustring; + function GetFunctionHandler: ICefv8Handler; + function ExecuteFunction(const obj: ICefv8Value; + const arguments: TCefv8ValueArray): ICefv8Value; + function ExecuteFunctionWithContext(const context: ICefv8Context; + const obj: ICefv8Value; const arguments: TCefv8ValueArray): ICefv8Value; + end; + + ICefV8StackFrame = interface(ICefBase) + ['{BA1FFBF4-E9F2-4842-A827-DC220F324286}'] + function IsValid: Boolean; + function GetScriptName: ustring; + function GetScriptNameOrSourceUrl: ustring; + function GetFunctionName: ustring; + function GetLineNumber: Integer; + function GetColumn: Integer; + function IsEval: Boolean; + function IsConstructor: Boolean; + + property ScriptName: ustring read GetScriptName; + property ScriptNameOrSourceUrl: ustring read GetScriptNameOrSourceUrl; + property FunctionName: ustring read GetFunctionName; + property LineNumber: Integer read GetLineNumber; + property Column: Integer read GetColumn; + end; + + ICefV8StackTrace = interface(ICefBase) + ['{32111C84-B7F7-4E3A-92B9-7CA1D0ADB613}'] + function IsValid: Boolean; + function GetFrameCount: Integer; + function GetFrame(index: Integer): ICefV8StackFrame; + property FrameCount: Integer read GetFrameCount; + property Frame[index: Integer]: ICefV8StackFrame read GetFrame; + end; + + ICefXmlReader = interface(ICefBase) + ['{0DE686C3-A8D7-45D2-82FD-92F7F4E62A90}'] + function MoveToNextNode: Boolean; + function Close: Boolean; + function HasError: Boolean; + function GetError: ustring; + function GetType: TCefXmlNodeType; + function GetDepth: Integer; + function GetLocalName: ustring; + function GetPrefix: ustring; + function GetQualifiedName: ustring; + function GetNamespaceUri: ustring; + function GetBaseUri: ustring; + function GetXmlLang: ustring; + function IsEmptyElement: Boolean; + function HasValue: Boolean; + function GetValue: ustring; + function HasAttributes: Boolean; + function GetAttributeCount: NativeUInt; + function GetAttributeByIndex(index: Integer): ustring; + function GetAttributeByQName(const qualifiedName: ustring): ustring; + function GetAttributeByLName(const localName, namespaceURI: ustring): ustring; + function GetInnerXml: ustring; + function GetOuterXml: ustring; + function GetLineNumber: Integer; + function MoveToAttributeByIndex(index: Integer): Boolean; + function MoveToAttributeByQName(const qualifiedName: ustring): Boolean; + function MoveToAttributeByLName(const localName, namespaceURI: ustring): Boolean; + function MoveToFirstAttribute: Boolean; + function MoveToNextAttribute: Boolean; + function MoveToCarryingElement: Boolean; + end; + + ICefZipReader = interface(ICefBase) + ['{3B6C591F-9877-42B3-8892-AA7B27DA34A8}'] + function MoveToFirstFile: Boolean; + function MoveToNextFile: Boolean; + function MoveToFile(const fileName: ustring; caseSensitive: Boolean): Boolean; + function Close: Boolean; + function GetFileName: ustring; + function GetFileSize: Int64; + function GetFileLastModified: TCefTime; + function OpenFile(const password: ustring): Boolean; + function CloseFile: Boolean; + function ReadFile(buffer: Pointer; bufferSize: NativeUInt): Integer; + function Tell: Int64; + function Eof: Boolean; + end; + + ICefDomNode = interface(ICefBase) + ['{96C03C9E-9C98-491A-8DAD-1947332232D6}'] + function GetType: TCefDomNodeType; + function IsText: Boolean; + function IsElement: Boolean; + function IsEditable: Boolean; + function IsFormControlElement: Boolean; + function GetFormControlElementType: ustring; + function IsSame(const that: ICefDomNode): Boolean; + function GetName: ustring; + function GetValue: ustring; + function SetValue(const value: ustring): Boolean; + function GetAsMarkup: ustring; + function GetDocument: ICefDomDocument; + function GetParent: ICefDomNode; + function GetPreviousSibling: ICefDomNode; + function GetNextSibling: ICefDomNode; + function HasChildren: Boolean; + function GetFirstChild: ICefDomNode; + function GetLastChild: ICefDomNode; + function GetElementTagName: ustring; + function HasElementAttributes: Boolean; + function HasElementAttribute(const attrName: ustring): Boolean; + function GetElementAttribute(const attrName: ustring): ustring; + procedure GetElementAttributes(const attrMap: ICefStringMap); + function SetElementAttribute(const attrName, value: ustring): Boolean; + function GetElementInnerText: ustring; + function GetElementBounds: TCefRect; + + property NodeType: TCefDomNodeType read GetType; + property Name: ustring read GetName; + property AsMarkup: ustring read GetAsMarkup; + property Document: ICefDomDocument read GetDocument; + property Parent: ICefDomNode read GetParent; + property PreviousSibling: ICefDomNode read GetPreviousSibling; + property NextSibling: ICefDomNode read GetNextSibling; + property FirstChild: ICefDomNode read GetFirstChild; + property LastChild: ICefDomNode read GetLastChild; + property ElementTagName: ustring read GetElementTagName; + property ElementInnerText: ustring read GetElementInnerText; + property ElementBounds: TCefRect read GetElementBounds; + end; + + ICefDomDocument = interface(ICefBase) + ['{08E74052-45AF-4F69-A578-98A5C3959426}'] + function GetType: TCefDomDocumentType; + function GetDocument: ICefDomNode; + function GetBody: ICefDomNode; + function GetHead: ICefDomNode; + function GetTitle: ustring; + function GetElementById(const id: ustring): ICefDomNode; + function GetFocusedNode: ICefDomNode; + function HasSelection: Boolean; + function GetSelectionStartOffset: Integer; + function GetSelectionEndOffset: Integer; + function GetSelectionAsMarkup: ustring; + function GetSelectionAsText: ustring; + function GetBaseUrl: ustring; + function GetCompleteUrl(const partialURL: ustring): ustring; + property DocType: TCefDomDocumentType read GetType; + property Document: ICefDomNode read GetDocument; + property Body: ICefDomNode read GetBody; + property Head: ICefDomNode read GetHead; + property Title: ustring read GetTitle; + property FocusedNode: ICefDomNode read GetFocusedNode; + property SelectionStartOffset: Integer read GetSelectionStartOffset; + property SelectionEndOffset: Integer read GetSelectionEndOffset; + property SelectionAsMarkup: ustring read GetSelectionAsMarkup; + property SelectionAsText: ustring read GetSelectionAsText; + property BaseUrl: ustring read GetBaseUrl; + end; + + ICefDomVisitor = interface(ICefBase) + ['{30398428-3196-4531-B968-2DDBED36F6B0}'] + procedure visit(const document: ICefDomDocument); + end; + + ICefCookieVisitor = interface(ICefBase) + ['{8378CF1B-84AB-4FDB-9B86-34DDABCCC402}'] + function visit(const name, value, domain, path: ustring; secure, httponly, + hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; + count, total: Integer; out deleteCookie: Boolean): Boolean; + end; + + ICefResourceBundleHandler = interface(ICefBase) + ['{09C264FD-7E03-41E3-87B3-4234E82B5EA2}'] + function GetLocalizedString(stringId: Integer; out stringVal: ustring): Boolean; + function GetDataResource(resourceId: Integer; out data: Pointer; out dataSize: NativeUInt): Boolean; + end; + + ICefCommandLine = interface(ICefBase) + ['{6B43D21B-0F2C-4B94-B4E6-4AF0D7669D8E}'] + function IsValid: Boolean; + function IsReadOnly: Boolean; + function Copy: ICefCommandLine; + procedure InitFromArgv(argc: Integer; const argv: PPAnsiChar); + procedure InitFromString(const commandLine: ustring); + procedure Reset; + function GetCommandLineString: ustring; + procedure GetArgv(args: TStrings); + function GetProgram: ustring; + procedure SetProgram(const prog: ustring); + function HasSwitches: Boolean; + function HasSwitch(const name: ustring): Boolean; + function GetSwitchValue(const name: ustring): ustring; + procedure GetSwitches(switches: TStrings); + procedure AppendSwitch(const name: ustring); + procedure AppendSwitchWithValue(const name, value: ustring); + function HasArguments: Boolean; + procedure GetArguments(arguments: TStrings); + procedure AppendArgument(const argument: ustring); + procedure PrependWrapper(const wrapper: ustring); + property CommandLineString: ustring read GetCommandLineString; + end; + + ICefBrowserProcessHandler = interface(ICefBase) + ['{27291B7A-C0AE-4EE0-9115-15C810E22F6C}'] + procedure OnContextInitialized; + procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); + procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); + procedure OnScheduleMessagePumpWork(delayMs: Int64); + end; + + ICefSchemeRegistrar = interface(ICefBase) + ['{1832FF6E-100B-4E8B-B996-AD633168BEE7}'] + function AddCustomScheme(const schemeName: ustring; IsStandard, IsLocal, + IsDisplayIsolated: Boolean): Boolean; stdcall; + end; + + ICefRenderProcessHandler = interface(IcefBase) + ['{FADEE3BC-BF66-430A-BA5D-1EE3782ECC58}'] + procedure OnRenderThreadCreated(const extraInfo: ICefListValue) ; + procedure OnWebKitInitialized; + procedure OnBrowserCreated(const browser: ICefBrowser); + procedure OnBrowserDestroyed(const browser: ICefBrowser); + procedure OnContextCreated(const browser: ICefBrowser; + const frame: ICefFrame; const context: ICefv8Context); + procedure OnContextReleased(const browser: ICefBrowser; + const frame: ICefFrame; const context: ICefv8Context); + procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; + const context: ICefv8Context; const exception: ICefV8Exception; + const stackTrace: ICefV8StackTrace); + procedure OnFocusedNodeChanged(const browser: ICefBrowser; + const frame: ICefFrame; const node: ICefDomNode); + function OnProcessMessageReceived(const browser: ICefBrowser; + sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; + end; + + ICefApp = interface(ICefBase) + ['{970CA670-9070-4642-B188-7D8A22DAEED4}'] + procedure OnBeforeCommandLineProcessing(const processType: ustring; + const commandLine: ICefCommandLine); + procedure OnRegisterCustomSchemes(const registrar: ICefSchemeRegistrar); + function GetResourceBundleHandler: ICefResourceBundleHandler; + function GetBrowserProcessHandler: ICefBrowserProcessHandler; + function GetRenderProcessHandler: ICefRenderProcessHandler; + end; + + TCefCookieVisitorProc = reference to function( + const name, value, domain, path: ustring; secure, httponly, + hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; + count, total: Integer; out deleteCookie: Boolean): Boolean; + + ICefCompletionCallback = interface(ICefBase) + ['{A8ECCFBB-FEE0-446F-AB32-AD69A7478D57}'] + procedure OnComplete; + end; + + ICefSetCookieCallback = interface(ICefBase) + ['{16E14B6F-CB0A-4F9D-A008-239E0BC7B892}'] + procedure OnComplete(success: Boolean); + end; + + ICefDeleteCookiesCallback = interface(ICefBase) + ['{758B79A1-B9E8-4F0D-94A0-DCE5AFADE33D}'] + procedure OnComplete(numDeleted: Integer); + end; + + ICefCookieManager = Interface(ICefBase) + ['{CC1749E6-9AD3-4283-8430-AF6CBF3E8785}'] + procedure SetSupportedSchemes(schemes: TStrings; const callback: ICefCompletionCallback); + procedure SetSupportedSchemesProc(schemes: TStrings; const callback: TCefCompletionCallbackProc); + function VisitAllCookies(const visitor: ICefCookieVisitor): Boolean; + function VisitAllCookiesProc(const visitor: TCefCookieVisitorProc): Boolean; + function VisitUrlCookies(const url: ustring; + includeHttpOnly: Boolean; const visitor: ICefCookieVisitor): Boolean; + function VisitUrlCookiesProc(const url: ustring; + includeHttpOnly: Boolean; const visitor: TCefCookieVisitorProc): Boolean; + function SetCookie(const url: ustring; const name, value, domain, path: ustring; secure, httponly, + hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; + const callback: ICefSetCookieCallback): Boolean; + function SetCookieProc(const url: ustring; const name, value, domain, path: ustring; secure, httponly, + hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; + const callback: TCefSetCookieCallbackProc): Boolean; + function DeleteCookies(const url, cookieName: ustring; const callback: ICefDeleteCookiesCallback): Boolean; + function DeleteCookiesProc(const url, cookieName: ustring; const callback: TCefDeleteCookiesCallbackProc): Boolean; + function SetStoragePath(const path: ustring; persistSessionCookies: Boolean; const callback: ICefCompletionCallback): Boolean; + function SetStoragePathProc(const path: ustring; persistSessionCookies: Boolean; const callback: TCefCompletionCallbackProc): Boolean; + function FlushStore(const handler: ICefCompletionCallback): Boolean; + function FlushStoreProc(const proc: TCefCompletionCallbackProc): Boolean; + end; + + ICefWebPluginInfo = interface(ICefBase) + ['{AA879E58-F649-44B1-AF9C-655FF5B79A02}'] + function GetName: ustring; + function GetPath: ustring; + function GetVersion: ustring; + function GetDescription: ustring; + + property Name: ustring read GetName; + property Path: ustring read GetPath; + property Version: ustring read GetVersion; + property Description: ustring read GetDescription; + end; + + ICefCallback = interface(ICefBase) + ['{1B8C449F-E2D6-4B78-9BBA-6F47E8BCDF37}'] + procedure Cont; + procedure Cancel; + end; + + ICefResourceHandler = interface(ICefBase) + ['{BD3EA208-AAAD-488C-BFF2-76993022F2B5}'] + function ProcessRequest(const request: ICefRequest; const callback: ICefCallback): Boolean; + procedure GetResponseHeaders(const response: ICefResponse; + out responseLength: Int64; out redirectUrl: ustring); + function ReadResponse(const dataOut: Pointer; bytesToRead: Integer; + var bytesRead: Integer; const callback: ICefCallback): Boolean; + function CanGetCookie(const cookie: PCefCookie): Boolean; + function CanSetCookie(const cookie: PCefCookie): Boolean; + procedure Cancel; + end; + + ICefSchemeHandlerFactory = interface(ICefBase) + ['{4D9B7960-B73B-4EBD-9ABE-6C1C43C245EB}'] + function New(const browser: ICefBrowser; const frame: ICefFrame; + const schemeName: ustring; const request: ICefRequest): ICefResourceHandler; + end; + + ICefAuthCallback = interface(ICefBase) + ['{500C2023-BF4D-4FF7-9C04-165E5C389131}'] + procedure Cont(const username, password: ustring); + procedure Cancel; + end; + + ICefJsDialogCallback = interface(ICefBase) + ['{187B2156-9947-4108-87AB-32E559E1B026}'] + procedure Cont(success: Boolean; const userInput: ustring); + end; + + ICefContextMenuParams = interface(ICefBase) + ['{E31BFA9E-D4E2-49B7-A05D-20018C8794EB}'] + function GetXCoord: Integer; + function GetYCoord: Integer; + function GetTypeFlags: TCefContextMenuTypeFlags; + function GetLinkUrl: ustring; + function GetUnfilteredLinkUrl: ustring; + function GetSourceUrl: ustring; + function HasImageContents: Boolean; + function GetTitleText: ustring; + function GetPageUrl: ustring; + function GetFrameUrl: ustring; + function GetFrameCharset: ustring; + function GetMediaType: TCefContextMenuMediaType; + function GetMediaStateFlags: TCefContextMenuMediaStateFlags; + function GetSelectionText: ustring; + function GetMisspelledWord: ustring; + function GetDictionarySuggestions(const suggestions: TStringList): Boolean; + function IsEditable: Boolean; + function IsSpellCheckEnabled: Boolean; + function GetEditStateFlags: TCefContextMenuEditStateFlags; + function IsCustomMenu: Boolean; + function IsPepperMenu: Boolean; + + property XCoord: Integer read GetXCoord; + property YCoord: Integer read GetYCoord; + property TypeFlags: TCefContextMenuTypeFlags read GetTypeFlags; + property LinkUrl: ustring read GetLinkUrl; + property UnfilteredLinkUrl: ustring read GetUnfilteredLinkUrl; + property SourceUrl: ustring read GetSourceUrl; + property TitleText: ustring read GetTitleText; + property PageUrl: ustring read GetPageUrl; + property FrameUrl: ustring read GetFrameUrl; + property FrameCharset: ustring read GetFrameCharset; + property MediaType: TCefContextMenuMediaType read GetMediaType; + property MediaStateFlags: TCefContextMenuMediaStateFlags read GetMediaStateFlags; + property SelectionText: ustring read GetSelectionText; + property EditStateFlags: TCefContextMenuEditStateFlags read GetEditStateFlags; + end; + + ICefMenuModel = interface(ICefBase) + ['{40AF19D3-8B4E-44B8-8F89-DEB5907FC495}'] + function Clear: Boolean; + function GetCount: Integer; + function AddSeparator: Boolean; + function AddItem(commandId: Integer; const text: ustring): Boolean; + function AddCheckItem(commandId: Integer; const text: ustring): Boolean; + function AddRadioItem(commandId: Integer; const text: ustring; groupId: Integer): Boolean; + function AddSubMenu(commandId: Integer; const text: ustring): ICefMenuModel; + function InsertSeparatorAt(index: Integer): Boolean; + function InsertItemAt(index, commandId: Integer; const text: ustring): Boolean; + function InsertCheckItemAt(index, commandId: Integer; const text: ustring): Boolean; + function InsertRadioItemAt(index, commandId: Integer; const text: ustring; groupId: Integer): Boolean; + function InsertSubMenuAt(index, commandId: Integer; const text: ustring): ICefMenuModel; + function Remove(commandId: Integer): Boolean; + function RemoveAt(index: Integer): Boolean; + function GetIndexOf(commandId: Integer): Integer; + function GetCommandIdAt(index: Integer): Integer; + function SetCommandIdAt(index, commandId: Integer): Boolean; + function GetLabel(commandId: Integer): ustring; + function GetLabelAt(index: Integer): ustring; + function SetLabel(commandId: Integer; const text: ustring): Boolean; + function SetLabelAt(index: Integer; const text: ustring): Boolean; + function GetType(commandId: Integer): TCefMenuItemType; + function GetTypeAt(index: Integer): TCefMenuItemType; + function GetGroupId(commandId: Integer): Integer; + function GetGroupIdAt(index: Integer): Integer; + function SetGroupId(commandId, groupId: Integer): Boolean; + function SetGroupIdAt(index, groupId: Integer): Boolean; + function GetSubMenu(commandId: Integer): ICefMenuModel; + function GetSubMenuAt(index: Integer): ICefMenuModel; + function IsVisible(commandId: Integer): Boolean; + function isVisibleAt(index: Integer): Boolean; + function SetVisible(commandId: Integer; visible: Boolean): Boolean; + function SetVisibleAt(index: Integer; visible: Boolean): Boolean; + function IsEnabled(commandId: Integer): Boolean; + function IsEnabledAt(index: Integer): Boolean; + function SetEnabled(commandId: Integer; enabled: Boolean): Boolean; + function SetEnabledAt(index: Integer; enabled: Boolean): Boolean; + function IsChecked(commandId: Integer): Boolean; + function IsCheckedAt(index: Integer): Boolean; + function setChecked(commandId: Integer; checked: Boolean): Boolean; + function setCheckedAt(index: Integer; checked: Boolean): Boolean; + function HasAccelerator(commandId: Integer): Boolean; + function HasAcceleratorAt(index: Integer): Boolean; + function SetAccelerator(commandId, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; + function SetAcceleratorAt(index, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; + function RemoveAccelerator(commandId: Integer): Boolean; + function RemoveAcceleratorAt(index: Integer): Boolean; + function GetAccelerator(commandId: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; + function GetAcceleratorAt(index: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; + end; + + ICefValue = interface(ICefBase) + ['{66F9F439-B12B-4EC3-A945-91AE4EF4D4BA}'] + function IsValid: Boolean; + function IsOwned: Boolean; + function IsReadOnly: Boolean; + function IsSame(const that: ICefValue): Boolean; + function IsEqual(const that: ICefValue): Boolean; + + function Copy: ICefValue; + + function GetType: TCefValueType; + function GetBool: Boolean; + function GetInt: Integer; + function GetDouble: Double; + function GetString: ustring; + function GetBinary: ICefBinaryValue; + function GetDictionary: ICefDictionaryValue; + function GetList: ICefListValue; + + function SetNull: Boolean; + function SetBool(value: Integer): Boolean; + function SetInt(value: Integer): Boolean; + function SetDouble(value: Double): Boolean; + function SetString(const value: ustring): Boolean; + function SetBinary(const value: ICefBinaryValue): Boolean; + function SetDictionary(const value: ICefDictionaryValue): Boolean; + function SetList(const value: ICefListValue): Boolean; + end; + + ICefBinaryValue = interface(ICefBase) + ['{974AA40A-9C5C-4726-81F0-9F0D46D7C5B3}'] + function IsValid: Boolean; + function IsOwned: Boolean; + function IsSame(const that: ICefBinaryValue): Boolean; + function IsEqual(const that: ICefBinaryValue): Boolean; + function Copy: ICefBinaryValue; + function GetSize: NativeUInt; + function GetData(buffer: Pointer; bufferSize, dataOffset: NativeUInt): NativeUInt; + end; + + ICefDictionaryValue = interface(ICefBase) + ['{B9638559-54DC-498C-8185-233EEF12BC69}'] + function IsValid: Boolean; + function isOwned: Boolean; + function IsReadOnly: Boolean; + function IsSame(const that: ICefDictionaryValue): Boolean; + function IsEqual(const that: ICefDictionaryValue): Boolean; + function Copy(excludeEmptyChildren: Boolean): ICefDictionaryValue; + function GetSize: NativeUInt; + function Clear: Boolean; + function HasKey(const key: ustring): Boolean; + function GetKeys(const keys: TStrings): Boolean; + function Remove(const key: ustring): Boolean; + function GetType(const key: ustring): TCefValueType; + function GetValue(const key: ustring): ICefValue; + function GetBool(const key: ustring): Boolean; + function GetInt(const key: ustring): Integer; + function GetDouble(const key: ustring): Double; + function GetString(const key: ustring): ustring; + function GetBinary(const key: ustring): ICefBinaryValue; + function GetDictionary(const key: ustring): ICefDictionaryValue; + function GetList(const key: ustring): ICefListValue; + function SetValue(const key: ustring; const value: ICefValue): Boolean; + function SetNull(const key: ustring): Boolean; + function SetBool(const key: ustring; value: Boolean): Boolean; + function SetInt(const key: ustring; value: Integer): Boolean; + function SetDouble(const key: ustring; value: Double): Boolean; + function SetString(const key, value: ustring): Boolean; + function SetBinary(const key: ustring; const value: ICefBinaryValue): Boolean; + function SetDictionary(const key: ustring; const value: ICefDictionaryValue): Boolean; + function SetList(const key: ustring; const value: ICefListValue): Boolean; + end; + + + ICefListValue = interface(ICefBase) + ['{09174B9D-0CC6-4360-BBB0-3CC0117F70F6}'] + function IsValid: Boolean; + function IsOwned: Boolean; + function IsReadOnly: Boolean; + function IsSame(const that: ICefListValue): Boolean; + function IsEqual(const that: ICefListValue): Boolean; + function Copy: ICefListValue; + function SetSize(size: NativeUInt): Boolean; + function GetSize: NativeUInt; + function Clear: Boolean; + function Remove(index: NativeUInt): Boolean; + function GetType(index: NativeUInt): TCefValueType; + function GetValue(index: NativeUInt): ICefValue; + function GetBool(index: NativeUInt): Boolean; + function GetInt(index: NativeUInt): Integer; + function GetDouble(index: NativeUInt): Double; + function GetString(index: NativeUInt): ustring; + function GetBinary(index: NativeUInt): ICefBinaryValue; + function GetDictionary(index: NativeUInt): ICefDictionaryValue; + function GetList(index: NativeUInt): ICefListValue; + function SetValue(index: NativeUInt; const value: ICefValue): Boolean; + function SetNull(index: NativeUInt): Boolean; + function SetBool(index: NativeUInt; value: Boolean): Boolean; + function SetInt(index: NativeUInt; value: Integer): Boolean; + function SetDouble(index: NativeUInt; value: Double): Boolean; + function SetString(index: NativeUInt; const value: ustring): Boolean; + function SetBinary(index: NativeUInt; const value: ICefBinaryValue): Boolean; + function SetDictionary(index: NativeUInt; const value: ICefDictionaryValue): Boolean; + function SetList(index: NativeUInt; const value: ICefListValue): Boolean; + end; + + + ICefLifeSpanHandler = interface(ICefBase) + ['{0A3EB782-A319-4C35-9B46-09B2834D7169}'] + function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; + const targetUrl, targetFrameName: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; + var popupFeatures: TCefPopupFeatures; + var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; + var noJavascriptAccess: Boolean): Boolean; + procedure OnAfterCreated(const browser: ICefBrowser); + procedure OnBeforeClose(const browser: ICefBrowser); + function DoClose(const browser: ICefBrowser): Boolean; + end; + + ICefLoadHandler = interface(ICefBase) + ['{2C63FB82-345D-4A5B-9858-5AE7A85C9F49}'] + procedure OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); + procedure OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); + procedure OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); + procedure OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; + const errorText, failedUrl: ustring); + end; + + ICefRequestCallback = interface(ICefBase) + ['{A35B8FD5-226B-41A8-A763-1940787D321C}'] + procedure Cont(allow: Boolean); + procedure Cancel; + end; + + ICefResponseFilter = interface(ICefBase) + ['{5013BC3C-F1AE-407A-A571-A4C6B1D6831E}'] + function InitFilter: Boolean; + function Filter(dataIn: Pointer; dataInSize, dataInRead: NativeUInt; + dataOut: Pointer; dataOutSize, dataOutWritten: NativeUInt): TCefResponseFilterStatus; + end; + + ICefRequestHandler = interface(ICefBase) + ['{050877A9-D1F8-4EB3-B58E-50DC3E3D39FD}'] + function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; isRedirect: Boolean): Boolean; + function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; + function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; + function GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; + procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); + function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; + function GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; + procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); + function GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; + function OnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; + procedure OnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); + function OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; + function OnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; + procedure OnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); + procedure OnRenderViewReady(const browser: ICefBrowser); + procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); + end; + + ICefDisplayHandler = interface(ICefBase) + ['{1EC7C76D-6969-41D1-B26D-079BCFF054C4}'] + procedure OnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); + procedure OnTitleChange(const browser: ICefBrowser; const title: ustring); + procedure OnFaviconUrlChange(const browser: ICefBrowser; icon_urls: TStrings); + procedure OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); + function OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; + procedure OnStatusMessage(const browser: ICefBrowser; const value: ustring); + function OnConsoleMessage(const browser: ICefBrowser; const message, source: ustring; line: Integer): Boolean; + end; + + ICefFocusHandler = interface(ICefBase) + ['{BB7FA3FA-7B1A-4ADC-8E50-12A24018DD90}'] + procedure OnTakeFocus(const browser: ICefBrowser; next: Boolean); + function OnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; + procedure OnGotFocus(const browser: ICefBrowser); + end; + + ICefKeyboardHandler = interface(ICefBase) + ['{0512F4EC-ED88-44C9-90D3-5C6D03D3B146}'] + function OnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; + osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; + function OnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; + osEvent: TCefEventHandle): Boolean; + end; + + ICefJsDialogHandler = interface(ICefBase) + ['{64E18F86-DAC5-4ED1-8589-44DE45B9DB56}'] + function OnJsdialog(const browser: ICefBrowser; const originUrl: ustring; + dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; + const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; + function OnBeforeUnloadDialog(const browser: ICefBrowser; + const messageText: ustring; isReload: Boolean; + const callback: ICefJsDialogCallback): Boolean; + procedure OnResetDialogState(const browser: ICefBrowser); + procedure OnDialogClosed(const browser: ICefBrowser); + end; + + ICefRunContextMenuCallback = interface(ICefBase) + ['{44C3C6E3-B64D-4F6E-A318-4A0F3A72EB00}'] + procedure Cont(commandId: Integer; eventFlags: TCefEventFlags); + procedure Cancel; + end; + ICefContextMenuHandler = interface(ICefBase) + ['{C2951895-4087-49D5-BA18-4D9BA4F5EDD7}'] + procedure OnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; + const params: ICefContextMenuParams; const model: ICefMenuModel); + function RunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; + const params: ICefContextMenuParams; const model: ICefMenuModel; + const callback: ICefRunContextMenuCallback): Boolean; + function OnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; + const params: ICefContextMenuParams; commandId: Integer; + eventFlags: TCefEventFlags): Boolean; + procedure OnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); + end; + + ICefDialogHandler = interface(ICefBase) + ['{7763F4B2-8BE1-4E80-AC43-8B825850DC67}'] + function OnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; + const title, defaultFilePath: ustring; acceptFilters: TStrings; + selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; + end; + + ICefGeolocationCallback = interface(ICefBase) + ['{272B8E4F-4AE4-4F14-BC4E-5924FA0C149D}'] + procedure Cont(allow: Boolean); + end; + + ICefGeolocationHandler = interface(ICefBase) + ['{1178EE62-BAE7-4E44-932B-EAAC7A18191C}'] + function OnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; + procedure OnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); + end; + + ICefRenderHandler = interface(ICefBase) + ['{1FC1C22B-085A-4741-9366-5249B88EC410}'] + function GetRootScreenRect(const browser: ICefBrowser; rect: PCefRect): Boolean; + function GetViewRect(const browser: ICefBrowser; rect: PCefRect): Boolean; + function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; screenX, screenY: PInteger): Boolean; + function GetScreenInfo(const browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean; + procedure OnPopupShow(const browser: ICefBrowser; show: Boolean); + procedure OnPopupSize(const browser: ICefBrowser; const rect: PCefRect); + procedure OnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); + procedure OnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); + function OnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; + procedure OnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); + procedure OnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); + procedure OnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); + end; + + ICefClient = interface(ICefBase) + ['{1D502075-2FF0-4E13-A112-9E541CD811F4}'] + function GetContextMenuHandler: ICefContextMenuHandler; + function GetDisplayHandler: ICefDisplayHandler; + function GetDownloadHandler: ICefDownloadHandler; + function GetFocusHandler: ICefFocusHandler; + function GetGeolocationHandler: ICefGeolocationHandler; + function GetJsdialogHandler: ICefJsdialogHandler; + function GetKeyboardHandler: ICefKeyboardHandler; + function GetLifeSpanHandler: ICefLifeSpanHandler; + function GetLoadHandler: ICefLoadHandler; + function GetRenderHandler: ICefRenderHandler; + function GetRequestHandler: ICefRequestHandler; + function OnProcessMessageReceived(const browser: ICefBrowser; + sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; + end; + + ICefUrlRequest = interface(ICefBase) + ['{59226AC1-A0FA-4D59-9DF4-A65C42391A67}'] + function GetRequest: ICefRequest; + function GetRequestStatus: TCefUrlRequestStatus; + function GetRequestError: Integer; + function GetResponse: ICefResponse; + procedure Cancel; + end; + + ICefUrlrequestClient = interface(ICefBase) + ['{114155BD-C248-4651-9A4F-26F3F9A4F737}'] + procedure OnRequestComplete(const request: ICefUrlRequest); + procedure OnUploadProgress(const request: ICefUrlRequest; current, total: Int64); + procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); + procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); + function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; + const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; + end; + + ICefWebPluginInfoVisitor = interface(ICefBase) + ['{7523D432-4424-4804-ACAD-E67D2313436E}'] + function Visit(const info: ICefWebPluginInfo; count, total: Integer): Boolean; + end; + + ICefWebPluginUnstableCallback = interface(ICefBase) + ['{67459829-EB47-4B7E-9D69-2EE77DF0E71E}'] + procedure IsUnstable(const path: ustring; unstable: Boolean); + end; + + ICefRegisterCDMCallback = interface(ICefBase) + ['{6C39AB3B-F724-483F-ABA0-37F6E0AECF35}'] + procedure OnCDMRegistrationComplete(result: TCefCDMRegistrationError; const error_message: ustring); + end; + + ICefEndTracingCallback = interface(ICefBase) + ['{79020EBE-9D1D-49A6-9714-8778FE8929F2}'] + procedure OnEndTracingComplete(const tracingFile: ustring); + end; + + ICefGetGeolocationCallback = interface(ICefBase) + ['{ACB82FD9-3FFD-43F9-BF1A-A4849BF5B814}'] + procedure OnLocationUpdate(const position: PCefGeoposition); + end; + + ICefFileDialogCallback = interface(ICefBase) + ['{1AF659AB-4522-4E39-9C52-184000D8E3C7}'] + procedure Cont(selectedAcceptFilter: Integer; filePaths: TStrings); + procedure Cancel; + end; + + ICefDragData = interface(ICefBase) + ['{FBB6A487-F633-4055-AB3E-6619EDE75683}'] + function Clone: ICefDragData; + function IsReadOnly: Boolean; + function IsLink: Boolean; + function IsFragment: Boolean; + function IsFile: Boolean; + function GetLinkUrl: ustring; + function GetLinkTitle: ustring; + function GetLinkMetadata: ustring; + function GetFragmentText: ustring; + function GetFragmentHtml: ustring; + function GetFragmentBaseUrl: ustring; + function GetFileName: ustring; + function GetFileContents(const writer: ICefStreamWriter): NativeUInt; + function GetFileNames(names: TStrings): Integer; + procedure SetLinkUrl(const url: ustring); + procedure SetLinkTitle(const title: ustring); + procedure SetLinkMetadata(const data: ustring); + procedure SetFragmentText(const text: ustring); + procedure SetFragmentHtml(const html: ustring); + procedure SetFragmentBaseUrl(const baseUrl: ustring); + procedure ResetFileContents; + procedure AddFile(const path, displayName: ustring); + end; + + ICefDragHandler = interface(ICefBase) + ['{59A89579-5B18-489F-A25C-5CC25FF831FC}'] + function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; + mask: TCefDragOperations): Boolean; + procedure OnDraggableRegionsChanged(const browser: ICefBrowser; + regionsCount: NativeUInt; regions: PCefDraggableRegionArray); + end; + + ICefFindHandler = interface(ICefBase) + ['{F20DF234-BD43-42B3-A80B-D354A9E5B787}'] + procedure OnFindResult(const browser: ICefBrowser; + identifier, count: Integer; const selectionRect: PCefRect; + activeMatchOrdinal: Integer; finalUpdate: Boolean); + end; + + ICefRequestContextHandler = interface(ICefBase) + ['{76EB1FA7-78DF-4FD5-ABB3-1CDD3E73A140}'] + function GetCookieManager: ICefCookieManager; + function OnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; + const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; + end; + + ICefResolveCallback = interface(ICefBase) + ['{0C0EA252-7968-4163-A1BE-A1453576DD06}'] + procedure OnResolveCompleted(result: TCefErrorCode; resolvedIps: TStrings); + end; + + ICefRequestContext = interface(ICefBase) + ['{5830847A-2971-4BD5-ABE6-21451F8923F7}'] + function IsSame(const other: ICefRequestContext): Boolean; + function IsSharingWith(const other: ICefRequestContext): Boolean; + function IsGlobal: Boolean; + function GetHandler: ICefRequestContextHandler; + function GetCachePath: ustring; + function GetDefaultCookieManager(const callback: ICefCompletionCallback): ICefCookieManager; + function GetDefaultCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; + function RegisterSchemeHandlerFactory(const schemeName, domainName: ustring; + const factory: ICefSchemeHandlerFactory): Boolean; + function ClearSchemeHandlerFactories: Boolean; + procedure PurgePluginListCache(reloadPages: Boolean); + function HasPreference(const name: ustring): Boolean; + function GetPreference(const name: ustring): ICefValue; + function GetAllPreferences(includeDefaults: Boolean): ICefDictionaryValue; + function CanSetPreference(const name: ustring): Boolean; + function SetPreference(const name: ustring; const value: ICefValue; out error: ustring): Boolean; + procedure ClearCertificateExceptions(const callback: ICefCompletionCallback); + procedure CloseAllConnections(const callback: ICefCompletionCallback); + procedure ResolveHost(const origin: ustring; const callback: ICefResolveCallback); + function ResolveHostCached(const origin: ustring; resolvedIps: TStrings): TCefErrorCode; + end; + + ICefPrintSettings = Interface(ICefBase) + ['{ACBD2395-E9C1-49E5-B7F3-344DAA4A0F12}'] + function IsValid: Boolean; + function IsReadOnly: Boolean; + function Copy: ICefPrintSettings; + procedure SetOrientation(landscape: Boolean); + function IsLandscape: Boolean; + procedure SetPrinterPrintableArea( + const physicalSizeDeviceUnits: PCefSize; + const printableAreaDeviceUnits: PCefRect; + landscapeNeedsFlip: Boolean); stdcall; + procedure SetDeviceName(const name: ustring); + function GetDeviceName: ustring; + procedure SetDpi(dpi: Integer); + function GetDpi: Integer; + procedure SetPageRanges(const ranges: TCefRangeArray); + function GetPageRangesCount: NativeUInt; + procedure GetPageRanges(out ranges: TCefRangeArray); + procedure SetSelectionOnly(selectionOnly: Boolean); + function IsSelectionOnly: Boolean; + procedure SetCollate(collate: Boolean); + function WillCollate: Boolean; + procedure SetColorModel(model: TCefColorModel); + function GetColorModel: TCefColorModel; + procedure SetCopies(copies: Integer); + function GetCopies: Integer; + procedure SetDuplexMode(mode: TCefDuplexMode); + function GetDuplexMode: TCefDuplexMode; + + property Landscape: Boolean read IsLandscape write SetOrientation; + property DeviceName: ustring read GetDeviceName write SetDeviceName; + property Dpi: Integer read GetDpi write SetDpi; + property SelectionOnly: Boolean read IsSelectionOnly write SetSelectionOnly; + property Collate: Boolean read WillCollate write SetCollate; + property ColorModel: TCefColorModel read GetColorModel write SetColorModel; + property Copies: Integer read GetCopies write SetCopies; + property DuplexMode: TCefDuplexMode read GetDuplexMode write SetDuplexMode; + end; + + ICefNavigationEntry = interface(ICefBase) + ['{D17B4B37-AA45-42D9-B4E4-AAB6FE2AB297}'] + function IsValid: Boolean; + function GetUrl: ustring; + function GetDisplayUrl: ustring; + function GetOriginalUrl: ustring; + function GetTitle: ustring; + function GetTransitionType: TCefTransitionType; + function HasPostData: Boolean; + function GetCompletionTime: TDateTime; + function GetHttpStatusCode: Integer; + function GetSSLStatus: ICefSSLStatus; + + property Url: ustring read GetUrl; + property DisplayUrl: ustring read GetDisplayUrl; + property OriginalUrl: ustring read GetOriginalUrl; + property Title: ustring read GetTitle; + property TransitionType: TCefTransitionType read GetTransitionType; + property CompletionTime: TDateTime read GetCompletionTime; + property HttpStatusCode: Integer read GetHttpStatusCode; + property SSLStatus: ICefSSLStatus read GetSSLStatus; + end; + + ICefX509CertPrincipal = interface(ICefBase) + ['{CD3621ED-7D68-4A1F-95B5-190C7001B65F}'] + function GetDisplayName: ustring; + function GetCommonName: ustring; + function GetLocalityName: ustring; + function GetStateOrProvinceName: ustring; + function GetCountryName: ustring; + procedure GetStreetAddresses(addresses: TStrings); + procedure GetOrganizationNames(names: TStrings); + procedure GetOrganizationUnitNames(names: TStrings); + procedure GetDomainComponents(components: TStrings); + end; + + ICefX509Certificate = interface(ICefBase) + ['{C897979D-F068-4428-82DF-4221612FF7E0}'] + function GetSubject: ICefX509CertPrincipal; + function GetIssuer: ICefX509CertPrincipal; + function GetSerialNumber: ICefBinaryValue; + function GetValidStart: TCefTime; + function GetValidExpiry: TCefTime; + function GetDerEncoded: ICefBinaryValue; + function GetPemEncoded: ICefBinaryValue; + function GetIssuerChainSize: NativeUInt; + function GetDEREncodedIssuerChain(chainCount: NativeUInt): IInterfaceList; + function GetPEMEncodedIssuerChain(chainCount: NativeUInt): IInterfaceList; + end; + + ICefSslInfo = interface(ICefBase) + ['{67EC86BD-DE7D-453D-908F-AD15626C514F}'] + function GetCertStatus: TCefCertStatus; + function GetX509Certificate: ICefX509Certificate; + end; + + ICefSSLStatus = interface(ICefBase) + ['{E3F004F2-03D5-46A2-91D0-510C50F3B225}'] + function IsSecureConnection: boolean; + function GetCertStatus: TCefCertStatus; + function GetSSLVersion: TCefSSLVersion; + function GetContentStatus: TCefSSLContentStatus; + function GetX509Certificate: ICefX509Certificate; + end; + + ICefSelectClientCertificateCallback = interface(ICefBase) + ['{003E3D09-ADE8-4C6E-A174-079D3D616608}'] + procedure Select(const cert: ICefX509Certificate); + end; + + ICefResourceBundle = interface(ICefBase) + ['{3213CF97-C854-452B-B615-39192F8D07DC}'] + function GetLocalizedString(stringId: Integer): ustring; + function GetDataResource(resourceId: Integer; + out data: Pointer; out dataSize: NativeUInt): Boolean; + function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; + out data: Pointer; out dataSize: NativeUInt): Boolean; + end; + + ICefImage = interface(ICefBase) + ['{E2C2F424-26A2-4498-BB45-DA23219831BE}'] + function IsEmpty: Boolean; + function IsSame(const that: ICefImage): Boolean; + function AddBitmap(scaleFactor: Single; pixelWidth, pixelHeight: Integer; + colorType: TCefColorType; alphaType: TCefAlphaType; pixelData: Pointer; + pixelDataSize: NativeUInt): Boolean; + function AddPng(scaleFactor: Single; const pngData: Pointer; pngDataSize: NativeUInt): Boolean; + function AddJpeg(scaleFactor: Single; const jpegData: Pointer; jpegDataSize: NativeUInt): Boolean; + function GetWidth: NativeUInt; + function GetHeight: NativeUInt; + function HasRepresentation(scaleFactor: Single): Boolean; + function RemoveRepresentation(scaleFactor: Single): Boolean; + function GetRepresentationInfo(scaleFactor: Single; actualScaleFactor: PSingle; + pixelWidth, pixelHeight: PInteger): Boolean; + function GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; + alphaType: TCefAlphaType; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; + function GetAsPng(scaleFactor: Single; withTransparency: Boolean; + pixelWidth, pixelHeight: PInteger): ICefBinaryValue; + function GetAsJpeg(scaleFactor: Single; quality: Integer; + pixelWidth, pixelHeight: PInteger): ICefBinaryValue; + + property Width: NativeUInt read GetHeight; + property Height: NativeUInt read GetHeight; + end; + + ICefMenuModelDelegate = interface(ICefBase) + ['{1430D202-2795-433E-9A35-C79A0996F316}'] + procedure ExecuteCommand(const menuModel: ICefMenuModel; commandId: Integer; eventFlags: TCefEventFlags); + procedure MenuWillShow(const menuModel: ICefMenuModel); + procedure MenuClosed(const menuModel: ICefMenuModel); + function FormatLabel(const menuModel: ICefMenuModel; const label_ : ustring) : boolean; + end; + + IChromiumEvents = interface + ['{0C139DB1-0349-4D7F-8155-76FEA6A0126D}'] + procedure GetSettings(var settings: TCefBrowserSettings); + function doOnProcessMessageReceived(const browser: ICefBrowser; + sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; + + procedure doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); + procedure doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); + procedure doOnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); + procedure doOnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; + const errorText, failedUrl: ustring); + + procedure doOnTakeFocus(const browser: ICefBrowser; next: Boolean); + function doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; + procedure doOnGotFocus(const browser: ICefBrowser); + + procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; + const params: ICefContextMenuParams; const model: ICefMenuModel); + function doOnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; + const params: ICefContextMenuParams; commandId: Integer; + eventFlags: TCefEventFlags): Boolean; + procedure doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); + + function doOnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; + osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; + function doOnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; + osEvent: TCefEventHandle): Boolean; + + procedure doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); + procedure doOnTitleChange(const browser: ICefBrowser; const title: ustring); + procedure doOnFaviconUrlChange(const browser: ICefBrowser; iconUrls: TStrings); + procedure doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); + function doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; + procedure doOnStatusMessage(const browser: ICefBrowser; const value: ustring); + function doOnConsoleMessage(const browser: ICefBrowser; const message, source: ustring; line: Integer): Boolean; + + function doOnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; + procedure doOnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); + + procedure doOnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; + const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); + procedure doOnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; + const callback: ICefDownloadItemCallback); + + function doOnJsdialog(const browser: ICefBrowser; const originUrl: ustring; + dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; + const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; + function doOnBeforeUnloadDialog(const browser: ICefBrowser; + const messageText: ustring; isReload: Boolean; + const callback: ICefJsDialogCallback): Boolean; + procedure doOnResetDialogState(const browser: ICefBrowser); + procedure doOnDialogClosed(const browser: ICefBrowser); + + function doOnBeforePopup(const browser: ICefBrowser; + const frame: ICefFrame; const targetUrl, targetFrameName: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; + var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; + var client: ICefClient; var settings: TCefBrowserSettings; + var noJavascriptAccess: Boolean): Boolean; + procedure doOnAfterCreated(const browser: ICefBrowser); + procedure doOnBeforeClose(const browser: ICefBrowser); + function doOnClose(const browser: ICefBrowser): Boolean; + + function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; isRedirect: Boolean): Boolean; + function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; + const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; + userGesture: Boolean): Boolean; + function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; + function doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest): ICefResourceHandler; + procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); + function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; const response: ICefResponse): Boolean; + function doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; + procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; + receivedContentLength: Int64); + function doOnGetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; + isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; + const callback: ICefAuthCallback): Boolean; + function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; + newSize: Int64; const callback: ICefRequestCallback): Boolean; + procedure doOnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); + function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; + const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; + function doOnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; + procedure doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); + procedure doOnRenderViewReady(const browser: ICefBrowser); + procedure doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); + + + function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; + const title, defaultFilePath: ustring; acceptFilters: TStrings; + selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; + + function doOnGetRootScreenRect(const browser: ICefBrowser; rect: PCefRect): Boolean; + function doOnGetViewRect(const browser: ICefBrowser; rect: PCefRect): Boolean; + function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; + screenX, screenY: PInteger): Boolean; + function doOnGetScreenInfo(const browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean; + procedure doOnPopupShow(const browser: ICefBrowser; show: Boolean); + procedure doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); + procedure doOnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; + dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; + const buffer: Pointer; width, height: Integer); + procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; + cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); + function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; + allowedOps: TCefDragOperations; x, y: Integer): Boolean; + procedure doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); + procedure doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); + procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; + const selected_range: PCefRange; + character_boundsCount: NativeUInt; + const character_bounds: PCefRect); + + function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; + mask: TCefDragOperations): Boolean; + procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; + regionsCount: NativeUInt; regions: PCefDraggableRegionArray); + + procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; + const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); + end; + + ICefClientHandler = interface + ['{E76F6888-D9C3-4FCE-9C23-E89659820A36}'] + procedure Disconnect; + end; + +implementation + +end. diff --git a/uCEFJsDialogCallback.pas b/uCEFJsDialogCallback.pas new file mode 100644 index 00000000..8bd2456a --- /dev/null +++ b/uCEFJsDialogCallback.pas @@ -0,0 +1,81 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFJsDialogCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefJsDialogCallbackRef = class(TCefBaseRef, ICefJsDialogCallback) + protected + procedure Cont(success: Boolean; const userInput: ustring); + public + class function UnWrap(data: Pointer): ICefJsDialogCallback; + end; + + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefJsDialogCallbackRef.Cont(success: Boolean; + const userInput: ustring); +var + ui: TCefString; +begin + ui := CefString(userInput); + PCefJsDialogCallback(FData).cont(PCefJsDialogCallback(FData), Ord(success), @ui); +end; + +class function TCefJsDialogCallbackRef.UnWrap( + data: Pointer): ICefJsDialogCallback; +begin + if data <> nil then + Result := Create(data) as ICefJsDialogCallback else + Result := nil; +end; + +end. diff --git a/uCEFJsDialogHandler.pas b/uCEFJsDialogHandler.pas new file mode 100644 index 00000000..53ff4ea9 --- /dev/null +++ b/uCEFJsDialogHandler.pas @@ -0,0 +1,192 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFJsDialogHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefJsDialogHandlerOwn = class(TCefBaseOwn, ICefJsDialogHandler) + protected + function OnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; virtual; + function OnBeforeUnloadDialog(const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback): Boolean; virtual; + procedure OnResetDialogState(const browser: ICefBrowser); virtual; + procedure OnDialogClosed(const browser: ICefBrowser); virtual; + + public + constructor Create; virtual; + end; + + TCustomJsDialogHandler = class(TCefJsDialogHandlerOwn) + protected + FEvent: IChromiumEvents; + + function OnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; override; + function OnBeforeUnloadDialog(const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback): Boolean; override; + procedure OnResetDialogState(const browser: ICefBrowser); override; + procedure OnDialogClosed(const browser: ICefBrowser); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFJsDialogCallback; + +function cef_jsdialog_handler_on_jsdialog(self: PCefJsDialogHandler; + browser: PCefBrowser; const origin_url: PCefString; + dialog_type: TCefJsDialogType; const message_text, default_prompt_text: PCefString; + callback: PCefJsDialogCallback; suppress_message: PInteger): Integer; stdcall; +var + sm: Boolean; +begin + sm := suppress_message^ <> 0; + with TCefJsDialogHandlerOwn(CefGetObject(self)) do + Result := Ord(OnJsdialog(TCefBrowserRef.UnWrap(browser), CefString(origin_url), + dialog_type, CefString(message_text), CefString(default_prompt_text), + TCefJsDialogCallbackRef.UnWrap(callback), sm)); + suppress_message^ := Ord(sm); +end; + +function cef_jsdialog_handler_on_before_unload_dialog(self: PCefJsDialogHandler; + browser: PCefBrowser; const message_text: PCefString; is_reload: Integer; + callback: PCefJsDialogCallback): Integer; stdcall; +begin + with TCefJsDialogHandlerOwn(CefGetObject(self)) do + Result := Ord(OnBeforeUnloadDialog(TCefBrowserRef.UnWrap(browser), CefString(message_text), + is_reload <> 0, TCefJsDialogCallbackRef.UnWrap(callback))); +end; + +procedure cef_jsdialog_handler_on_reset_dialog_state(self: PCefJsDialogHandler; + browser: PCefBrowser); stdcall; +begin + with TCefJsDialogHandlerOwn(CefGetObject(self)) do + OnResetDialogState(TCefBrowserRef.UnWrap(browser)); +end; + +procedure cef_jsdialog_handler_on_dialog_closed(self: PCefJsDialogHandler; + browser: PCefBrowser); stdcall; +begin + with TCefJsDialogHandlerOwn(CefGetObject(self)) do + OnDialogClosed(TCefBrowserRef.UnWrap(browser)); +end; + +constructor TCefJsDialogHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefJsDialogHandler)); + with PCefJsDialogHandler(FData)^ do + begin + on_jsdialog := cef_jsdialog_handler_on_jsdialog; + on_before_unload_dialog := cef_jsdialog_handler_on_before_unload_dialog; + on_reset_dialog_state := cef_jsdialog_handler_on_reset_dialog_state; + on_dialog_closed := cef_jsdialog_handler_on_dialog_closed; + end; +end; + +function TCefJsDialogHandlerOwn.OnJsdialog(const browser: ICefBrowser; + const originUrl: ustring; dialogType: TCefJsDialogType; + const messageText, defaultPromptText: ustring; + const callback: ICefJsDialogCallback; + out suppressMessage: Boolean): Boolean; +begin + Result := False; +end; + +function TCefJsDialogHandlerOwn.OnBeforeUnloadDialog(const browser: ICefBrowser; + const messageText: ustring; isReload: Boolean; + const callback: ICefJsDialogCallback): Boolean; +begin + + Result := False; +end; + +procedure TCefJsDialogHandlerOwn.OnDialogClosed(const browser: ICefBrowser); +begin + +end; + +procedure TCefJsDialogHandlerOwn.OnResetDialogState(const browser: ICefBrowser); +begin + +end; + +// TCustomJsDialogHandler + +constructor TCustomJsDialogHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +function TCustomJsDialogHandler.OnBeforeUnloadDialog(const browser: ICefBrowser; + const messageText: ustring; isReload: Boolean; + const callback: ICefJsDialogCallback): Boolean; +begin + Result := FEvent.doOnBeforeUnloadDialog(browser, messageText, isReload, callback); +end; + +procedure TCustomJsDialogHandler.OnDialogClosed(const browser: ICefBrowser); +begin + FEvent.doOnDialogClosed(browser); +end; + +function TCustomJsDialogHandler.OnJsdialog(const browser: ICefBrowser; + const originUrl: ustring; dialogType: TCefJsDialogType; + const messageText, defaultPromptText: ustring; + const callback: ICefJsDialogCallback; + out suppressMessage: Boolean): Boolean; +begin + Result := FEvent.doOnJsdialog(browser, originUrl, dialogType, + messageText, defaultPromptText, callback, suppressMessage); +end; + +procedure TCustomJsDialogHandler.OnResetDialogState(const browser: ICefBrowser); +begin + FEvent.doOnResetDialogState(browser); +end; + +end. diff --git a/uCEFKeyboardHandler.pas b/uCEFKeyboardHandler.pas new file mode 100644 index 00000000..3917baad --- /dev/null +++ b/uCEFKeyboardHandler.pas @@ -0,0 +1,137 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFKeyboardHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefKeyboardHandlerOwn = class(TCefBaseOwn, ICefKeyboardHandler) + protected + function OnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; virtual; + function OnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle): Boolean; virtual; + + public + constructor Create; virtual; + end; + + TCustomKeyboardHandler = class(TCefKeyboardHandlerOwn) + protected + FEvent: IChromiumEvents; + + function OnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; override; + function OnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle): Boolean; override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser; + +function cef_keyboard_handler_on_pre_key_event(self: PCefKeyboardHandler; + browser: PCefBrowser; const event: PCefKeyEvent; + os_event: TCefEventHandle; is_keyboard_shortcut: PInteger): Integer; stdcall; +var + ks: Boolean; +begin + ks := is_keyboard_shortcut^ <> 0; + with TCefKeyboardHandlerOwn(CefGetObject(self)) do + Result := Ord(OnPreKeyEvent(TCefBrowserRef.UnWrap(browser), event, os_event, ks)); + is_keyboard_shortcut^ := Ord(ks); +end; + +function cef_keyboard_handler_on_key_event(self: PCefKeyboardHandler; + browser: PCefBrowser; const event: PCefKeyEvent; os_event: TCefEventHandle): Integer; stdcall; +begin + with TCefKeyboardHandlerOwn(CefGetObject(self)) do + Result := Ord(OnKeyEvent(TCefBrowserRef.UnWrap(browser), event, os_event)); +end; + +constructor TCefKeyboardHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefKeyboardHandler)); + + with PCefKeyboardHandler(FData)^ do + begin + on_pre_key_event := cef_keyboard_handler_on_pre_key_event; + on_key_event := cef_keyboard_handler_on_key_event; + end; +end; + +function TCefKeyboardHandlerOwn.OnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; +begin + Result := False; +end; + +function TCefKeyboardHandlerOwn.OnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle): Boolean; +begin + Result := False; +end; + +// TCustomKeyboardHandler + +constructor TCustomKeyboardHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +function TCustomKeyboardHandler.OnKeyEvent(const browser: ICefBrowser; + const event: PCefKeyEvent; osEvent: TCefEventHandle): Boolean; +begin + Result := FEvent.doOnKeyEvent(browser, event, osEvent); +end; + +function TCustomKeyboardHandler.OnPreKeyEvent(const browser: ICefBrowser; + const event: PCefKeyEvent; osEvent: TCefEventHandle; + out isKeyboardShortcut: Boolean): Boolean; +begin + Result := FEvent.doOnPreKeyEvent(browser, event, osEvent, isKeyboardShortcut); +end; + +end. diff --git a/uCEFLibFunctions.pas b/uCEFLibFunctions.pas new file mode 100644 index 00000000..46efb415 --- /dev/null +++ b/uCEFLibFunctions.pas @@ -0,0 +1,301 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLibFunctions; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + WinApi.Windows, System.Math, + uCEFTypes; + +const + LibcefDLL = 'libcef.dll'; + + +// /include/capi/cef_app_capi.h +function cef_initialize(const args: PCefMainArgs; const settings: PCefSettings; application: PCefApp; windows_sandbox_info: Pointer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_shutdown; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_execute_process(const args: PCefMainArgs; application: PCefApp; windows_sandbox_info: Pointer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_do_message_loop_work; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_run_message_loop; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_quit_message_loop; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_set_osmodal_loop(osModalLoop: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_enable_highdpi_support; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_browser_capi.h +function cef_browser_host_create_browser(const windowInfo: PCefWindowInfo; client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; request_context: PCefRequestContext): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_browser_host_create_browser_sync(const windowInfo: PCefWindowInfo; client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; request_context: PCefRequestContext): PCefBrowser; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_command_line_capi.h +function cef_command_line_create : PCefCommandLine; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_command_line_get_global : PCefCommandLine; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_cookie_capi.h +function cef_cookie_manager_get_global_manager(callback: PCefCompletionCallback): PCefCookieManager; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_cookie_manager_create_manager(const path: PCefString; persist_session_cookies: Integer; callback: PCefCompletionCallback): PCefCookieManager; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_crash_util.h +function cef_crash_reporting_enabled: integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_set_crash_key_value(const key, value : PCefString); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_drag_data_capi.h +function cef_drag_data_create : PCefDragData; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_file_util_capi.h +function cef_create_directory(const full_path : PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_get_temp_directory(temp_dir : PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_create_new_temp_directory(const prefix : PCefString; new_temp_path: PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_create_temp_directory_in_directory(const base_dir, prefix : PCefString; new_dir : PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_directory_exists(const path : PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_delete_file(const path : PCefString; recursive : integer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_zip_directory(const src_dir, dest_file : PCefString; include_hidden_files : integer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_geolocation_capi.h +function cef_get_geolocation(callback: PCefGetGeolocationCallback): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_image_capi.h +function cef_image_create : PCefImage; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_menu_model_capi.h +function cef_menu_model_create(delegate: PCefMenuModelDelegate): PCefMenuModel; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_origin_whitelist_capi.h +function cef_add_cross_origin_whitelist_entry(const source_origin, target_protocol, target_domain: PCefString; allow_target_subdomains: Integer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_remove_cross_origin_whitelist_entry(const source_origin, target_protocol, target_domain: PCefString; allow_target_subdomains: Integer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_clear_cross_origin_whitelist : Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_parser_capi.h +function cef_parse_url(const url: PCefString; var parts: TCefUrlParts): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_create_url(parts: PCefUrlParts; url: PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_format_url_for_security_display(const origin_url: PCefString): PCefStringUserFree; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_get_mime_type(const extension: PCefString): PCefStringUserFree; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_get_extensions_for_mime_type(const mime_type: PCefString; extensions: TCefStringList); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_base64encode(const data: Pointer; data_size: NativeUInt): PCefStringUserFree; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_base64decode(const data: PCefString): PCefBinaryValue; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_uriencode(const text: PCefString; use_plus: Integer): PCefStringUserFree; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_uridecode(const text: PCefString; convert_to_utf8: Integer; unescape_rule: TCefUriUnescapeRule): PCefStringUserFree; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_parse_json(const json_string: PCefString; options: TCefJsonParserOptions): PCefValue; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_parse_jsonand_return_error(const json_string: PCefString; options: TCefJsonParserOptions; error_code_out: PCefJsonParserError; error_msg_out: PCefString): PCefValue; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_write_json(node: PCefValue; options: TCefJsonWriterOptions): PCefStringUserFree; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_path_util_capi.h +function cef_get_path(key: TCefPathKey; path: PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_print_settings_capi.h +function cef_print_settings_create : PCefPrintSettings; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_process_message_capi.h +function cef_process_message_create(const name: PCefString): PCefProcessMessage; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_process_util_capi.h +function cef_launch_process(command_line: PCefCommandLine): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_request_capi.h +function cef_request_create : PCefRequest; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_post_data_create : PCefPostData; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_post_data_element_create : PCefPostDataElement; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_request_context_capi.h +function cef_request_context_get_global_context : PCefRequestContext; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_request_context_create_context(const settings: PCefRequestContextSettings; handler: PCefRequestContextHandler): PCefRequestContext; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_create_context_shared(other: PCefRequestContext; handler: PCefRequestContextHandler): PCefRequestContext; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_resource_bundle_capi.h +function cef_resource_bundle_get_global : PCefResourceBundle; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_response_capi.h +function cef_response_create : PCefResponse; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_scheme_capi.h +function cef_register_scheme_handler_factory(const scheme_name, domain_name: PCefString; factory: PCefSchemeHandlerFactory): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_clear_scheme_handler_factories : Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_ssl_info_capi.h +function cef_is_cert_status_error(status : TCefCertStatus) : integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_is_cert_status_minor_error(status : TCefCertStatus) : integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_stream_capi.h +function cef_stream_reader_create_for_file(const fileName: PCefString): PCefStreamReader; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_stream_reader_create_for_data(data: Pointer; size: NativeUInt): PCefStreamReader; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_stream_reader_create_for_handler(handler: PCefReadHandler): PCefStreamReader; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_stream_writer_create_for_file(const fileName: PCefString): PCefStreamWriter; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_stream_writer_create_for_handler(handler: PCefWriteHandler): PCefStreamWriter; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_task_capi.h +function cef_task_runner_get_for_current_thread : PCefTaskRunner; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_task_runner_get_for_thread(threadId: TCefThreadId): PCefTaskRunner; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_currently_on(threadId: TCefThreadId): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_post_task(threadId: TCefThreadId; task: PCefTask): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_post_delayed_task(threadId: TCefThreadId; task: PCefTask; delay_ms: Int64): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_thread_capi.h +function cef_thread_create(const display_name: PCefString; priority: TCefThreadPriority; message_loop_type: TCefMessageLoopType; stoppable: integer; com_init_mode: TCefCOMInitMode): PCefThread; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_trace_capi.h +function cef_begin_tracing(const categories: PCefString; callback: PCefCompletionCallback): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_end_tracing(const tracing_file: PCefString; callback: PCefEndTracingCallback): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_now_from_system_trace_time : int64; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_urlrequest_capi.h +function cef_urlrequest_create(request: PCefRequest; client: PCefUrlRequestClient; request_context: PCefRequestContext): PCefUrlRequest; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_v8_capi.h +function cef_v8context_get_current_context : PCefv8Context; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8context_get_entered_context : PCefv8Context; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8context_in_context : Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_undefined : PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_null : PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_bool(value: Integer): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_int(value: Integer): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_uint(value: Cardinal): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_double(value: Double): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_date(const value: PCefTime): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_string(const value: PCefString): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_object(accessor: PCefV8Accessor; interceptor: PCefV8Interceptor): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_array(length: Integer): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8value_create_function(const name: PCefString; handler: PCefv8Handler): PCefv8Value; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_v8stack_trace_get_current(frame_limit: Integer): PCefV8StackTrace; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_register_extension(const extension_name, javascript_code: PCefString; handler: PCefv8Handler): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_values_capi.h +function cef_value_create : PCefValue; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_binary_value_create(const data: Pointer; data_size: NativeUInt): PCefBinaryValue; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_dictionary_value_create: PCefDictionaryValue; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_list_value_create : PCefListValue; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_waitable_event_capi.h +function cef_waitable_event_create(automatic_reset, initially_signaled : integer): PCefWaitableEvent; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_web_plugin_capi.h +procedure cef_visit_web_plugin_info(visitor: PCefWebPluginInfoVisitor); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_refresh_web_plugins; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_unregister_internal_web_plugin(const path: PCefString); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_register_web_plugin_crash(const path: PCefString); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_is_web_plugin_unstable(const path: PCefString; callback: PCefWebPluginUnstableCallback); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_register_widevine_cdm(const path: PCefString; callback: PCefRegisterCDMCallback); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_xml_reader_capi.h +function cef_xml_reader_create(stream: PCefStreamReader; encodingType: TCefXmlEncodingType; const URI: PCefString): PCefXmlReader; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/capi/cef_zip_reader_capi.h +function cef_zip_reader_create(stream: PCefStreamReader): PCefZipReader; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/internal/cef_logging_internal.h +function cef_get_min_log_level : Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_get_vlog_level(const file_start: PAnsiChar; N: NativeInt): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_log(const file_: PAnsiChar; line, severity: Integer; const message: PAnsiChar); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/internal/cef_string_list.h +function cef_string_list_alloc(): TCefStringList; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_list_size(list: TCefStringList): NativeUInt; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_list_value(list: TCefStringList; index: NativeUInt; value: PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_list_append(list: TCefStringList; const value: PCefString); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_list_clear(list: TCefStringList); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_list_free(list: TCefStringList); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_list_copy(list: TCefStringList): TCefStringList; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/internal/cef_string_map.h +function cef_string_map_alloc: TCefStringMap; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_map_size(map: TCefStringMap): NativeUInt; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_map_find(map: TCefStringMap; const key: PCefString; var value: TCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_map_key(map: TCefStringMap; index: NativeUInt; var key: TCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_map_value(map: TCefStringMap; index: NativeUInt; var value: TCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_map_append(map: TCefStringMap; const key, value: PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_map_clear(map: TCefStringMap); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_map_free(map: TCefStringMap); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/internal/cef_string_multimap.h +function cef_string_multimap_alloc : TCefStringMultimap; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_multimap_size(map: TCefStringMultimap): NativeUInt; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_multimap_find_count(map: TCefStringMultimap; const key: PCefString): NativeUInt; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_multimap_enumerate(map: TCefStringMultimap; const key: PCefString; value_index: NativeUInt; var value: TCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_multimap_key(map: TCefStringMultimap; index: NativeUInt; var key: TCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_multimap_value(map: TCefStringMultimap; index: NativeUInt; var value: TCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_multimap_append(map: TCefStringMultimap; const key, value: PCefString): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_multimap_clear(map: TCefStringMultimap); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_multimap_free(map: TCefStringMultimap); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/internal/cef_string_types.h +function cef_string_wide_set(const src: PWideChar; src_len: NativeUInt; output: PCefStringWide; copy: Integer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_utf8_set(const src: PAnsiChar; src_len: NativeUInt; output: PCefStringUtf8; copy: Integer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_utf16_set(const src: PChar16; src_len: NativeUInt; output: PCefStringUtf16; copy: Integer): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_wide_clear(str: PCefStringWide); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_utf8_clear(str: PCefStringUtf8); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_utf16_clear(str: PCefStringUtf16); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_wide_cmp(const str1, str2: PCefStringWide): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_utf8_cmp(const str1, str2: PCefStringUtf8): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_utf16_cmp(const str1, str2: PCefStringUtf16): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_wide_to_utf8(const src: PWideChar; src_len: NativeUInt; output: PCefStringUtf8): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_utf8_to_wide(const src: PAnsiChar; src_len: NativeUInt; output: PCefStringWide): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_wide_to_utf16 (const src: PWideChar; src_len: NativeUInt; output: PCefStringUtf16): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_utf16_to_wide(const src: PChar16; src_len: NativeUInt; output: PCefStringWide): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_utf8_to_utf16(const src: PAnsiChar; src_len: NativeUInt; output: PCefStringUtf16): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_utf16_to_utf8(const src: PChar16; src_len: NativeUInt; output: PCefStringUtf8): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_ascii_to_wide(const src: PAnsiChar; src_len: NativeUInt; output: PCefStringWide): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_ascii_to_utf16(const src: PAnsiChar; src_len: NativeUInt; output: PCefStringUtf16): Integer; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_userfree_wide_alloc : PCefStringUserFreeWide; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_userfree_utf8_alloc : PCefStringUserFreeUtf8; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_string_userfree_utf16_alloc : PCefStringUserFreeUtf16; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_userfree_wide_free(str: PCefStringUserFreeWide); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_userfree_utf8_free(str: PCefStringUserFreeUtf8); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_string_userfree_utf16_free(str: PCefStringUserFreeUtf16); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/internal/cef_thread_internal.h +function cef_get_current_platform_thread_id : TCefPlatformThreadId; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +function cef_get_current_platform_thread_handle : TCefPlatformThreadHandle; {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + +// /include/internal/cef_trace_event_internal.h +procedure cef_trace_event_instant(const category, name, arg1_name: PAnsiChar; arg1_val: uint64; const arg2_name: PAnsiChar; arg2_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_trace_event_begin(const category, name, arg1_name: PAnsiChar; arg1_val: UInt64; const arg2_name: PAnsiChar; arg2_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_trace_event_end(const category, name, arg1_name: PAnsiChar; arg1_val: UInt64; const arg2_name: PAnsiChar; arg2_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_trace_counter(const category, name, value1_name: PAnsiChar; value1_val: UInt64; const value2_name: PAnsiChar; value2_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_trace_counter_id(const category, name: PAnsiChar; id: UInt64; const value1_name: PAnsiChar; value1_val: UInt64; const value2_name: PAnsiChar; value2_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_trace_event_async_begin(const category, name: PAnsiChar; id: UInt64; const arg1_name: PAnsiChar; arg1_val: UInt64; const arg2_name: PAnsiChar; arg2_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_trace_event_async_step_into(const category, name: PAnsiChar; id, step: UInt64; const arg1_name: PAnsiChar; arg1_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_trace_event_async_step_past(const category, name: PAnsiChar; id, step: UInt64; const arg1_name: PAnsiChar; arg1_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; +procedure cef_trace_event_async_end(const category, name: PAnsiChar; id: UInt64; const arg1_name: PAnsiChar; arg1_val: UInt64; const arg2_name: PAnsiChar; arg2_val: UInt64; copy: Integer); {$IFDEF CPUX64}stdcall{$ELSE}cdecl{$ENDIF}; external LibcefDLL; + + +implementation + +end. diff --git a/uCEFLifeSpanHandler.pas b/uCEFLifeSpanHandler.pas new file mode 100644 index 00000000..67361b61 --- /dev/null +++ b/uCEFLifeSpanHandler.pas @@ -0,0 +1,206 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLifeSpanHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefLifeSpanHandlerOwn = class(TCefBaseOwn, ICefLifeSpanHandler) + protected + function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean): Boolean; virtual; + procedure OnAfterCreated(const browser: ICefBrowser); virtual; + procedure OnBeforeClose(const browser: ICefBrowser); virtual; + function DoClose(const browser: ICefBrowser): Boolean; virtual; + + public + constructor Create; virtual; + end; + + TCustomLifeSpanHandler = class(TCefLifeSpanHandlerOwn) + protected + FEvent: IChromiumEvents; + + function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean): Boolean; override; + procedure OnAfterCreated(const browser: ICefBrowser); override; + procedure OnBeforeClose(const browser: ICefBrowser); override; + function DoClose(const browser: ICefBrowser): Boolean; override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFClient, uCEFBrowser, uCEFFrame; + +function cef_life_span_handler_on_before_popup(self: PCefLifeSpanHandler; + browser: PCefBrowser; frame: PCefFrame; const target_url, target_frame_name: PCefString; + target_disposition: TCefWindowOpenDisposition; user_gesture: Integer; + const popupFeatures: PCefPopupFeatures; windowInfo: PCefWindowInfo; var client: PCefClient; + settings: PCefBrowserSettings; no_javascript_access: PInteger): Integer; stdcall; +var + _url, _frame: ustring; + _client: ICefClient; + _nojs: Boolean; +begin + _url := CefString(target_url); + _frame := CefString(target_frame_name); + _client := TCefClientOwn(CefGetObject(client)) as ICefClient; + _nojs := no_javascript_access^ <> 0; + with TCefLifeSpanHandlerOwn(CefGetObject(self)) do + Result := Ord(OnBeforePopup( + TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + _url, + _frame, + target_disposition, + user_gesture <> 0, + popupFeatures^, + windowInfo^, + _client, + settings^, + _nojs + )); + CefStringSet(target_url, _url); + CefStringSet(target_frame_name, _frame); + client := CefGetData(_client); + no_javascript_access^ := Ord(_nojs); + _client := nil; +end; + +procedure cef_life_span_handler_on_after_created(self: PCefLifeSpanHandler; browser: PCefBrowser); stdcall; +begin + with TCefLifeSpanHandlerOwn(CefGetObject(self)) do + OnAfterCreated(TCefBrowserRef.UnWrap(browser)); +end; + +procedure cef_life_span_handler_on_before_close(self: PCefLifeSpanHandler; browser: PCefBrowser); stdcall; +begin + with TCefLifeSpanHandlerOwn(CefGetObject(self)) do + OnBeforeClose(TCefBrowserRef.UnWrap(browser)); +end; + +function cef_life_span_handler_do_close(self: PCefLifeSpanHandler; browser: PCefBrowser): Integer; stdcall; +begin + with TCefLifeSpanHandlerOwn(CefGetObject(self)) do + Result := Ord(DoClose(TCefBrowserRef.UnWrap(browser))); +end; + +constructor TCefLifeSpanHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefLifeSpanHandler)); + with PCefLifeSpanHandler(FData)^ do + begin + on_before_popup := cef_life_span_handler_on_before_popup; + on_after_created := cef_life_span_handler_on_after_created; + on_before_close := cef_life_span_handler_on_before_close; + do_close := cef_life_span_handler_do_close; + end; +end; + +procedure TCefLifeSpanHandlerOwn.OnAfterCreated(const browser: ICefBrowser); +begin + +end; + +procedure TCefLifeSpanHandlerOwn.OnBeforeClose(const browser: ICefBrowser); +begin + +end; + +function TCefLifeSpanHandlerOwn.OnBeforePopup(const browser: ICefBrowser; + const frame: ICefFrame; const targetUrl, targetFrameName: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; + var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; + var client: ICefClient; var settings: TCefBrowserSettings; + var noJavascriptAccess: Boolean): Boolean; +begin + Result := False; +end; + +function TCefLifeSpanHandlerOwn.DoClose(const browser: ICefBrowser): Boolean; +begin + Result := False; +end; + +// TCustomLifeSpanHandler + +constructor TCustomLifeSpanHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +function TCustomLifeSpanHandler.DoClose(const browser: ICefBrowser): Boolean; +begin + Result := FEvent.doOnClose(browser); +end; + +procedure TCustomLifeSpanHandler.OnAfterCreated(const browser: ICefBrowser); +begin + FEvent.doOnAfterCreated(browser); +end; + +procedure TCustomLifeSpanHandler.OnBeforeClose(const browser: ICefBrowser); +begin + FEvent.doOnBeforeClose(browser); +end; + + +function TCustomLifeSpanHandler.OnBeforePopup(const browser: ICefBrowser; + const frame: ICefFrame; const targetUrl, targetFrameName: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; + var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; + var client: ICefClient; var settings: TCefBrowserSettings; + var noJavascriptAccess: Boolean): Boolean; +begin + Result := FEvent.doOnBeforePopup(browser, frame, targetUrl, targetFrameName, + targetDisposition, userGesture, popupFeatures, windowInfo, client, settings, + noJavascriptAccess); +end; + +end. diff --git a/uCEFListValue.pas b/uCEFListValue.pas new file mode 100644 index 00000000..c15042a1 --- /dev/null +++ b/uCEFListValue.pas @@ -0,0 +1,247 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFListValue; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefListValueRef = class(TCefBaseRef, ICefListValue) + protected + function IsValid: Boolean; + function IsOwned: Boolean; + function IsReadOnly: Boolean; + function IsSame(const that: ICefListValue): Boolean; + function IsEqual(const that: ICefListValue): Boolean; + function Copy: ICefListValue; + function SetSize(size: NativeUInt): Boolean; + function GetSize: NativeUInt; + function Clear: Boolean; + function Remove(index: NativeUInt): Boolean; + function GetType(index: NativeUInt): TCefValueType; + function GetValue(index: NativeUInt): ICefValue; + function GetBool(index: NativeUInt): Boolean; + function GetInt(index: NativeUInt): Integer; + function GetDouble(index: NativeUInt): Double; + function GetString(index: NativeUInt): ustring; + function GetBinary(index: NativeUInt): ICefBinaryValue; + function GetDictionary(index: NativeUInt): ICefDictionaryValue; + function GetList(index: NativeUInt): ICefListValue; + function SetValue(index: NativeUInt; const value: ICefValue): Boolean; + function SetNull(index: NativeUInt): Boolean; + function SetBool(index: NativeUInt; value: Boolean): Boolean; + function SetInt(index: NativeUInt; value: Integer): Boolean; + function SetDouble(index: NativeUInt; value: Double): Boolean; + function SetString(index: NativeUInt; const value: ustring): Boolean; + function SetBinary(index: NativeUInt; const value: ICefBinaryValue): Boolean; + function SetDictionary(index: NativeUInt; const value: ICefDictionaryValue): Boolean; + function SetList(index: NativeUInt; const value: ICefListValue): Boolean; + + public + class function UnWrap(data: Pointer): ICefListValue; + class function New: ICefListValue; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue, uCEFValue, uCEFDictionaryValue; + +function TCefListValueRef.Clear: Boolean; +begin + Result := PCefListValue(FData).clear(PCefListValue(FData)) <> 0; +end; + +function TCefListValueRef.Copy: ICefListValue; +begin + Result := UnWrap(PCefListValue(FData).copy(PCefListValue(FData))); +end; + +class function TCefListValueRef.New: ICefListValue; +begin + Result := UnWrap(cef_list_value_create); +end; + +function TCefListValueRef.GetBinary(index: NativeUInt): ICefBinaryValue; +begin + Result := TCefBinaryValueRef.UnWrap(PCefListValue(FData).get_binary(PCefListValue(FData), index)); +end; + +function TCefListValueRef.GetBool(index: NativeUInt): Boolean; +begin + Result := PCefListValue(FData).get_bool(PCefListValue(FData), index) <> 0; +end; + +function TCefListValueRef.GetDictionary(index: NativeUInt): ICefDictionaryValue; +begin + Result := TCefDictionaryValueRef.UnWrap(PCefListValue(FData).get_dictionary(PCefListValue(FData), index)); +end; + +function TCefListValueRef.GetDouble(index: NativeUInt): Double; +begin + Result := PCefListValue(FData).get_double(PCefListValue(FData), index); +end; + +function TCefListValueRef.GetInt(index: NativeUInt): Integer; +begin + Result := PCefListValue(FData).get_int(PCefListValue(FData), index); +end; + +function TCefListValueRef.GetList(index: NativeUInt): ICefListValue; +begin + Result := UnWrap(PCefListValue(FData).get_list(PCefListValue(FData), index)); +end; + +function TCefListValueRef.GetSize: NativeUInt; +begin + Result := PCefListValue(FData).get_size(PCefListValue(FData)); +end; + +function TCefListValueRef.GetString(index: NativeUInt): ustring; +begin + Result := CefStringFreeAndGet(PCefListValue(FData).get_string(PCefListValue(FData), index)); +end; + +function TCefListValueRef.GetType(index: NativeUInt): TCefValueType; +begin + Result := PCefListValue(FData).get_type(PCefListValue(FData), index); +end; + +function TCefListValueRef.GetValue(index: NativeUInt): ICefValue; +begin + Result := TCefValueRef.UnWrap(PCefListValue(FData).get_value(PCefListValue(FData), index)); +end; + +function TCefListValueRef.IsEqual(const that: ICefListValue): Boolean; +begin + Result := PCefListValue(FData).is_equal(PCefListValue(FData), CefGetData(that)) <> 0; +end; + +function TCefListValueRef.IsOwned: Boolean; +begin + Result := PCefListValue(FData).is_owned(PCefListValue(FData)) <> 0; +end; + +function TCefListValueRef.IsReadOnly: Boolean; +begin + Result := PCefListValue(FData).is_read_only(PCefListValue(FData)) <> 0; +end; + +function TCefListValueRef.IsSame(const that: ICefListValue): Boolean; +begin + Result := PCefListValue(FData).is_same(PCefListValue(FData), CefGetData(that)) <> 0; +end; + +function TCefListValueRef.IsValid: Boolean; +begin + Result := PCefListValue(FData).is_valid(PCefListValue(FData)) <> 0; +end; + +function TCefListValueRef.Remove(index: NativeUInt): Boolean; +begin + Result := PCefListValue(FData).remove(PCefListValue(FData), index) <> 0; +end; + +function TCefListValueRef.SetBinary(index: NativeUInt; const value: ICefBinaryValue): Boolean; +begin + Result := PCefListValue(FData).set_binary(PCefListValue(FData), index, CefGetData(value)) <> 0; +end; + +function TCefListValueRef.SetBool(index: NativeUInt; value: Boolean): Boolean; +begin + Result := PCefListValue(FData).set_bool(PCefListValue(FData), index, Ord(value)) <> 0; +end; + +function TCefListValueRef.SetDictionary(index: NativeUInt; const value: ICefDictionaryValue): Boolean; +begin + Result := PCefListValue(FData).set_dictionary(PCefListValue(FData), index, CefGetData(value)) <> 0; +end; + +function TCefListValueRef.SetDouble(index: NativeUInt; value: Double): Boolean; +begin + Result := PCefListValue(FData).set_double(PCefListValue(FData), index, value) <> 0; +end; + +function TCefListValueRef.SetInt(index: NativeUInt; value: Integer): Boolean; +begin + Result := PCefListValue(FData).set_int(PCefListValue(FData), index, value) <> 0; +end; + +function TCefListValueRef.SetList(index: NativeUInt; const value: ICefListValue): Boolean; +begin + Result := PCefListValue(FData).set_list(PCefListValue(FData), index, CefGetData(value)) <> 0; +end; + +function TCefListValueRef.SetNull(index: NativeUInt): Boolean; +begin + Result := PCefListValue(FData).set_null(PCefListValue(FData), index) <> 0; +end; + +function TCefListValueRef.SetSize(size: NativeUInt): Boolean; +begin + Result := PCefListValue(FData).set_size(PCefListValue(FData), size) <> 0; +end; + +function TCefListValueRef.SetString(index: NativeUInt; const value: ustring): Boolean; +var + v: TCefString; +begin + v := CefString(value); + Result := PCefListValue(FData).set_string(PCefListValue(FData), index, @v) <> 0; +end; + +function TCefListValueRef.SetValue(index: NativeUInt; const value: ICefValue): Boolean; +begin + Result := PCefListValue(FData).set_value(PCefListValue(FData), index, CefGetData(value)) <> 0; +end; + +class function TCefListValueRef.UnWrap(data: Pointer): ICefListValue; +begin + if data <> nil then + Result := Create(data) as ICefListValue else + Result := nil; +end; + +end. diff --git a/uCEFLoadHandler.pas b/uCEFLoadHandler.pas new file mode 100644 index 00000000..26647477 --- /dev/null +++ b/uCEFLoadHandler.pas @@ -0,0 +1,166 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLoadHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefLoadHandlerOwn = class(TCefBaseOwn, ICefLoadHandler) + protected + procedure OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual; + procedure OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); virtual; + procedure OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); virtual; + procedure OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); virtual; + + public + constructor Create; virtual; + end; + + TCustomLoadHandler = class(TCefLoadHandlerOwn) + protected + FEvent: IChromiumEvents; + + procedure OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); override; + procedure OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); override; + procedure OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); override; + procedure OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame; + +procedure cef_load_handler_on_loading_state_change(self: PCefLoadHandler; browser: PCefBrowser; isLoading, canGoBack, canGoForward: Integer); stdcall; +begin + with TCefLoadHandlerOwn(CefGetObject(self)) do + OnLoadingStateChange(TCefBrowserRef.UnWrap(browser), isLoading <> 0, canGoBack <> 0, canGoForward <> 0); +end; + +procedure cef_load_handler_on_load_start(self: PCefLoadHandler; browser: PCefBrowser; frame: PCefFrame; transition_type: TCefTransitionType); stdcall; +begin + with TCefLoadHandlerOwn(CefGetObject(self)) do + OnLoadStart(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), transition_type); +end; + +procedure cef_load_handler_on_load_end(self: PCefLoadHandler; browser: PCefBrowser; frame: PCefFrame; httpStatusCode: Integer); stdcall; +begin + with TCefLoadHandlerOwn(CefGetObject(self)) do + OnLoadEnd(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), httpStatusCode); +end; + +procedure cef_load_handler_on_load_error(self: PCefLoadHandler; browser: PCefBrowser; frame: PCefFrame; errorCode: Integer; const errorText, failedUrl: PCefString); stdcall; +begin + with TCefLoadHandlerOwn(CefGetObject(self)) do + OnLoadError(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), errorCode, CefString(errorText), CefString(failedUrl)); +end; + +constructor TCefLoadHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefLoadHandler)); + + with PCefLoadHandler(FData)^ do + begin + on_loading_state_change := cef_load_handler_on_loading_state_change; + on_load_start := cef_load_handler_on_load_start; + on_load_end := cef_load_handler_on_load_end; + on_load_error := cef_load_handler_on_load_error; + end; +end; + +procedure TCefLoadHandlerOwn.OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); +begin + // +end; + +procedure TCefLoadHandlerOwn.OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); +begin + // +end; + +procedure TCefLoadHandlerOwn.OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); +begin + // +end; + +procedure TCefLoadHandlerOwn.OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); +begin + // +end; + +// TCustomLoadHandler + +constructor TCustomLoadHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + + FEvent := events; +end; + +procedure TCustomLoadHandler.OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); +begin + FEvent.doOnLoadEnd(browser, frame, httpStatusCode); +end; + +procedure TCustomLoadHandler.OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); +begin + FEvent.doOnLoadError(browser, frame, errorCode, errorText, failedUrl); +end; + +procedure TCustomLoadHandler.OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); +begin + FEvent.doOnLoadingStateChange(browser, isLoading, canGoBack, canGoForward); +end; + +procedure TCustomLoadHandler.OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); +begin + FEvent.doOnLoadStart(browser, frame, transitionType); +end; + +end. diff --git a/uCEFMenuModel.pas b/uCEFMenuModel.pas new file mode 100644 index 00000000..dddad037 --- /dev/null +++ b/uCEFMenuModel.pas @@ -0,0 +1,440 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMenuModel; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefMenuModelRef = class(TCefBaseRef, ICefMenuModel) + protected + function Clear: Boolean; + function GetCount: Integer; + function AddSeparator: Boolean; + function AddItem(commandId: Integer; const text: ustring): Boolean; + function AddCheckItem(commandId: Integer; const text: ustring): Boolean; + function AddRadioItem(commandId: Integer; const text: ustring; groupId: Integer): Boolean; + function AddSubMenu(commandId: Integer; const text: ustring): ICefMenuModel; + function InsertSeparatorAt(index: Integer): Boolean; + function InsertItemAt(index, commandId: Integer; const text: ustring): Boolean; + function InsertCheckItemAt(index, commandId: Integer; const text: ustring): Boolean; + function InsertRadioItemAt(index, commandId: Integer; const text: ustring; groupId: Integer): Boolean; + function InsertSubMenuAt(index, commandId: Integer; const text: ustring): ICefMenuModel; + function Remove(commandId: Integer): Boolean; + function RemoveAt(index: Integer): Boolean; + function GetIndexOf(commandId: Integer): Integer; + function GetCommandIdAt(index: Integer): Integer; + function SetCommandIdAt(index, commandId: Integer): Boolean; + function GetLabel(commandId: Integer): ustring; + function GetLabelAt(index: Integer): ustring; + function SetLabel(commandId: Integer; const text: ustring): Boolean; + function SetLabelAt(index: Integer; const text: ustring): Boolean; + function GetType(commandId: Integer): TCefMenuItemType; + function GetTypeAt(index: Integer): TCefMenuItemType; + function GetGroupId(commandId: Integer): Integer; + function GetGroupIdAt(index: Integer): Integer; + function SetGroupId(commandId, groupId: Integer): Boolean; + function SetGroupIdAt(index, groupId: Integer): Boolean; + function GetSubMenu(commandId: Integer): ICefMenuModel; + function GetSubMenuAt(index: Integer): ICefMenuModel; + function IsVisible(commandId: Integer): Boolean; + function isVisibleAt(index: Integer): Boolean; + function SetVisible(commandId: Integer; visible: Boolean): Boolean; + function SetVisibleAt(index: Integer; visible: Boolean): Boolean; + function IsEnabled(commandId: Integer): Boolean; + function IsEnabledAt(index: Integer): Boolean; + function SetEnabled(commandId: Integer; enabled: Boolean): Boolean; + function SetEnabledAt(index: Integer; enabled: Boolean): Boolean; + function IsChecked(commandId: Integer): Boolean; + function IsCheckedAt(index: Integer): Boolean; + function setChecked(commandId: Integer; checked: Boolean): Boolean; + function setCheckedAt(index: Integer; checked: Boolean): Boolean; + function HasAccelerator(commandId: Integer): Boolean; + function HasAcceleratorAt(index: Integer): Boolean; + function SetAccelerator(commandId, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; + function SetAcceleratorAt(index, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; + function RemoveAccelerator(commandId: Integer): Boolean; + function RemoveAcceleratorAt(index: Integer): Boolean; + function GetAccelerator(commandId: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; + function GetAcceleratorAt(index: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; + public + class function UnWrap(data: Pointer): ICefMenuModel; + class function New(const delegate: ICefMenuModelDelegate): ICefMenuModel; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +function TCefMenuModelRef.AddCheckItem(commandId: Integer; + const text: ustring): Boolean; +var + t: TCefString; +begin + t := CefString(text); + Result := PCefMenuModel(FData).add_check_item(PCefMenuModel(FData), commandId, @t) <> 0; +end; + +function TCefMenuModelRef.AddItem(commandId: Integer; + const text: ustring): Boolean; +var + t: TCefString; +begin + t := CefString(text); + Result := PCefMenuModel(FData).add_item(PCefMenuModel(FData), commandId, @t) <> 0; +end; + +function TCefMenuModelRef.AddRadioItem(commandId: Integer; const text: ustring; + groupId: Integer): Boolean; +var + t: TCefString; +begin + t := CefString(text); + Result := PCefMenuModel(FData).add_radio_item(PCefMenuModel(FData), commandId, @t, groupId) <> 0; +end; + +function TCefMenuModelRef.AddSeparator: Boolean; +begin + Result := PCefMenuModel(FData).add_separator(PCefMenuModel(FData)) <> 0; +end; + +function TCefMenuModelRef.AddSubMenu(commandId: Integer; + const text: ustring): ICefMenuModel; +var + t: TCefString; +begin + t := CefString(text); + Result := TCefMenuModelRef.UnWrap(PCefMenuModel(FData).add_sub_menu(PCefMenuModel(FData), commandId, @t)); +end; + +function TCefMenuModelRef.Clear: Boolean; +begin + Result := PCefMenuModel(FData).clear(PCefMenuModel(FData)) <> 0; +end; + +function TCefMenuModelRef.GetAccelerator(commandId: Integer; + out keyCode: Integer; out shiftPressed, ctrlPressed, + altPressed: Boolean): Boolean; +var + sp, cp, ap: Integer; +begin + Result := PCefMenuModel(FData).get_accelerator(PCefMenuModel(FData), + commandId, @keyCode, @sp, @cp, @ap) <> 0; + shiftPressed := sp <> 0; + ctrlPressed := cp <> 0; + altPressed := ap <> 0; +end; + +function TCefMenuModelRef.GetAcceleratorAt(index: Integer; out keyCode: Integer; + out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; +var + sp, cp, ap: Integer; +begin + Result := PCefMenuModel(FData).get_accelerator_at(PCefMenuModel(FData), + index, @keyCode, @sp, @cp, @ap) <> 0; + shiftPressed := sp <> 0; + ctrlPressed := cp <> 0; + altPressed := ap <> 0; +end; + +function TCefMenuModelRef.GetCommandIdAt(index: Integer): Integer; +begin + Result := PCefMenuModel(FData).get_command_id_at(PCefMenuModel(FData), index); +end; + +function TCefMenuModelRef.GetCount: Integer; +begin + Result := PCefMenuModel(FData).get_count(PCefMenuModel(FData)); +end; + +function TCefMenuModelRef.GetGroupId(commandId: Integer): Integer; +begin + Result := PCefMenuModel(FData).get_group_id(PCefMenuModel(FData), commandId); +end; + +function TCefMenuModelRef.GetGroupIdAt(index: Integer): Integer; +begin + Result := PCefMenuModel(FData).get_group_id(PCefMenuModel(FData), index); +end; + +function TCefMenuModelRef.GetIndexOf(commandId: Integer): Integer; +begin + Result := PCefMenuModel(FData).get_index_of(PCefMenuModel(FData), commandId); +end; + +function TCefMenuModelRef.GetLabel(commandId: Integer): ustring; +begin + Result := CefStringFreeAndGet(PCefMenuModel(FData).get_label(PCefMenuModel(FData), commandId)); +end; + +function TCefMenuModelRef.GetLabelAt(index: Integer): ustring; +begin + Result := CefStringFreeAndGet(PCefMenuModel(FData).get_label_at(PCefMenuModel(FData), index)); +end; + +function TCefMenuModelRef.GetSubMenu(commandId: Integer): ICefMenuModel; +begin + Result := TCefMenuModelRef.UnWrap(PCefMenuModel(FData).get_sub_menu(PCefMenuModel(FData), commandId)); +end; + +function TCefMenuModelRef.GetSubMenuAt(index: Integer): ICefMenuModel; +begin + Result := TCefMenuModelRef.UnWrap(PCefMenuModel(FData).get_sub_menu_at(PCefMenuModel(FData), index)); +end; + +function TCefMenuModelRef.GetType(commandId: Integer): TCefMenuItemType; +begin + Result := PCefMenuModel(FData).get_type(PCefMenuModel(FData), commandId); +end; + +function TCefMenuModelRef.GetTypeAt(index: Integer): TCefMenuItemType; +begin + Result := PCefMenuModel(FData).get_type_at(PCefMenuModel(FData), index); +end; + +function TCefMenuModelRef.HasAccelerator(commandId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).has_accelerator(PCefMenuModel(FData), commandId) <> 0; +end; + +function TCefMenuModelRef.HasAcceleratorAt(index: Integer): Boolean; +begin + Result := PCefMenuModel(FData).has_accelerator_at(PCefMenuModel(FData), index) <> 0; +end; + +function TCefMenuModelRef.InsertCheckItemAt(index, commandId: Integer; + const text: ustring): Boolean; +var + t: TCefString; +begin + t := CefString(text); + Result := PCefMenuModel(FData).insert_check_item_at(PCefMenuModel(FData), index, commandId, @t) <> 0; +end; + +function TCefMenuModelRef.InsertItemAt(index, commandId: Integer; + const text: ustring): Boolean; +var + t: TCefString; +begin + t := CefString(text); + Result := PCefMenuModel(FData).insert_item_at(PCefMenuModel(FData), index, commandId, @t) <> 0; +end; + +function TCefMenuModelRef.InsertRadioItemAt(index, commandId: Integer; + const text: ustring; groupId: Integer): Boolean; +var + t: TCefString; +begin + t := CefString(text); + Result := PCefMenuModel(FData).insert_radio_item_at(PCefMenuModel(FData), + index, commandId, @t, groupId) <> 0; +end; + +function TCefMenuModelRef.InsertSeparatorAt(index: Integer): Boolean; +begin + Result := PCefMenuModel(FData).insert_separator_at(PCefMenuModel(FData), index) <> 0; +end; + +function TCefMenuModelRef.InsertSubMenuAt(index, commandId: Integer; + const text: ustring): ICefMenuModel; +var + t: TCefString; +begin + t := CefString(text); + Result := TCefMenuModelRef.UnWrap(PCefMenuModel(FData).insert_sub_menu_at( + PCefMenuModel(FData), index, commandId, @t)); +end; + +function TCefMenuModelRef.IsChecked(commandId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).is_checked(PCefMenuModel(FData), commandId) <> 0; +end; + +function TCefMenuModelRef.IsCheckedAt(index: Integer): Boolean; +begin + Result := PCefMenuModel(FData).is_checked_at(PCefMenuModel(FData), index) <> 0; +end; + +function TCefMenuModelRef.IsEnabled(commandId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).is_enabled(PCefMenuModel(FData), commandId) <> 0; +end; + +function TCefMenuModelRef.IsEnabledAt(index: Integer): Boolean; +begin + Result := PCefMenuModel(FData).is_enabled_at(PCefMenuModel(FData), index) <> 0; +end; + +function TCefMenuModelRef.IsVisible(commandId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).is_visible(PCefMenuModel(FData), commandId) <> 0; +end; + +function TCefMenuModelRef.isVisibleAt(index: Integer): Boolean; +begin + Result := PCefMenuModel(FData).is_visible_at(PCefMenuModel(FData), index) <> 0; +end; + +class function TCefMenuModelRef.New( + const delegate: ICefMenuModelDelegate): ICefMenuModel; +begin + Result := UnWrap(cef_menu_model_create(CefGetData(delegate))); +end; + +function TCefMenuModelRef.Remove(commandId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).remove(PCefMenuModel(FData), commandId) <> 0; +end; + +function TCefMenuModelRef.RemoveAccelerator(commandId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).remove_accelerator(PCefMenuModel(FData), commandId) <> 0; +end; + +function TCefMenuModelRef.RemoveAcceleratorAt(index: Integer): Boolean; +begin + Result := PCefMenuModel(FData).remove_accelerator_at(PCefMenuModel(FData), index) <> 0; +end; + +function TCefMenuModelRef.RemoveAt(index: Integer): Boolean; +begin + Result := PCefMenuModel(FData).remove_at(PCefMenuModel(FData), index) <> 0; +end; + +function TCefMenuModelRef.SetAccelerator(commandId, keyCode: Integer; + shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; +begin + Result := PCefMenuModel(FData).set_accelerator(PCefMenuModel(FData), + commandId, keyCode, Ord(shiftPressed), Ord(ctrlPressed), Ord(altPressed)) <> 0; +end; + +function TCefMenuModelRef.SetAcceleratorAt(index, keyCode: Integer; + shiftPressed, ctrlPressed, altPressed: Boolean): Boolean; +begin + Result := PCefMenuModel(FData).set_accelerator_at(PCefMenuModel(FData), + index, keyCode, Ord(shiftPressed), Ord(ctrlPressed), Ord(altPressed)) <> 0; +end; + +function TCefMenuModelRef.setChecked(commandId: Integer; + checked: Boolean): Boolean; +begin + Result := PCefMenuModel(FData).set_checked(PCefMenuModel(FData), + commandId, Ord(checked)) <> 0; +end; + +function TCefMenuModelRef.setCheckedAt(index: Integer; + checked: Boolean): Boolean; +begin + Result := PCefMenuModel(FData).set_checked_at(PCefMenuModel(FData), index, Ord(checked)) <> 0; +end; + +function TCefMenuModelRef.SetCommandIdAt(index, commandId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).set_command_id_at(PCefMenuModel(FData), index, commandId) <> 0; +end; + +function TCefMenuModelRef.SetEnabled(commandId: Integer; + enabled: Boolean): Boolean; +begin + Result := PCefMenuModel(FData).set_enabled(PCefMenuModel(FData), commandId, Ord(enabled)) <> 0; +end; + +function TCefMenuModelRef.SetEnabledAt(index: Integer; + enabled: Boolean): Boolean; +begin + Result := PCefMenuModel(FData).set_enabled_at(PCefMenuModel(FData), index, Ord(enabled)) <> 0; +end; + +function TCefMenuModelRef.SetGroupId(commandId, groupId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).set_group_id(PCefMenuModel(FData), commandId, groupId) <> 0; +end; + +function TCefMenuModelRef.SetGroupIdAt(index, groupId: Integer): Boolean; +begin + Result := PCefMenuModel(FData).set_group_id_at(PCefMenuModel(FData), index, groupId) <> 0; +end; + +function TCefMenuModelRef.SetLabel(commandId: Integer; + const text: ustring): Boolean; +var + t: TCefString; +begin + t := CefString(text); + Result := PCefMenuModel(FData).set_label(PCefMenuModel(FData), commandId, @t) <> 0; +end; + +function TCefMenuModelRef.SetLabelAt(index: Integer; + const text: ustring): Boolean; +var + t: TCefString; +begin + t := CefString(text); + Result := PCefMenuModel(FData).set_label_at(PCefMenuModel(FData), index, @t) <> 0; +end; + +function TCefMenuModelRef.SetVisible(commandId: Integer; + visible: Boolean): Boolean; +begin + Result := PCefMenuModel(FData).set_visible(PCefMenuModel(FData), commandId, Ord(visible)) <> 0; +end; + +function TCefMenuModelRef.SetVisibleAt(index: Integer; + visible: Boolean): Boolean; +begin + Result := PCefMenuModel(FData).set_visible_at(PCefMenuModel(FData), index, Ord(visible)) <> 0; +end; + +class function TCefMenuModelRef.UnWrap(data: Pointer): ICefMenuModel; +begin + if data <> nil then + Result := Create(data) as ICefMenuModel else + Result := nil; +end; + + +end. diff --git a/uCEFMenuModelDelegate.pas b/uCEFMenuModelDelegate.pas new file mode 100644 index 00000000..8855202d --- /dev/null +++ b/uCEFMenuModelDelegate.pas @@ -0,0 +1,126 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMenuModelDelegate; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefMenuModelDelegateOwn = class(TCefBaseOwn, ICefMenuModelDelegate) + protected + procedure ExecuteCommand(const menuModel: ICefMenuModel; commandId: Integer; eventFlags: TCefEventFlags); virtual; + procedure MenuWillShow(const menuModel: ICefMenuModel); virtual; + procedure MenuClosed(const menuModel: ICefMenuModel); virtual; + function FormatLabel(const menuModel: ICefMenuModel; const label_ : uString) : boolean; virtual; + public + constructor Create; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFMenuModel; + +procedure cef_menu_model_delegate_execute_command(self: PCefMenuModelDelegate; + menu_model: PCefMenuModel; command_id: Integer; event_flags: TCefEventFlags); stdcall; +begin + with TCefMenuModelDelegateOwn(CefGetObject(self)) do + ExecuteCommand(TCefMenuModelRef.UnWrap(menu_model), command_id, event_flags); +end; + +procedure cef_menu_model_delegate_menu_will_show(self: PCefMenuModelDelegate; menu_model: PCefMenuModel); stdcall; +begin + with TCefMenuModelDelegateOwn(CefGetObject(self)) do + MenuWillShow(TCefMenuModelRef.UnWrap(menu_model)); +end; + +procedure cef_menu_model_delegate_menu_closed(self: PCefMenuModelDelegate; menu_model: PCefMenuModel); stdcall; +begin + with TCefMenuModelDelegateOwn(CefGetObject(self)) do + MenuClosed(TCefMenuModelRef.UnWrap(menu_model)); +end; + +function cef_menu_model_delegate_format_label(self: PCefMenuModelDelegate; menu_model: PCefMenuModel; label_ : PCefString) : integer; stdcall; +begin + with TCefMenuModelDelegateOwn(CefGetObject(self)) do + Result := Ord(FormatLabel(TCefMenuModelRef.UnWrap(menu_model), CefString(label_))); +end; + +constructor TCefMenuModelDelegateOwn.Create; +begin + CreateData(SizeOf(TCefMenuModelDelegate), False); + + with PCefMenuModelDelegate(FData)^ do + begin + execute_command := cef_menu_model_delegate_execute_command; + menu_will_show := cef_menu_model_delegate_menu_will_show; + menu_closed := cef_menu_model_delegate_menu_closed; + format_label := cef_menu_model_delegate_format_label; + end; +end; + +procedure TCefMenuModelDelegateOwn.ExecuteCommand( + const menuModel: ICefMenuModel; commandId: Integer; + eventFlags: TCefEventFlags); +begin + +end; + +procedure TCefMenuModelDelegateOwn.MenuWillShow(const menuModel: ICefMenuModel); +begin + +end; + +procedure TCefMenuModelDelegateOwn.MenuClosed(const menuModel: ICefMenuModel); +begin + +end; + +function TCefMenuModelDelegateOwn.FormatLabel(const menuModel: ICefMenuModel; const label_ : uString) : boolean; +begin + Result := False; +end; + +end. diff --git a/uCEFMiscFunctions.pas b/uCEFMiscFunctions.pas new file mode 100644 index 00000000..84cc2780 --- /dev/null +++ b/uCEFMiscFunctions.pas @@ -0,0 +1,416 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMiscFunctions; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + WinApi.Windows, System.Classes, System.SysUtils, + uCEFTypes, uCEFInterfaces, uCEFLibFunctions; + +const + Kernel32DLL = 'kernel32.dll'; + +procedure CefStringListToStringList(var aSrcSL : TCefStringList; var aDstSL : TStringList); overload; +procedure CefStringListToStringList(var aSrcSL : TCefStringList; var aDstSL : TStrings); overload; + +function CefColorGetA(color: TCefColor): Byte; +function CefColorGetR(color: TCefColor): byte; +function CefColorGetG(color: TCefColor): Byte; +function CefColorGetB(color: TCefColor): Byte; + +function CefColorSetARGB(a, r, g, b: Byte): TCefColor; + +function CefInt64Set(int32_low, int32_high: Integer): Int64; + +function CefInt64GetLow(const int64_val: Int64): Integer; +function CefInt64GetHigh(const int64_val: Int64): Integer; + +function CefGetObject(ptr: Pointer): TObject; +function CefGetData(const i: ICefBase): Pointer; + +function CefStringAlloc(const str: ustring): TCefString; +function CefStringClearAndGet(var str: TCefString): ustring; + +function CefString(const str: ustring): TCefString; overload; +function CefString(const str: PCefString): ustring; overload; +function CefUserFreeString(const str: ustring): PCefStringUserFree; +procedure CefStringFree(const str: PCefString); +function CefStringFreeAndGet(const str: PCefStringUserFree): ustring; +procedure CefStringSet(const str: PCefString; const value: ustring); + +function CefExecuteProcess(var app : ICefApp; aWindowsSandboxInfo : Pointer = nil) : integer; +function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Handler): Boolean; +procedure CefPostTask(ThreadId: TCefThreadId; const task: ICefTask); +procedure CefPostDelayedTask(ThreadId: TCefThreadId; const task: ICefTask; delayMs: Int64); + +function CefTimeToSystemTime(const dt: TCefTime): TSystemTime; +function SystemTimeToCefTime(const dt: TSystemTime): TCefTime; +function CefTimeToDateTime(const dt: TCefTime): TDateTime; +function DateTimeToCefTime(dt: TDateTime): TCefTime; + +function cef_string_wide_copy(const src: PWideChar; src_len: NativeUInt; output: PCefStringWide): Integer; +function cef_string_utf8_copy(const src: PAnsiChar; src_len: NativeUInt; output: PCefStringUtf8): Integer; +function cef_string_utf16_copy(const src: PChar16; src_len: NativeUInt; output: PCefStringUtf16): Integer; +function cef_string_copy(const src: PCefChar; src_len: NativeUInt; output: PCefString): Integer; + +procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : THandle; aRect : TRect; const aWindowName : string = ''); +procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle; const aWindowName : string = ''); +procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle; aTransparent : boolean; const aWindowName : string = ''); + +function TzSpecificLocalTimeToSystemTime(lpTimeZoneInformation: PTimeZoneInformation; lpLocalTime, lpUniversalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL; +function SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation: PTimeZoneInformation; lpUniversalTime, lpLocalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL; + +function CefIsCertStatusError(Status : TCefCertStatus) : boolean; +function CefIsCertStatusMinorError(Status : TCefCertStatus) : boolean; + +function CefCrashReportingEnabled : boolean; +procedure CefSetCrashKeyValue(const aKey, aValue : ustring); + +implementation + +function CefColorGetA(color: TCefColor): Byte; +begin + Result := (color shr 24) and $FF; +end; + +function CefColorGetR(color: TCefColor): byte; +begin + Result := (color shr 16) and $FF; +end; + +function CefColorGetG(color: TCefColor): Byte; +begin + Result := (color shr 8) and $FF; +end; + +function CefColorGetB(color: TCefColor): Byte; +begin + Result := color and $FF; +end; + +function CefColorSetARGB(a, r, g, b: Byte): TCefColor; +begin + Result := (a shl 24) or (r shl 16) or (g shl 8) or b; +end; + +function CefInt64Set(int32_low, int32_high: Integer): Int64; +begin + Result := int32_low or (int32_high shl 32); +end; + +function CefInt64GetLow(const int64_val: Int64): Integer; +begin + Result := Integer(int64_val); +end; + +function CefInt64GetHigh(const int64_val: Int64): Integer; +begin + Result := (int64_val shr 32) and $FFFFFFFF; +end; + +procedure CefStringListToStringList(var aSrcSL : TCefStringList; var aDstSL : TStringList); +begin + CefStringListToStringList(aSrcSL, TStrings(aDstSL)); +end; + +procedure CefStringListToStringList(var aSrcSL : TCefStringList; var aDstSL : TStrings); +var + i, j : NativeUInt; + TempString : TCefString; +begin + if (aSrcSL <> nil) and (aDstSL <> nil) then + begin + i := 0; + j := pred(cef_string_list_size(aSrcSL)); + + while (i < j) do + begin + FillChar(TempString, SizeOf(TempString), 0); + cef_string_list_value(aSrcSL, i, @TempString); + aDstSL.Add(CefStringClearAndGet(TempString)); + inc(i); + end; + end; +end; + +function CefStringClearAndGet(var str: TCefString): ustring; +begin + Result := CefString(@str); + cef_string_utf16_clear(@str); +end; + +function CefGetObject(ptr: Pointer): TObject; inline; +begin + Dec(PByte(ptr), SizeOf(Pointer)); + Result := TObject(PPointer(ptr)^); +end; + +function CefGetData(const i: ICefBase): Pointer; inline; +begin + if (i <> nil) then + Result := i.Wrap + else + Result := nil; +end; + +function CefString(const str: PCefString): ustring; +begin + if str <> nil then + SetString(Result, str.str, str.length) + else + Result := ''; +end; + +function CefString(const str: ustring): TCefString; +begin + Result.str := PChar16(PWideChar(str)); + Result.length := Length(str); + Result.dtor := nil; +end; + +procedure CefStringFree(const str: PCefString); +begin + if str <> nil then + cef_string_utf16_clear(str); +end; + +procedure CefStringSet(const str: PCefString; const value: ustring); +begin + if str <> nil then + cef_string_utf16_set(PWideChar(value), Length(value), str, 1); +end; + +function CefStringFreeAndGet(const str: PCefStringUserFree): ustring; +begin + if str <> nil then + begin + Result := CefString(PCefString(str)); + cef_string_userfree_utf16_free(str); + end else + Result := ''; +end; + +function CefStringAlloc(const str: ustring): TCefString; +begin + FillChar(Result, SizeOf(Result), 0); + if str <> '' then + cef_string_wide_to_utf16(PWideChar(str), Length(str), @Result); +end; + +procedure _free_string(str: PChar16); stdcall; +begin + if str <> nil then + FreeMem(str); +end; + +function CefUserFreeString(const str: ustring): PCefStringUserFree; +begin + Result := cef_string_userfree_utf16_alloc; + Result.length := Length(str); + GetMem(Result.str, Result.length * SizeOf(TCefChar)); + Move(PCefChar(str)^, Result.str^, Result.length * SizeOf(TCefChar)); + Result.dtor := @_free_string; +end; + +function CefExecuteProcess(var app : ICefApp; aWindowsSandboxInfo : Pointer) : integer; +begin + Result := cef_execute_process(@HInstance, CefGetData(app), aWindowsSandboxInfo); +end; + +function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Handler): Boolean; +var + n, c: TCefString; +begin + n := CefString(name); + c := CefString(code); + Result := cef_register_extension(@n, @c, CefGetData(handler)) <> 0; +end; + +procedure CefPostTask(ThreadId: TCefThreadId; const task: ICefTask); +begin + cef_post_task(ThreadId, CefGetData(task)); +end; + +procedure CefPostDelayedTask(ThreadId: TCefThreadId; const task: ICefTask; delayMs: Int64); +begin + cef_post_delayed_task(ThreadId, CefGetData(task), delayMs); +end; + +function CefTimeToSystemTime(const dt: TCefTime): TSystemTime; +begin + Result.wYear := dt.year; + Result.wMonth := dt.month; + Result.wDayOfWeek := dt.day_of_week; + Result.wDay := dt.day_of_month; + Result.wHour := dt.hour; + Result.wMinute := dt.minute; + Result.wSecond := dt.second; + Result.wMilliseconds := dt.millisecond; +end; + +function SystemTimeToCefTime(const dt: TSystemTime): TCefTime; +begin + Result.year := dt.wYear; + Result.month := dt.wMonth; + Result.day_of_week := dt.wDayOfWeek; + Result.day_of_month := dt.wDay; + Result.hour := dt.wHour; + Result.minute := dt.wMinute; + Result.second := dt.wSecond; + Result.millisecond := dt.wMilliseconds; +end; + +function CefTimeToDateTime(const dt: TCefTime): TDateTime; +var + st: TSystemTime; +begin + st := CefTimeToSystemTime(dt); + SystemTimeToTzSpecificLocalTime(nil, @st, @st); + Result := SystemTimeToDateTime(st); +end; + +function DateTimeToCefTime(dt: TDateTime): TCefTime; +var + st: TSystemTime; +begin + DateTimeToSystemTime(dt, st); + TzSpecificLocalTimeToSystemTime(nil, @st, @st); + Result := SystemTimeToCefTime(st); +end; + +function cef_string_wide_copy(const src: PWideChar; src_len: NativeUInt; output: PCefStringWide): Integer; +begin + Result := cef_string_wide_set(src, src_len, output, ord(True)); +end; + +function cef_string_utf8_copy(const src: PAnsiChar; src_len: NativeUInt; output: PCefStringUtf8): Integer; +begin + Result := cef_string_utf8_set(src, src_len, output, ord(True)); +end; + +function cef_string_utf16_copy(const src: PChar16; src_len: NativeUInt; output: PCefStringUtf16): Integer; +begin + Result := cef_string_utf16_set(src, src_len, output, ord(True)); +end; + +function cef_string_copy(const src: PCefChar; src_len: NativeUInt; output: PCefString): Integer; +begin + Result := cef_string_utf16_set(src, src_len, output, ord(True)); +end; + +procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : THandle; aRect : TRect; const aWindowName : string); +begin + aWindowInfo.ex_style := 0; + aWindowInfo.window_name := CefString(aWindowName); + aWindowInfo.style := WS_CHILD or WS_VISIBLE or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or WS_TABSTOP; + aWindowInfo.x := aRect.left; + aWindowInfo.y := aRect.top; + aWindowInfo.width := aRect.right - aRect.left; + aWindowInfo.height := aRect.bottom - aRect.top; + aWindowInfo.parent_window := aParent; + aWindowInfo.menu := 0; + aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.transparent_painting_enabled := ord(False); + aWindowInfo.window := 0; +end; + +procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle; const aWindowName : string); +begin + aWindowInfo.ex_style := 0; + aWindowInfo.window_name := CefString(aWindowName); + aWindowInfo.style := WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or WS_VISIBLE; + aWindowInfo.x := integer(CW_USEDEFAULT); + aWindowInfo.y := integer(CW_USEDEFAULT); + aWindowInfo.width := integer(CW_USEDEFAULT); + aWindowInfo.height := integer(CW_USEDEFAULT); + aWindowInfo.parent_window := aParent; + aWindowInfo.menu := 0; + aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.transparent_painting_enabled := ord(False); + aWindowInfo.window := 0; +end; + +procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle; aTransparent : boolean; const aWindowName : string); +begin + aWindowInfo.ex_style := 0; + aWindowInfo.window_name := CefString(aWindowName); + aWindowInfo.style := 0; + aWindowInfo.x := 0; + aWindowInfo.y := 0; + aWindowInfo.width := 0; + aWindowInfo.height := 0; + aWindowInfo.parent_window := aParent; + aWindowInfo.menu := 0; + aWindowInfo.windowless_rendering_enabled := ord(True); + aWindowInfo.transparent_painting_enabled := ord(aTransparent); + aWindowInfo.window := 0; +end; + +function CefIsCertStatusError(Status : TCefCertStatus) : boolean; +begin + Result := (cef_is_cert_status_error(Status) <> 0); +end; + +function CefIsCertStatusMinorError(Status : TCefCertStatus) : boolean; +begin + Result := (cef_is_cert_status_minor_error(Status) <> 0); +end; + +function CefCrashReportingEnabled : boolean; +begin + Result := (cef_crash_reporting_enabled <> 0); +end; + +procedure CefSetCrashKeyValue(const aKey, aValue : ustring); +var + TempKey, TempValue : TCefString; +begin + TempKey := CefString(aKey); + TempValue := CefString(aValue); + cef_set_crash_key_value(@TempKey, @TempValue); +end; + + + +end. diff --git a/uCEFNavigationEntry.pas b/uCEFNavigationEntry.pas new file mode 100644 index 00000000..e3c0c248 --- /dev/null +++ b/uCEFNavigationEntry.pas @@ -0,0 +1,131 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFNavigationEntry; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefNavigationEntryRef = class(TCefBaseRef, ICefNavigationEntry) + protected + function IsValid: Boolean; + function GetUrl: ustring; + function GetDisplayUrl: ustring; + function GetOriginalUrl: ustring; + function GetTitle: ustring; + function GetTransitionType: TCefTransitionType; + function HasPostData: Boolean; + function GetCompletionTime: TDateTime; + function GetHttpStatusCode: Integer; + function GetSSLStatus: ICefSSLStatus; + + public + class function UnWrap(data: Pointer): ICefNavigationEntry; + end; + +implementation + +uses + uCEFMiscFunctions, uCefSSLStatus; + +function TCefNavigationEntryRef.IsValid: Boolean; +begin + Result := PCefNavigationEntry(FData).is_valid(FData) <> 0; +end; + +function TCefNavigationEntryRef.GetUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefNavigationEntry(FData).get_url(FData)); +end; + +function TCefNavigationEntryRef.GetDisplayUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefNavigationEntry(FData).get_display_url(FData)); +end; + +function TCefNavigationEntryRef.GetOriginalUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefNavigationEntry(FData).get_original_url(FData)); +end; + +function TCefNavigationEntryRef.GetTitle: ustring; +begin + Result := CefStringFreeAndGet(PCefNavigationEntry(FData).get_title(FData)); +end; + +function TCefNavigationEntryRef.GetTransitionType: TCefTransitionType; +begin + Result := PCefNavigationEntry(FData).get_transition_type(FData); +end; + +function TCefNavigationEntryRef.HasPostData: Boolean; +begin + Result := PCefNavigationEntry(FData).has_post_data(FData) <> 0; +end; + +function TCefNavigationEntryRef.GetCompletionTime: TDateTime; +begin + Result := CefTimeToDateTime(PCefNavigationEntry(FData).get_completion_time(FData)); +end; + +function TCefNavigationEntryRef.GetHttpStatusCode: Integer; +begin + Result := PCefNavigationEntry(FData).get_http_status_code(FData); +end; + +function TCefNavigationEntryRef.GetSSLStatus: ICefSSLStatus; +begin + Result := TCefSSLStatusRef.UnWrap(PCefNavigationEntry(FData).get_sslstatus(FData)); +end; + +class function TCefNavigationEntryRef.UnWrap(data: Pointer): ICefNavigationEntry; +begin + if (data <> nil) then + Result := Create(data) as ICefNavigationEntry + else + Result := nil; +end; + +end. diff --git a/uCEFNavigationEntryVisitor.pas b/uCEFNavigationEntryVisitor.pas new file mode 100644 index 00000000..1aac5025 --- /dev/null +++ b/uCEFNavigationEntryVisitor.pas @@ -0,0 +1,110 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFNavigationEntryVisitor; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces; + +type + TCefNavigationEntryVisitorOwn = class(TCefBaseOwn, ICefNavigationEntryVisitor) + protected + function Visit(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer): Boolean; virtual; + + public + constructor Create; + end; + + TCefFastNavigationEntryVisitor = class(TCefNavigationEntryVisitorOwn) + protected + FVisitor: TCefNavigationEntryVisitorProc; + + function Visit(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer): Boolean; override; + + public + constructor Create(const proc: TCefNavigationEntryVisitorProc); reintroduce; + end; + +implementation + +uses + uCEFTypes, uCEFMiscFunctions, uCEFNavigationEntry; + +function cef_navigation_entry_visitor_visit(self: PCefNavigationEntryVisitor; entry: PCefNavigationEntry; current, index, total: Integer): Integer; stdcall; +begin + with TCefNavigationEntryVisitorOwn(CefGetObject(self)) do + Result := Ord(Visit(TCefNavigationEntryRef.UnWrap(entry), current <> 0, index, total)); +end; + +// TCefNavigationEntryVisitorOwn + +constructor TCefNavigationEntryVisitorOwn.Create; +begin + CreateData(SizeOf(TCefNavigationEntryVisitor), False); + with PCefNavigationEntryVisitor(FData)^ do + visit := cef_navigation_entry_visitor_visit; +end; + +function TCefNavigationEntryVisitorOwn.Visit(const entry: ICefNavigationEntry; + current: Boolean; index, total: Integer): Boolean; +begin + Result:= False; +end; + +// TCefFastNavigationEntryVisitor + +constructor TCefFastNavigationEntryVisitor.Create( + const proc: TCefNavigationEntryVisitorProc); +begin + FVisitor := proc; + inherited Create; +end; + +function TCefFastNavigationEntryVisitor.Visit(const entry: ICefNavigationEntry; + current: Boolean; index, total: Integer): Boolean; +begin + Result := FVisitor(entry, current, index, total); +end; + +end. diff --git a/uCEFPDFPrintCallback.pas b/uCEFPDFPrintCallback.pas new file mode 100644 index 00000000..6de30cb9 --- /dev/null +++ b/uCEFPDFPrintCallback.pas @@ -0,0 +1,124 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPDFPrintCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefPdfPrintCallbackOwn = class(TCefBaseOwn, ICefPdfPrintCallback) + protected + procedure OnPdfPrintFinished(const path: ustring; ok: Boolean); virtual; abstract; + + public + constructor Create; virtual; + end; + + TCefFastPdfPrintCallback = class(TCefPdfPrintCallbackOwn) + protected + FProc: TOnPdfPrintFinishedProc; + + procedure OnPdfPrintFinished(const path: ustring; ok: Boolean); override; + + public + constructor Create(const proc: TOnPdfPrintFinishedProc); reintroduce; + end; + + TCefPDFPrintCallBack = class(TCefPdfPrintCallbackOwn) + protected + FChromiumBrowser : TObject; + + procedure OnPdfPrintFinished(const path: ustring; aResultOK : Boolean); override; + + public + constructor Create(const aChromiumBrowser : TObject); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFChromium; + +procedure cef_pdf_print_callback_on_pdf_print_finished(self: PCefPdfPrintCallback; const path: PCefString; ok: Integer); stdcall; +begin + with TCefPdfPrintCallbackOwn(CefGetObject(self)) do OnPdfPrintFinished(CefString(path), ok <> 0); +end; + +constructor TCefPdfPrintCallbackOwn.Create; +begin + CreateData(SizeOf(TCefPdfPrintCallback), False); + + with PCefPdfPrintCallback(FData)^ do on_pdf_print_finished := cef_pdf_print_callback_on_pdf_print_finished; +end; + +// TCefFastPdfPrintCallback + +constructor TCefFastPdfPrintCallback.Create(const proc: TOnPdfPrintFinishedProc); +begin + FProc := proc; + inherited Create; +end; + +procedure TCefFastPdfPrintCallback.OnPdfPrintFinished(const path: ustring; ok: Boolean); +begin + FProc(path, ok); +end; + +// TCefPDFPrintCallBack + +constructor TCefPDFPrintCallBack.Create(const aChromiumBrowser : TObject); +begin + inherited Create; + + FChromiumBrowser := aChromiumBrowser; +end; + +procedure TCefPDFPrintCallBack.OnPdfPrintFinished(const path: ustring; aResultOK : Boolean); +begin + if (FChromiumBrowser <> nil) and (FChromiumBrowser is TChromium) then + TChromium(FChromiumBrowser).PdfPrintFinished(aResultOK); +end; + +end. diff --git a/uCEFPDFPrintOptions.pas b/uCEFPDFPrintOptions.pas new file mode 100644 index 00000000..92cbe89a --- /dev/null +++ b/uCEFPDFPrintOptions.pas @@ -0,0 +1,100 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPDFPrintOptions; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFTypes; + +type + TPDFPrintOptions = class(TPersistent) + protected + Fpage_width : integer; + Fpage_height : Integer; + Fmargin_top : double; + Fmargin_right : double; + Fmargin_bottom : double; + Fmargin_left : double; + Fmargin_type : TCefPdfPrintMarginType; + Fheader_footer_enabled : integer; + Fselection_only : integer; + Flandscape : integer; + Fbackgrounds_enabled : integer; + + public + constructor Create; virtual; + + published + property page_width : integer read Fpage_width write Fpage_width default 0; + property page_height : Integer read Fpage_height write Fpage_height default 0; + property margin_top : double read Fmargin_top write Fmargin_top; + property margin_right : double read Fmargin_right write Fmargin_right; + property margin_bottom : double read Fmargin_bottom write Fmargin_bottom; + property margin_left : double read Fmargin_left write Fmargin_left; + property margin_type : TCefPdfPrintMarginType read Fmargin_type write Fmargin_type default PDF_PRINT_MARGIN_DEFAULT; + property header_footer_enabled : integer read Fheader_footer_enabled write Fheader_footer_enabled default 0; + property selection_only : integer read Fselection_only write Fselection_only default 0; + property landscape : integer read Flandscape write Flandscape default 0; + property backgrounds_enabled : integer read Fbackgrounds_enabled write Fbackgrounds_enabled default 0; + end; + +implementation + +constructor TPDFPrintOptions.Create; +begin + Fpage_width := 0; + Fpage_height := 0; + Fmargin_top := 0; + Fmargin_right := 0; + Fmargin_bottom := 0; + Fmargin_left := 0; + Fmargin_type := PDF_PRINT_MARGIN_DEFAULT; + Fheader_footer_enabled := 0; + Fselection_only := 0; + Flandscape := 0; + Fbackgrounds_enabled := 0; +end; + +end. diff --git a/uCEFPostData.pas b/uCEFPostData.pas new file mode 100644 index 00000000..ddd67581 --- /dev/null +++ b/uCEFPostData.pas @@ -0,0 +1,134 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPostData; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefPostDataRef = class(TCefBaseRef, ICefPostData) + protected + function IsReadOnly: Boolean; + function HasExcludedElements: Boolean; + function GetCount: NativeUInt; + function GetElements(Count: NativeUInt): IInterfaceList; // ICefPostDataElement + function RemoveElement(const element: ICefPostDataElement): Integer; + function AddElement(const element: ICefPostDataElement): Integer; + procedure RemoveElements; + + public + class function UnWrap(data: Pointer): ICefPostData; + class function New: ICefPostData; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFPostDataElement; + + +function TCefPostDataRef.IsReadOnly: Boolean; +begin + Result := PCefPostData(FData)^.is_read_only(PCefPostData(FData)) <> 0; +end; + +function TCefPostDataRef.HasExcludedElements: Boolean; +begin + Result := PCefPostData(FData)^.has_excluded_elements(PCefPostData(FData)) <> 0; +end; + +function TCefPostDataRef.AddElement( + const element: ICefPostDataElement): Integer; +begin + Result := PCefPostData(FData)^.add_element(PCefPostData(FData), CefGetData(element)); +end; + +function TCefPostDataRef.GetCount: NativeUInt; +begin + Result := PCefPostData(FData)^.get_element_count(PCefPostData(FData)) +end; + +function TCefPostDataRef.GetElements(Count: NativeUInt): IInterfaceList; +var + items: PCefPostDataElementArray; + i: Integer; +begin + Result := TInterfaceList.Create; + GetMem(items, SizeOf(PCefPostDataElement) * Count); + FillChar(items^, SizeOf(PCefPostDataElement) * Count, 0); + try + PCefPostData(FData)^.get_elements(PCefPostData(FData), @Count, items); + for i := 0 to Count - 1 do + Result.Add(TCefPostDataElementRef.UnWrap(items[i])); + finally + FreeMem(items); + end; +end; + +class function TCefPostDataRef.New: ICefPostData; +begin + Result := UnWrap(cef_post_data_create); +end; + +function TCefPostDataRef.RemoveElement( + const element: ICefPostDataElement): Integer; +begin + Result := PCefPostData(FData)^.remove_element(PCefPostData(FData), CefGetData(element)); +end; + +procedure TCefPostDataRef.RemoveElements; +begin + PCefPostData(FData)^.remove_elements(PCefPostData(FData)); +end; + +class function TCefPostDataRef.UnWrap(data: Pointer): ICefPostData; +begin + if data <> nil then + Result := Create(data) as ICefPostData else + Result := nil; +end; + +end. diff --git a/uCEFPostDataElement.pas b/uCEFPostDataElement.pas new file mode 100644 index 00000000..f001ac0a --- /dev/null +++ b/uCEFPostDataElement.pas @@ -0,0 +1,304 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPostDataElement; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefPostDataElementRef = class(TCefBaseRef, ICefPostDataElement) + protected + function IsReadOnly: Boolean; + procedure SetToEmpty; + procedure SetToFile(const fileName: ustring); + procedure SetToBytes(size: NativeUInt; bytes: Pointer); + function GetType: TCefPostDataElementType; + function GetFile: ustring; + function GetBytesCount: NativeUInt; + function GetBytes(size: NativeUInt; bytes: Pointer): NativeUInt; + + public + class function UnWrap(data: Pointer): ICefPostDataElement; + class function New: ICefPostDataElement; + end; + + TCefPostDataElementOwn = class(TCefBaseOwn, ICefPostDataElement) + protected + FDataType: TCefPostDataElementType; + FValueByte: Pointer; + FValueStr: TCefString; + FSize: NativeUInt; + FReadOnly: Boolean; + + procedure Clear; + function IsReadOnly: Boolean; virtual; + procedure SetToEmpty; virtual; + procedure SetToFile(const fileName: ustring); virtual; + procedure SetToBytes(size: NativeUInt; bytes: Pointer); virtual; + function GetType: TCefPostDataElementType; virtual; + function GetFile: ustring; virtual; + function GetBytesCount: NativeUInt; virtual; + function GetBytes(size: NativeUInt; bytes: Pointer): NativeUInt; virtual; + + public + constructor Create(readonly: Boolean); virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +function cef_post_data_element_is_read_only(self: PCefPostDataElement): Integer; stdcall; +begin + with TCefPostDataElementOwn(CefGetObject(self)) do + Result := Ord(IsReadOnly) +end; + +procedure cef_post_data_element_set_to_empty(self: PCefPostDataElement); stdcall; +begin + with TCefPostDataElementOwn(CefGetObject(self)) do + SetToEmpty; +end; + +procedure cef_post_data_element_set_to_file(self: PCefPostDataElement; const fileName: PCefString); stdcall; +begin + with TCefPostDataElementOwn(CefGetObject(self)) do + SetToFile(CefString(fileName)); +end; + +procedure cef_post_data_element_set_to_bytes(self: PCefPostDataElement; size: NativeUInt; const bytes: Pointer); stdcall; +begin + with TCefPostDataElementOwn(CefGetObject(self)) do + SetToBytes(size, bytes); +end; + +function cef_post_data_element_get_type(self: PCefPostDataElement): TCefPostDataElementType; stdcall; +begin + with TCefPostDataElementOwn(CefGetObject(self)) do + Result := GetType; +end; + +function cef_post_data_element_get_file(self: PCefPostDataElement): PCefStringUserFree; stdcall; +begin + with TCefPostDataElementOwn(CefGetObject(self)) do + Result := CefUserFreeString(GetFile); +end; + +function cef_post_data_element_get_bytes_count(self: PCefPostDataElement): NativeUInt; stdcall; +begin + with TCefPostDataElementOwn(CefGetObject(self)) do + Result := GetBytesCount; +end; + +function cef_post_data_element_get_bytes(self: PCefPostDataElement; size: NativeUInt; bytes: Pointer): NativeUInt; stdcall; +begin + with TCefPostDataElementOwn(CefGetObject(self)) do + Result := GetBytes(size, bytes) +end; + +function TCefPostDataElementRef.IsReadOnly: Boolean; +begin + Result := PCefPostDataElement(FData)^.is_read_only(PCefPostDataElement(FData)) <> 0; +end; + +function TCefPostDataElementRef.GetBytes(size: NativeUInt; + bytes: Pointer): NativeUInt; +begin + Result := PCefPostDataElement(FData)^.get_bytes(PCefPostDataElement(FData), size, bytes); +end; + +function TCefPostDataElementRef.GetBytesCount: NativeUInt; +begin + Result := PCefPostDataElement(FData)^.get_bytes_count(PCefPostDataElement(FData)); +end; + +function TCefPostDataElementRef.GetFile: ustring; +begin + Result := CefStringFreeAndGet(PCefPostDataElement(FData)^.get_file(PCefPostDataElement(FData))); +end; + +function TCefPostDataElementRef.GetType: TCefPostDataElementType; +begin + Result := PCefPostDataElement(FData)^.get_type(PCefPostDataElement(FData)); +end; + +class function TCefPostDataElementRef.New: ICefPostDataElement; +begin + Result := UnWrap(cef_post_data_element_create); +end; + +procedure TCefPostDataElementRef.SetToBytes(size: NativeUInt; bytes: Pointer); +begin + PCefPostDataElement(FData)^.set_to_bytes(PCefPostDataElement(FData), size, bytes); +end; + +procedure TCefPostDataElementRef.SetToEmpty; +begin + PCefPostDataElement(FData)^.set_to_empty(PCefPostDataElement(FData)); +end; + +procedure TCefPostDataElementRef.SetToFile(const fileName: ustring); +var + f: TCefString; +begin + f := CefString(fileName); + PCefPostDataElement(FData)^.set_to_file(PCefPostDataElement(FData), @f); +end; + +class function TCefPostDataElementRef.UnWrap(data: Pointer): ICefPostDataElement; +begin + if data <> nil then + Result := Create(data) as ICefPostDataElement else + Result := nil; +end; + +// TCefPostDataElementOwn + +procedure TCefPostDataElementOwn.Clear; +begin + case FDataType of + PDE_TYPE_BYTES: + if (FValueByte <> nil) then + begin + FreeMem(FValueByte); + FValueByte := nil; + end; + PDE_TYPE_FILE: + CefStringFree(@FValueStr) + end; + FDataType := PDE_TYPE_EMPTY; + FSize := 0; +end; + +constructor TCefPostDataElementOwn.Create(readonly: Boolean); +begin + inherited CreateData(SizeOf(TCefPostDataElement)); + FReadOnly := readonly; + FDataType := PDE_TYPE_EMPTY; + FValueByte := nil; + FillChar(FValueStr, SizeOf(FValueStr), 0); + FSize := 0; + with PCefPostDataElement(FData)^ do + begin + is_read_only := cef_post_data_element_is_read_only; + set_to_empty := cef_post_data_element_set_to_empty; + set_to_file := cef_post_data_element_set_to_file; + set_to_bytes := cef_post_data_element_set_to_bytes; + get_type := cef_post_data_element_get_type; + get_file := cef_post_data_element_get_file; + get_bytes_count := cef_post_data_element_get_bytes_count; + get_bytes := cef_post_data_element_get_bytes; + end; +end; + +function TCefPostDataElementOwn.GetBytes(size: NativeUInt; + bytes: Pointer): NativeUInt; +begin + if (FDataType = PDE_TYPE_BYTES) and (FValueByte <> nil) then + begin + if size > FSize then + Result := FSize else + Result := size; + Move(FValueByte^, bytes^, Result); + end else + Result := 0; +end; + +function TCefPostDataElementOwn.GetBytesCount: NativeUInt; +begin + if (FDataType = PDE_TYPE_BYTES) then + Result := FSize else + Result := 0; +end; + +function TCefPostDataElementOwn.GetFile: ustring; +begin + if (FDataType = PDE_TYPE_FILE) then + Result := CefString(@FValueStr) else + Result := ''; +end; + +function TCefPostDataElementOwn.GetType: TCefPostDataElementType; +begin + Result := FDataType; +end; + +function TCefPostDataElementOwn.IsReadOnly: Boolean; +begin + Result := FReadOnly; +end; + +procedure TCefPostDataElementOwn.SetToBytes(size: NativeUInt; bytes: Pointer); +begin + Clear; + if (size > 0) and (bytes <> nil) then + begin + GetMem(FValueByte, size); + Move(bytes^, FValueByte, size); + FSize := size; + end else + begin + FValueByte := nil; + FSize := 0; + end; + FDataType := PDE_TYPE_BYTES; +end; + +procedure TCefPostDataElementOwn.SetToEmpty; +begin + Clear; +end; + +procedure TCefPostDataElementOwn.SetToFile(const fileName: ustring); +begin + Clear; + FSize := 0; + FValueStr := CefStringAlloc(fileName); + FDataType := PDE_TYPE_FILE; +end; + +end. diff --git a/uCEFPrintSettings.pas b/uCEFPrintSettings.pas new file mode 100644 index 00000000..ea6ca54e --- /dev/null +++ b/uCEFPrintSettings.pas @@ -0,0 +1,233 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPrintSettings; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefPrintSettingsRef = class(TCefBaseRef, ICefPrintSettings) + protected + function IsValid: Boolean; + function IsReadOnly: Boolean; + function Copy: ICefPrintSettings; + procedure SetOrientation(landscape: Boolean); + function IsLandscape: Boolean; + procedure SetPrinterPrintableArea(const physicalSizeDeviceUnits: PCefSize; const printableAreaDeviceUnits: PCefRect; landscapeNeedsFlip: Boolean); stdcall; + procedure SetDeviceName(const name: ustring); + function GetDeviceName: ustring; + procedure SetDpi(dpi: Integer); + function GetDpi: Integer; + procedure SetPageRanges(const ranges: TCefRangeArray); + function GetPageRangesCount: NativeUInt; + procedure GetPageRanges(out ranges: TCefRangeArray); + procedure SetSelectionOnly(selectionOnly: Boolean); + function IsSelectionOnly: Boolean; + procedure SetCollate(collate: Boolean); + function WillCollate: Boolean; + procedure SetColorModel(model: TCefColorModel); + function GetColorModel: TCefColorModel; + procedure SetCopies(copies: Integer); + function GetCopies: Integer; + procedure SetDuplexMode(mode: TCefDuplexMode); + function GetDuplexMode: TCefDuplexMode; + public + class function New: ICefPrintSettings; + class function UnWrap(data: Pointer): ICefPrintSettings; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +function TCefPrintSettingsRef.Copy: ICefPrintSettings; +begin + Result := UnWrap(PCefPrintSettings(FData).copy(FData)) +end; + +function TCefPrintSettingsRef.GetColorModel: TCefColorModel; +begin + Result := PCefPrintSettings(FData).get_color_model(FData); +end; + +function TCefPrintSettingsRef.GetCopies: Integer; +begin + Result := PCefPrintSettings(FData).get_copies(FData); +end; + +function TCefPrintSettingsRef.GetDeviceName: ustring; +begin + Result := CefStringFreeAndGet(PCefPrintSettings(FData).get_device_name(FData)); +end; + +function TCefPrintSettingsRef.GetDpi: Integer; +begin + Result := PCefPrintSettings(FData).get_dpi(FData); +end; + +function TCefPrintSettingsRef.GetDuplexMode: TCefDuplexMode; +begin + Result := PCefPrintSettings(FData).get_duplex_mode(FData); +end; + +procedure TCefPrintSettingsRef.GetPageRanges( + out ranges: TCefRangeArray); +var + len: NativeUInt; +begin + len := GetPageRangesCount; + SetLength(ranges, len); + if len > 0 then + PCefPrintSettings(FData).get_page_ranges(FData, @len, @ranges[0]); +end; + +function TCefPrintSettingsRef.GetPageRangesCount: NativeUInt; +begin + Result := PCefPrintSettings(FData).get_page_ranges_count(FData); +end; + +function TCefPrintSettingsRef.IsLandscape: Boolean; +begin + Result := PCefPrintSettings(FData).is_landscape(FData) <> 0; +end; + +function TCefPrintSettingsRef.IsReadOnly: Boolean; +begin + Result := PCefPrintSettings(FData).is_read_only(FData) <> 0; +end; + +function TCefPrintSettingsRef.IsSelectionOnly: Boolean; +begin + Result := PCefPrintSettings(FData).is_selection_only(FData) <> 0; +end; + +function TCefPrintSettingsRef.IsValid: Boolean; +begin + Result := PCefPrintSettings(FData).is_valid(FData) <> 0; +end; + +class function TCefPrintSettingsRef.New: ICefPrintSettings; +begin + Result := UnWrap(cef_print_settings_create); +end; + +procedure TCefPrintSettingsRef.SetCollate(collate: Boolean); +begin + PCefPrintSettings(FData).set_collate(FData, Ord(collate)); +end; + +procedure TCefPrintSettingsRef.SetColorModel(model: TCefColorModel); +begin + PCefPrintSettings(FData).set_color_model(FData, model); +end; + +procedure TCefPrintSettingsRef.SetCopies(copies: Integer); +begin + PCefPrintSettings(FData).set_copies(FData, copies); +end; + +procedure TCefPrintSettingsRef.SetDeviceName(const name: ustring); +var + s: TCefString; +begin + s := CefString(name); + PCefPrintSettings(FData).set_device_name(FData, @s); +end; + +procedure TCefPrintSettingsRef.SetDpi(dpi: Integer); +begin + PCefPrintSettings(FData).set_dpi(FData, dpi); +end; + +procedure TCefPrintSettingsRef.SetDuplexMode(mode: TCefDuplexMode); +begin + PCefPrintSettings(FData).set_duplex_mode(FData, mode); +end; + +procedure TCefPrintSettingsRef.SetOrientation(landscape: Boolean); +begin + PCefPrintSettings(FData).set_orientation(FData, Ord(landscape)); +end; + +procedure TCefPrintSettingsRef.SetPageRanges( + const ranges: TCefRangeArray); +var + len: NativeUInt; +begin + len := Length(ranges); + if len > 0 then + PCefPrintSettings(FData).set_page_ranges(FData, len, @ranges[0]) else + PCefPrintSettings(FData).set_page_ranges(FData, 0, nil); +end; + +procedure TCefPrintSettingsRef.SetPrinterPrintableArea( + const physicalSizeDeviceUnits: PCefSize; + const printableAreaDeviceUnits: PCefRect; landscapeNeedsFlip: Boolean); +begin + PCefPrintSettings(FData).set_printer_printable_area(FData, physicalSizeDeviceUnits, + printableAreaDeviceUnits, Ord(landscapeNeedsFlip)); +end; + +procedure TCefPrintSettingsRef.SetSelectionOnly(selectionOnly: Boolean); +begin + PCefPrintSettings(FData).set_selection_only(FData, Ord(selectionOnly)); +end; + +class function TCefPrintSettingsRef.UnWrap( + data: Pointer): ICefPrintSettings; +begin + if data <> nil then + Result := Create(data) as ICefPrintSettings else + Result := nil; +end; + +function TCefPrintSettingsRef.WillCollate: Boolean; +begin + Result := PCefPrintSettings(FData).will_collate(FData) <> 0; +end; + +end. diff --git a/uCEFProcessMessage.pas b/uCEFProcessMessage.pas new file mode 100644 index 00000000..f2fc87c6 --- /dev/null +++ b/uCEFProcessMessage.pas @@ -0,0 +1,109 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFProcessMessage; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefProcessMessageRef = class(TCefBaseRef, ICefProcessMessage) + protected + function IsValid: Boolean; + function IsReadOnly: Boolean; + function Copy: ICefProcessMessage; + function GetName: ustring; + function GetArgumentList: ICefListValue; + + public + class function UnWrap(data: Pointer): ICefProcessMessage; + class function New(const name: ustring): ICefProcessMessage; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFListValue; + +function TCefProcessMessageRef.Copy: ICefProcessMessage; +begin + Result := UnWrap(PCefProcessMessage(FData)^.copy(PCefProcessMessage(FData))); +end; + +function TCefProcessMessageRef.GetArgumentList: ICefListValue; +begin + Result := TCefListValueRef.UnWrap(PCefProcessMessage(FData)^.get_argument_list(PCefProcessMessage(FData))); +end; + +function TCefProcessMessageRef.GetName: ustring; +begin + Result := CefStringFreeAndGet(PCefProcessMessage(FData)^.get_name(PCefProcessMessage(FData))); +end; + +function TCefProcessMessageRef.IsReadOnly: Boolean; +begin + Result := PCefProcessMessage(FData)^.is_read_only(PCefProcessMessage(FData)) <> 0; +end; + +function TCefProcessMessageRef.IsValid: Boolean; +begin + Result := PCefProcessMessage(FData)^.is_valid(PCefProcessMessage(FData)) <> 0; +end; + +class function TCefProcessMessageRef.New(const name: ustring): ICefProcessMessage; +var + n: TCefString; +begin + n := CefString(name); + Result := UnWrap(cef_process_message_create(@n)); +end; + +class function TCefProcessMessageRef.UnWrap(data: Pointer): ICefProcessMessage; +begin + if data <> nil then + Result := Create(data) as ICefProcessMessage else + Result := nil; +end; + +end. diff --git a/uCEFRegisterCDMCallback.pas b/uCEFRegisterCDMCallback.pas new file mode 100644 index 00000000..7b57818b --- /dev/null +++ b/uCEFRegisterCDMCallback.pas @@ -0,0 +1,113 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRegisterCDMCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefRegisterCDMProc = reference to procedure(result: TCefCDMRegistrationError; const error_message: ustring); + + TCefRegisterCDMCallbackOwn = class(TCefBaseOwn, ICefRegisterCDMCallback) + protected + procedure OnCDMRegistrationComplete(result: TCefCDMRegistrationError; const error_message: ustring); virtual; + + public + constructor Create; virtual; + end; + + TCefFastRegisterCDMCallback = class(TCefRegisterCDMCallbackOwn) + protected + FCallback: TCefRegisterCDMProc; + + procedure OnCDMRegistrationComplete(result: TCefCDMRegistrationError; const error_message: ustring); override; + + public + constructor Create(const callback: TCefRegisterCDMProc); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure cef_register_cdm_callback_on_cdm_registration_complete(self:PCefRegisterCDMCallback; + result: TCefCDMRegistrationError; + const error_message: PCefString); stdcall; +begin + with TCefRegisterCDMCallbackOwn(CefGetObject(self)) do + OnCDMRegistrationComplete(result, CefString(error_message)); +end; + +// TCefRegisterCDMCallbackOwn + +constructor TCefRegisterCDMCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefRegisterCDMCallback)); + + PCefRegisterCDMCallback(FData).on_cdm_registration_complete := cef_register_cdm_callback_on_cdm_registration_complete; +end; + +procedure TCefRegisterCDMCallbackOwn.OnCDMRegistrationComplete(result: TCefCDMRegistrationError; + const error_message: ustring); +begin + // +end; + +// TCefFastRegisterCDMCallback + +constructor TCefFastRegisterCDMCallback.Create(const callback: TCefRegisterCDMProc); +begin + FCallback := callback; +end; + +procedure TCefFastRegisterCDMCallback.OnCDMRegistrationComplete(result: TCefCDMRegistrationError; + const error_message: ustring); +begin + FCallback(result, error_message); +end; + + +end. diff --git a/uCEFRegisterComponents.pas b/uCEFRegisterComponents.pas new file mode 100644 index 00000000..9e24bb66 --- /dev/null +++ b/uCEFRegisterComponents.pas @@ -0,0 +1,58 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRegisterComponents; + +{$R chromium.dcr} + +interface + +procedure Register; + +implementation +uses + System.Classes, + uCEFChromium, + uCEFWindowParent, + uCEFChromiumWindow; + +procedure Register; +begin + RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow]); +end; + +end. diff --git a/uCEFRenderHandler.pas b/uCEFRenderHandler.pas new file mode 100644 index 00000000..45e007f2 --- /dev/null +++ b/uCEFRenderHandler.pas @@ -0,0 +1,370 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRenderHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefRenderHandlerOwn = class(TCefBaseOwn, ICefRenderHandler) + protected + function GetRootScreenRect(const browser: ICefBrowser; rect: PCefRect): Boolean; virtual; + function GetViewRect(const browser: ICefBrowser; rect: PCefRect): Boolean; virtual; + function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; screenX, screenY: PInteger): Boolean; virtual; + function GetScreenInfo(const browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean; virtual; + procedure OnPopupShow(const browser: ICefBrowser; show: Boolean); virtual; + procedure OnPopupSize(const browser: ICefBrowser; const rect: PCefRect); virtual; + procedure OnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); virtual; + procedure OnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); virtual; + function OnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; virtual; + procedure OnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); virtual; + procedure OnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); virtual; + procedure OnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); virtual; + + public + constructor Create; virtual; + end; + + TCustomRenderHandler = class(TCefRenderHandlerOwn) + protected + FEvent: IChromiumEvents; + + function GetRootScreenRect(const browser: ICefBrowser; rect: PCefRect): Boolean; override; + function GetViewRect(const browser: ICefBrowser; rect: PCefRect): Boolean; override; + function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; screenX, screenY: PInteger): Boolean; override; + procedure OnPopupShow(const browser: ICefBrowser; show: Boolean); override; + procedure OnPopupSize(const browser: ICefBrowser; const rect: PCefRect); override; + procedure OnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); override; + procedure OnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); override; + function GetScreenInfo(const browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean; override; + function OnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; override; + procedure OnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); override; + procedure OnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); override; + procedure OnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFDragData; + + +function cef_render_handler_get_root_screen_rect(self: PCefRenderHandler; + browser: PCefBrowser; rect: PCefRect): Integer; stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + Result := Ord(GetRootScreenRect(TCefBrowserRef.UnWrap(browser), rect)); +end; + +function cef_render_handler_get_view_rect(self: PCefRenderHandler; + browser: PCefBrowser; rect: PCefRect): Integer; stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + Result := Ord(GetViewRect(TCefBrowserRef.UnWrap(browser), rect)); +end; + +function cef_render_handler_get_screen_point(self: PCefRenderHandler; + browser: PCefBrowser; viewX, viewY: Integer; screenX, screenY: PInteger): Integer; stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + Result := Ord(GetScreenPoint(TCefBrowserRef.UnWrap(browser), viewX, viewY, screenX, screenY)); +end; + +function cef_render_handler_get_screen_info(self: PCefRenderHandler; + browser: PCefBrowser; screen_info: PCefScreenInfo): Integer; stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + Result := Ord(GetScreenInfo(TCefBrowserRef.UnWrap(browser), screen_info)); +end; + +procedure cef_render_handler_on_popup_show(self: PCefRenderProcessHandler; + browser: PCefBrowser; show: Integer); stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + OnPopupShow(TCefBrowserRef.UnWrap(browser), show <> 0); +end; + +procedure cef_render_handler_on_popup_size(self: PCefRenderProcessHandler; + browser: PCefBrowser; const rect: PCefRect); stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + OnPopupSize(TCefBrowserRef.UnWrap(browser), rect); +end; + +procedure cef_render_handler_on_paint(self: PCefRenderProcessHandler; + browser: PCefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; + const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + OnPaint(TCefBrowserRef.UnWrap(browser), kind, dirtyRectsCount, dirtyRects, + buffer, width, height); +end; + +procedure cef_render_handler_on_cursor_change(self: PCefRenderProcessHandler; + browser: PCefBrowser; cursor: TCefCursorHandle; type_: TCefCursorType; + const custom_cursor_info: PCefCursorInfo); stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + OnCursorChange(TCefBrowserRef.UnWrap(browser), cursor, type_, custom_cursor_info); +end; + +function cef_render_handler_start_dragging(self: PCefRenderProcessHandler; browser: PCefBrowser; + drag_data: PCefDragData; allowed_ops: TCefDragOperations; x, y: Integer): Integer; stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + Result := Ord(OnStartDragging(TCefBrowserRef.UnWrap(browser), + TCefDragDataRef.UnWrap(drag_data), allowed_ops, x, y)); +end; + +procedure cef_render_handler_update_drag_cursor(self: PCefRenderProcessHandler; + browser: PCefBrowser; operation: TCefDragOperation); stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + OnUpdateDragCursor(TCefBrowserRef.UnWrap(browser), operation); +end; + +procedure cef_render_handler_on_scroll_offset_changed(self: PCefRenderProcessHandler; + browser: PCefBrowser; x, y: Double); stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + OnScrollOffsetChanged(TCefBrowserRef.UnWrap(browser), x, y); +end; + +procedure cef_render_handler_on_ime_composition_range_changed(self: PCefRenderProcessHandler; + browser: PCefBrowser; + const selected_range: PCefRange; + character_boundsCount: NativeUInt; + const character_bounds: PCefRect); stdcall; +begin + with TCefRenderHandlerOwn(CefGetObject(self)) do + OnIMECompositionRangeChanged(TCefBrowserRef.UnWrap(browser), selected_range, character_boundsCount, character_bounds); +end; + +constructor TCefRenderHandlerOwn.Create; +begin + CreateData(SizeOf(TCefRenderHandler), False); + + with PCefRenderHandler(FData)^ do + begin + get_root_screen_rect := cef_render_handler_get_root_screen_rect; + get_view_rect := cef_render_handler_get_view_rect; + get_screen_point := cef_render_handler_get_screen_point; + on_popup_show := cef_render_handler_on_popup_show; + on_popup_size := cef_render_handler_on_popup_size; + on_paint := cef_render_handler_on_paint; + on_cursor_change := cef_render_handler_on_cursor_change; + start_dragging := cef_render_handler_start_dragging; + update_drag_cursor := cef_render_handler_update_drag_cursor; + on_scroll_offset_changed := cef_render_handler_on_scroll_offset_changed; + on_ime_composition_range_changed := cef_render_handler_on_ime_composition_range_changed; + end; +end; + +function TCefRenderHandlerOwn.GetRootScreenRect(const browser: ICefBrowser; + rect: PCefRect): Boolean; +begin + Result := False; +end; + +function TCefRenderHandlerOwn.GetScreenInfo(const browser: ICefBrowser; + screenInfo: PCefScreenInfo): Boolean; +begin + Result := False; +end; + +function TCefRenderHandlerOwn.GetScreenPoint(const browser: ICefBrowser; viewX, + viewY: Integer; screenX, screenY: PInteger): Boolean; +begin + Result := False; +end; + +function TCefRenderHandlerOwn.GetViewRect(const browser: ICefBrowser; + rect: PCefRect): Boolean; +begin + Result := False; +end; + +procedure TCefRenderHandlerOwn.OnCursorChange(const browser: ICefBrowser; + cursor: TCefCursorHandle; CursorType: TCefCursorType; + const customCursorInfo: PCefCursorInfo); +begin + +end; + +procedure TCefRenderHandlerOwn.OnPaint(const browser: ICefBrowser; + kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; + const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); +begin + +end; + +procedure TCefRenderHandlerOwn.OnPopupShow(const browser: ICefBrowser; + show: Boolean); +begin + +end; + +procedure TCefRenderHandlerOwn.OnPopupSize(const browser: ICefBrowser; + const rect: PCefRect); +begin + +end; + +procedure TCefRenderHandlerOwn.OnScrollOffsetChanged( + const browser: ICefBrowser; x, y: Double); +begin + +end; + +procedure TCefRenderHandlerOwn.OnIMECompositionRangeChanged(const browser : ICefBrowser; + const selected_range : PCefRange; + character_boundsCount : NativeUInt; + const character_bounds : PCefRect); +begin + +end; + +function TCefRenderHandlerOwn.OnStartDragging(const browser: ICefBrowser; + const dragData: ICefDragData; allowedOps: TCefDragOperations; x, + y: Integer): Boolean; +begin + Result := False; +end; + +procedure TCefRenderHandlerOwn.OnUpdateDragCursor(const browser: ICefBrowser; + operation: TCefDragOperation); +begin + +end; + +// TCustomRenderHandler + +constructor TCustomRenderHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +function TCustomRenderHandler.GetRootScreenRect(const browser: ICefBrowser; + rect: PCefRect): Boolean; +begin + Result := FEvent.doOnGetRootScreenRect(browser, rect); +end; + +function TCustomRenderHandler.GetScreenInfo(const browser: ICefBrowser; + screenInfo: PCefScreenInfo): Boolean; +begin + Result := FEvent.doOnGetScreenInfo(browser, screenInfo); +end; + +function TCustomRenderHandler.GetScreenPoint(const browser: ICefBrowser; viewX, + viewY: Integer; screenX, screenY: PInteger): Boolean; +begin + Result := FEvent.doOnGetScreenPoint(browser, viewX, viewY, screenX, screenY); +end; + +function TCustomRenderHandler.GetViewRect(const browser: ICefBrowser; + rect: PCefRect): Boolean; +begin + Result := FEvent.doOnGetViewRect(browser, rect); +end; + +procedure TCustomRenderHandler.OnCursorChange(const browser: ICefBrowser; + cursor: TCefCursorHandle; cursorType: TCefCursorType; + const customCursorInfo: PCefCursorInfo); +begin + FEvent.doOnCursorChange(browser, cursor, cursorType, customCursorInfo); +end; + +procedure TCustomRenderHandler.OnPaint(const browser: ICefBrowser; + kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; + const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); +begin + FEvent.doOnPaint(browser, kind, dirtyRectsCount, dirtyRects, buffer, width, height); +end; + +procedure TCustomRenderHandler.OnPopupShow(const browser: ICefBrowser; + show: Boolean); +begin + FEvent.doOnPopupShow(browser, show); +end; + +procedure TCustomRenderHandler.OnPopupSize(const browser: ICefBrowser; + const rect: PCefRect); +begin + FEvent.doOnPopupSize(browser, rect); +end; + +procedure TCustomRenderHandler.OnScrollOffsetChanged( + const browser: ICefBrowser; x, y: Double); +begin + FEvent.doOnScrollOffsetChanged(browser, x, y); +end; + +procedure TCustomRenderHandler.OnIMECompositionRangeChanged(const browser: ICefBrowser; + const selected_range: PCefRange; + character_boundsCount: NativeUInt; + const character_bounds: PCefRect); +begin + FEvent.doOnIMECompositionRangeChanged(browser, selected_range, character_boundsCount, character_bounds); +end; + +function TCustomRenderHandler.OnStartDragging(const browser: ICefBrowser; + const dragData: ICefDragData; allowedOps: TCefDragOperations; x, + y: Integer): Boolean; +begin + Result := FEvent.doOnStartDragging(browser, dragData, allowedOps, x, y); +end; + +procedure TCustomRenderHandler.OnUpdateDragCursor(const browser: ICefBrowser; + operation: TCefDragOperation); +begin + FEvent.doOnUpdateDragCursor(browser, operation); +end; + +end. diff --git a/uCEFRenderProcessHandler.pas b/uCEFRenderProcessHandler.pas new file mode 100644 index 00000000..2309f791 --- /dev/null +++ b/uCEFRenderProcessHandler.pas @@ -0,0 +1,249 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRenderProcessHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes, uCEFListValue, uCEFBrowser, uCEFFrame, uCEFRequest, + uCEFv8Context, uCEFv8Exception, uCEFv8StackTrace, uCEFDomNode, uCEFProcessMessage; + +type + TCefRenderProcessHandlerOwn = class(TCefBaseOwn, ICefRenderProcessHandler) + protected + procedure OnRenderThreadCreated(const extraInfo: ICefListValue); virtual; + procedure OnWebKitInitialized; virtual; + procedure OnBrowserCreated(const browser: ICefBrowser); virtual; + procedure OnBrowserDestroyed(const browser: ICefBrowser); virtual; + function GetLoadHandler: PCefLoadHandler; virtual; + function OnBeforeNavigation(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean): Boolean; virtual; + procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; + procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; + procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); virtual; + procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); virtual; + function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; virtual; + public + constructor Create; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +procedure cef_render_process_handler_on_render_thread_created( + self: PCefRenderProcessHandler; extra_info: PCefListValue); stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + OnRenderThreadCreated(TCefListValueRef.UnWrap(extra_info)); +end; + +procedure cef_render_process_handler_on_web_kit_initialized(self: PCefRenderProcessHandler); stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + OnWebKitInitialized; +end; + +procedure cef_render_process_handler_on_browser_created(self: PCefRenderProcessHandler; + browser: PCefBrowser); stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + OnBrowserCreated(TCefBrowserRef.UnWrap(browser)); +end; + +procedure cef_render_process_handler_on_browser_destroyed(self: PCefRenderProcessHandler; + browser: PCefBrowser); stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + OnBrowserDestroyed(TCefBrowserRef.UnWrap(browser)); +end; + +function cef_render_process_handler_get_load_handler(self: PCefRenderProcessHandler): PCefLoadHandler; stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + Result := GetLoadHandler(); +end; + +function cef_render_process_handler_on_before_navigation(self: PCefRenderProcessHandler; + browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; + navigation_type: TCefNavigationType; is_redirect: Integer): Integer; stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + Result := Ord(OnBeforeNavigation(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), TCefRequestRef.UnWrap(request), + navigation_type, is_redirect <> 0)); +end; + +procedure cef_render_process_handler_on_context_created(self: PCefRenderProcessHandler; + browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + OnContextCreated(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), TCefv8ContextRef.UnWrap(context)); +end; + +procedure cef_render_process_handler_on_context_released(self: PCefRenderProcessHandler; + browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + OnContextReleased(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), TCefv8ContextRef.UnWrap(context)); +end; + +procedure cef_render_process_handler_on_uncaught_exception(self: PCefRenderProcessHandler; + browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context; + exception: PCefV8Exception; stackTrace: PCefV8StackTrace); stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + OnUncaughtException(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), + TCefv8ContextRef.UnWrap(context), TCefV8ExceptionRef.UnWrap(exception), + TCefV8StackTraceRef.UnWrap(stackTrace)); +end; + +procedure cef_render_process_handler_on_focused_node_changed(self: PCefRenderProcessHandler; + browser: PCefBrowser; frame: PCefFrame; node: PCefDomNode); stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + OnFocusedNodeChanged(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), + TCefDomNodeRef.UnWrap(node)); +end; + +function cef_render_process_handler_on_process_message_received(self: PCefRenderProcessHandler; + browser: PCefBrowser; source_process: TCefProcessId; + message: PCefProcessMessage): Integer; stdcall; +begin + with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do + Result := Ord(OnProcessMessageReceived(TCefBrowserRef.UnWrap(browser), source_process, + TCefProcessMessageRef.UnWrap(message))); +end; + + +constructor TCefRenderProcessHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefRenderProcessHandler)); + with PCefRenderProcessHandler(FData)^ do + begin + on_render_thread_created := cef_render_process_handler_on_render_thread_created; + on_web_kit_initialized := cef_render_process_handler_on_web_kit_initialized; + on_browser_created := cef_render_process_handler_on_browser_created; + on_browser_destroyed := cef_render_process_handler_on_browser_destroyed; + get_load_handler := cef_render_process_handler_get_load_handler; + on_before_navigation := cef_render_process_handler_on_before_navigation; + on_context_created := cef_render_process_handler_on_context_created; + on_context_released := cef_render_process_handler_on_context_released; + on_uncaught_exception := cef_render_process_handler_on_uncaught_exception; + on_focused_node_changed := cef_render_process_handler_on_focused_node_changed; + on_process_message_received := cef_render_process_handler_on_process_message_received; + end; +end; + +function TCefRenderProcessHandlerOwn.GetLoadHandler: PCefLoadHandler; +begin + Result := nil; +end; + +function TCefRenderProcessHandlerOwn.OnBeforeNavigation( + const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; navigationType: TCefNavigationType; + isRedirect: Boolean): Boolean; +begin + Result := False; +end; + +procedure TCefRenderProcessHandlerOwn.OnBrowserCreated( + const browser: ICefBrowser); +begin + +end; + +procedure TCefRenderProcessHandlerOwn.OnBrowserDestroyed( + const browser: ICefBrowser); +begin + +end; + +procedure TCefRenderProcessHandlerOwn.OnContextCreated( + const browser: ICefBrowser; const frame: ICefFrame; + const context: ICefv8Context); +begin + +end; + +procedure TCefRenderProcessHandlerOwn.OnContextReleased( + const browser: ICefBrowser; const frame: ICefFrame; + const context: ICefv8Context); +begin + +end; + +procedure TCefRenderProcessHandlerOwn.OnFocusedNodeChanged( + const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); +begin + +end; + +function TCefRenderProcessHandlerOwn.OnProcessMessageReceived( + const browser: ICefBrowser; sourceProcess: TCefProcessId; + const message: ICefProcessMessage): Boolean; +begin + Result := False; +end; + +procedure TCefRenderProcessHandlerOwn.OnRenderThreadCreated(const extraInfo: ICefListValue); +begin + +end; + +procedure TCefRenderProcessHandlerOwn.OnUncaughtException( + const browser: ICefBrowser; const frame: ICefFrame; + const context: ICefv8Context; const exception: ICefV8Exception; + const stackTrace: ICefV8StackTrace); +begin + +end; + +procedure TCefRenderProcessHandlerOwn.OnWebKitInitialized; +begin + +end; + +end. diff --git a/uCEFRequest.pas b/uCEFRequest.pas new file mode 100644 index 00000000..9fb4ffff --- /dev/null +++ b/uCEFRequest.pas @@ -0,0 +1,213 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRequest; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefRequestRef = class(TCefBaseRef, ICefRequest) + protected + function IsReadOnly: Boolean; + function GetUrl: ustring; + function GetMethod: ustring; + function GetPostData: ICefPostData; + procedure GetHeaderMap(const HeaderMap: ICefStringMultimap); + procedure SetUrl(const value: ustring); + procedure SetMethod(const value: ustring); + procedure SetReferrer(const referrerUrl: ustring; policy: TCefReferrerPolicy); + function GetReferrerUrl: ustring; + function GetReferrerPolicy: TCefReferrerPolicy; + procedure SetPostData(const value: ICefPostData); + procedure SetHeaderMap(const HeaderMap: ICefStringMultimap); + function GetFlags: TCefUrlRequestFlags; + procedure SetFlags(flags: TCefUrlRequestFlags); + function GetFirstPartyForCookies: ustring; + procedure SetFirstPartyForCookies(const url: ustring); + procedure Assign(const url, method: ustring; const postData: ICefPostData; const headerMap: ICefStringMultimap); + function GetResourceType: TCefResourceType; + function GetTransitionType: TCefTransitionType; + function GetIdentifier: UInt64; + public + class function UnWrap(data: Pointer): ICefRequest; + class function New: ICefRequest; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFPostData; + +function TCefRequestRef.IsReadOnly: Boolean; +begin + Result := PCefRequest(FData).is_read_only(PCefRequest(FData)) <> 0; +end; + +procedure TCefRequestRef.Assign(const url, method: ustring; const postData: ICefPostData; const headerMap: ICefStringMultimap); +var + u, m: TCefString; +begin + u := cefstring(url); + m := cefstring(method); + PCefRequest(FData).set_(PCefRequest(FData), @u, @m, CefGetData(postData), headerMap.Handle); +end; + +function TCefRequestRef.GetFirstPartyForCookies: ustring; +begin + Result := CefStringFreeAndGet(PCefRequest(FData).get_first_party_for_cookies(PCefRequest(FData))); +end; + +function TCefRequestRef.GetFlags: TCefUrlRequestFlags; +begin + Byte(Result) := PCefRequest(FData)^.get_flags(PCefRequest(FData)); +end; + +procedure TCefRequestRef.GetHeaderMap(const HeaderMap: ICefStringMultimap); +begin + PCefRequest(FData)^.get_header_map(PCefRequest(FData), HeaderMap.Handle); +end; + +function TCefRequestRef.GetIdentifier: UInt64; +begin + Result := PCefRequest(FData)^.get_identifier(PCefRequest(FData)); +end; + +function TCefRequestRef.GetMethod: ustring; +begin + Result := CefStringFreeAndGet(PCefRequest(FData)^.get_method(PCefRequest(FData))) +end; + +function TCefRequestRef.GetPostData: ICefPostData; +begin + Result := TCefPostDataRef.UnWrap(PCefRequest(FData)^.get_post_data(PCefRequest(FData))); +end; + +function TCefRequestRef.GetResourceType: TCefResourceType; +begin + Result := PCefRequest(FData).get_resource_type(FData); +end; + +function TCefRequestRef.GetTransitionType: TCefTransitionType; +begin + Result := PCefRequest(FData).get_transition_type(FData); +end; + +function TCefRequestRef.GetUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefRequest(FData)^.get_url(PCefRequest(FData))) +end; + +class function TCefRequestRef.New: ICefRequest; +begin + Result := UnWrap(cef_request_create); +end; + +procedure TCefRequestRef.SetFirstPartyForCookies(const url: ustring); +var + str: TCefString; +begin + str := CefString(url); + PCefRequest(FData).set_first_party_for_cookies(PCefRequest(FData), @str); +end; + +procedure TCefRequestRef.SetFlags(flags: TCefUrlRequestFlags); +begin + PCefRequest(FData)^.set_flags(PCefRequest(FData), PByte(@flags)^); +end; + +procedure TCefRequestRef.SetHeaderMap(const HeaderMap: ICefStringMultimap); +begin + PCefRequest(FData)^.set_header_map(PCefRequest(FData), HeaderMap.Handle); +end; + +procedure TCefRequestRef.SetMethod(const value: ustring); +var + v: TCefString; +begin + v := CefString(value); + PCefRequest(FData)^.set_method(PCefRequest(FData), @v); +end; + +procedure TCefRequestRef.SetReferrer(const referrerUrl: ustring; policy: TCefReferrerPolicy); +var + u: TCefString; +begin + u := CefString(referrerUrl); + PCefRequest(FData)^.set_referrer(PCefRequest(FData), @u, policy); +end; + +function TCefRequestRef.GetReferrerUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefRequest(FData)^.get_referrer_url(PCefRequest(FData))); +end; + +function TCefRequestRef.GetReferrerPolicy: TCefReferrerPolicy; +begin + Result := PCefRequest(FData)^.get_referrer_policy(PCefRequest(FData)); +end; + +procedure TCefRequestRef.SetPostData(const value: ICefPostData); +begin + if value <> nil then + PCefRequest(FData)^.set_post_data(PCefRequest(FData), CefGetData(value)); +end; + +procedure TCefRequestRef.SetUrl(const value: ustring); +var + v: TCefString; +begin + v := CefString(value); + PCefRequest(FData)^.set_url(PCefRequest(FData), @v); +end; + +class function TCefRequestRef.UnWrap(data: Pointer): ICefRequest; +begin + if data <> nil then + Result := Create(data) as ICefRequest else + Result := nil; +end; + + +end. diff --git a/uCEFRequestCallback.pas b/uCEFRequestCallback.pas new file mode 100644 index 00000000..138ccbb3 --- /dev/null +++ b/uCEFRequestCallback.pas @@ -0,0 +1,83 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRequestCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefRequestCallbackRef = class(TCefBaseRef, ICefRequestCallback) + protected + procedure Cont(allow: Boolean); + procedure Cancel; + + public + class function UnWrap(data: Pointer): ICefRequestCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefRequestCallbackRef.Cont(allow: Boolean); +begin + PCefRequestCallback(FData).cont(FData, Ord(allow)); +end; + +procedure TCefRequestCallbackRef.Cancel; +begin + PCefRequestCallback(FData).cancel(FData); +end; + +class function TCefRequestCallbackRef.UnWrap(data: Pointer): ICefRequestCallback; +begin + if (data <> nil) then + Result := Create(data) as ICefRequestCallback + else + Result := nil; +end; + +end. diff --git a/uCEFRequestContext.pas b/uCEFRequestContext.pas new file mode 100644 index 00000000..08684480 --- /dev/null +++ b/uCEFRequestContext.pas @@ -0,0 +1,252 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRequestContext; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefRequestContextRef = class(TCefBaseRef, ICefRequestContext) + protected + function IsSame(const other: ICefRequestContext): Boolean; + function IsSharingWith(const other: ICefRequestContext): Boolean; + function IsGlobal: Boolean; + function GetHandler: ICefRequestContextHandler; + function GetCachePath: ustring; + function GetDefaultCookieManager(const callback: ICefCompletionCallback): ICefCookieManager; + function GetDefaultCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; + function RegisterSchemeHandlerFactory(const schemeName, domainName: ustring; const factory: ICefSchemeHandlerFactory): Boolean; + function ClearSchemeHandlerFactories: Boolean; + procedure PurgePluginListCache(reloadPages: Boolean); + function HasPreference(const name: ustring): Boolean; + function GetPreference(const name: ustring): ICefValue; + function GetAllPreferences(includeDefaults: Boolean): ICefDictionaryValue; + function CanSetPreference(const name: ustring): Boolean; + function SetPreference(const name: ustring; const value: ICefValue; out error: ustring): Boolean; + procedure ClearCertificateExceptions(const callback: ICefCompletionCallback); + procedure CloseAllConnections(const callback: ICefCompletionCallback); + procedure ResolveHost(const origin: ustring; const callback: ICefResolveCallback); + function ResolveHostCached(const origin: ustring; resolvedIps: TStrings): TCefErrorCode; + + public + class function UnWrap(data: Pointer): ICefRequestContext; + class function Global: ICefRequestContext; + class function New(const settings: PCefRequestContextSettings; const handler: ICefRequestContextHandler): ICefRequestContext; + class function Shared(const other: ICefRequestContext; const handler: ICefRequestContextHandler): ICefRequestContext; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFValue, uCEFDictionaryValue, uCEFCookieManager, + uCEFCompletionCallback, uCEFRequestContextHandler; + +function TCefRequestContextRef.ClearSchemeHandlerFactories: Boolean; +begin + Result := PCefRequestContext(FData).clear_scheme_handler_factories(FData) <> 0; +end; + +function TCefRequestContextRef.GetCachePath: ustring; +begin + Result := CefStringFreeAndGet(PCefRequestContext(FData).get_cache_path(FData)); +end; + +function TCefRequestContextRef.GetDefaultCookieManager( + const callback: ICefCompletionCallback): ICefCookieManager; +begin + Result := TCefCookieManagerRef.UnWrap( + PCefRequestContext(FData).get_default_cookie_manager( + FData, CefGetData(callback))); +end; + +function TCefRequestContextRef.GetDefaultCookieManagerProc( + const callback: TCefCompletionCallbackProc): ICefCookieManager; +begin + Result := GetDefaultCookieManager(TCefFastCompletionCallback.Create(callback)); +end; + +function TCefRequestContextRef.GetHandler: ICefRequestContextHandler; +begin + Result := TCefRequestContextHandlerRef.UnWrap(PCefRequestContext(FData).get_handler(FData)); +end; + +class function TCefRequestContextRef.Global: ICefRequestContext; +begin + Result:= UnWrap(cef_request_context_get_global_context()); +end; + +function TCefRequestContextRef.IsGlobal: Boolean; +begin + Result:= PCefRequestContext(FData).is_global(FData) <> 0; +end; + +function TCefRequestContextRef.IsSame(const other: ICefRequestContext): Boolean; +begin + Result:= PCefRequestContext(FData).is_same(FData, CefGetData(other)) <> 0; +end; + +function TCefRequestContextRef.IsSharingWith( + const other: ICefRequestContext): Boolean; +begin + Result:= PCefRequestContext(FData).is_sharing_with(FData, CefGetData(other)) <> 0; +end; + +class function TCefRequestContextRef.New(const settings: PCefRequestContextSettings; + const handler: ICefRequestContextHandler): ICefRequestContext; +begin + Result := UnWrap(cef_request_context_create_context(settings, CefGetData(handler))); +end; + +procedure TCefRequestContextRef.PurgePluginListCache(reloadPages: Boolean); +begin + PCefRequestContext(FData).purge_plugin_list_cache(FData, Ord(reloadPages)); +end; + +function TCefRequestContextRef.HasPreference(const name: ustring): Boolean; +var + n: TCefString; +begin + n := CefString(name); + Result := PCefRequestContext(FData).has_preference(FData, @n) <> 0; +end; + +function TCefRequestContextRef.GetPreference(const name: ustring): ICefValue; +var + n: TCefString; +begin + n := CefString(name); + Result := TCefValueRef.UnWrap(PCefRequestContext(FData).get_preference(FData, @n)); +end; + +function TCefRequestContextRef.GetAllPreferences(includeDefaults: Boolean): ICefDictionaryValue; +begin + Result := TCefDictionaryValueRef.UnWrap(PCefRequestContext(FData).get_all_preferences(FData, Ord(includeDefaults))); +end; + +function TCefRequestContextRef.CanSetPreference(const name: ustring): Boolean; +var + n: TCefString; +begin + n := CefString(name); + Result := PCefRequestContext(FData).can_set_preference(FData, @n) <> 0; +end; + +function TCefRequestContextRef.SetPreference(const name: ustring; const value: ICefValue; out error: ustring): Boolean; +var + n, e: TCefString; +begin + n := CefString(name); + FillChar(e, SizeOf(e), 0); + Result := PCefRequestContext(FData).set_preference(FData, @n, CefGetData(value), @e) <> 0; + error := CefString(@e); +end; + +procedure TCefRequestContextRef.ClearCertificateExceptions(const callback: ICefCompletionCallback); +begin + PCefRequestContext(FData).clear_certificate_exceptions(FData, CefGetData(callback)); +end; + +procedure TCefRequestContextRef.CloseAllConnections(const callback: ICefCompletionCallback); +begin + PCefRequestContext(FData).close_all_connections(FData, CefGetData(callback)); +end; + +procedure TCefRequestContextRef.ResolveHost(const origin: ustring; + const callback: ICefResolveCallback); +var + o: TCefString; +begin + o := CefString(origin); + PCefRequestContext(FData).resolve_host(FData, @o, CefGetData(callback)); +end; + +function TCefRequestContextRef.ResolveHostCached(const origin: ustring; + resolvedIps: TStrings): TCefErrorCode; +var + ips: TCefStringList; + o, str: TCefString; + i: Integer; +begin + ips := cef_string_list_alloc; + try + o := CefString(origin); + Result := PCefRequestContext(FData).resolve_host_cached(FData, @o, ips); + if Assigned(ips) then + for i := 0 to cef_string_list_size(ips) - 1 do + begin + FillChar(str, SizeOf(str), 0); + cef_string_list_value(ips, i, @str); + resolvedIps.Add(CefStringClearAndGet(str)); + end; + finally + cef_string_list_free(ips); + end; +end; + +function TCefRequestContextRef.RegisterSchemeHandlerFactory(const schemeName, + domainName: ustring; const factory: ICefSchemeHandlerFactory): Boolean; +var + s, d: TCefString; +begin + s := CefString(schemeName); + d := CefString(domainName); + Result := PCefRequestContext(FData).register_scheme_handler_factory(FData, @s, @d, CefGetData(factory)) <> 0; +end; + +class function TCefRequestContextRef.Shared(const other: ICefRequestContext; + const handler: ICefRequestContextHandler): ICefRequestContext; +begin + Result := UnWrap(cef_create_context_shared(CefGetData(other), CefGetData(handler))); +end; + +class function TCefRequestContextRef.UnWrap(data: Pointer): ICefRequestContext; +begin + if data <> nil then + Result := Create(data) as ICefRequestContext else + Result := nil; +end; + +end. diff --git a/uCEFRequestContextHandler.pas b/uCEFRequestContextHandler.pas new file mode 100644 index 00000000..39e20fdc --- /dev/null +++ b/uCEFRequestContextHandler.pas @@ -0,0 +1,176 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRequestContextHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefRequestContextHandlerProc = reference to function: ICefCookieManager; + + TCefRequestContextHandlerRef = class(TCefBaseRef, ICefRequestContextHandler) + protected + function GetCookieManager: ICefCookieManager; + function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; + + public + class function UnWrap(data: Pointer): ICefRequestContextHandler; + end; + + TCefRequestContextHandlerOwn = class(TCefBaseOwn, ICefRequestContextHandler) + protected + function GetCookieManager: ICefCookieManager; virtual; + function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; virtual; + + public + constructor Create; virtual; + end; + + TCefFastRequestContextHandler = class(TCefRequestContextHandlerOwn) + protected + FProc: TCefRequestContextHandlerProc; + + function GetCookieManager: ICefCookieManager; override; + + public + constructor Create(const proc: TCefRequestContextHandlerProc); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFCookieManager, uCEFWebPluginInfo; + +function cef_request_context_handler_get_cookie_manager(self: PCefRequestContextHandler): PCefCookieManager; stdcall; +begin + with TCefRequestContextHandlerOwn(CefGetObject(self)) do + Result := CefGetData(GetCookieManager()); +end; + +function cef_request_context_handler_on_before_plugin_load(self: PCefRequestContextHandler; + const mime_type, plugin_url : PCefString; + is_main_frame : integer; + const top_origin_url: PCefString; + plugin_info: PCefWebPluginInfo; + plugin_policy: PCefPluginPolicy): Integer; stdcall; +begin + with TCefRequestContextHandlerOwn(CefGetObject(self)) do + Result := Ord(OnBeforePluginLoad(CefString(mime_type), + CefString(plugin_url), + (is_main_frame <> 0), + CefString(top_origin_url), + TCefWebPluginInfoRef.UnWrap(plugin_info), + plugin_policy)); +end; + +function TCefRequestContextHandlerRef.GetCookieManager: ICefCookieManager; +begin + Result := TCefCookieManagerRef.UnWrap(PCefRequestContextHandler(FData).get_cookie_manager(FData)); +end; + +function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType, pluginUrl : ustring; + isMainFrame : boolean; + const topOriginUrl: ustring; + const pluginInfo: ICefWebPluginInfo; + pluginPolicy: PCefPluginPolicy): Boolean; +var + mt, pu, ou: TCefString; +begin + mt := CefString(mimeType); + pu := CefString(pluginUrl); + ou := CefString(topOriginUrl); + + Result := PCefRequestContextHandler(FData).on_before_plugin_load(FData, @mt, @pu, ord(isMainFrame), @ou, CefGetData(pluginInfo), pluginPolicy) <> 0; +end; + +class function TCefRequestContextHandlerRef.UnWrap(data: Pointer): ICefRequestContextHandler; +begin + if (data <> nil) then + Result := Create(data) as ICefRequestContextHandler + else + Result := nil; +end; + +// TCefRequestContextHandlerOwn + +constructor TCefRequestContextHandlerOwn.Create; +begin + CreateData(SizeOf(TCefRequestContextHandler), False); + + with PCefRequestContextHandler(FData)^ do + begin + get_cookie_manager := cef_request_context_handler_get_cookie_manager; + on_before_plugin_load := cef_request_context_handler_on_before_plugin_load; + end; +end; + +function TCefRequestContextHandlerOwn.GetCookieManager: ICefCookieManager; +begin + Result:= nil; +end; + +function TCefRequestContextHandlerOwn.OnBeforePluginLoad(const mimeType, pluginUrl : ustring; + isMainFrame : boolean; + const topOriginUrl: ustring; + const pluginInfo: ICefWebPluginInfo; + pluginPolicy: PCefPluginPolicy): Boolean; +begin + Result := False; +end; + +// TCefFastRequestContextHandler + +constructor TCefFastRequestContextHandler.Create(const proc: TCefRequestContextHandlerProc); +begin + FProc := proc; + inherited Create; +end; + +function TCefFastRequestContextHandler.GetCookieManager: ICefCookieManager; +begin + Result := FProc(); +end; + +end. diff --git a/uCEFRequestHandler.pas b/uCEFRequestHandler.pas new file mode 100644 index 00000000..46045987 --- /dev/null +++ b/uCEFRequestHandler.pas @@ -0,0 +1,570 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRequestHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefRequestHandlerOwn = class(TCefBaseOwn, ICefRequestHandler) + protected + function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; isRedirect: Boolean): Boolean; virtual; + function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual; + function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; virtual; + function GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; virtual; + procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); virtual; + function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; virtual; + function GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; virtual; + procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); virtual; + function GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual; + function OnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; virtual; + function GetCookieManager(const browser: ICefBrowser; const mainUrl: ustring): ICefCookieManager; virtual; + procedure OnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); virtual; + function OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual; + function OnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; virtual; + procedure OnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); virtual; + procedure OnRenderViewReady(const browser: ICefBrowser); virtual; + procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); virtual; + + public + constructor Create; virtual; + end; + + TCustomRequestHandler = class(TCefRequestHandlerOwn) + protected + FEvent: IChromiumEvents; + + function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; isRedirect: Boolean): Boolean; override; + function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; override; + function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; override; + function GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; override; + procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); override; + function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; override; + function GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; override; + procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); override; + function GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; override; + function OnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; override; + procedure OnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); override; + function OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; override; + function OnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; override; + procedure OnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); override; + procedure OnRenderViewReady(const browser: ICefBrowser); override; + procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; virtual; + end; + +implementation + +uses + WinApi.Windows, System.SysUtils, + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFRequest, uCEFRequestCallback, + uCEFResponse, uCEFAuthCallback, uCEFSslInfo, uCEFSelectClientCertificateCallback, uCEFX509Certificate; + +function cef_request_handler_on_before_browse(self: PCefRequestHandler; browser: PCefBrowser; + frame: PCefFrame; request: PCefRequest; isRedirect: Integer): Integer; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := Ord(OnBeforeBrowse(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), isRedirect <> 0)); +end; + +function cef_request_handler_on_open_urlfrom_tab(self: PCefRequestHandler; browser: PCefBrowser; + frame: PCefFrame; const target_url: PCefString; target_disposition: TCefWindowOpenDisposition; + user_gesture: Integer): Integer; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := Ord(OnOpenUrlFromTab(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), + CefString(target_url), target_disposition, user_gesture <> 0)); +end; + +function cef_request_handler_on_before_resource_load(self: PCefRequestHandler; + browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; + callback: PCefRequestCallback): TCefReturnValue; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := OnBeforeResourceLoad( + TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TcefRequestCallbackRef.UnWrap(callback)); +end; + +function cef_request_handler_get_resource_handler(self: PCefRequestHandler; + browser: PCefBrowser; frame: PCefFrame; request: PCefRequest): PCefResourceHandler; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := CefGetData(GetResourceHandler(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), TCefRequestRef.UnWrap(request))); +end; + +procedure cef_request_handler_on_resource_redirect(self: PCefRequestHandler; + browser: PCefBrowser; frame: PCefFrame; const request: PCefRequest; response: PCefResponse; new_url: PCefString); stdcall; +var + url: ustring; +begin + url := CefString(new_url); + with TCefRequestHandlerOwn(CefGetObject(self)) do + OnResourceRedirect(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), TCefResponseRef.UnWrap(response), url); + if url <> '' then + CefStringSet(new_url, url); +end; + +function cef_request_handler_on_resource_response(self: PCefRequestHandler; + browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; + response: PCefResponse): Integer; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := Ord(OnResourceResponse(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), TCefResponseRef.UnWrap(response))); +end; + +function cef_request_handler_get_resource_response_filter(self: PCefRequestHandler; browser: PCefBrowser; + frame: PCefFrame; request: PCefRequest; response: PCefResponse): PCefResponseFilter; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := CefGetData(GetResourceResponseFilter(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), TCefRequestRef.UnWrap(request), + TCefResponseRef.UnWrap(response))); +end; + +procedure cef_request_handler_on_resource_load_complete(self: PCefRequestHandler; browser: PCefBrowser; + frame: PCefFrame; request: PCefRequest; response: PCefResponse; + status: TCefUrlRequestStatus; received_content_length: Int64); stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + OnResourceLoadComplete(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), TCefRequestRef.UnWrap(request), + TCefResponseRef.UnWrap(response), status, received_content_length); +end; + +function cef_request_handler_get_auth_credentials(self: PCefRequestHandler; + browser: PCefBrowser; frame: PCefFrame; isProxy: Integer; const host: PCefString; + port: Integer; const realm, scheme: PCefString; callback: PCefAuthCallback): Integer; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := Ord(GetAuthCredentials( + TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), isProxy <> 0, + CefString(host), port, CefString(realm), CefString(scheme), TCefAuthCallbackRef.UnWrap(callback))); +end; + +function cef_request_handler_on_quota_request(self: PCefRequestHandler; browser: PCefBrowser; + const origin_url: PCefString; new_size: Int64; callback: PCefRequestCallback): Integer; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := Ord(OnQuotaRequest(TCefBrowserRef.UnWrap(browser), + CefString(origin_url), new_size, TCefRequestCallbackRef.UnWrap(callback))); +end; + +procedure cef_request_handler_on_protocol_execution(self: PCefRequestHandler; + browser: PCefBrowser; const url: PCefString; allow_os_execution: PInteger); stdcall; +var + allow: Boolean; +begin + allow := allow_os_execution^ <> 0; + with TCefRequestHandlerOwn(CefGetObject(self)) do + OnProtocolExecution( + TCefBrowserRef.UnWrap(browser), + CefString(url), allow); + allow_os_execution^ := Ord(allow); +end; + +function cef_request_handler_on_certificate_error(self: PCefRequestHandler; + browser: PCefBrowser; cert_error: TCefErrorcode; const request_url: PCefString; + ssl_info: PCefSslInfo; callback: PCefRequestCallback): Integer; stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := Ord(OnCertificateError(TCefBrowserRef.UnWrap(browser), cert_error, + CefString(request_url), TCefSslInfoRef.UnWrap(ssl_info), + TCefRequestCallbackRef.UnWrap(callback))); +end; + +procedure cef_request_handler_on_plugin_crashed(self: PCefRequestHandler; + browser: PCefBrowser; const plugin_path: PCefString); stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + OnPluginCrashed(TCefBrowserRef.UnWrap(browser), CefString(plugin_path)); +end; + +procedure cef_request_handler_on_render_view_ready(self: PCefRequestHandler; + browser: PCefBrowser); stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + OnRenderViewReady(TCefBrowserRef.UnWrap(browser)); +end; + +procedure cef_request_handler_on_render_process_terminated(self: PCefRequestHandler; + browser: PCefBrowser; status: TCefTerminationStatus); stdcall; +begin + with TCefRequestHandlerOwn(CefGetObject(self)) do + OnRenderProcessTerminated(TCefBrowserRef.UnWrap(browser), status); +end; + +function cef_request_handler_on_select_client_certificate(self: PCefRequestHandler; + browser: PCefBrowser; + isProxy: integer; + const host: PCefString; + port: integer; + certificatesCount: NativeUInt; + const certificates: PPCefX509Certificate; + callback: PCefSelectClientCertificateCallback): integer; stdcall; +var + TempCertArray : TCefX509CertificateArray; + i : NativeUInt; +begin + TempCertArray := nil; + Result := 0; + + try + try + if (certificatesCount > 0) and (certificates <> nil) then + begin + SetLength(TempCertArray, certificatesCount); + + i := 0; + while (i < certificatesCount) do + begin + TempCertArray[i] := TCEFX509CertificateRef.UnWrap(PPointerArray(certificates)[i]); + inc(i); + end; + + with TCefRequestHandlerOwn(CefGetObject(self)) do + Result := Ord(OnSelectClientCertificate(TCefBrowserRef.UnWrap(browser), + (isProxy <> 0), + CefString(host), + port, + certificatesCount, + TempCertArray, + TCefSelectClientCertificateCallbackRef.UnWrap(callback))); + + i := 0; + while (i < certificatesCount) do + begin + TempCertArray[i] := nil; + inc(i); + end; + end; + except + on e : exception do + begin + {$IFDEF DEBUG} + OutputDebugString(PWideChar('cef_request_handler_on_select_client_certificate error: ' + e.Message + chr(0))); + {$ENDIF} + end; + end; + finally + if (TempCertArray <> nil) then + begin + Finalize(TempCertArray); + TempCertArray := nil; + end; + end; +end; + +constructor TCefRequestHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefRequestHandler)); + with PCefRequestHandler(FData)^ do + begin + on_before_browse := cef_request_handler_on_before_browse; + on_open_urlfrom_tab := cef_request_handler_on_open_urlfrom_tab; + on_before_resource_load := cef_request_handler_on_before_resource_load; + get_resource_handler := cef_request_handler_get_resource_handler; + on_resource_redirect := cef_request_handler_on_resource_redirect; + on_resource_response := cef_request_handler_on_resource_response; + get_resource_response_filter := cef_request_handler_get_resource_response_filter; + on_resource_load_complete := cef_request_handler_on_resource_load_complete; + get_auth_credentials := cef_request_handler_get_auth_credentials; + on_quota_request := cef_request_handler_on_quota_request; + on_protocol_execution := cef_request_handler_on_protocol_execution; + on_certificate_error := cef_request_handler_on_certificate_error; + on_select_client_certificate := cef_request_handler_on_select_client_certificate; + on_plugin_crashed := cef_request_handler_on_plugin_crashed; + on_render_view_ready := cef_request_handler_on_render_view_ready; + on_render_process_terminated := cef_request_handler_on_render_process_terminated; + end; +end; + +function TCefRequestHandlerOwn.GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; + isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; + const callback: ICefAuthCallback): Boolean; +begin + Result := False; +end; + +function TCefRequestHandlerOwn.GetCookieManager(const browser: ICefBrowser; + const mainUrl: ustring): ICefCookieManager; +begin + Result := nil; +end; + +function TCefRequestHandlerOwn.OnBeforeBrowse(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest; + isRedirect: Boolean): Boolean; +begin + Result := False; +end; + +function TCefRequestHandlerOwn.OnBeforeResourceLoad(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest; + const callback: ICefRequestCallback): TCefReturnValue; +begin + Result := RV_CONTINUE; +end; + +function TCefRequestHandlerOwn.OnCertificateError(const browser: ICefBrowser; + certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; + const callback: ICefRequestCallback): Boolean; +begin + Result := False; +end; + +function TCefRequestHandlerOwn.OnSelectClientCertificate(const browser : ICefBrowser; + isProxy : boolean; + const host : ustring; + port : integer; + certificatesCount : NativeUInt; + const certificates : TCefX509CertificateArray; + const callback : ICefSelectClientCertificateCallback): boolean; +begin + Result := False; +end; + +function TCefRequestHandlerOwn.OnOpenUrlFromTab(const browser: ICefBrowser; + const frame: ICefFrame; const targetUrl: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; +begin + Result := False; +end; + +function TCefRequestHandlerOwn.GetResourceHandler(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; +begin + Result := nil; +end; + +procedure TCefRequestHandlerOwn.OnPluginCrashed(const browser: ICefBrowser; + const pluginPath: ustring); +begin + +end; + +procedure TCefRequestHandlerOwn.OnProtocolExecution(const browser: ICefBrowser; + const url: ustring; out allowOsExecution: Boolean); +begin + +end; + +function TCefRequestHandlerOwn.OnQuotaRequest(const browser: ICefBrowser; + const originUrl: ustring; newSize: Int64; + const callback: ICefRequestCallback): Boolean; +begin + Result := False; +end; + +procedure TCefRequestHandlerOwn.OnRenderProcessTerminated( + const browser: ICefBrowser; status: TCefTerminationStatus); +begin + +end; + +procedure TCefRequestHandlerOwn.OnRenderViewReady(const browser: ICefBrowser); +begin + +end; + +procedure TCefRequestHandlerOwn.OnResourceRedirect(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); +begin + +end; + +function TCefRequestHandlerOwn.OnResourceResponse(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest; + const response: ICefResponse): Boolean; +begin + Result := False; +end; + +function TCefRequestHandlerOwn.GetResourceResponseFilter( + const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; +begin + Result := nil; +end; + +procedure TCefRequestHandlerOwn.OnResourceLoadComplete( + const browser: ICefBrowser; const frame: ICefFrame; + const request: ICefRequest; const response: ICefResponse; + status: TCefUrlRequestStatus; receivedContentLength: Int64); +begin + +end; + +// TCustomRequestHandler + +constructor TCustomRequestHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + FEvent := events; +end; + +function TCustomRequestHandler.GetAuthCredentials(const browser: ICefBrowser; + const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; + const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; +begin + Result := FEvent.doOnGetAuthCredentials(browser, frame, isProxy, host, port, + realm, scheme, callback); +end; + +function TCustomRequestHandler.GetResourceHandler(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; +begin + Result := FEvent.doOnGetResourceHandler(browser, frame, request); +end; + +function TCustomRequestHandler.OnBeforeBrowse(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest; + isRedirect: Boolean): Boolean; +begin + Result := FEvent.doOnBeforeBrowse(browser, frame, request, isRedirect); +end; + +function TCustomRequestHandler.OnBeforeResourceLoad(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest; + const callback: ICefRequestCallback): TCefReturnValue; +begin + Result := FEvent.doOnBeforeResourceLoad(browser, frame, request, callback); +end; + +function TCustomRequestHandler.OnCertificateError(const browser: ICefBrowser; + certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; + const callback: ICefRequestCallback): Boolean; +begin + Result := FEvent.doOnCertificateError(browser, certError, requestUrl, sslInfo, callback); +end; + +function TCustomRequestHandler.OnOpenUrlFromTab(const browser: ICefBrowser; + const frame: ICefFrame; const targetUrl: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; +begin + Result := FEvent.doOnOpenUrlFromTab(browser, frame, targetUrl, targetDisposition, userGesture); +end; + +function TCustomRequestHandler.OnSelectClientCertificate(const browser : ICefBrowser; + isProxy : boolean; + const host : ustring; + port : integer; + certificatesCount : NativeUInt; + const certificates : TCefX509CertificateArray; + const callback : ICefSelectClientCertificateCallback): boolean; +begin + Result := FEvent.doOnSelectClientCertificate(browser, isProxy, host, port, certificatesCount, certificates, callback); +end; + +procedure TCustomRequestHandler.OnPluginCrashed(const browser: ICefBrowser; + const pluginPath: ustring); +begin + FEvent.doOnPluginCrashed(browser, pluginPath); +end; + +procedure TCustomRequestHandler.OnProtocolExecution(const browser: ICefBrowser; + const url: ustring; out allowOsExecution: Boolean); +begin + FEvent.doOnProtocolExecution(browser, url, allowOsExecution); +end; + +function TCustomRequestHandler.OnQuotaRequest(const browser: ICefBrowser; + const originUrl: ustring; newSize: Int64; + const callback: ICefRequestCallback): Boolean; +begin + Result := FEvent.doOnQuotaRequest(browser, originUrl, newSize, callback); +end; + +procedure TCustomRequestHandler.OnRenderProcessTerminated( + const browser: ICefBrowser; status: TCefTerminationStatus); +begin + FEvent.doOnRenderProcessTerminated(browser, status); +end; + +procedure TCustomRequestHandler.OnRenderViewReady(const browser: ICefBrowser); +begin + FEvent.doOnRenderViewReady(browser); +end; + +procedure TCustomRequestHandler.OnResourceRedirect(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); +begin + FEvent.doOnResourceRedirect(browser, frame, request, response, newUrl); +end; + +function TCustomRequestHandler.OnResourceResponse(const browser: ICefBrowser; + const frame: ICefFrame; const request: ICefRequest; + const response: ICefResponse): Boolean; +begin + Result := FEvent.doOnResourceResponse(browser, frame, request, response); +end; + +function TCustomRequestHandler.GetResourceResponseFilter(const browser: ICefBrowser; + const frame: ICefFrame; + const request: ICefRequest; + const response: ICefResponse): ICefResponseFilter; +begin + Result := FEvent.doOnGetResourceResponseFilter(browser, frame, request, response); +end; + +procedure TCustomRequestHandler.OnResourceLoadComplete(const browser: ICefBrowser; + const frame: ICefFrame; + const request: ICefRequest; + const response: ICefResponse; + status: TCefUrlRequestStatus; + receivedContentLength: Int64); +begin + FEvent.doOnResourceLoadComplete(browser, frame, request, response, status, receivedContentLength); +end; + +end. diff --git a/uCEFResolveCallback.pas b/uCEFResolveCallback.pas new file mode 100644 index 00000000..bb8b4d4a --- /dev/null +++ b/uCEFResolveCallback.pas @@ -0,0 +1,95 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResolveCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefResolveCallbackOwn = class(TCefBaseOwn, ICefResolveCallback) + protected + procedure OnResolveCompleted(result: TCefErrorCode; resolvedIps: TStrings); virtual; abstract; + public + constructor Create; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure cef_resolve_callback_on_resolve_completed(self: PCefResolveCallback; + result: TCefErrorCode; resolved_ips: TCefStringList); stdcall; +var + list: TStringList; + i: Integer; + str: TCefString; +begin + list := TStringList.Create; + try + for i := 0 to cef_string_list_size(resolved_ips) - 1 do + begin + FillChar(str, SizeOf(str), 0); + cef_string_list_value(resolved_ips, i, @str); + list.Add(CefStringClearAndGet(str)); + end; + with TCefResolveCallbackOwn(CefGetObject(self)) do + OnResolveCompleted(result, list); + finally + list.Free; + end; +end; + +// TCefResolveCallbackOwn + +constructor TCefResolveCallbackOwn.Create; +begin + CreateData(SizeOf(TCefResolveCallback), False); + with PCefResolveCallback(FData)^ do + on_resolve_completed := cef_resolve_callback_on_resolve_completed; +end; + +end. diff --git a/uCEFResourceBundle.pas b/uCEFResourceBundle.pas new file mode 100644 index 00000000..9ff4aedf --- /dev/null +++ b/uCEFResourceBundle.pas @@ -0,0 +1,101 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResourceBundle; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefResourceBundleRef = class(TCefBaseRef, ICefResourceBundle) + protected + function GetLocalizedString(stringId: Integer): ustring; + function GetDataResource(resourceId: Integer; + out data: Pointer; out dataSize: NativeUInt): Boolean; + function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; + out data: Pointer; out dataSize: NativeUInt): Boolean; + public + class function UnWrap(data: Pointer): ICefResourceBundle; + class function Global: ICefResourceBundle; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +function TCefResourceBundleRef.GetDataResource(resourceId: Integer; + out data: Pointer; out dataSize: NativeUInt): Boolean; +begin + Result := PCefResourceBundle(FData).get_data_resource(FData, resourceId, + data, dataSize) <> 0; +end; + +function TCefResourceBundleRef.GetDataResourceForScale(resourceId: Integer; + scaleFactor: TCefScaleFactor; out data: Pointer; + out dataSize: NativeUInt): Boolean; +begin + Result := PCefResourceBundle(FData).get_data_resource_for_scale(FData, + resourceId, scaleFactor, data, dataSize) <> 0; +end; + +function TCefResourceBundleRef.GetLocalizedString(stringId: Integer): ustring; +begin + Result := CefStringFreeAndGet(PCefResourceBundle(FData).get_localized_string(FData, stringId)); +end; + +class function TCefResourceBundleRef.Global: ICefResourceBundle; +begin + Result := UnWrap(cef_resource_bundle_get_global()); +end; + +class function TCefResourceBundleRef.UnWrap(data: Pointer): ICefResourceBundle; +begin + if data <> nil then + Result := Create(data) as ICefResourceBundle else + Result := nil; +end; + +end. diff --git a/uCEFResourceBundleHandler.pas b/uCEFResourceBundleHandler.pas new file mode 100644 index 00000000..9458bb6b --- /dev/null +++ b/uCEFResourceBundleHandler.pas @@ -0,0 +1,157 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResourceBundleHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefResourceBundleHandlerOwn = class(TCefBaseOwn, ICefResourceBundleHandler) + protected + function GetDataResource(stringId: Integer; out data: Pointer; out dataSize: NativeUInt): Boolean; virtual; abstract; + function GetLocalizedString(messageId: Integer; out stringVal: ustring): Boolean; virtual; abstract; + function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; out data: Pointer; dataSize: NativeUInt): Boolean; virtual; abstract; + + public + constructor Create; virtual; + end; + + TGetDataResource = reference to function(resourceId: Integer; out data: Pointer; out dataSize: NativeUInt): Boolean; + TGetLocalizedString = reference to function(stringId: Integer; out stringVal: ustring): Boolean; + TGetDataResourceForScale = reference to function(resourceId: Integer; scaleFactor: TCefScaleFactor; out data: Pointer; out dataSize: NativeUInt): Boolean; + + TCefFastResourceBundle = class(TCefResourceBundleHandlerOwn) + protected + FGetDataResource: TGetDataResource; + FGetLocalizedString: TGetLocalizedString; + FGetDataResourceForScale: TGetDataResourceForScale; + + function GetDataResource(resourceId: Integer; out data: Pointer; out dataSize: NativeUInt): Boolean; override; + function GetLocalizedString(stringId: Integer; out stringVal: ustring): Boolean; override; + function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; out data: Pointer; dataSize: NativeUInt): Boolean; override; + + public + constructor Create(AGetDataResource: TGetDataResource; AGetLocalizedString: TGetLocalizedString; AGetDataResourceForScale: TGetDataResourceForScale); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +function cef_resource_bundle_handler_get_localized_string(self: PCefResourceBundleHandler; + string_id: Integer; string_val: PCefString): Integer; stdcall; +var + str: ustring; +begin + Result := Ord(TCefResourceBundleHandlerOwn(CefGetObject(self)). + GetLocalizedString(string_id, str)); + if Result <> 0 then + string_val^ := CefString(str); +end; + +function cef_resource_bundle_handler_get_data_resource(self: PCefResourceBundleHandler; + resource_id: Integer; var data: Pointer; var data_size: NativeUInt): Integer; stdcall; +begin + Result := Ord(TCefResourceBundleHandlerOwn(CefGetObject(self)). + GetDataResource(resource_id, data, data_size)); +end; + +function cef_resource_bundle_handler_get_data_resource_for_scale( + self: PCefResourceBundleHandler; resource_id: Integer; scale_factor: TCefScaleFactor; + out data: Pointer; data_size: NativeUInt): Integer; stdcall; +begin + Result := Ord(TCefResourceBundleHandlerOwn(CefGetObject(self)). + GetDataResourceForScale(resource_id, scale_factor, data, data_size)); +end; + +constructor TCefResourceBundleHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefResourceBundleHandler)); + with PCefResourceBundleHandler(FData)^ do + begin + get_localized_string := cef_resource_bundle_handler_get_localized_string; + get_data_resource := cef_resource_bundle_handler_get_data_resource; + get_data_resource_for_scale := cef_resource_bundle_handler_get_data_resource_for_scale; + end; +end; + +// TCefFastResourceBundle + +constructor TCefFastResourceBundle.Create(AGetDataResource: TGetDataResource; + AGetLocalizedString: TGetLocalizedString; AGetDataResourceForScale: TGetDataResourceForScale); +begin + inherited Create; + FGetDataResource := AGetDataResource; + FGetLocalizedString := AGetLocalizedString; + FGetDataResourceForScale := AGetDataResourceForScale; +end; + +function TCefFastResourceBundle.GetDataResource(resourceId: Integer; + out data: Pointer; out dataSize: NativeUInt): Boolean; +begin + if Assigned(FGetDataResource) then + Result := FGetDataResource(resourceId, data, dataSize) else + Result := False; +end; + +function TCefFastResourceBundle.GetDataResourceForScale(resourceId: Integer; + scaleFactor: TCefScaleFactor; out data: Pointer; + dataSize: NativeUInt): Boolean; +begin + if Assigned(FGetDataResourceForScale) then + Result := FGetDataResourceForScale(resourceId, scaleFactor, data, dataSize) else + Result := False; +end; + +function TCefFastResourceBundle.GetLocalizedString(stringId: Integer; + out stringVal: ustring): Boolean; +begin + if Assigned(FGetLocalizedString) then + Result := FGetLocalizedString(stringId, stringVal) else + Result := False; +end; + +end. diff --git a/uCEFResourceHandler.pas b/uCEFResourceHandler.pas new file mode 100644 index 00000000..e37cd3f3 --- /dev/null +++ b/uCEFResourceHandler.pas @@ -0,0 +1,161 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResourceHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefResourceHandlerOwn = class(TCefBaseOwn, ICefResourceHandler) + protected + function ProcessRequest(const request: ICefRequest; const callback: ICefCallback): Boolean; virtual; + procedure GetResponseHeaders(const response: ICefResponse; out responseLength: Int64; out redirectUrl: ustring); virtual; + function ReadResponse(const dataOut: Pointer; bytesToRead: Integer; var bytesRead: Integer; const callback: ICefCallback): Boolean; virtual; + function CanGetCookie(const cookie: PCefCookie): Boolean; virtual; + function CanSetCookie(const cookie: PCefCookie): Boolean; virtual; + procedure Cancel; virtual; + + public + constructor Create(const browser: ICefBrowser; const frame: ICefFrame; const schemeName: ustring; const request: ICefRequest); virtual; + end; + + TCefResourceHandlerClass = class of TCefResourceHandlerOwn; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFCallback, uCEFRequest, uCEFResponse; + +function cef_resource_handler_process_request(self: PCefResourceHandler; request: PCefRequest; callback: PCefCallback): Integer; stdcall; +begin + with TCefResourceHandlerOwn(CefGetObject(self)) do + Result := Ord(ProcessRequest(TCefRequestRef.UnWrap(request), TCefCallbackRef.UnWrap(callback))); +end; + +procedure cef_resource_handler_get_response_headers(self: PCefResourceHandler; response: PCefResponse; response_length: PInt64; redirectUrl: PCefString); stdcall; +var + ru: ustring; +begin + ru := ''; + + with TCefResourceHandlerOwn(CefGetObject(self)) do + GetResponseHeaders(TCefResponseRef.UnWrap(response), response_length^, ru); + + if ru <> '' then CefStringSet(redirectUrl, ru); +end; + +function cef_resource_handler_read_response(self: PCefResourceHandler; data_out: Pointer; bytes_to_read: Integer; bytes_read: PInteger; callback: PCefCallback): Integer; stdcall; +begin + with TCefResourceHandlerOwn(CefGetObject(self)) do + Result := Ord(ReadResponse(data_out, bytes_to_read, bytes_read^, TCefCallbackRef.UnWrap(callback))); +end; + +function cef_resource_handler_can_get_cookie(self: PCefResourceHandler; const cookie: PCefCookie): Integer; stdcall; +begin + with TCefResourceHandlerOwn(CefGetObject(self)) do Result := Ord(CanGetCookie(cookie)); +end; + +function cef_resource_handler_can_set_cookie(self: PCefResourceHandler; const cookie: PCefCookie): Integer; stdcall; +begin + with TCefResourceHandlerOwn(CefGetObject(self)) do Result := Ord(CanSetCookie(cookie)); +end; + +procedure cef_resource_handler_cancel(self: PCefResourceHandler); stdcall; +begin + with TCefResourceHandlerOwn(CefGetObject(self)) do Cancel; +end; + +procedure TCefResourceHandlerOwn.Cancel; +begin + +end; + +function TCefResourceHandlerOwn.CanGetCookie(const cookie: PCefCookie): Boolean; +begin + Result := False; +end; + +function TCefResourceHandlerOwn.CanSetCookie(const cookie: PCefCookie): Boolean; +begin + Result := False; +end; + +constructor TCefResourceHandlerOwn.Create(const browser: ICefBrowser; + const frame: ICefFrame; const schemeName: ustring; + const request: ICefRequest); +begin + inherited CreateData(SizeOf(TCefResourceHandler)); + with PCefResourceHandler(FData)^ do + begin + process_request := cef_resource_handler_process_request; + get_response_headers := cef_resource_handler_get_response_headers; + read_response := cef_resource_handler_read_response; + can_get_cookie := cef_resource_handler_can_get_cookie; + can_set_cookie := cef_resource_handler_can_set_cookie; + cancel:= cef_resource_handler_cancel; + end; +end; + +procedure TCefResourceHandlerOwn.GetResponseHeaders( + const response: ICefResponse; out responseLength: Int64; + out redirectUrl: ustring); +begin + +end; + +function TCefResourceHandlerOwn.ProcessRequest(const request: ICefRequest; + const callback: ICefCallback): Boolean; +begin + Result := False; +end; + +function TCefResourceHandlerOwn.ReadResponse(const dataOut: Pointer; + bytesToRead: Integer; var bytesRead: Integer; + const callback: ICefCallback): Boolean; +begin + Result := False; +end; + +end. diff --git a/uCEFResponse.pas b/uCEFResponse.pas new file mode 100644 index 00000000..23b60537 --- /dev/null +++ b/uCEFResponse.pas @@ -0,0 +1,157 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResponse; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefResponseRef = class(TCefBaseRef, ICefResponse) + protected + function IsReadOnly: Boolean; + function GetError: TCefErrorCode; + procedure SetError(error: TCefErrorCode); + function GetStatus: Integer; + procedure SetStatus(status: Integer); + function GetStatusText: ustring; + procedure SetStatusText(const StatusText: ustring); + function GetMimeType: ustring; + procedure SetMimeType(const mimetype: ustring); + function GetHeader(const name: ustring): ustring; + procedure GetHeaderMap(const headerMap: ICefStringMultimap); + procedure SetHeaderMap(const headerMap: ICefStringMultimap); + public + class function UnWrap(data: Pointer): ICefResponse; + class function New: ICefResponse; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +class function TCefResponseRef.New: ICefResponse; +begin + Result := UnWrap(cef_response_create); +end; + +function TCefResponseRef.GetError: TCefErrorCode; +begin + Result := PCefResponse(FData)^.get_error(FData); +end; + +function TCefResponseRef.GetHeader(const name: ustring): ustring; +var + n: TCefString; +begin + n := CefString(name); + Result := CefStringFreeAndGet(PCefResponse(FData)^.get_header(PCefResponse(FData), @n)); +end; + +procedure TCefResponseRef.GetHeaderMap(const headerMap: ICefStringMultimap); +begin + PCefResponse(FData)^.get_header_map(PCefResponse(FData), headermap.Handle); +end; + +function TCefResponseRef.GetMimeType: ustring; +begin + Result := CefStringFreeAndGet(PCefResponse(FData)^.get_mime_type(PCefResponse(FData))); +end; + +function TCefResponseRef.GetStatus: Integer; +begin + Result := PCefResponse(FData)^.get_status(PCefResponse(FData)); +end; + +function TCefResponseRef.GetStatusText: ustring; +begin + Result := CefStringFreeAndGet(PCefResponse(FData)^.get_status_text(PCefResponse(FData))); +end; + +function TCefResponseRef.IsReadOnly: Boolean; +begin + Result := PCefResponse(FData)^.is_read_only(PCefResponse(FData)) <> 0; +end; + +procedure TCefResponseRef.SetError(error: TCefErrorCode); +begin + PCefResponse(FData)^.set_error(FData, error); +end; + +procedure TCefResponseRef.SetHeaderMap(const headerMap: ICefStringMultimap); +begin + PCefResponse(FData)^.set_header_map(PCefResponse(FData), headerMap.Handle); +end; + +procedure TCefResponseRef.SetMimeType(const mimetype: ustring); +var + txt: TCefString; +begin + txt := CefString(mimetype); + PCefResponse(FData)^.set_mime_type(PCefResponse(FData), @txt); +end; + +procedure TCefResponseRef.SetStatus(status: Integer); +begin + PCefResponse(FData)^.set_status(PCefResponse(FData), status); +end; + +procedure TCefResponseRef.SetStatusText(const StatusText: ustring); +var + txt: TCefString; +begin + txt := CefString(StatusText); + PCefResponse(FData)^.set_status_text(PCefResponse(FData), @txt); +end; + +class function TCefResponseRef.UnWrap(data: Pointer): ICefResponse; +begin + if data <> nil then + Result := Create(data) as ICefResponse else + Result := nil; +end; + +end. diff --git a/uCEFResponseFilter.pas b/uCEFResponseFilter.pas new file mode 100644 index 00000000..bacf159c --- /dev/null +++ b/uCEFResponseFilter.pas @@ -0,0 +1,88 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResponseFilter; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefResponseFilterOwn = class(TCefBaseOwn, ICefResponseFilter) + protected + function InitFilter: Boolean; virtual; abstract; + function Filter(dataIn: Pointer; dataInSize, dataInRead: NativeUInt; dataOut: Pointer; + dataOutSize, dataOutWritten: NativeUInt): TCefResponseFilterStatus; virtual; abstract; + public + constructor Create; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +function cef_response_filter_init_filter(self: PCefResponseFilter): Integer; stdcall; +begin + with TCefResponseFilterOwn(CefGetObject(self)) do + Result := Ord(InitFilter()); +end; + +function cef_response_filter_filter(self: PCefResponseFilter; data_in: Pointer; data_in_size, data_in_read: NativeUInt; + data_out: Pointer; data_out_size, data_out_written: NativeUInt): TCefResponseFilterStatus; stdcall; +begin + with TCefResponseFilterOwn(CefGetObject(self)) do + Result := Filter(data_in, data_in_size, data_in_read, data_out, data_out_size, data_out_written); +end; + +constructor TCefResponseFilterOwn.Create; +begin + CreateData(SizeOf(TCefResponseFilter), False); + with PCefResponseFilter(FData)^ do + begin + init_filter := cef_response_filter_init_filter; + filter := cef_response_filter_filter; + end; +end; + +end. diff --git a/uCEFRunContextMenuCallback.pas b/uCEFRunContextMenuCallback.pas new file mode 100644 index 00000000..33192384 --- /dev/null +++ b/uCEFRunContextMenuCallback.pas @@ -0,0 +1,83 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRunContextMenuCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefRunContextMenuCallbackRef = class(TCefBaseRef, ICefRunContextMenuCallback) + protected + procedure Cont(commandId: Integer; eventFlags: TCefEventFlags); + procedure Cancel; + public + class function UnWrap(data: Pointer): ICefRunContextMenuCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefRunContextMenuCallbackRef.Cancel; +begin + PCefRunContextMenuCallback(FData).cancel(FData); +end; + +procedure TCefRunContextMenuCallbackRef.Cont(commandId: Integer; + eventFlags: TCefEventFlags); +begin + PCefRunContextMenuCallback(FData).cont(FData, commandId, eventFlags); +end; + +class function TCefRunContextMenuCallbackRef.UnWrap( + data: Pointer): ICefRunContextMenuCallback; +begin + if data <> nil then + Result := Create(data) as ICefRunContextMenuCallback else + Result := nil; +end; + +end. diff --git a/uCEFRunFileDialogCallback.pas b/uCEFRunFileDialogCallback.pas new file mode 100644 index 00000000..db26374c --- /dev/null +++ b/uCEFRunFileDialogCallback.pas @@ -0,0 +1,124 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRunFileDialogCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces; + +type + TCefRunFileDialogCallbackOwn = class(TCefBaseOwn, ICefRunFileDialogCallback) + protected + procedure OnFileDialogDismissed(selectedAcceptFilter: Integer; filePaths: TStrings); virtual; + + public + constructor Create; + end; + + TCefFastRunFileDialogCallback = class(TCefRunFileDialogCallbackOwn) + protected + FCallback: TCefRunFileDialogCallbackProc; + + procedure OnFileDialogDismissed(selectedAcceptFilter: Integer; filePaths: TStrings); override; + + public + constructor Create(callback: TCefRunFileDialogCallbackProc); reintroduce; virtual; + end; + +implementation + +uses + uCEFTypes, uCEFMiscFunctions, uCEFLibFunctions; + +procedure cef_run_file_dialog_callback_on_file_dialog_dismissed(self: PCefRunFileDialogCallback; selected_accept_filter: Integer; file_paths: TCefStringList); stdcall; +var + TempSL : TStringList; + i: Integer; + str: TCefString; +begin + TempSL := TStringList.Create; + try + for i := 0 to cef_string_list_size(file_paths) - 1 do + begin + FillChar(str, SizeOf(str), 0); + cef_string_list_value(file_paths, i, @str); + TempSL.Add(CefStringClearAndGet(str)); + end; + with TCefRunFileDialogCallbackOwn(CefGetObject(self)) do + OnFileDialogDismissed(selected_accept_filter, TempSL); + finally + TempSL.Free; + end; +end; + +// TCefRunFileDialogCallbackOwn + +constructor TCefRunFileDialogCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefRunFileDialogCallback)); + + with PCefRunFileDialogCallback(FData)^ do on_file_dialog_dismissed := cef_run_file_dialog_callback_on_file_dialog_dismissed; +end; + +procedure TCefRunFileDialogCallbackOwn.OnFileDialogDismissed(selectedAcceptFilter: Integer; filePaths: TStrings); +begin + // +end; + +// TCefFastRunFileDialogCallback + +procedure TCefFastRunFileDialogCallback.OnFileDialogDismissed(selectedAcceptFilter: Integer; filePaths: TStrings); +begin + FCallback(selectedAcceptFilter, filePaths); +end; + +constructor TCefFastRunFileDialogCallback.Create(callback: TCefRunFileDialogCallbackProc); +begin + inherited Create; + + FCallback := callback; +end; + +end. diff --git a/uCEFSSLStatus.pas b/uCEFSSLStatus.pas new file mode 100644 index 00000000..584daf9f --- /dev/null +++ b/uCEFSSLStatus.pas @@ -0,0 +1,102 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFSSLStatus; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefSSLStatusRef = class(TCefBaseRef, ICefSSLStatus) + protected + function IsSecureConnection: boolean; + function GetCertStatus: TCefCertStatus; + function GetSSLVersion: TCefSSLVersion; + function GetContentStatus: TCefSSLContentStatus; + function GetX509Certificate: ICefX509Certificate; + + public + class function UnWrap(data: Pointer): ICefSSLStatus; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue, uCEFX509Certificate; + +function TCefSSLStatusRef.IsSecureConnection: boolean; +begin + Result := (PCefSSLStatus(FData).is_secure_connection(FData) <> 0); +end; + +function TCefSSLStatusRef.GetCertStatus: TCefCertStatus; +begin + Result := PCefSSLStatus(FData).get_cert_status(FData); +end; + +function TCefSSLStatusRef.GetSSLVersion: TCefSSLVersion; +begin + Result := PCefSSLStatus(FData).get_sslversion(FData); +end; + +function TCefSSLStatusRef.GetContentStatus: TCefSSLContentStatus; +begin + Result := PCefSSLStatus(FData).get_content_status(FData); +end; + +function TCefSSLStatusRef.GetX509Certificate: ICefX509Certificate; +begin + Result := TCEFX509CertificateRef.UnWrap(PCefSSLStatus(FData).get_x509certificate(FData)); +end; + +class function TCefSSLStatusRef.UnWrap(data: Pointer): ICefSSLStatus; +begin + if (data <> nil) then + Result := Create(data) as ICefSSLStatus + else + Result := nil; +end; + +end. diff --git a/uCEFSchemeHandlerFactory.pas b/uCEFSchemeHandlerFactory.pas new file mode 100644 index 00000000..df37e53c --- /dev/null +++ b/uCEFSchemeHandlerFactory.pas @@ -0,0 +1,93 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFSchemeHandlerFactory; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes, uCEFResourceHandler; + +type + TCefSchemeHandlerFactoryOwn = class(TCefBaseOwn, ICefSchemeHandlerFactory) + protected + FClass: TCefResourceHandlerClass; + + function New(const browser: ICefBrowser; const frame: ICefFrame; const schemeName: ustring; const request: ICefRequest): ICefResourceHandler; virtual; + + public + constructor Create(const AClass: TCefResourceHandlerClass); virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFRequest; + +function cef_scheme_handler_factory_create(self: PCefSchemeHandlerFactory; + browser: PCefBrowser; frame: PCefFrame; const scheme_name: PCefString; + request: PCefRequest): PCefResourceHandler; stdcall; +begin + + with TCefSchemeHandlerFactoryOwn(CefGetObject(self)) do + Result := CefGetData(New(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), + CefString(scheme_name), TCefRequestRef.UnWrap(request))); +end; + +constructor TCefSchemeHandlerFactoryOwn.Create( + const AClass: TCefResourceHandlerClass); +begin + inherited CreateData(SizeOf(TCefSchemeHandlerFactory)); + FClass := AClass; + with PCefSchemeHandlerFactory(FData)^ do + create := cef_scheme_handler_factory_create; +end; + +function TCefSchemeHandlerFactoryOwn.New(const browser: ICefBrowser; + const frame: ICefFrame; const schemeName: ustring; + const request: ICefRequest): ICefResourceHandler; +begin + Result := FClass.Create(browser, frame, schemeName, request); +end; + + +end. diff --git a/uCEFSchemeRegistrar.pas b/uCEFSchemeRegistrar.pas new file mode 100644 index 00000000..24ad96e2 --- /dev/null +++ b/uCEFSchemeRegistrar.pas @@ -0,0 +1,79 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFSchemeRegistrar; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefSchemeRegistrarRef = class(TCefBaseRef, ICefSchemeRegistrar) + protected + function AddCustomScheme(const schemeName: ustring; IsStandard, IsLocal, IsDisplayIsolated: Boolean): Boolean; stdcall; + + public + class function UnWrap(data: Pointer): ICefSchemeRegistrar; + end; + +implementation + +uses + uCEFMiscFunctions; + +function TCefSchemeRegistrarRef.AddCustomScheme(const schemeName: ustring; IsStandard, IsLocal, IsDisplayIsolated: Boolean): Boolean; +var + sn: TCefString; +begin + sn := CefString(schemeName); + Result := PCefSchemeRegistrar(FData).add_custom_scheme(PCefSchemeRegistrar(FData), @sn, Ord(IsStandard), Ord(IsLocal), Ord(IsDisplayIsolated)) <> 0; +end; + +class function TCefSchemeRegistrarRef.UnWrap(data: Pointer): ICefSchemeRegistrar; +begin + if data <> nil then + Result := Create(data) as ICefSchemeRegistrar else + Result := nil; +end; + +end. diff --git a/uCEFSelectClientCertificateCallback.pas b/uCEFSelectClientCertificateCallback.pas new file mode 100644 index 00000000..e236782a --- /dev/null +++ b/uCEFSelectClientCertificateCallback.pas @@ -0,0 +1,79 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFSelectClientCertificateCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefSelectClientCertificateCallbackRef = class(TCefBaseRef, ICefSelectClientCertificateCallback) + protected + procedure Select(const cert: ICefX509Certificate); + + public + class function UnWrap(data: Pointer): ICefSelectClientCertificateCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFX509Certificate; + +// TCefSelectClientCertificateCallbackRef + +procedure TCefSelectClientCertificateCallbackRef.Select(const cert: ICefX509Certificate); +begin + PCefSelectClientCertificateCallback(FData).select(PCefSelectClientCertificateCallback(FData), CefGetData(cert)); +end; + +class function TCefSelectClientCertificateCallbackRef.UnWrap(data: Pointer): ICefSelectClientCertificateCallback; +begin + if (data <> nil) then + Result := Create(data) as ICefSelectClientCertificateCallback + else + Result := nil; +end; + +end. diff --git a/uCEFSetCookieCallback.pas b/uCEFSetCookieCallback.pas new file mode 100644 index 00000000..75584674 --- /dev/null +++ b/uCEFSetCookieCallback.pas @@ -0,0 +1,101 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFSetCookieCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefSetCookieCallbackOwn = class(TCefBaseOwn, ICefSetCookieCallback) + protected + procedure OnComplete(success: Boolean); virtual; abstract; + + public + constructor Create; virtual; + end; + + TCefFastSetCookieCallback = class(TCefSetCookieCallbackOwn) + protected + FCallback: TCefSetCookieCallbackProc; + + procedure OnComplete(success: Boolean); override; + + public + constructor Create(const callback: TCefSetCookieCallbackProc); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure cef_set_cookie_callback_on_complete(self: PCefSetCookieCallback; success: Integer); stdcall; +begin + with TCefSetCookieCallbackOwn(CefGetObject(self)) do + OnComplete(success <> 0); +end; + +constructor TCefSetCookieCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefSetCookieCallback)); + with PCefSetCookieCallback(FData)^ do + on_complete := cef_set_cookie_callback_on_complete; +end; + +// TCefFastSetCookieCallback + +constructor TCefFastSetCookieCallback.Create( + const callback: TCefSetCookieCallbackProc); +begin + inherited Create; + FCallback := callback; +end; + +procedure TCefFastSetCookieCallback.OnComplete(success: Boolean); +begin + FCallback(success); +end; + +end. diff --git a/uCEFSslInfo.pas b/uCEFSslInfo.pas new file mode 100644 index 00000000..19b2bb83 --- /dev/null +++ b/uCEFSslInfo.pas @@ -0,0 +1,85 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFSslInfo; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefSslInfoRef = class(TCefBaseRef, ICefSslInfo) + protected + function GetCertStatus: TCefCertStatus; + function GetX509Certificate: ICefX509Certificate; + + public + class function UnWrap(data: Pointer): ICefSslInfo; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue, uCEFX509Certificate; + + +function TCefSslInfoRef.GetCertStatus: TCefCertStatus; +begin + Result := PCefSslInfo(FData).get_cert_status(FData); +end; + +function TCefSslInfoRef.GetX509Certificate: ICefX509Certificate; +begin + Result := TCEFX509CertificateRef.UnWrap(PCefSslInfo(FData).get_x509certificate(FData)); +end; + +class function TCefSslInfoRef.UnWrap(data: Pointer): ICefSslInfo; +begin + if (data <> nil) then + Result := Create(data) as ICefSslInfo + else + Result := nil; +end; + +end. diff --git a/uCEFStreamReader.pas b/uCEFStreamReader.pas new file mode 100644 index 00000000..147f2850 --- /dev/null +++ b/uCEFStreamReader.pas @@ -0,0 +1,129 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFStreamReader; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefStreamReaderRef = class(TCefBaseRef, ICefStreamReader) + protected + function Read(ptr: Pointer; size, n: NativeUInt): NativeUInt; + function Seek(offset: Int64; whence: Integer): Integer; + function Tell: Int64; + function Eof: Boolean; + function MayBlock: Boolean; + public + class function UnWrap(data: Pointer): ICefStreamReader; + class function CreateForFile(const filename: ustring): ICefStreamReader; + class function CreateForCustomStream(const stream: ICefCustomStreamReader): ICefStreamReader; + class function CreateForStream(const stream: TSTream; owned: Boolean): ICefStreamReader; + class function CreateForData(data: Pointer; size: NativeUInt): ICefStreamReader; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFCustomStreamReader; + +class function TCefStreamReaderRef.CreateForCustomStream( + const stream: ICefCustomStreamReader): ICefStreamReader; +begin + Result := UnWrap(cef_stream_reader_create_for_handler(CefGetData(stream))) +end; + +class function TCefStreamReaderRef.CreateForData(data: Pointer; size: NativeUInt): ICefStreamReader; +begin + Result := UnWrap(cef_stream_reader_create_for_data(data, size)) +end; + +class function TCefStreamReaderRef.CreateForFile(const filename: ustring): ICefStreamReader; +var + f: TCefString; +begin + f := CefString(filename); + Result := UnWrap(cef_stream_reader_create_for_file(@f)) +end; + +class function TCefStreamReaderRef.CreateForStream(const stream: TSTream; + owned: Boolean): ICefStreamReader; +begin + Result := CreateForCustomStream(TCefCustomStreamReader.Create(stream, owned) as ICefCustomStreamReader); +end; + +function TCefStreamReaderRef.Eof: Boolean; +begin + Result := PCefStreamReader(FData)^.eof(PCefStreamReader(FData)) <> 0; +end; + +function TCefStreamReaderRef.MayBlock: Boolean; +begin + Result := PCefStreamReader(FData)^.may_block(FData) <> 0; +end; + +function TCefStreamReaderRef.Read(ptr: Pointer; size, n: NativeUInt): NativeUInt; +begin + Result := PCefStreamReader(FData)^.read(PCefStreamReader(FData), ptr, size, n); +end; + +function TCefStreamReaderRef.Seek(offset: Int64; whence: Integer): Integer; +begin + Result := PCefStreamReader(FData)^.seek(PCefStreamReader(FData), offset, whence); +end; + +function TCefStreamReaderRef.Tell: Int64; +begin + Result := PCefStreamReader(FData)^.tell(PCefStreamReader(FData)); +end; + +class function TCefStreamReaderRef.UnWrap(data: Pointer): ICefStreamReader; +begin + if data <> nil then + Result := Create(data) as ICefStreamReader else + Result := nil; +end; + +end. diff --git a/uCEFStreamWriter.pas b/uCEFStreamWriter.pas new file mode 100644 index 00000000..5c14e4c8 --- /dev/null +++ b/uCEFStreamWriter.pas @@ -0,0 +1,115 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFStreamWriter; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefStreamWriterRef = class(TCefBaseRef, ICefStreamWriter) + protected + function write(const ptr: Pointer; size, n: NativeUInt): NativeUInt; + function Seek(offset: Int64; whence: Integer): Integer; + function Tell: Int64; + function Flush: Integer; + function MayBlock: Boolean; + + public + class function UnWrap(data: Pointer): ICefStreamWriter; + class function CreateForFile(const fileName: ustring): ICefStreamWriter; + class function CreateForHandler(const handler: ICefWriteHandler): ICefStreamWriter; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +class function TCefStreamWriterRef.CreateForFile(const fileName: ustring): ICefStreamWriter; +var + s: TCefString; +begin + s := CefString(fileName); + Result := UnWrap(cef_stream_writer_create_for_file(@s)); +end; + +class function TCefStreamWriterRef.CreateForHandler(const handler: ICefWriteHandler): ICefStreamWriter; +begin + Result := UnWrap(cef_stream_writer_create_for_handler(CefGetData(handler))); +end; + +function TCefStreamWriterRef.Flush: Integer; +begin + Result := PCefStreamWriter(FData).flush(FData); +end; + +function TCefStreamWriterRef.MayBlock: Boolean; +begin + Result := PCefStreamWriter(FData).may_block(FData) <> 0; +end; + +function TCefStreamWriterRef.Seek(offset: Int64; whence: Integer): Integer; +begin + Result := PCefStreamWriter(FData).seek(FData, offset, whence); +end; + +function TCefStreamWriterRef.Tell: Int64; +begin + Result := PCefStreamWriter(FData).tell(FData); +end; + +class function TCefStreamWriterRef.UnWrap(data: Pointer): ICefStreamWriter; +begin + if data <> nil then + Result := Create(data) as ICefStreamWriter else + Result := nil; +end; + +function TCefStreamWriterRef.write(const ptr: Pointer; size, n: NativeUInt): NativeUInt; +begin + Result := PCefStreamWriter(FData).write(FData, ptr, size, n); +end; + +end. diff --git a/uCEFStringMap.pas b/uCEFStringMap.pas new file mode 100644 index 00000000..1931e570 --- /dev/null +++ b/uCEFStringMap.pas @@ -0,0 +1,135 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFStringMap; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefStringMapOwn = class(TInterfacedObject, ICefStringMap) + protected + FStringMap: TCefStringMap; + + function GetHandle: TCefStringMap; virtual; + function GetSize: Integer; virtual; + function Find(const key: ustring): ustring; virtual; + function GetKey(index: Integer): ustring; virtual; + function GetValue(index: Integer): ustring; virtual; + procedure Append(const key, value: ustring); virtual; + procedure Clear; virtual; + + public + constructor Create; virtual; + destructor Destroy; override; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefStringMapOwn.Append(const key, value: ustring); +var + k, v: TCefString; +begin + k := CefString(key); + v := CefString(value); + cef_string_map_append(FStringMap, @k, @v); +end; + +procedure TCefStringMapOwn.Clear; +begin + cef_string_map_clear(FStringMap); +end; + +constructor TCefStringMapOwn.Create; +begin + FStringMap := cef_string_map_alloc; +end; + +destructor TCefStringMapOwn.Destroy; +begin + cef_string_map_free(FStringMap); +end; + +function TCefStringMapOwn.Find(const key: ustring): ustring; +var + str, k: TCefString; +begin + FillChar(str, SizeOf(str), 0); + k := CefString(key); + cef_string_map_find(FStringMap, @k, str); + Result := CefString(@str); +end; + +function TCefStringMapOwn.GetHandle: TCefStringMap; +begin + Result := FStringMap; +end; + +function TCefStringMapOwn.GetKey(index: Integer): ustring; +var + str: TCefString; +begin + FillChar(str, SizeOf(str), 0); + cef_string_map_key(FStringMap, index, str); + Result := CefString(@str); +end; + +function TCefStringMapOwn.GetSize: Integer; +begin + Result := cef_string_map_size(FStringMap); +end; + +function TCefStringMapOwn.GetValue(index: Integer): ustring; +var + str: TCefString; +begin + FillChar(str, SizeOf(str), 0); + cef_string_map_value(FStringMap, index, str); + Result := CefString(@str); +end; + +end. diff --git a/uCEFStringMultimap.pas b/uCEFStringMultimap.pas new file mode 100644 index 00000000..47a5a5ec --- /dev/null +++ b/uCEFStringMultimap.pas @@ -0,0 +1,146 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFStringMultimap; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefStringMultimapOwn = class(TInterfacedObject, ICefStringMultimap) + protected + FStringMap: TCefStringMultimap; + + function GetHandle: TCefStringMultimap; virtual; + function GetSize: Integer; virtual; + function FindCount(const Key: ustring): Integer; virtual; + function GetEnumerate(const Key: ustring; ValueIndex: Integer): ustring; virtual; + function GetKey(Index: Integer): ustring; virtual; + function GetValue(Index: Integer): ustring; virtual; + procedure Append(const Key, Value: ustring); virtual; + procedure Clear; virtual; + + public + constructor Create; virtual; + destructor Destroy; override; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefStringMultimapOwn.Append(const Key, Value: ustring); +var + k, v: TCefString; +begin + k := CefString(key); + v := CefString(value); + cef_string_multimap_append(FStringMap, @k, @v); +end; + +procedure TCefStringMultimapOwn.Clear; +begin + cef_string_multimap_clear(FStringMap); +end; + +constructor TCefStringMultimapOwn.Create; +begin + FStringMap := cef_string_multimap_alloc; +end; + +destructor TCefStringMultimapOwn.Destroy; +begin + cef_string_multimap_free(FStringMap); + inherited; +end; + +function TCefStringMultimapOwn.FindCount(const Key: ustring): Integer; +var + k: TCefString; +begin + k := CefString(Key); + Result := cef_string_multimap_find_count(FStringMap, @k); +end; + +function TCefStringMultimapOwn.GetEnumerate(const Key: ustring; + ValueIndex: Integer): ustring; +var + k, v: TCefString; +begin + k := CefString(Key); + FillChar(v, SizeOf(v), 0); + cef_string_multimap_enumerate(FStringMap, @k, ValueIndex, v); + Result := CefString(@v); +end; + +function TCefStringMultimapOwn.GetHandle: TCefStringMultimap; +begin + Result := FStringMap; +end; + +function TCefStringMultimapOwn.GetKey(Index: Integer): ustring; +var + str: TCefString; +begin + FillChar(str, SizeOf(str), 0); + cef_string_multimap_key(FStringMap, index, str); + Result := CefString(@str); +end; + +function TCefStringMultimapOwn.GetSize: Integer; +begin + Result := cef_string_multimap_size(FStringMap); +end; + +function TCefStringMultimapOwn.GetValue(Index: Integer): ustring; +var + str: TCefString; +begin + FillChar(str, SizeOf(str), 0); + cef_string_multimap_value(FStringMap, index, str); + Result := CefString(@str); +end; + +end. diff --git a/uCEFStringVisitor.pas b/uCEFStringVisitor.pas new file mode 100644 index 00000000..b91c556a --- /dev/null +++ b/uCEFStringVisitor.pas @@ -0,0 +1,132 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFStringVisitor; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefStringVisitorOwn = class(TCefBaseOwn, ICefStringVisitor) + protected + procedure Visit(const str: ustring); virtual; + + public + constructor Create; virtual; + end; + + TCefFastStringVisitor = class(TCefStringVisitorOwn, ICefStringVisitor) + protected + FVisit: TCefStringVisitorProc; + + procedure Visit(const str: ustring); override; + + public + constructor Create(const callback: TCefStringVisitorProc); reintroduce; + end; + + TCustomCefStringVisitor = class(TCefStringVisitorOwn) + protected + FChromiumBrowser : TObject; + + procedure Visit(const str: ustring); override; + + public + constructor Create(const aChromiumBrowser : TObject); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFChromium; + +procedure cef_string_visitor_visit(self: PCefStringVisitor; const str: PCefString); stdcall; +begin + TCefStringVisitorOwn(CefGetObject(self)).Visit(CefString(str)); +end; + +// TCefStringVisitorOwn + +constructor TCefStringVisitorOwn.Create; +begin + inherited CreateData(SizeOf(TCefStringVisitor)); + + with PCefStringVisitor(FData)^ do visit := cef_string_visitor_visit; +end; + +procedure TCefStringVisitorOwn.Visit(const str: ustring); +begin + // +end; + +// TCefFastStringVisitor + +constructor TCefFastStringVisitor.Create(const callback: TCefStringVisitorProc); +begin + inherited Create; + + FVisit := callback; +end; + +procedure TCefFastStringVisitor.Visit(const str: ustring); +begin + FVisit(str); +end; + +// TCustomCefStringVisitor + +constructor TCustomCefStringVisitor.Create(const aChromiumBrowser : TObject); +begin + inherited Create; + + FChromiumBrowser := aChromiumBrowser; +end; + +procedure TCustomCefStringVisitor.Visit(const str: ustring); +begin + if (FChromiumBrowser <> nil) and (FChromiumBrowser is TChromium) then + TChromium(FChromiumBrowser).TextResultAvailable(str); +end; + +end. diff --git a/uCEFTask.pas b/uCEFTask.pas new file mode 100644 index 00000000..82e61706 --- /dev/null +++ b/uCEFTask.pas @@ -0,0 +1,217 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFTask; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefTaskOwn = class(TCefBaseOwn, ICefTask) + protected + procedure Execute; virtual; + + public + constructor Create; virtual; + end; + + TCefTaskRef = class(TCefBaseRef, ICefTask) + protected + procedure Execute; virtual; + + public + class function UnWrap(data: Pointer): ICefTask; + end; + + TCefFastTaskProc = reference to procedure; + + TCefFastTask = class(TCefTaskOwn) + protected + FMethod: TCefFastTaskProc; + + procedure Execute; override; + + public + class procedure New(threadId: TCefThreadId; const method: TCefFastTaskProc); + class procedure NewDelayed(threadId: TCefThreadId; Delay: Int64; const method: TCefFastTaskProc); + constructor Create(const method: TCefFastTaskProc); reintroduce; + end; + + TCefGetHTMLTask = class(TCefTaskOwn) + protected + FChromiumBrowser : TObject; + + procedure Execute; override; + + public + constructor Create(const aChromiumBrowser : TObject); reintroduce; + end; + + TCefGetDocumentTask = class(TCefTaskOwn) + protected + FChromiumBrowser : TObject; + + procedure Execute; override; + + public + constructor Create(const aChromiumBrowser : TObject); reintroduce; + end; + + TCefDeleteCookiesTask = class(TCefTaskOwn) + protected + FCallBack : ICefDeleteCookiesCallback; + + procedure Execute; override; + + public + constructor Create(const aCallBack : ICefDeleteCookiesCallback); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFChromium, uCEFCookieManager; + +procedure cef_task_execute(self: PCefTask); stdcall; +begin + TCefTaskOwn(CefGetObject(self)).Execute(); +end; + +constructor TCefTaskOwn.Create; +begin + inherited CreateData(SizeOf(TCefTask)); + + with PCefTask(FData)^ do execute := cef_task_execute; +end; + +procedure TCefTaskOwn.Execute; +begin + // +end; + +// TCefTaskRef + +procedure TCefTaskRef.Execute; +begin + PCefTask(FData).execute(FData); +end; + +class function TCefTaskRef.UnWrap(data: Pointer): ICefTask; +begin + if data <> nil then + Result := Create(data) as ICefTask + else + Result := nil; +end; + +// TCefFastTask + +constructor TCefFastTask.Create(const method: TCefFastTaskProc); +begin + inherited Create; + + FMethod := method; +end; + +procedure TCefFastTask.Execute; +begin + FMethod(); +end; + +class procedure TCefFastTask.New(threadId: TCefThreadId; const method: TCefFastTaskProc); +begin + CefPostTask(threadId, Create(method)); +end; + +class procedure TCefFastTask.NewDelayed(threadId: TCefThreadId; Delay: Int64; const method: TCefFastTaskProc); +begin + CefPostDelayedTask(threadId, Create(method), Delay); +end; + +// TCefGetHTMLTask +constructor TCefGetHTMLTask.Create(const aChromiumBrowser : TObject); +begin + inherited Create; + + FChromiumBrowser := aChromiumBrowser; +end; + +procedure TCefGetHTMLTask.Execute; +begin + if (FChromiumBrowser <> nil) and (FChromiumBrowser is TChromium) then + TChromium(FChromiumBrowser).GetHTML; +end; + +// TCefGetDocumentTask +constructor TCefGetDocumentTask.Create(const aChromiumBrowser : TObject); +begin + inherited Create; + + FChromiumBrowser := aChromiumBrowser; +end; + +procedure TCefGetDocumentTask.Execute; +begin + if (FChromiumBrowser <> nil) and (FChromiumBrowser is TChromium) then + TChromium(FChromiumBrowser).VisitDOM; +end; + +// TCefDeleteCookiesTask + +constructor TCefDeleteCookiesTask.Create(const aCallBack : ICefDeleteCookiesCallback); +begin + inherited Create; + + FCallBack := aCallBack; +end; + +procedure TCefDeleteCookiesTask.Execute; +var + CookieManager : ICefCookieManager; +begin + CookieManager := TCefCookieManagerRef.Global(nil); + CookieManager.DeleteCookies('', '', FCallBack); +end; + +end. diff --git a/uCEFTaskRunner.pas b/uCEFTaskRunner.pas new file mode 100644 index 00000000..5634788a --- /dev/null +++ b/uCEFTaskRunner.pas @@ -0,0 +1,113 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFTaskRunner; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefTaskRunnerRef = class(TCefBaseRef, ICefTaskRunner) + protected + function IsSame(const that: ICefTaskRunner): Boolean; + function BelongsToCurrentThread: Boolean; + function BelongsToThread(threadId: TCefThreadId): Boolean; + function PostTask(const task: ICefTask): Boolean; stdcall; + function PostDelayedTask(const task: ICefTask; delayMs: Int64): Boolean; + public + class function UnWrap(data: Pointer): ICefTaskRunner; + class function GetForCurrentThread: ICefTaskRunner; + class function GetForThread(threadId: TCefThreadId): ICefTaskRunner; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +function TCefTaskRunnerRef.BelongsToCurrentThread: Boolean; +begin + Result := PCefTaskRunner(FData).belongs_to_current_thread(FData) <> 0; +end; + +function TCefTaskRunnerRef.BelongsToThread(threadId: TCefThreadId): Boolean; +begin + Result := PCefTaskRunner(FData).belongs_to_thread(FData, threadId) <> 0; +end; + +class function TCefTaskRunnerRef.GetForCurrentThread: ICefTaskRunner; +begin + Result := UnWrap(cef_task_runner_get_for_current_thread()); +end; + +class function TCefTaskRunnerRef.GetForThread(threadId: TCefThreadId): ICefTaskRunner; +begin + Result := UnWrap(cef_task_runner_get_for_thread(threadId)); +end; + +function TCefTaskRunnerRef.IsSame(const that: ICefTaskRunner): Boolean; +begin + Result := PCefTaskRunner(FData).is_same(FData, CefGetData(that)) <> 0; +end; + +function TCefTaskRunnerRef.PostDelayedTask(const task: ICefTask; + delayMs: Int64): Boolean; +begin + Result := PCefTaskRunner(FData).post_delayed_task(FData, CefGetData(task), delayMs) <> 0; +end; + +function TCefTaskRunnerRef.PostTask(const task: ICefTask): Boolean; +begin + Result := PCefTaskRunner(FData).post_task(FData, CefGetData(task)) <> 0; +end; + +class function TCefTaskRunnerRef.UnWrap(data: Pointer): ICefTaskRunner; +begin + if data <> nil then + Result := Create(data) as ICefTaskRunner else + Result := nil; +end; + +end. diff --git a/uCEFThread.pas b/uCEFThread.pas new file mode 100644 index 00000000..cfd04f86 --- /dev/null +++ b/uCEFThread.pas @@ -0,0 +1,103 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFThread; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefThreadRef = class(TCefBaseRef, ICefThread) + protected + function GetTaskRunner : ICefTaskRunner; + function GetPlatformThreadID : TCefPlatformThreadId; + procedure Stop; + function IsRunning : boolean; + public + class function UnWrap(data: Pointer): ICefThread; + class function New(const display_name: ustring; priority: TCefThreadPriority; message_loop_type: TCefMessageLoopType; stoppable: integer; com_init_mode: TCefCOMInitMode): ICefThread; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFTaskRunner; + +function TCefThreadRef.GetTaskRunner : ICefTaskRunner; +begin + Result := TCefTaskRunnerRef.UnWrap(PCefThread(FData).get_task_runner(FData)); +end; + +function TCefThreadRef.GetPlatformThreadID : TCefPlatformThreadId; +begin + Result := PCefThread(FData).get_platform_thread_id(FData); +end; + +procedure TCefThreadRef.Stop; +begin + PCefThread(FData).stop(FData); +end; + +function TCefThreadRef.IsRunning: Boolean; +begin + Result := (PCefThread(FData).is_running(FData) <> 0); +end; + +class function TCefThreadRef.UnWrap(data: Pointer): ICefThread; +begin + if (data <> nil) then + Result := Create(data) as ICefThread + else + Result := nil; +end; + +class function TCefThreadRef.New(const display_name: ustring; priority: TCefThreadPriority; message_loop_type: TCefMessageLoopType; stoppable: integer; com_init_mode: TCefCOMInitMode): ICefThread; +var + TempString : TCefString; +begin + TempString := CefString(display_name); + Result := UnWrap(cef_thread_create(@TempString, priority, message_loop_type, stoppable, com_init_mode)); +end; + +end. diff --git a/uCEFTypes.pas b/uCEFTypes.pas new file mode 100644 index 00000000..fab319fb --- /dev/null +++ b/uCEFTypes.pas @@ -0,0 +1,2524 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFTypes; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + WinApi.Windows, System.Math; + +type + PCefStringWide = ^TCefStringWide; + PCefDictionaryValue = ^TCefDictionaryValue; + PCefListValue = ^TCefListValue; + PCefBrowser = ^TCefBrowser; + PCefValue = ^TCefValue; + PCefBinaryValue = ^TCefBinaryValue; + PPCefBinaryValue = ^PCefBinaryValue; + PCefSchemeRegistrar = ^TCefSchemeRegistrar; + PCefCommandLine = ^TCefCommandLine; + PCefBase = ^TCefBase; + PCefWindowInfo = ^TCefWindowInfo; + PCefSettings = ^TCefSettings; + PCefStringUtf8 = ^TCefStringUtf8; + PCefStringUtf16 = ^TCefStringUtf16; + PCefStringUserFreeWide = ^TCefStringUserFreeWide; + PCefStringUserFreeUtf8 = ^TCefStringUserFreeUtf8; + PCefStringUserFreeUtf16 = ^TCefStringUserFreeUtf16; + PCefMainArgs = ^TCefMainArgs; + PCefColor = ^TCefColor; + PCefBrowserHost = ^TCefBrowserHost; + PCefClient = ^TCefClient; + PCefPrintHandler = ^TCefPrintHandler; + PCefResourceBundleHandler = ^TCefResourceBundleHandler; + PCefBrowserProcessHandler = ^TCefBrowserProcessHandler; + PCefContextMenuHandler = ^TCefContextMenuHandler; + PCefFrame = ^TCefFrame; + PCefApp = ^TCefApp; + PCefStringVisitor = ^TCefStringVisitor; + PCefRequest = ^TCefRequest; + PCefPostData = ^TCefPostData; + PCefPostDataElementArray = ^TCefPostDataElementArray; + PCefPostDataElement = ^TCefPostDataElement; + PPCefPostDataElement = ^PCefPostDataElement; + PCefv8Context = ^TCefv8Context; + PCefV8Interceptor = ^TCefV8Interceptor; + PCefTask = ^TCefTask; + PCefv8Value = ^TCefv8Value; + PCefTime = ^TCefTime; + PCefV8Exception = ^TCefV8Exception; + PCefv8Handler = ^TCefv8Handler; + PPCefV8Value = ^PCefV8ValueArray; + PCefDomVisitor = ^TCefDomVisitor; + PCefDomDocument = ^TCefDomDocument; + PCefDomNode = ^TCefDomNode; + PCefContextMenuParams = ^TCefContextMenuParams; + PCefMenuModel = ^TCefMenuModel; + PCefRunContextMenuCallback = ^TCefRunContextMenuCallback; + PCefDialogHandler = ^TCefDialogHandler; + PCefFileDialogCallback = ^TCefFileDialogCallback; + PCefDisplayHandler = ^TCefDisplayHandler; + PCefDownloadHandler = ^TCefDownloadHandler; + PCefDownloadItem = ^TCefDownloadItem; + PCefBeforeDownloadCallback = ^TCefBeforeDownloadCallback; + PCefDownloadItemCallback = ^TCefDownloadItemCallback; + PCefDragHandler = ^TCefDragHandler; + PCefDragData = ^TCefDragData; + PCefDraggableRegionArray = ^TCefDraggableRegionArray; + PCefDraggableRegion = ^TCefDraggableRegion; + PCefRect = ^TCefRect; + PCefPoint = ^TCefPoint; + PCefSize = ^TCefSize; + PCefRectArray = ^TCefRectArray; + PCefRange = ^TCefRange; + PCefStreamWriter = ^TCefStreamWriter; + PCefFindHandler = ^TCefFindHandler; + PCefFocusHandler = ^TCefFocusHandler; + PCefGeolocationHandler = ^TCefGeolocationHandler; + PCefGeolocationCallback = ^TCefGeolocationCallback; + PCefJsDialogHandler = ^TCefJsDialogHandler; + PCefJsDialogCallback = ^TCefJsDialogCallback; + PCefKeyboardHandler = ^TCefKeyboardHandler; + PCefKeyEvent = ^TCefKeyEvent; + PCefLifeSpanHandler = ^TCefLifeSpanHandler; + PCefPopupFeatures = ^TCefPopupFeatures; + PCefBrowserSettings = ^TCefBrowserSettings; + PCefLoadHandler = ^TCefLoadHandler; + PCefRenderHandler = ^TCefRenderHandler; + PCefScreenInfo = ^TCefScreenInfo; + PCefRenderProcessHandler = ^TCefRenderProcessHandler; + PCefCursorInfo = ^TCefCursorInfo; + PCefThread = ^TCefThread; + PCefWaitableEvent = ^TCefWaitableEvent; + PCefV8StackTrace = ^TCefV8StackTrace; + PCefV8StackFrame = ^TCefV8StackFrame; + PCefProcessMessage = ^TCefProcessMessage; + PCefRequestHandler = ^TCefRequestHandler; + PCefRequestCallback = ^TCefRequestCallback; + PCefResourceHandler = ^TCefResourceHandler; + PCefResponse = ^TCefResponse; + PCefResponseFilter = ^TCefResponseFilter; + PCefAuthCallback = ^TCefAuthCallback; + PCefSslInfo = ^TCefSslInfo; + PCefSSLStatus = ^TCefSSLStatus; + PCefSelectClientCertificateCallback = ^TCefSelectClientCertificateCallback; + PCefCallback = ^TCefCallback; + PCefCookie = ^TCefCookie; + PCefRequestContext = ^TCefRequestContext; + PCefRequestContextHandler = ^TCefRequestContextHandler; + PCefCompletionCallback = ^TCefCompletionCallback; + PCefCookieManager = ^TCefCookieManager; + PCefSchemeHandlerFactory = ^TCefSchemeHandlerFactory; + PCefResolveCallback = ^TCefResolveCallback; + PCefWebPluginInfo = ^TCefWebPluginInfo; + PCefPluginPolicy = ^TCefPluginPolicy; + PCefCookieVisitor = ^TCefCookieVisitor; + PCefSetCookieCallback = ^TCefSetCookieCallback; + PCefDeleteCookiesCallback = ^TCefDeleteCookiesCallback; + PCefRunFileDialogCallback = ^TCefRunFileDialogCallback; + PCefDownloadImageCallback = ^TCefDownloadImageCallback; + PCefImage = ^TCefImage; + PCefPdfPrintSettings = ^TCefPdfPrintSettings; + PCefPdfPrintCallback = ^TCefPdfPrintCallback; + PCefNavigationEntryVisitor = ^TCefNavigationEntryVisitor; + PCefNavigationEntry = ^TCefNavigationEntry; + PCefMouseEvent = ^TCefMouseEvent; + PCefPrintSettings = ^TCefPrintSettings; + PCefPrintDialogCallback = ^TCefPrintDialogCallback; + PCefPrintJobCallback = ^TCefPrintJobCallback; + PCefUrlParts = ^TCefUrlParts; + PCefJsonParserError = ^TCefJsonParserError; + PCefStreamReader = ^TCefStreamReader; + PCefReadHandler = ^TCefReadHandler; + PCefWriteHandler = ^TCefWriteHandler; + PCefV8Accessor = ^TCefV8Accessor; + PCefXmlReader = ^TCefXmlReader; + PCefZipReader = ^TCefZipReader; + PCefUrlRequestClient = ^TCefUrlRequestClient; + PCefUrlRequest = ^TCefUrlRequest; + PCefWebPluginInfoVisitor = ^TCefWebPluginInfoVisitor; + PCefWebPluginUnstableCallback = ^TCefWebPluginUnstableCallback; + PCefRegisterCDMCallback = ^TCefRegisterCDMCallback; + PCefGetGeolocationCallback = ^TCefGetGeolocationCallback; + PCefGeoposition = ^TCefGeoposition; + PCefTaskRunner = ^TCefTaskRunner; + PCefEndTracingCallback = ^TCefEndTracingCallback; + PCefRequestContextSettings = ^TCefRequestContextSettings; + PCefResourceBundle = ^TCefResourceBundle; + PCefMenuModelDelegate = ^TCefMenuModelDelegate; + PCefInsets = ^TCefInsets; + PCefCompositionUnderline = ^TCefCompositionUnderline; + PCefX509CertPrincipal = ^TCefX509CertPrincipal; + PCefX509Certificate = ^TCefX509Certificate; + PPCefX509Certificate = ^PCefX509Certificate; + + + TCefWindowHandle = HWND; // /include/internal/cef_types_win.h (cef_window_handle_t) + TCefCursorHandle = HCURSOR; // /include/internal/cef_types_win.h (cef_cursor_handle_t) + TCefEventHandle = PMsg; // /include/internal/cef_types_win.h (cef_event_handle_t) + TCefPlatformThreadId = DWORD; // /include/internal/cef_thread_internal.h (cef_platform_thread_id_t) + TCefPlatformThreadHandle = DWORD; // /include/internal/cef_thread_internal.h (cef_platform_thread_handle_t) + TCefTransitionType = Cardinal; // /include/internal/cef_types.h (cef_transition_type_t) + TCefColor = Cardinal; // /include/internal/cef_types.h (cef_color_t) + TCefErrorcode = Integer; // /include/internal/cef_types.h (cef_errorcode_t) + TCefCertStatus = Integer; // /include/internal/cef_types.h (cef_cert_status_t) + TCefSSLVersion = integer; // /include/internal/cef_types.h (cef_ssl_version_t) + TCefStringList = Pointer; // /include/internal/cef_string_list.h (cef_string_list_t) + TCefStringMap = Pointer; // /include/internal/cef_string_map.h (cef_string_map_t) + TCefStringMultimap = Pointer; // /include/internal/cef_string_multimap.h (cef_string_multimap_t) + TCefUriUnescapeRule = Integer; // /include/internal/cef_types.h (cef_uri_unescape_rule_t) + TCefDomEventCategory = Integer; // /include/internal/cef_types.h (cef_dom_event_category_t) + + + ustring = type string; + rbstring = type RawByteString; + + Char16 = WideChar; + PChar16 = PWideChar; + + TCefStringWide = record + str: PWideChar; + length: NativeUInt; + dtor: procedure(str: PWideChar); stdcall; + end; + + TCefStringUtf8 = record + str: PAnsiChar; + length: NativeUInt; + dtor: procedure(str: PAnsiChar); stdcall; + end; + + TCefStringUtf16 = record + str: PChar16; + length: NativeUInt; + dtor: procedure(str: PChar16); stdcall; + end; + + TCefStringUserFreeWide = type TCefStringWide; + TCefStringUserFreeUtf8 = type TCefStringUtf8; + TCefStringUserFreeUtf16 = type TCefStringUtf16; + + TCefChar = Char16; + PCefChar = PChar16; + TCefStringUserFree = TCefStringUserFreeUtf16; + PCefStringUserFree = PCefStringUserFreeUtf16; + TCefString = TCefStringUtf16; + PCefString = PCefStringUtf16; + + TCefMainArgs = record + instance: HINST; + end; + + // /include/internal/cef_types.h (cef_rect_t) + TCefRect = record + x: Integer; + y: Integer; + width: Integer; + height: Integer; + end; + TCefRectArray = array[0..(High(Integer) div SizeOf(TCefRect))-1] of TCefRect; + + // /include/internal/cef_types.h (cef_point_t) + TCefPoint = record + x: Integer; + y: Integer; + end; + + // /include/internal/cef_types.h (cef_size_t) + TCefSize = record + width: Integer; + height: Integer; + end; + + // /include/internal/cef_types.h (cef_range_t) + TCefRange = record + from: Integer; + to_: Integer; + end; + TCefRangeArray = array of TCefRange; + + // /include/internal/cef_types.h (cef_cursor_info_t) + TCefCursorInfo = record + hotspot: TCefPoint; + image_scale_factor: Single; + buffer: Pointer; + size: TCefSize; + end; + + // /include/internal/cef_types.h (cef_urlparts_t) + TCefUrlParts = record + spec: TCefString; + scheme: TCefString; + username: TCefString; + password: TCefString; + host: TCefString; + port: TCefString; + origin: TCefString; + path: TCefString; + query: TCefString; + end; + + // /include/internal/cef_types.h (cef_insets_t) + TCefInsets = record + top: Integer; + left: Integer; + bottom: Integer; + right: Integer; + end; + + // /include/internal/cef_types.h (cef_json_parser_error_t) + TCefJsonParserError = ( + JSON_NO_ERROR = 0, + JSON_INVALID_ESCAPE, + JSON_SYNTAX_ERROR, + JSON_UNEXPECTED_TOKEN, + JSON_TRAILING_COMMA, + JSON_TOO_MUCH_NESTING, + JSON_UNEXPECTED_DATA_AFTER_ROOT, + JSON_UNSUPPORTED_ENCODING, + JSON_UNQUOTED_DICTIONARY_KEY, + JSON_PARSE_ERROR_COUNT + ); + + // /include/internal/cef_types.h (cef_json_writer_options_t) + TCefJsonWriterOption = ( + JSON_WRITER_OMIT_BINARY_VALUES, + JSON_WRITER_OMIT_DOUBLE_TYPE_PRESERVATION, + JSON_WRITER_PRETTY_PRINT + ); + TCefJsonWriterOptions = set of TCefJsonWriterOption; + + // /include/internal/cef_types.h (cef_state_t) + TCefState = ( + STATE_DEFAULT = 0, + STATE_ENABLED, + STATE_DISABLED + ); + + // /include/internal/cef_types.h (cef_log_severity_t) + TCefLogSeverity = ( + LOGSEVERITY_DEFAULT, + LOGSEVERITY_VERBOSE, + LOGSEVERITY_INFO, + LOGSEVERITY_WARNING, + LOGSEVERITY_ERROR, + LOGSEVERITY_DISABLE = 99 + ); + + // /include/internal/cef_types.h (cef_scale_factor_t) + TCefScaleFactor = ( + SCALE_FACTOR_NONE = 0, + SCALE_FACTOR_100P, + SCALE_FACTOR_125P, + SCALE_FACTOR_133P, + SCALE_FACTOR_140P, + SCALE_FACTOR_150P, + SCALE_FACTOR_180P, + SCALE_FACTOR_200P, + SCALE_FACTOR_250P, + SCALE_FACTOR_300P + ); + + // /include/internal/cef_types.h (cef_value_type_t) + TCefValueType = ( + VTYPE_INVALID = 0, + VTYPE_NULL, + VTYPE_BOOL, + VTYPE_INT, + VTYPE_DOUBLE, + VTYPE_STRING, + VTYPE_BINARY, + VTYPE_DICTIONARY, + VTYPE_LIST + ); + + // /include/internal/cef_types.h (cef_referrer_policy_t) + TCefReferrerPolicy = ( + REFERRER_POLICY_ALWAYS, + REFERRER_POLICY_DEFAULT, + REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE, + REFERRER_POLICY_NEVER, + REFERRER_POLICY_ORIGIN, + REFERRER_POLICY_ORIGIN_WHEN_CROSS_ORIGIN + ); + + // /include/internal/cef_types.h (cef_postdataelement_type_t) + TCefPostDataElementType = ( + PDE_TYPE_EMPTY = 0, + PDE_TYPE_BYTES, + PDE_TYPE_FILE + ); + + // /include/internal/cef_types.h (cef_resource_type_t) + TCefResourceType = ( + RT_MAIN_FRAME, + RT_SUB_FRAME, + RT_STYLESHEET, + RT_SCRIPT, + RT_IMAGE, + RT_FONT_RESOURCE, + RT_SUB_RESOURCE, + RT_OBJECT, + RT_MEDIA, + RT_WORKER, + RT_SHARED_WORKER, + RT_PREFETCH, + RT_FAVICON, + RT_XHR, + RT_PING, + RT_SERVICE_WORKER, + RT_CSP_REPORT, + RT_PLUGIN_RESOURCE + ); + + // /include/internal/cef_types.h (cef_dom_document_type_t) + TCefDomDocumentType = ( + DOM_DOCUMENT_TYPE_UNKNOWN = 0, + DOM_DOCUMENT_TYPE_HTML, + DOM_DOCUMENT_TYPE_XHTML, + DOM_DOCUMENT_TYPE_PLUGIN + ); + + // /include/internal/cef_types.h (cef_dom_node_type_t) + TCefDomNodeType = ( + DOM_NODE_TYPE_UNSUPPORTED = 0, + DOM_NODE_TYPE_ELEMENT, + DOM_NODE_TYPE_ATTRIBUTE, + DOM_NODE_TYPE_TEXT, + DOM_NODE_TYPE_CDATA_SECTION, + DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS, + DOM_NODE_TYPE_COMMENT, + DOM_NODE_TYPE_DOCUMENT, + DOM_NODE_TYPE_DOCUMENT_TYPE, + DOM_NODE_TYPE_DOCUMENT_FRAGMENT + ); + + // /include/internal/cef_types.h (cef_context_menu_media_type_t) + TCefContextMenuMediaType = ( + CM_MEDIATYPE_NONE, + CM_MEDIATYPE_IMAGE, + CM_MEDIATYPE_VIDEO, + CM_MEDIATYPE_AUDIO, + CM_MEDIATYPE_FILE, + CM_MEDIATYPE_PLUGIN + ); + + // /include/internal/cef_types.h (cef_menu_item_type_t) + TCefMenuItemType = ( + MENUITEMTYPE_NONE, + MENUITEMTYPE_COMMAND, + MENUITEMTYPE_CHECK, + MENUITEMTYPE_RADIO, + MENUITEMTYPE_SEPARATOR, + MENUITEMTYPE_SUBMENU + ); + + // /include/internal/cef_types.h (cef_event_flags_t) + TCefEventFlag = ( + EVENTFLAG_CAPS_LOCK_ON, + EVENTFLAG_SHIFT_DOWN, + EVENTFLAG_CONTROL_DOWN, + EVENTFLAG_ALT_DOWN, + EVENTFLAG_LEFT_MOUSE_BUTTON, + EVENTFLAG_MIDDLE_MOUSE_BUTTON, + EVENTFLAG_RIGHT_MOUSE_BUTTON, + EVENTFLAG_COMMAND_DOWN, + EVENTFLAG_NUM_LOCK_ON, + EVENTFLAG_IS_KEY_PAD, + EVENTFLAG_IS_LEFT, + EVENTFLAG_IS_RIGHT + ); + TCefEventFlags = set of TCefEventFlag; + + // /include/internal/cef_types.h (cef_drag_operations_mask_t) + TCefDragOperation = ( + DRAG_OPERATION_COPY, + DRAG_OPERATION_LINK, + DRAG_OPERATION_GENERIC, + DRAG_OPERATION_PRIVATE, + DRAG_OPERATION_MOVE, + DRAG_OPERATION_DELETE + ); + TCefDragOperations = set of TCefDragOperation; + + // /include/internal/cef_types.h (cef_file_dialog_mode_t) + TCefFileDialogMode = ( + FILE_DIALOG_OPEN, + FILE_DIALOG_OPEN_MULTIPLE, + FILE_DIALOG_OPEN_FOLDER, + FILE_DIALOG_SAVE + ); + + // /include/internal/cef_types.h (cef_focus_source_t) + TCefFocusSource = ( + FOCUS_SOURCE_NAVIGATION = 0, + FOCUS_SOURCE_SYSTEM + ); + + // /include/internal/cef_types.h (cef_jsdialog_type_t) + TCefJsDialogType = ( + JSDIALOGTYPE_ALERT = 0, + JSDIALOGTYPE_CONFIRM, + JSDIALOGTYPE_PROMPT + ); + + // /include/internal/cef_types.h (cef_key_event_type_t) + TCefKeyEventType = ( + KEYEVENT_RAWKEYDOWN = 0, + KEYEVENT_KEYDOWN, + KEYEVENT_KEYUP, + KEYEVENT_CHAR + ); + + // /include/internal/cef_types.h (cef_window_open_disposition_t) + TCefWindowOpenDisposition = ( + WOD_UNKNOWN, + WOD_CURRENT_TAB, + WOD_SINGLETON_TAB, + WOD_NEW_FOREGROUND_TAB, + WOD_NEW_BACKGROUND_TAB, + WOD_NEW_POPUP, + WOD_NEW_WINDOW, + WOD_SAVE_TO_DISK, + WOD_OFF_THE_RECORD, + WOD_IGNORE_ACTION + ); + + // /include/internal/cef_types.h (cef_paint_element_type_t) + TCefPaintElementType = ( + PET_VIEW, + PET_POPUP + ); + + // /include/internal/cef_types.h (cef_cursor_type_t) + TCefCursorType = ( + CT_POINTER = 0, + CT_CROSS, + CT_HAND, + CT_IBEAM, + CT_WAIT, + CT_HELP, + CT_EASTRESIZE, + CT_NORTHRESIZE, + CT_NORTHEASTRESIZE, + CT_NORTHWESTRESIZE, + CT_SOUTHRESIZE, + CT_SOUTHEASTRESIZE, + CT_SOUTHWESTRESIZE, + CT_WESTRESIZE, + CT_NORTHSOUTHRESIZE, + CT_EASTWESTRESIZE, + CT_NORTHEASTSOUTHWESTRESIZE, + CT_NORTHWESTSOUTHEASTRESIZE, + CT_COLUMNRESIZE, + CT_ROWRESIZE, + CT_MIDDLEPANNING, + CT_EASTPANNING, + CT_NORTHPANNING, + CT_NORTHEASTPANNING, + CT_NORTHWESTPANNING, + CT_SOUTHPANNING, + CT_SOUTHEASTPANNING, + CT_SOUTHWESTPANNING, + CT_WESTPANNING, + CT_MOVE, + CT_VERTICALTEXT, + CT_CELL, + CT_CONTEXTMENU, + CT_ALIAS, + CT_PROGRESS, + CT_NODROP, + CT_COPY, + CT_NONE, + CT_NOTALLOWED, + CT_ZOOMIN, + CT_ZOOMOUT, + CT_GRAB, + CT_GRABBING, + CT_CUSTOM + ); + + // /include/internal/cef_types.h (cef_navigation_type_t) + TCefNavigationType = ( + NAVIGATION_LINK_CLICKED, + NAVIGATION_FORM_SUBMITTED, + NAVIGATION_BACK_FORWARD, + NAVIGATION_RELOAD, + NAVIGATION_FORM_RESUBMITTED, + NAVIGATION_OTHER + ); + + // /include/internal/cef_types.h (cef_process_id_t) + TCefProcessId = ( + PID_BROWSER, + PID_RENDERER + ); + + // /include/internal/cef_types.h (cef_thread_id_t) + TCefThreadId = ( + TID_UI, + TID_DB, + TID_FILE, + TID_FILE_USER_BLOCKING, + TID_PROCESS_LAUNCHER, + TID_CACHE, + TID_IO, + TID_RENDERER + ); + + // /include/internal/cef_types.h (cef_thread_priority_t) + TCefThreadPriority = ( + TP_BACKGROUND, + TP_NORMAL, + TP_DISPLAY, + TP_REALTIME_AUDIO + ); + + // /include/internal/cef_types.h (cef_message_loop_type_t) + TCefMessageLoopType = ( + ML_TYPE_DEFAULT, + ML_TYPE_UI, + ML_TYPE_IO + ); + + // /include/internal/cef_types.h (cef_com_init_mode_t) + TCefCOMInitMode = ( + COM_INIT_MODE_NONE, + COM_INIT_MODE_STA, + COM_INIT_MODE_MTA + ); + + // /include/internal/cef_types.h (cef_mouse_button_type_t) + TCefMouseButtonType = ( + MBT_LEFT, + MBT_MIDDLE, + MBT_RIGHT + ); + + // /include/internal/cef_types.h (cef_return_value_t) + TCefReturnValue = ( + RV_CANCEL = 0, + RV_CONTINUE, + RV_CONTINUE_ASYNC + ); + + // /include/internal/cef_types.h (cef_urlrequest_flags_t) + TCefUrlRequestFlag = ( + UR_FLAG_SKIP_CACHE, + UR_FLAG_ALLOW_CACHED_CREDENTIALS, + UR_FLAG_DUMMY_1, + UR_FLAG_REPORT_UPLOAD_PROGRESS, + UR_FLAG_DUMMY_2, + UR_FLAG_DUMMY_3, + UR_FLAG_NO_DOWNLOAD_DATA, + UR_FLAG_NO_RETRY_ON_5XX + ); + TCefUrlRequestFlags = set of TCefUrlRequestFlag; + + // /include/internal/cef_types.h (cef_urlrequest_status_t) + TCefUrlRequestStatus = ( + UR_UNKNOWN = 0, + UR_SUCCESS, + UR_IO_PENDING, + UR_CANCELED, + UR_FAILED + ); + + // /include/internal/cef_types.h (cef_termination_status_t) + TCefTerminationStatus = ( + TS_ABNORMAL_TERMINATION, + TS_PROCESS_WAS_KILLED, + TS_PROCESS_CRASHED + ); + + // /include/internal/cef_types.h (cef_path_key_t) + TCefPathKey = ( + PK_DIR_CURRENT, + PK_DIR_EXE, + PK_DIR_MODULE, + PK_DIR_TEMP, + PK_FILE_EXE, + PK_FILE_MODULE, + PK_LOCAL_APP_DATA, + PK_USER_DATA + ); + + // /include/internal/cef_types.h (cef_storage_type_t) + TCefStorageType = ( + ST_LOCALSTORAGE = 0, + ST_SESSIONSTORAGE + ); + + // /include/internal/cef_types.h (cef_v8_accesscontrol_t) + TCefV8AccessControl = ( + V8_ACCESS_CONTROL_ALL_CAN_READ, + V8_ACCESS_CONTROL_ALL_CAN_WRITE, + V8_ACCESS_CONTROL_PROHIBITS_OVERWRITING + ); + TCefV8AccessControls = set of TCefV8AccessControl; + + // /include/internal/cef_types.h (cef_v8_propertyattribute_t) + TCefV8PropertyAttribute = ( + V8_PROPERTY_ATTRIBUTE_READONLY, + V8_PROPERTY_ATTRIBUTE_DONTENUM, + V8_PROPERTY_ATTRIBUTE_DONTDELETE + ); + TCefV8PropertyAttributes = set of TCefV8PropertyAttribute; + + // /include/internal/cef_types.h (cef_response_filter_status_t) + TCefResponseFilterStatus = ( + RESPONSE_FILTER_NEED_MORE_DATA, + RESPONSE_FILTER_DONE, + RESPONSE_FILTER_ERROR + ); + + // /include/internal/cef_types.h (cef_plugin_policy_t) + TCefPluginPolicy = ( + PLUGIN_POLICY_ALLOW, + PLUGIN_POLICY_DETECT_IMPORTANT, + PLUGIN_POLICY_BLOCK, + PLUGIN_POLICY_DISABLE + ); + + // /include/internal/cef_types.h (cef_color_type_t) + TCefColorType = ( + CEF_COLOR_TYPE_RGBA_8888, + CEF_COLOR_TYPE_BGRA_8888 + ); + + // /include/internal/cef_types.h (cef_alpha_type_t) + TCefAlphaType = ( + CEF_ALPHA_TYPE_OPAQUE, + CEF_ALPHA_TYPE_PREMULTIPLIED, + CEF_ALPHA_TYPE_POSTMULTIPLIED + ); + + // /include/internal/cef_types.h (cef_text_style_t) + TCefTextStyle = ( + CEF_TEXT_STYLE_BOLD, + CEF_TEXT_STYLE_ITALIC, + CEF_TEXT_STYLE_STRIKE, + CEF_TEXT_STYLE_DIAGONAL_STRIKE, + CEF_TEXT_STYLE_UNDERLINE + ); + + // /include/internal/cef_types.h (cef_main_axis_alignment_t) + TCefMainAxisAlignment = ( + CEF_MAIN_AXIS_ALIGNMENT_START, + CEF_MAIN_AXIS_ALIGNMENT_CENTER, + CEF_MAIN_AXIS_ALIGNMENT_END + ); + + // /include/internal/cef_types.h (cef_cross_axis_alignment_t) + TCefCrossAxisAlignment = ( + CEF_CROSS_AXIS_ALIGNMENT_STRETCH, + CEF_CROSS_AXIS_ALIGNMENT_START, + CEF_CROSS_AXIS_ALIGNMENT_CENTER, + CEF_CROSS_AXIS_ALIGNMENT_END + ); + + // /include/internal/cef_types.h (cef_pdf_print_margin_type_t) + TCefPdfPrintMarginType = ( + PDF_PRINT_MARGIN_DEFAULT, + PDF_PRINT_MARGIN_NONE, + PDF_PRINT_MARGIN_MINIMUM, + PDF_PRINT_MARGIN_CUSTOM + ); + + // /include/internal/cef_types.h (cef_color_model_t) + TCefColorModel = ( + COLOR_MODEL_UNKNOWN, + COLOR_MODEL_GRAY, + COLOR_MODEL_COLOR, + COLOR_MODEL_CMYK, + COLOR_MODEL_CMY, + COLOR_MODEL_KCMY, + COLOR_MODEL_CMY_K, + COLOR_MODEL_BLACK, + COLOR_MODEL_GRAYSCALE, + COLOR_MODEL_RGB, + COLOR_MODEL_RGB16, + COLOR_MODEL_RGBA, + COLOR_MODEL_COLORMODE_COLOR, + COLOR_MODEL_COLORMODE_MONOCHROME, + COLOR_MODEL_HP_COLOR_COLOR, + COLOR_MODEL_HP_COLOR_BLACK, + COLOR_MODEL_PRINTOUTMODE_NORMAL, + COLOR_MODEL_PRINTOUTMODE_NORMAL_GRAY, + COLOR_MODEL_PROCESSCOLORMODEL_CMYK, + COLOR_MODEL_PROCESSCOLORMODEL_GREYSCALE, + COLOR_MODEL_PROCESSCOLORMODEL_RGB + ); + + // /include/internal/cef_types.h (cef_duplex_mode_t) + TCefDuplexMode = ( + DUPLEX_MODE_UNKNOWN = -1, + DUPLEX_MODE_SIMPLEX, + DUPLEX_MODE_LONG_EDGE, + DUPLEX_MODE_SHORT_EDGE + ); + + // /include/internal/cef_types.h (cef_json_parser_options_t) + TCefJsonParserOptions = ( + JSON_PARSER_RFC = 0, + JSON_PARSER_ALLOW_TRAILING_COMMAS = 1 shl 0 + ); + + // /include/internal/cef_types.h (cef_xml_encoding_type_t) + TCefXmlEncodingType = ( + XML_ENCODING_NONE = 0, + XML_ENCODING_UTF8, + XML_ENCODING_UTF16LE, + XML_ENCODING_UTF16BE, + XML_ENCODING_ASCII + ); + + // /include/internal/cef_types.h (cef_xml_node_type_t) + TCefXmlNodeType = ( + XML_NODE_UNSUPPORTED = 0, + XML_NODE_PROCESSING_INSTRUCTION, + XML_NODE_DOCUMENT_TYPE, + XML_NODE_ELEMENT_START, + XML_NODE_ELEMENT_END, + XML_NODE_ATTRIBUTE, + XML_NODE_TEXT, + XML_NODE_CDATA, + XML_NODE_ENTITY_REFERENCE, + XML_NODE_WHITESPACE, + XML_NODE_COMMENT + ); + + // /include/internal/cef_types.h (cef_dom_event_phase_t) + TCefDomEventPhase = ( + DOM_EVENT_PHASE_UNKNOWN = 0, + DOM_EVENT_PHASE_CAPTURING, + DOM_EVENT_PHASE_AT_TARGET, + DOM_EVENT_PHASE_BUBBLING + ); + + // /include/internal/cef_types.h (cef_geoposition_error_code_t) + TCefGeopositionErrorCode = ( + GEOPOSITON_ERROR_NONE, + GEOPOSITON_ERROR_PERMISSION_DENIED, + GEOPOSITON_ERROR_POSITION_UNAVAILABLE, + GEOPOSITON_ERROR_TIMEOUT + ); + + // /include/internal/cef_types.h (cef_context_menu_type_flags_t) + TCefContextMenuTypeFlag = ( + CM_TYPEFLAG_PAGE, + CM_TYPEFLAG_FRAME, + CM_TYPEFLAG_LINK, + CM_TYPEFLAG_MEDIA, + CM_TYPEFLAG_SELECTION, + CM_TYPEFLAG_EDITABLE + ); + TCefContextMenuTypeFlags = set of TCefContextMenuTypeFlag; + + // /include/internal/cef_types.h (cef_context_menu_media_state_flags_t) + TCefContextMenuMediaStateFlag = ( + CM_MEDIAFLAG_ERROR, + CM_MEDIAFLAG_PAUSED, + CM_MEDIAFLAG_MUTED, + CM_MEDIAFLAG_LOOP, + CM_MEDIAFLAG_CAN_SAVE, + CM_MEDIAFLAG_HAS_AUDIO, + CM_MEDIAFLAG_HAS_VIDEO, + CM_MEDIAFLAG_CONTROL_ROOT_ELEMENT, + CM_MEDIAFLAG_CAN_PRINT, + CM_MEDIAFLAG_CAN_ROTATE + ); + TCefContextMenuMediaStateFlags = set of TCefContextMenuMediaStateFlag; + + // /include/internal/cef_types.h (cef_context_menu_edit_state_flags_t) + TCefContextMenuEditStateFlag = ( + CM_EDITFLAG_CAN_UNDO, + CM_EDITFLAG_CAN_REDO, + CM_EDITFLAG_CAN_CUT, + CM_EDITFLAG_CAN_COPY, + CM_EDITFLAG_CAN_PASTE, + CM_EDITFLAG_CAN_DELETE, + CM_EDITFLAG_CAN_SELECT_ALL, + CM_EDITFLAG_CAN_TRANSLATE + ); + TCefContextMenuEditStateFlags = set of TCefContextMenuEditStateFlag; + + // /include/internal/cef_types.h (cef_button_state_t) + TCefButtonState = ( + CEF_BUTTON_STATE_NORMAL, + CEF_BUTTON_STATE_HOVERED, + CEF_BUTTON_STATE_PRESSED, + CEF_BUTTON_STATE_DISABLED + ); + + // /include/internal/cef_types.h (cef_horizontal_alignment_t) + TCefHorizontalAlignment = ( + CEF_HORIZONTAL_ALIGNMENT_LEFT, + CEF_HORIZONTAL_ALIGNMENT_CENTER, + CEF_HORIZONTAL_ALIGNMENT_RIGHT + ); + + // /include/internal/cef_types.h (cef_menu_anchor_position_t) + TCefMenuAnchorPosition = ( + CEF_MENU_ANCHOR_TOPLEFT, + CEF_MENU_ANCHOR_TOPRIGHT, + CEF_MENU_ANCHOR_BOTTOMCENTER + ); + + // /include/internal/cef_types.h (cef_ssl_content_status_t) + TCefSSLContentStatusFlags = ( + SSL_CONTENT_DISPLAYED_INSECURE_CONTENT, + SSL_CONTENT_RAN_INSECURE_CONTENT + ); + TCefSSLContentStatus = set of TCefSSLContentStatusFlags; + + // /include/internal/cef_types.h (cef_cdm_registration_error_t) + TCefCDMRegistrationError = ( + CEF_CDM_REGISTRATION_ERROR_NONE, + CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS, + CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE, + CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED + ); + + // /include/internal/cef_types.h (cef_composition_underline_t) + TCefCompositionUnderline = record + range : TCefRange; + color : TCefColor; + background_color : TCefColor; + thick : integer; + end; + + // /include/internal/cef_time.h (cef_time_t) + TCefTime = record + year: Integer; + month: Integer; + day_of_week: Integer; + day_of_month: Integer; + hour: Integer; + minute: Integer; + second: Integer; + millisecond: Integer; + end; + + // /include/capi/cef_base_capi.h (cef_base_t) + TCefBase = record + size: NativeUInt; + add_ref: procedure(self: PCefBase); stdcall; + release: function(self: PCefBase): Integer; stdcall; + has_one_ref: function(self: PCefBase): Integer; stdcall; + end; + + // /include/capi/cef_stream_capi.h (cef_stream_writer_t) + TCefStreamWriter = record + base: TCefBase; + write: function(self: PCefStreamWriter; const ptr: Pointer; size, n: NativeUInt): NativeUInt; stdcall; + seek: function(self: PCefStreamWriter; offset: Int64; whence: Integer): Integer; stdcall; + tell: function(self: PCefStreamWriter): Int64; stdcall; + flush: function(self: PCefStreamWriter): Integer; stdcall; + may_block: function(self: PCefStreamWriter): Integer; stdcall; + end; + + // /include/internal/cef_types.h (cef_box_layout_settings_t) + TCefBoxLayoutSettings = record + horizontal: Integer; + inside_border_horizontal_spacing: Integer; + inside_border_vertical_spacing: Integer; + inside_border_insets: TCefInsets; + between_child_spacing: Integer; + main_axis_alignment: TCefMainAxisAlignment; + cross_axis_alignment: TCefCrossAxisAlignment; + minimum_cross_axis_size: Integer; + default_flex: Integer; + end; + + // /include/internal/cef_types.h (cef_settings_t) + TCefSettings = record + size: NativeUInt; + single_process: Integer; + no_sandbox: Integer; + browser_subprocess_path: TCefString; + multi_threaded_message_loop: Integer; + external_message_pump:integer; + windowless_rendering_enabled: Integer; + command_line_args_disabled: Integer; + cache_path: TCefString; + user_data_path: TCefString; + persist_session_cookies: Integer; + persist_user_preferences: Integer; + user_agent: TCefString; + product_version: TCefString; + locale: TCefString; + log_file: TCefString; + log_severity: TCefLogSeverity; + javascript_flags: TCefString; + resources_dir_path: TCefString; + locales_dir_path: TCefString; + pack_loading_disabled: Integer; + remote_debugging_port: Integer; + uncaught_exception_stack_size: Integer; + context_safety_implementation: Integer; + ignore_certificate_errors: Integer; + enable_net_security_expiration : integer; + background_color: TCefColor; + accept_language_list: TCefString; + end; + + // /include/internal/cef_win.h (cef_window_info_t) + TCefWindowInfo = record + ex_style: DWORD; + window_name: TCefString; + style: DWORD; + x: Integer; + y: Integer; + width: Integer; + height: Integer; + parent_window: HWND; + menu: HMENU; + windowless_rendering_enabled: Integer; + transparent_painting_enabled: Integer; + window: HWND; + end; + + // /include/capi/cef_x509_certificate_capi.h (cef_x509cert_principal_t) + TCefX509CertPrincipal = record + base: TCefBase; + get_display_name: function(self: PCefX509CertPrincipal): PCefStringUserFree; stdcall; + get_common_name: function(self: PCefX509CertPrincipal): PCefStringUserFree; stdcall; + get_locality_name: function(self: PCefX509CertPrincipal): PCefStringUserFree; stdcall; + get_state_or_province_name: function(self: PCefX509CertPrincipal): PCefStringUserFree; stdcall; + get_country_name: function(self: PCefX509CertPrincipal): PCefStringUserFree; stdcall; + get_street_addresses: procedure(self: PCefX509CertPrincipal; addresses: TCefStringList); stdcall; + get_organization_names: procedure(self: PCefX509CertPrincipal; names: TCefStringList); stdcall; + get_organization_unit_names: procedure(self: PCefX509CertPrincipal; names: TCefStringList); stdcall; + get_domain_components: procedure(self: PCefX509CertPrincipal; components: TCefStringList); stdcall; + end; + + // /include/capi/cef_x509_certificate_capi.h (cef_x509certificate_t) + TCefX509Certificate = record + base: TCefBase; + get_subject: function(self: PCefX509Certificate): PCefX509CertPrincipal; stdcall; + get_issuer: function(self: PCefX509Certificate): PCefX509CertPrincipal; stdcall; + get_serial_number: function(self: PCefX509Certificate): PCefBinaryValue; stdcall; + get_valid_start: function(self: PCefX509Certificate): TCefTime; stdcall; + get_valid_expiry: function(self: PCefX509Certificate): TCefTime; stdcall; + get_derencoded: function(self: PCefX509Certificate): PCefBinaryValue; stdcall; + get_pemencoded: function(self: PCefX509Certificate): PCefBinaryValue; stdcall; + get_issuer_chain_size: function(self: PCefX509Certificate): NativeUInt; stdcall; + get_derencoded_issuer_chain: procedure(self: PCefX509Certificate; out chainCount: NativeUInt; chain: PPCefBinaryValue); stdcall; + get_pemencoded_issuer_chain: procedure(self: PCefX509Certificate; out chainCount: NativeUInt; chain: PPCefBinaryValue); stdcall; + end; + + // /include/capi/cef_ssl_info_capi.h (cef_sslinfo_t) + TCefSslInfo = record + base: TCefBase; + get_cert_status: function(self: PCefSslInfo): TCefCertStatus; stdcall; + get_x509certificate: function(self: PCefSslInfo): PCefX509Certificate; stdcall; + end; + + // /include/capi/cef_ssl_status_capi.h (cef_sslstatus_t) + TCefSSLStatus = record + base: TCefBase; + is_secure_connection: function(self: PCefSSLStatus): integer; stdcall; + get_cert_status: function(self: PCefSSLStatus): TCefCertStatus; stdcall; + get_sslversion: function(self: PCefSSLStatus): TCefSSLVersion; stdcall; + get_content_status: function(self: PCefSSLStatus): TCefSSLContentStatus; stdcall; + get_x509certificate: function(self: PCefSSLStatus): PCefX509Certificate; stdcall; + end; + + // /include/capi/cef_request_handler_capi.h (cef_select_client_certificate_callback_t) + TCefSelectClientCertificateCallback = record + base: TCefBase; + select: procedure(self: PCefSelectClientCertificateCallback; cert: PCefX509Certificate); stdcall; + end; + + // /include/capi/cef_context_menu_handler_capi.h (cef_run_context_menu_callback_t) + TCefRunContextMenuCallback = record + base: TCefBase; + cont: procedure(self: PCefRunContextMenuCallback; command_id: Integer; event_flags: TCefEventFlags); stdcall; + cancel: procedure(self: PCefRunContextMenuCallback); stdcall; + end; + + // /include/capi/cef_dialog_handler_capi.h (cef_file_dialog_callback_t) + TCefFileDialogCallback = record + base: TCefBase; + cont: procedure(self: PCefFileDialogCallback; selected_accept_filter: Integer; file_paths: TCefStringList); stdcall; + cancel: procedure(self: PCefFileDialogCallback); stdcall; + end; + + // /include/capi/cef_dialog_handler_capi.h (cef_dialog_handler_t) + TCefDialogHandler = record + base: TCefBase; + on_file_dialog: function(self: PCefDialogHandler; browser: PCefBrowser; mode: TCefFileDialogMode; const title, default_file_path: PCefString; accept_filters: TCefStringList; selected_accept_filter: Integer; callback: PCefFileDialogCallback): Integer; stdcall; + end; + + // /include/capi/cef_display_handler_capi.h (cef_display_handler_t) + TCefDisplayHandler = record + base: TCefBase; + on_address_change: procedure(self: PCefDisplayHandler; browser: PCefBrowser; frame: PCefFrame; const url: PCefString); stdcall; + on_title_change: procedure(self: PCefDisplayHandler; browser: PCefBrowser; const title: PCefString); stdcall; + on_favicon_urlchange: procedure(self: PCefDisplayHandler; browser: PCefBrowser; icon_urls: TCefStringList); stdcall; + on_fullscreen_mode_change: procedure(self: PCefDisplayHandler; browser: PCefBrowser; fullscreen: Integer); stdcall; + on_tooltip: function(self: PCefDisplayHandler; browser: PCefBrowser; text: PCefString): Integer; stdcall; + on_status_message: procedure(self: PCefDisplayHandler; browser: PCefBrowser; const value: PCefString); stdcall; + on_console_message: function(self: PCefDisplayHandler; browser: PCefBrowser; const message: PCefString; const source: PCefString; line: Integer): Integer; stdcall; + end; + + // /include/capi/cef_download_handler_capi.h (cef_download_handler_t) + TCefDownloadHandler = record + base: TCefBase; + on_before_download: procedure(self: PCefDownloadHandler; browser: PCefBrowser; download_item: PCefDownloadItem; const suggested_name: PCefString; callback: PCefBeforeDownloadCallback); stdcall; + on_download_updated: procedure(self: PCefDownloadHandler; browser: PCefBrowser; download_item: PCefDownloadItem; callback: PCefDownloadItemCallback); stdcall; + end; + + // /include/internal/cef_types.h (cef_draggable_region_t) + TCefDraggableRegion = record + bounds: TCefRect; + draggable: Integer; + end; + + TCefDraggableRegionArray = array[0..(High(Integer) div SizeOf(TCefDraggableRegion))-1] of TCefDraggableRegion; + + // /include/capi/cef_drag_handler_capi.h (cef_drag_handler_t) + TCefDragHandler = record + base: TCefBase; + on_drag_enter: function(self: PCefDragHandler; browser: PCefBrowser; dragData: PCefDragData; mask: TCefDragOperations): Integer; stdcall; + on_draggable_regions_changed: procedure(self: PCefDragHandler; browser: PCefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); stdcall; + end; + + // /include/capi/cef_find_handler_capi.h (cef_find_handler_t) + TCefFindHandler = record + base: TCefBase; + on_find_result: procedure(self: PCefFindHandler; browser: PCefBrowser; identifier, count: Integer; const selection_rect: PCefRect; active_match_ordinal, final_update: Integer); stdcall; + end; + + // /include/capi/cef_focus_handler_capi.h (cef_focus_handler_t) + TCefFocusHandler = record + base: TCefBase; + on_take_focus: procedure(self: PCefFocusHandler; browser: PCefBrowser; next: Integer); stdcall; + on_set_focus: function(self: PCefFocusHandler; browser: PCefBrowser; source: TCefFocusSource): Integer; stdcall; + on_got_focus: procedure(self: PCefFocusHandler; browser: PCefBrowser); stdcall; + end; + + // /include/capi/cef_jsdialog_handler_capi.h (cef_jsdialog_handler_t) + TCefJsDialogHandler = record + base: TCefBase; + on_jsdialog: function(self: PCefJsDialogHandler; browser: PCefBrowser; const origin_url: PCefString; dialog_type: TCefJsDialogType; const message_text, default_prompt_text: PCefString; callback: PCefJsDialogCallback; suppress_message: PInteger): Integer; stdcall; + on_before_unload_dialog: function(self: PCefJsDialogHandler; browser: PCefBrowser; const message_text: PCefString; is_reload: Integer; callback: PCefJsDialogCallback): Integer; stdcall; + on_reset_dialog_state: procedure(self: PCefJsDialogHandler; browser: PCefBrowser); stdcall; + on_dialog_closed: procedure(self: PCefJsDialogHandler; browser: PCefBrowser); stdcall; + end; + + // /include/capi/cef_jsdialog_handler_capi.h (cef_jsdialog_callback_t) + TCefJsDialogCallback = record + base: TCefBase; + cont: procedure(self: PCefJsDialogCallback; success: Integer; const user_input: PCefString); stdcall; + end; + + // /include/capi/cef_geolocation_handler_capi.h (cef_geolocation_handler_t) + TCefGeolocationHandler = record + base: TCefBase; + on_request_geolocation_permission: function(self: PCefGeolocationHandler; browser: PCefBrowser; const requesting_url: PCefString; request_id: Integer; callback: PCefGeolocationCallback): Integer; stdcall; + on_cancel_geolocation_permission: procedure(self: PCefGeolocationHandler; browser: PCefBrowser; request_id: Integer); stdcall; + end; + + // /include/capi/cef_geolocation_handler_capi.h (cef_geolocation_callback_t) + TCefGeolocationCallback = record + base: TCefBase; + cont: procedure(self: PCefGeolocationCallback; allow: Integer); stdcall; + end; + + // /include/internal/cef_types.h (cef_key_event_t) + TCefKeyEvent = record + kind: TCefKeyEventType; + modifiers: TCefEventFlags; + windows_key_code: Integer; + native_key_code: Integer; + is_system_key: Integer; + character: WideChar; + unmodified_character: WideChar; + focus_on_editable_field: Integer; + end; + + // /include/capi/cef_keyboard_handler_capi.h (cef_keyboard_handler_t) + TCefKeyboardHandler = record + base: TCefBase; + on_pre_key_event: function(self: PCefKeyboardHandler; browser: PCefBrowser; const event: PCefKeyEvent; os_event: TCefEventHandle; is_keyboard_shortcut: PInteger): Integer; stdcall; + on_key_event: function(self: PCefKeyboardHandler; browser: PCefBrowser; const event: PCefKeyEvent; os_event: TCefEventHandle): Integer; stdcall; + end; + + // /include/capi/cef_life_span_handler_capi.h (cef_life_span_handler_t) + TCefLifeSpanHandler = record + base: TCefBase; + on_before_popup: function(self: PCefLifeSpanHandler; browser: PCefBrowser; frame: PCefFrame; const target_url, target_frame_name: PCefString; target_disposition: TCefWindowOpenDisposition; user_gesture: Integer; const popupFeatures: PCefPopupFeatures; windowInfo: PCefWindowInfo; var client: PCefClient; settings: PCefBrowserSettings; no_javascript_access: PInteger): Integer; stdcall; + on_after_created: procedure(self: PCefLifeSpanHandler; browser: PCefBrowser); stdcall; + do_close: function(self: PCefLifeSpanHandler; browser: PCefBrowser): Integer; stdcall; + on_before_close: procedure(self: PCefLifeSpanHandler; browser: PCefBrowser); stdcall; + end; + + // /include/internal/cef_types.h (cef_popup_features_t) + TCefPopupFeatures = record + x: Integer; + xSet: Integer; + y: Integer; + ySet: Integer; + width: Integer; + widthSet: Integer; + height: Integer; + heightSet: Integer; + menuBarVisible: Integer; + statusBarVisible: Integer; + toolBarVisible: Integer; + locationBarVisible: Integer; + scrollbarsVisible: Integer; + resizable: Integer; + fullscreen: Integer; + dialog: Integer; + additionalFeatures: TCefStringList; + end; + + // /include/internal/cef_types.h (cef_browser_settings_t) + TCefBrowserSettings = record + size: NativeUInt; + windowless_frame_rate: Integer; + standard_font_family: TCefString; + fixed_font_family: TCefString; + serif_font_family: TCefString; + sans_serif_font_family: TCefString; + cursive_font_family: TCefString; + fantasy_font_family: TCefString; + default_font_size: Integer; + default_fixed_font_size: Integer; + minimum_font_size: Integer; + minimum_logical_font_size: Integer; + default_encoding: TCefString; + remote_fonts: TCefState; + javascript: TCefState; + javascript_open_windows: TCefState; + javascript_close_windows: TCefState; + javascript_access_clipboard: TCefState; + javascript_dom_paste: TCefState; + caret_browsing: TCefState; + plugins: TCefState; + universal_access_from_file_urls: TCefState; + file_access_from_file_urls: TCefState; + web_security: TCefState; + image_loading: TCefState; + image_shrink_standalone_to_fit: TCefState; + text_area_resize: TCefState; + tab_to_links: TCefState; + local_storage: TCefState; + databases: TCefState; + application_cache: TCefState; + webgl: TCefState; + background_color: TCefColor; + accept_language_list: TCefString; + end; + + // /include/capi/cef_load_handler_capi.h (cef_load_handler_t) + TCefLoadHandler = record + base: TCefBase; + on_loading_state_change: procedure(self: PCefLoadHandler; browser: PCefBrowser; isLoading, canGoBack, canGoForward: Integer); stdcall; + on_load_start: procedure(self: PCefLoadHandler; browser: PCefBrowser; frame: PCefFrame; transition_type:TCefTransitionType); stdcall; + on_load_end: procedure(self: PCefLoadHandler; browser: PCefBrowser; frame: PCefFrame; httpStatusCode: Integer); stdcall; + on_load_error: procedure(self: PCefLoadHandler; browser: PCefBrowser; frame: PCefFrame; errorCode: Integer; const errorText, failedUrl: PCefString); stdcall; + end; + + // /include/capi/cef_render_handler_capi.h (cef_render_handler_t) + TCefRenderHandler = record + base: TCefBase; + get_root_screen_rect: function(self: PCefRenderHandler; browser: PCefBrowser; rect: PCefRect): Integer; stdcall; + get_view_rect: function(self: PCefRenderHandler; browser: PCefBrowser; rect: PCefRect): Integer; stdcall; + get_screen_point: function(self: PCefRenderHandler; browser: PCefBrowser; viewX, viewY: Integer; screenX, screenY: PInteger): Integer; stdcall; + get_screen_info: function(self: PCefRenderHandler; browser: PCefBrowser; screen_info: PCefScreenInfo): Integer; stdcall; + on_popup_show: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; show: Integer); stdcall; + on_popup_size: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; const rect: PCefRect); stdcall; + on_paint: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); stdcall; + on_cursor_change: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; cursor: TCefCursorHandle; type_: TCefCursorType; const custom_cursor_info: PCefCursorInfo); stdcall; + start_dragging: function(self: PCefRenderProcessHandler; browser: PCefBrowser; drag_data: PCefDragData; allowed_ops: TCefDragOperations; x, y: Integer): Integer; stdcall; + update_drag_cursor: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; operation: TCefDragOperation); stdcall; + on_scroll_offset_changed: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; x, y: Double); stdcall; + on_ime_composition_range_changed: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); stdcall; + end; + + // /include/internal/cef_types.h (cef_screen_info_t) + TCefScreenInfo = record + device_scale_factor: Single; + depth: Integer; + depth_per_component: Integer; + is_monochrome: Integer; + rect: TCefRect; + available_rect: TCefRect; + end; + + // /include/capi/cef_v8_capi.h (cef_v8stack_trace_t) + TCefV8StackTrace = record + base: TCefBase; + is_valid: function(self: PCefV8StackTrace): Integer; stdcall; + get_frame_count: function(self: PCefV8StackTrace): Integer; stdcall; + get_frame: function(self: PCefV8StackTrace; index: Integer): PCefV8StackFrame; stdcall; + end; + + // /include/capi/cef_v8_capi.h (cef_v8stack_frame_t) + TCefV8StackFrame = record + base: TCefBase; + is_valid: function(self: PCefV8StackFrame): Integer; stdcall; + get_script_name: function(self: PCefV8StackFrame): PCefStringUserFree; stdcall; + get_script_name_or_source_url: function(self: PCefV8StackFrame): PCefStringUserFree; stdcall; + get_function_name: function(self: PCefV8StackFrame): PCefStringUserFree; stdcall; + get_line_number: function(self: PCefV8StackFrame): Integer; stdcall; + get_column: function(self: PCefV8StackFrame): Integer; stdcall; + is_eval: function(self: PCefV8StackFrame): Integer; stdcall; + is_constructor: function(self: PCefV8StackFrame): Integer; stdcall; + end; + + // /include/capi/cef_stream_capi.h (cef_stream_reader_t) + TCefStreamReader = record + base: TCefBase; + read: function(self: PCefStreamReader; ptr: Pointer; size, n: NativeUInt): NativeUInt; stdcall; + seek: function(self: PCefStreamReader; offset: Int64; whence: Integer): Integer; stdcall; + tell: function(self: PCefStreamReader): Int64; stdcall; + eof: function(self: PCefStreamReader): Integer; stdcall; + may_block: function(self: PCefStreamReader): Integer; stdcall; + end; + + // /include/capi/cef_stream_capi.h (cef_read_handler_t) + TCefReadHandler = record + base: TCefBase; + read: function(self: PCefReadHandler; ptr: Pointer; size, n: NativeUInt): NativeUInt; stdcall; + seek: function(self: PCefReadHandler; offset: Int64; whence: Integer): Integer; stdcall; + tell: function(self: PCefReadHandler): Int64; stdcall; + eof: function(self: PCefReadHandler): Integer; stdcall; + may_block: function(self: PCefReadHandler): Integer; stdcall; + end; + + // /include/capi/cef_stream_capi.h (cef_write_handler_t) + TCefWriteHandler = record + base: TCefBase; + write: function(self: PCefWriteHandler; const ptr: Pointer; size, n: NativeUInt): NativeUInt; stdcall; + seek: function(self: PCefWriteHandler; offset: Int64; whence: Integer): Integer; stdcall; + tell: function(self: PCefWriteHandler): Int64; stdcall; + flush: function(self: PCefWriteHandler): Integer; stdcall; + may_block: function(self: PCefWriteHandler): Integer; stdcall; + end; + + // /include/capi/cef_xml_reader_capi.h (cef_xml_reader_t) + TCefXmlReader = record + base: TcefBase; + move_to_next_node: function(self: PCefXmlReader): Integer; stdcall; + close: function(self: PCefXmlReader): Integer; stdcall; + has_error: function(self: PCefXmlReader): Integer; stdcall; + get_error: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + get_type: function(self: PCefXmlReader): TCefXmlNodeType; stdcall; + get_depth: function(self: PCefXmlReader): Integer; stdcall; + get_local_name: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + get_prefix: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + get_qualified_name: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + get_namespace_uri: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + get_base_uri: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + get_xml_lang: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + is_empty_element: function(self: PCefXmlReader): Integer; stdcall; + has_value: function(self: PCefXmlReader): Integer; stdcall; + get_value: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + has_attributes: function(self: PCefXmlReader): Integer; stdcall; + get_attribute_count: function(self: PCefXmlReader): NativeUInt; stdcall; + get_attribute_byindex: function(self: PCefXmlReader; index: Integer): PCefStringUserFree; stdcall; + get_attribute_byqname: function(self: PCefXmlReader; const qualifiedName: PCefString): PCefStringUserFree; stdcall; + get_attribute_bylname: function(self: PCefXmlReader; const localName, namespaceURI: PCefString): PCefStringUserFree; stdcall; + get_inner_xml: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + get_outer_xml: function(self: PCefXmlReader): PCefStringUserFree; stdcall; + get_line_number: function(self: PCefXmlReader): Integer; stdcall; + move_to_attribute_byindex: function(self: PCefXmlReader; index: Integer): Integer; stdcall; + move_to_attribute_byqname: function(self: PCefXmlReader; const qualifiedName: PCefString): Integer; stdcall; + move_to_attribute_bylname: function(self: PCefXmlReader; const localName, namespaceURI: PCefString): Integer; stdcall; + move_to_first_attribute: function(self: PCefXmlReader): Integer; stdcall; + move_to_next_attribute: function(self: PCefXmlReader): Integer; stdcall; + move_to_carrying_element: function(self: PCefXmlReader): Integer; stdcall; + end; + + // /include/capi/cef_zip_reader_capi.h (cef_zip_reader_t) + TCefZipReader = record + base: TCefBase; + move_to_first_file: function(self: PCefZipReader): Integer; stdcall; + move_to_next_file: function(self: PCefZipReader): Integer; stdcall; + move_to_file: function(self: PCefZipReader; const fileName: PCefString; caseSensitive: Integer): Integer; stdcall; + close: function(Self: PCefZipReader): Integer; stdcall; + get_file_name: function(Self: PCefZipReader): PCefStringUserFree; stdcall; + get_file_size: function(Self: PCefZipReader): Int64; stdcall; + get_file_last_modified: function(Self: PCefZipReader): TCefTime; stdcall; + open_file: function(Self: PCefZipReader; const password: PCefString): Integer; stdcall; + close_file: function(Self: PCefZipReader): Integer; stdcall; + read_file: function(Self: PCefZipReader; buffer: Pointer; bufferSize: NativeUInt): Integer; stdcall; + tell: function(Self: PCefZipReader): Int64; stdcall; + eof: function(Self: PCefZipReader): Integer; stdcall; + end; + + // /include/capi/cef_urlrequest_capi.h (cef_urlrequest_client_t) + TCefUrlrequestClient = record + base: TCefBase; + on_request_complete: procedure(self: PCefUrlRequestClient; request: PCefUrlRequest); stdcall; + on_upload_progress: procedure(self: PCefUrlRequestClient; request: PCefUrlRequest; current, total: Int64); stdcall; + on_download_progress: procedure(self: PCefUrlRequestClient; request: PCefUrlRequest; current, total: Int64); stdcall; + on_download_data: procedure(self: PCefUrlRequestClient; request: PCefUrlRequest; const data: Pointer; data_length: NativeUInt); stdcall; + get_auth_credentials: function(self: PCefUrlRequestClient; isProxy: Integer; const host: PCefString; port: Integer; const realm, scheme: PCefString; callback: PCefAuthCallback): Integer; stdcall; + end; + + // /include/capi/cef_urlrequest_capi.h (cef_urlrequest_t) + TCefUrlRequest = record + base: TCefBase; + get_request: function(self: PCefUrlRequest): PCefRequest; stdcall; + get_client: function(self: PCefUrlRequest): PCefUrlRequestClient; stdcall; + get_request_status: function(self: PCefUrlRequest): TCefUrlRequestStatus; stdcall; + get_request_error: function(self: PCefUrlRequest): TCefErrorcode; stdcall; + get_response: function(self: PCefUrlRequest): PCefResponse; stdcall; + cancel: procedure(self: PCefUrlRequest); stdcall; + end; + + // /include/capi/cef_web_plugin_capi.h (cef_web_plugin_info_visitor_t) + TCefWebPluginInfoVisitor = record + base: TCefBase; + visit: function(self: PCefWebPluginInfoVisitor; info: PCefWebPluginInfo; count, total: Integer): Integer; stdcall; + end; + + // /include/capi/cef_web_plugin_capi.h (cef_web_plugin_unstable_callback_t) + TCefWebPluginUnstableCallback = record + base: TCefBase; + is_unstable: procedure(self: PCefWebPluginUnstableCallback; const path: PCefString; unstable: Integer); stdcall; + end; + + // /include/capi/cef_web_plugin_capi.h (cef_register_cdm_callback_t) + TCefRegisterCDMCallback = record + base: TCefBase; + on_cdm_registration_complete: procedure(self:PCefRegisterCDMCallback; result: TCefCDMRegistrationError; const error_message: PCefString); stdcall; + end; + + // /include/capi/cef_geolocation_capi.h (cef_get_geolocation_callback_t) + TCefGetGeolocationCallback = record + base: TCefBase; + on_location_update: procedure(self: PCefGetGeolocationCallback; const position: Pcefgeoposition); stdcall; + end; + + // /include/internal/cef_types.h (cef_geoposition_t) + TCefGeoposition = record + latitude: Double; + longitude: Double; + altitude: Double; + accuracy: Double; + altitude_accuracy: Double; + heading: Double; + speed: Double; + timestamp: TCefTime; + error_code: TCefGeopositionErrorCode; + error_message: TCefString; + end; + + // /include/capi/cef_thread_capi.h (cef_thread_t) + TCefThread = record + base: TCefBase; + get_task_runner: function(self: PCefThread): PCefTaskRunner; stdcall; + get_platform_thread_id: function(self: PCefThread): TCefPlatformThreadId; stdcall; + stop: procedure(self: PCefThread); stdcall; + is_running: function(self: PCefThread): integer; stdcall; + end; + + // /include/capi/cef_waitable_event_capi.h (cef_waitable_event_t) + TCefWaitableEvent = record + base: TCefBase; + reset: procedure(self: PCefWaitableEvent); stdcall; + signal: procedure(self: PCefWaitableEvent); stdcall; + is_signaled: function(self: PCefWaitableEvent): integer; stdcall; + wait: procedure(self: PCefWaitableEvent); stdcall; + timed_wait: function(self: PCefWaitableEvent; max_ms: int64): integer; stdcall; + end; + + // /include/capi/cef_task_capi.h (cef_task_runner_t) + TCefTaskRunner = record + base: TCefBase; + is_same: function(self, that: PCefTaskRunner): Integer; stdcall; + belongs_to_current_thread: function(self: PCefTaskRunner): Integer; stdcall; + belongs_to_thread: function(self: PCefTaskRunner; threadId: TCefThreadId): Integer; stdcall; + post_task: function(self: PCefTaskRunner; task: PCefTask): Integer; stdcall; + post_delayed_task: function(self: PCefTaskRunner; task: PCefTask; delay_ms: Int64): Integer; stdcall; + end; + + // /include/capi/cef_trace_capi.h (cef_end_tracing_callback_t) + TCefEndTracingCallback = record + base: TCefBase; + on_end_tracing_complete: procedure(self: PCefEndTracingCallback; const tracing_file: PCefString); stdcall; + end; + + // /include/internal/cef_types.h (cef_request_context_settings_t) + TCefRequestContextSettings = record + size: NativeUInt; + cache_path: TCefString; + persist_session_cookies: Integer; + persist_user_preferences: Integer; + ignore_certificate_errors: Integer; + enable_net_security_expiration : integer; + accept_language_list: TCefString; + end; + + // /include/capi/cef_resource_bundle_capi.h (cef_resource_bundle_t) + TCefResourceBundle = record + base: TCefBase; + get_localized_string: function(self: PCefResourceBundle; string_id: Integer): PCefStringUserFree; stdcall; + get_data_resource: function(self: PCefResourceBundle; resource_id: Integer; out data: Pointer; out data_size: NativeUInt): Integer; stdcall; + get_data_resource_for_scale: function(self: PCefResourceBundle; resource_id: Integer; scale_factor: TCefScaleFactor; out data: Pointer; out data_size: NativeUInt): Integer; stdcall; + end; + + // /include/capi/cef_menu_model_delegate_capi.h (cef_menu_model_delegate_t) + TCefMenuModelDelegate = record + base: TCefBase; + execute_command: procedure(self: PCefMenuModelDelegate; menu_model: PCefMenuModel; command_id: Integer; event_flags: TCefEventFlags); stdcall; + menu_will_show: procedure(self: PCefMenuModelDelegate; menu_model: PCefMenuModel); stdcall; + menu_closed: procedure(self: PCefMenuModelDelegate; menu_model: PCefMenuModel); stdcall; + format_label: function(self: PCefMenuModelDelegate; menu_model: PCefMenuModel; label_ : PCefString) : integer; stdcall; + end; + + // /include/capi/cef_process_message_capi.h (cef_process_message_t) + TCefProcessMessage = record + base: TCefBase; + is_valid: function(self: PCefProcessMessage): Integer; stdcall; + is_read_only: function(self: PCefProcessMessage): Integer; stdcall; + copy: function(self: PCefProcessMessage): PCefProcessMessage; stdcall; + get_name: function(self: PCefProcessMessage): PCefStringUserFree; stdcall; + get_argument_list: function(self: PCefProcessMessage): PCefListValue; stdcall; + end; + + // /include/capi/cef_render_process_handler_capi.h (cef_render_process_handler_t) + TCefRenderProcessHandler = record + base: TCefBase; + on_render_thread_created: procedure(self: PCefRenderProcessHandler; extra_info: PCefListValue); stdcall; + on_web_kit_initialized: procedure(self: PCefRenderProcessHandler); stdcall; + on_browser_created: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser); stdcall; + on_browser_destroyed: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser); stdcall; + get_load_handler: function(self: PCefRenderProcessHandler): PCefLoadHandler; stdcall; + on_before_navigation: function(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; navigation_type: TCefNavigationType; is_redirect: Integer): Integer; stdcall; + on_context_created: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall; + on_context_released: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall; + on_uncaught_exception: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context; exception: PCefV8Exception; stackTrace: PCefV8StackTrace); stdcall; + on_focused_node_changed: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; node: PCefDomNode); stdcall; + on_process_message_received: function(self: PCefRenderProcessHandler; browser: PCefBrowser; source_process: TCefProcessId; message: PCefProcessMessage): Integer; stdcall; + end; + + // /include/capi/cef_request_handler_capi.h (cef_request_handler_t) + TCefRequestHandler = record + base: TCefBase; + on_before_browse: function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; isRedirect: Integer): Integer; stdcall; + on_open_urlfrom_tab: function(self: PCefRequestHandler; browser:PCefBrowser; frame: PCefFrame; const target_url: PCefString; target_disposition: TCefWindowOpenDisposition; user_gesture: Integer): Integer; stdcall; + on_before_resource_load: function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; callback: PCefRequestCallback): TCefReturnValue; stdcall; + get_resource_handler: function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest): PCefResourceHandler; stdcall; + on_resource_redirect: procedure(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; const request: PCefRequest; response: PCefResponse; new_url: PCefString); stdcall; + on_resource_response: function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse): Integer; stdcall; + get_resource_response_filter: function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse): PCefResponseFilter; stdcall; + on_resource_load_complete: procedure(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse; status: TCefUrlRequestStatus; received_content_length: Int64); stdcall; + get_auth_credentials: function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; isProxy: Integer; const host: PCefString; port: Integer; const realm, scheme: PCefString; callback: PCefAuthCallback): Integer; stdcall; + on_quota_request: function(self: PCefRequestHandler; browser: PCefBrowser; const origin_url: PCefString; new_size: Int64; callback: PCefRequestCallback): Integer; stdcall; + on_protocol_execution: procedure(self: PCefRequestHandler; browser: PCefBrowser; const url: PCefString; allow_os_execution: PInteger); stdcall; + on_certificate_error: function(self: PCefRequestHandler; browser: PCefBrowser; cert_error: TCefErrorcode; const request_url: PCefString; ssl_info: PCefSslInfo; callback: PCefRequestCallback): Integer; stdcall; + on_select_client_certificate: function(self: PCefRequestHandler; browser: PCefBrowser; isProxy: integer; const host: PCefString; port: integer; certificatesCount: NativeUInt; const certificates: PPCefX509Certificate; callback: PCefSelectClientCertificateCallback): integer; stdcall; + on_plugin_crashed: procedure(self: PCefRequestHandler; browser: PCefBrowser; const plugin_path: PCefString); stdcall; + on_render_view_ready: procedure(self: PCefRequestHandler; browser: PCefBrowser); stdcall; + on_render_process_terminated: procedure(self: PCefRequestHandler; browser: PCefBrowser; status: TCefTerminationStatus); stdcall; + end; + + // /include/capi/cef_request_handler_capi.h (cef_request_callback_t) + TCefRequestCallback = record + base: TCefBase; + cont: procedure(self: PCefRequestCallback; allow: Integer); stdcall; + cancel: procedure(self: PCefRequestCallback); stdcall; + end; + + // /include/capi/cef_resource_handler_capi.h (cef_resource_handler_t) + TCefResourceHandler = record + base: TCefBase; + process_request: function(self: PCefResourceHandler; request: PCefRequest; callback: PCefCallback): Integer; stdcall; + get_response_headers: procedure(self: PCefResourceHandler; response: PCefResponse; response_length: PInt64; redirectUrl: PCefString); stdcall; + read_response: function(self: PCefResourceHandler; data_out: Pointer; bytes_to_read: Integer; bytes_read: PInteger; callback: PCefCallback): Integer; stdcall; + can_get_cookie: function(self: PCefResourceHandler; const cookie: PCefCookie): Integer; stdcall; + can_set_cookie: function(self: PCefResourceHandler; const cookie: PCefCookie): Integer; stdcall; + cancel: procedure(self: PCefResourceHandler); stdcall; + end; + + // /include/capi/cef_response_capi.h (cef_response_t) + TCefResponse = record + base: TCefBase; + is_read_only: function(self: PCefResponse): Integer; stdcall; + get_error: function(self: PCefResponse): TCefErrorCode; stdcall; + set_error: procedure(self: PCefResponse; error: TCefErrorCode); stdcall; + get_status: function(self: PCefResponse): Integer; stdcall; + set_status: procedure(self: PCefResponse; status: Integer); stdcall; + get_status_text: function(self: PCefResponse): PCefStringUserFree; stdcall; + set_status_text: procedure(self: PCefResponse; const statusText: PCefString); stdcall; + get_mime_type: function(self: PCefResponse): PCefStringUserFree; stdcall; + set_mime_type: procedure(self: PCefResponse; const mimeType: PCefString); stdcall; + get_header: function(self: PCefResponse; const name: PCefString): PCefStringUserFree; stdcall; + get_header_map: procedure(self: PCefResponse; headerMap: TCefStringMultimap); stdcall; + set_header_map: procedure(self: PCefResponse; headerMap: TCefStringMultimap); stdcall; + end; + + // /include/capi/cef_response_filter_capi.h (cef_response_filter_t) + TCefResponseFilter = record + base: TCefBase; + init_filter: function(self: PCefResponseFilter): Integer; stdcall; + filter: function(self: PCefResponseFilter; data_in: Pointer; data_in_size, data_in_read: NativeUInt; data_out: Pointer; data_out_size, data_out_written: NativeUInt): TCefResponseFilterStatus; stdcall; + end; + + // /include/capi/cef_auth_callback_capi.h (cef_auth_callback_t) + TCefAuthCallback = record + base: TCefBase; + cont: procedure(self: PCefAuthCallback; const username, password: PCefString); stdcall; + cancel: procedure(self: PCefAuthCallback); stdcall; + end; + + // /include/capi/cef_callback_capi.h (cef_callback_t) + TCefCallback = record + base: TCefBase; + cont: procedure(self: PCefCallback); stdcall; + cancel: procedure(self: PCefCallback); stdcall; + end; + + // /include/internal/cef_types.h (cef_cookie_t) + TCefCookie = record + name: TCefString; + value: TCefString; + domain: TCefString; + path: TCefString; + secure: Integer; + httponly: Integer; + creation: TCefTime; + last_access: TCefTime; + has_expires: Integer; + expires: TCefTime; + end; + + // /include/capi/cef_request_context_capi.h (cef_request_context_t) + TCefRequestContext = record + base: TCefBase; + is_same: function(self, other: PCefRequestContext): Integer; stdcall; + is_sharing_with: function(self, other: PCefRequestContext): Integer; stdcall; + is_global: function(self: PCefRequestContext): Integer; stdcall; + get_handler: function(self: PCefRequestContext): PCefRequestContextHandler; stdcall; + get_cache_path: function(self: PCefRequestContext): PCefStringUserFree; stdcall; + get_default_cookie_manager: function(self: PCefRequestContext; callback: PCefCompletionCallback): PCefCookieManager; stdcall; + register_scheme_handler_factory: function(self: PCefRequestContext; const scheme_name, domain_name: PCefString; factory: PCefSchemeHandlerFactory): Integer; stdcall; + clear_scheme_handler_factories: function(self: PCefRequestContext): Integer; stdcall; + purge_plugin_list_cache: procedure(self: PCefRequestContext; reload_pages: Integer); stdcall; + has_preference: function(self: PCefRequestContext; const name: PCefString): Integer; stdcall; + get_preference: function(self: PCefRequestContext; const name: PCefString): PCefValue; stdcall; + get_all_preferences: function(self: PCefRequestContext; include_defaults: Integer): PCefDictionaryValue; stdcall; + can_set_preference: function(self: PCefRequestContext; const name: PCefString): Integer; stdcall; + set_preference: function(self: PCefRequestContext; const name: PCefString; value: PCefValue; error: PCefString): Integer; stdcall; + clear_certificate_exceptions: procedure(self: PCefRequestContext; callback: PCefCompletionCallback); stdcall; + close_all_connections: procedure(self: PCefRequestContext; callback: PCefCompletionCallback); stdcall; + resolve_host: procedure(self: PCefRequestContext; const origin: PCefString; callback: PCefResolveCallback); stdcall; + resolve_host_cached: function(self: PCefRequestContext; const origin: PCefString; resolved_ips: TCefStringList): TCefErrorCode; stdcall; + end; + + // /include/capi/cef_request_context_handler_capi.h (cef_request_context_handler_t) + TCefRequestContextHandler = record + base: TCefBase; + get_cookie_manager: function(self: PCefRequestContextHandler): PCefCookieManager; stdcall; + on_before_plugin_load: function(self: PCefRequestContextHandler; const mime_type, plugin_url : PCefString; is_main_frame : integer; const top_origin_url: PCefString; plugin_info: PCefWebPluginInfo; plugin_policy: PCefPluginPolicy): Integer; stdcall; + end; + + // /include/capi/cef_callback_capi.h (cef_completion_callback_t) + TCefCompletionCallback = record + base: TCefBase; + on_complete: procedure(self: PCefCompletionCallback); stdcall; + end; + + // /include/capi/cef_cookie_capi.h (cef_cookie_manager_t) + TCefCookieManager = record + base: TCefBase; + set_supported_schemes: procedure(self: PCefCookieManager; schemes: TCefStringList; callback: PCefCompletionCallback); stdcall; + visit_all_cookies: function(self: PCefCookieManager; visitor: PCefCookieVisitor): Integer; stdcall; + visit_url_cookies: function(self: PCefCookieManager; const url: PCefString; includeHttpOnly: Integer; visitor: PCefCookieVisitor): Integer; stdcall; + set_cookie: function(self: PCefCookieManager; const url: PCefString; const cookie: PCefCookie; callback: PCefSetCookieCallback): Integer; stdcall; + delete_cookies: function(self: PCefCookieManager; const url, cookie_name: PCefString; callback: PCefDeleteCookiesCallback): Integer; stdcall; + set_storage_path: function(self: PCefCookieManager; const path: PCefString; persist_session_cookies: Integer; callback: PCefCompletionCallback): Integer; stdcall; + flush_store: function(self: PCefCookieManager; handler: PCefCompletionCallback): Integer; stdcall; + end; + + // /include/capi/cef_scheme_capi.h (cef_scheme_handler_factory_t) + TCefSchemeHandlerFactory = record + base: TCefBase; + create: function(self: PCefSchemeHandlerFactory; browser: PCefBrowser; frame: PCefFrame; const scheme_name: PCefString; request: PCefRequest): PCefResourceHandler; stdcall; + end; + + // /include/capi/cef_request_context_capi.h (cef_resolve_callback_t) + TCefResolveCallback = record + base: TCefBase; + on_resolve_completed: procedure(self: PCefResolveCallback; result: TCefErrorCode; resolved_ips: TCefStringList); stdcall; + end; + + // /include/capi/cef_web_plugin_capi.h (cef_web_plugin_info_t) + TCefWebPluginInfo = record + base: TCefBase; + get_name: function(self: PCefWebPluginInfo): PCefStringUserFree; stdcall; + get_path: function(self: PCefWebPluginInfo): PCefStringUserFree; stdcall; + get_version: function(self: PCefWebPluginInfo): PCefStringUserFree; stdcall; + get_description: function(self: PCefWebPluginInfo): PCefStringUserFree; stdcall; + end; + + // /include/capi/cef_cookie_capi.h (cef_cookie_visitor_t) + TCefCookieVisitor = record + base: TCefBase; + visit: function(self: PCefCookieVisitor; const cookie: PCefCookie; count, total: Integer; deleteCookie: PInteger): Integer; stdcall; + end; + + // /include/capi/cef_cookie_capi.h (cef_set_cookie_callback_t) + TCefSetCookieCallback = record + base: TCefBase; + on_complete: procedure(self: PCefSetCookieCallback; success: Integer); stdcall; + end; + + // /include/capi/cef_cookie_capi.h (cef_delete_cookies_callback_t) + TCefDeleteCookiesCallback = record + base: TCefBase; + on_complete: procedure(self: PCefDeleteCookiesCallback; num_deleted: Integer); stdcall; + end; + + // /include/capi/cef_browser_capi.h (cef_run_file_dialog_callback_t) + TCefRunFileDialogCallback = record + base: TCefBase; + on_file_dialog_dismissed: procedure(self: PCefRunFileDialogCallback; selected_accept_filter: Integer; file_paths: TCefStringList); stdcall; + end; + + // /include/capi/cef_browser_capi.h (cef_download_image_callback_t) + TCefDownloadImageCallback = record + base: TCefBase; + on_download_image_finished: procedure(self: PCefDownloadImageCallback; const image_url: PCefString; http_status_code: Integer; image: PCefImage); stdcall; + end; + + // /include/capi/cef_image_capi.h (cef_image_t) + TCefImage = record + base: TCefBase; + is_empty: function(self: PCefImage): Integer; stdcall; + is_same: function(self, that: PCefImage): Integer; stdcall; + add_bitmap: function(self: PCefImage; scale_factor: Single; pixel_width, pixel_height: Integer; color_type: TCefColorType; alpha_type: TCefAlphaType; pixel_data: Pointer; pixel_data_size: NativeUInt): Integer; stdcall; + add_png: function(self: PCefImage; scale_factor: Single; const png_data: Pointer; png_data_size: NativeUInt): Integer; stdcall; + add_jpeg: function(self: PCefImage; scale_factor: Single; const jpeg_data: Pointer; jpeg_data_size: NativeUInt): Integer; stdcall; + get_width: function(self: PCefImage): NativeUInt; stdcall; + get_height: function(self: PCefImage): NativeUInt; stdcall; + has_representation: function(self: PCefImage; scale_factor: Single): Integer; stdcall; + remove_representation: function(self: PCefImage; scale_factor: Single): Integer; stdcall; + get_representation_info: function(self: PCefImage; scale_factor: Single; actual_scale_factor: PSingle; pixel_width, pixel_height: PInteger): Integer; stdcall; + get_as_bitmap: function(self: PCefImage; scale_factor: Single; color_type: TCefColorType; alpha_type: TCefAlphaType; pixel_width, pixel_height: PInteger): PCefBinaryValue; stdcall; + get_as_png: function(self: PCefImage; scale_factor: Single; with_transparency: Integer; pixel_width, pixel_height: PInteger): PCefBinaryValue; stdcall; + get_as_jpeg: function(self: PCefImage; scale_factor: Single; quality: Integer; pixel_width, pixel_height: PInteger): PCefBinaryValue; stdcall; + end; + + // /include/internal/cef_types.h (cef_pdf_print_settings_t) + TCefPdfPrintSettings = record + header_footer_title: TCefString; + header_footer_url: TCefString; + page_width: Integer; + page_height: Integer; + margin_top: double; + margin_right: double; + margin_bottom: double; + margin_left: double; + margin_type: TCefPdfPrintMarginType; + header_footer_enabled: Integer; + selection_only: Integer; + landscape: Integer; + backgrounds_enabled: Integer; + end; + + // /include/capi/cef_browser_capi.h (cef_pdf_print_callback_t) + TCefPdfPrintCallback = record + base: TCefBase; + on_pdf_print_finished: procedure(self: PCefPdfPrintCallback; const path: PCefString; ok: Integer); stdcall; + end; + + // /include/capi/cef_browser_capi.h (cef_navigation_entry_visitor_t) + TCefNavigationEntryVisitor = record + base: TCefBase; + visit: function(self: PCefNavigationEntryVisitor; entry: PCefNavigationEntry; current, index, total: Integer): Integer; stdcall; + end; + + // /include/capi/cef_navigation_entry_capi.h (cef_navigation_entry_t) + TCefNavigationEntry = record + base: TCefBase; + is_valid: function(self: PCefNavigationEntry): Integer; stdcall; + get_url: function(self: PCefNavigationEntry): PCefStringUserFree; stdcall; + get_display_url: function(self: PCefNavigationEntry): PCefStringUserFree; stdcall; + get_original_url: function(self: PCefNavigationEntry): PCefStringUserFree; stdcall; + get_title: function(self: PCefNavigationEntry): PCefStringUserFree; stdcall; + get_transition_type: function(self: PCefNavigationEntry): TCefTransitionType; stdcall; + has_post_data: function(self: PCefNavigationEntry): Integer; stdcall; + get_completion_time: function(self: PCefNavigationEntry): TCefTime; stdcall; + get_http_status_code: function(self: PCefNavigationEntry): Integer; stdcall; + get_sslstatus: function(self: PCefNavigationEntry): PCefSSLStatus; stdcall; + end; + + // /include/internal/cef_types.h (cef_mouse_event_t) + TCefMouseEvent = record + x: Integer; + y: Integer; + modifiers: TCefEventFlags; + end; + + // /include/capi/cef_print_settings_capi.h (cef_print_settings_t) + TCefPrintSettings = record + base: TCefBase; + is_valid: function(self: PCefPrintSettings): Integer; stdcall; + is_read_only: function(self: PCefPrintSettings): Integer; stdcall; + copy: function(self: PCefPrintSettings): PCefPrintSettings; stdcall; + set_orientation: procedure(self: PCefPrintSettings; landscape: Integer); stdcall; + is_landscape: function(self: PCefPrintSettings): Integer; stdcall; + set_printer_printable_area: procedure(self: PCefPrintSettings; const physical_size_device_units: PCefSize; const printable_area_device_units: PCefRect; landscape_needs_flip: Integer); stdcall; + set_device_name: procedure(self: PCefPrintSettings; const name: PCefString); stdcall; + get_device_name: function(self: PCefPrintSettings): PCefStringUserFree; stdcall; + set_dpi: procedure(self: PCefPrintSettings; dpi: Integer); stdcall; + get_dpi: function(self: PCefPrintSettings): Integer; stdcall; + set_page_ranges: procedure(self: PCefPrintSettings; rangesCount: NativeUInt; ranges: PCefRange); stdcall; + get_page_ranges_count: function(self: PCefPrintSettings): NativeUInt; stdcall; + get_page_ranges: procedure(self: PCefPrintSettings; rangesCount: PNativeUInt; ranges: PCefRange); stdcall; + set_selection_only:procedure(self: PCefPrintSettings; selection_only: Integer); stdcall; + is_selection_only: function(self: PCefPrintSettings): Integer; stdcall; + set_collate: procedure(self: PCefPrintSettings; collate: Integer); stdcall; + will_collate: function(self: PCefPrintSettings): Integer; stdcall; + set_color_model: procedure(self: PCefPrintSettings; model: TCefColorModel); stdcall; + get_color_model: function(self: PCefPrintSettings): TCefColorModel; stdcall; + set_copies: procedure(self: PCefPrintSettings; copies: Integer); stdcall; + get_copies: function(self: PCefPrintSettings): Integer; stdcall; + set_duplex_mode: procedure(self: PCefPrintSettings; mode: TCefDuplexMode); stdcall; + get_duplex_mode: function(self: PCefPrintSettings): TCefDuplexMode; stdcall; + end; + + // /include/capi/cef_print_handler_capi.h (cef_print_dialog_callback_t) + TCefPrintDialogCallback = record + base: TCefBase; + cont: procedure(self: PCefPrintDialogCallback; settings: PCefPrintSettings); stdcall; + cancel: procedure(self: PCefPrintDialogCallback); stdcall; + end; + + // /include/capi/cef_print_handler_capi.h (cef_print_job_callback_t) + TCefPrintJobCallback = record + base: TCefBase; + cont: procedure(self: PCefPrintJobCallback); stdcall; + end; + + // /include/capi/cef_drag_data_capi.h (cef_drag_data_t) + TCefDragData = record + base: TCefBase; + clone: function(self: PCefDragData): PCefDragData; stdcall; + is_read_only: function(self: PCefDragData): Integer; stdcall; + is_link: function(self: PCefDragData): Integer; stdcall; + is_fragment: function(self: PCefDragData): Integer; stdcall; + is_file: function(self: PCefDragData): Integer; stdcall; + get_link_url: function(self: PCefDragData): PCefStringUserFree; stdcall; + get_link_title: function(self: PCefDragData): PCefStringUserFree; stdcall; + get_link_metadata: function(self: PCefDragData): PCefStringUserFree; stdcall; + get_fragment_text: function(self: PCefDragData): PCefStringUserFree; stdcall; + get_fragment_html: function(self: PCefDragData): PCefStringUserFree; stdcall; + get_fragment_base_url: function(self: PCefDragData): PCefStringUserFree; stdcall; + get_file_name: function(self: PCefDragData): PCefStringUserFree; stdcall; + get_file_contents: function(self: PCefDragData; writer: PCefStreamWriter): NativeUInt; stdcall; + get_file_names: function(self: PCefDragData; names: TCefStringList): Integer; stdcall; + set_link_url: procedure(self: PCefDragData; const url: PCefString); stdcall; + set_link_title: procedure(self: PCefDragData; const title: PCefString); stdcall; + set_link_metadata: procedure(self: PCefDragData; const data: PCefString); stdcall; + set_fragment_text: procedure(self: PCefDragData; const text: PCefString); stdcall; + set_fragment_html: procedure(self: PCefDragData; const html: PCefString); stdcall; + set_fragment_base_url: procedure(self: PCefDragData; const base_url: PCefString); stdcall; + reset_file_contents: procedure(self: PCefDragData); stdcall; + add_file: procedure(self: PCefDragData; const path, display_name: PCefString); stdcall; + end; + + // /include/capi/cef_command_line_capi.h (cef_command_line_t) + TCefCommandLine = record + base: TCefBase; + is_valid: function(self: PCefCommandLine): Integer; stdcall; + is_read_only: function(self: PCefCommandLine): Integer; stdcall; + copy: function(self: PCefCommandLine): PCefCommandLine; stdcall; + init_from_argv: procedure(self: PCefCommandLine; argc: Integer; const argv: PPAnsiChar); stdcall; + init_from_string: procedure(self: PCefCommandLine; command_line: PCefString); stdcall; + reset: procedure(self: PCefCommandLine); stdcall; + get_argv: procedure(self: PCefCommandLine; argv: TCefStringList); stdcall; + get_command_line_string: function(self: PCefCommandLine): PCefStringUserFree; stdcall; + get_program: function(self: PCefCommandLine): PCefStringUserFree; stdcall; + set_program: procedure(self: PCefCommandLine; program_: PCefString); stdcall; + has_switches: function(self: PCefCommandLine): Integer; stdcall; + has_switch: function(self: PCefCommandLine; const name: PCefString): Integer; stdcall; + get_switch_value: function(self: PCefCommandLine; const name: PCefString): PCefStringUserFree; stdcall; + get_switches: procedure(self: PCefCommandLine; switches: TCefStringMap); stdcall; + append_switch: procedure(self: PCefCommandLine; const name: PCefString); stdcall; + append_switch_with_value: procedure(self: PCefCommandLine; const name, value: PCefString); stdcall; + has_arguments: function(self: PCefCommandLine): Integer; stdcall; + get_arguments: procedure(self: PCefCommandLine; arguments: TCefStringList); stdcall; + append_argument: procedure(self: PCefCommandLine; const argument: PCefString); stdcall; + prepend_wrapper: procedure(self: PCefCommandLine; const wrapper: PCefString); stdcall; + end; + + // /include/capi/cef_scheme_capi.h (cef_scheme_registrar_t) + TCefSchemeRegistrar = record + base: TCefBase; + add_custom_scheme: function(self: PCefSchemeRegistrar; const scheme_name: PCefString; is_standard, is_local, is_display_isolated: Integer): Integer; stdcall; + end; + + // /include/capi/cef_values_capi.h (cef_binary_value_t) + TCefBinaryValue = record + base: TCefBase; + is_valid: function(self: PCefBinaryValue): Integer; stdcall; + is_owned: function(self: PCefBinaryValue): Integer; stdcall; + is_same: function(self, that: PCefBinaryValue):Integer; stdcall; + is_equal: function(self, that: PCefBinaryValue): Integer; stdcall; + copy: function(self: PCefBinaryValue): PCefBinaryValue; stdcall; + get_size: function(self: PCefBinaryValue): NativeUInt; stdcall; + get_data: function(self: PCefBinaryValue; buffer: Pointer; buffer_size, data_offset: NativeUInt): NativeUInt; stdcall; + end; + + // /include/capi/cef_values_capi.h (cef_value_t) + TCefValue = record + base: TCefBase; + is_valid: function(self: PCefValue): Integer; stdcall; + is_owned: function(self: PCefValue): Integer; stdcall; + is_read_only: function(self: PCefValue): Integer; stdcall; + is_same: function(self, that: PCefValue): Integer; stdcall; + is_equal: function(self, that: PCefValue): Integer; stdcall; + copy: function(self: PCefValue): PCefValue; stdcall; + get_type: function(self: PCefValue): TCefValueType; stdcall; + get_bool: function(self: PCefValue): Integer; stdcall; + get_int: function(self: PCefValue): Integer; stdcall; + get_double: function(self: PCefValue): Double; stdcall; + get_string: function(self: PCefValue): PCefStringUserFree; stdcall; + get_binary: function(self: PCefValue): PCefBinaryValue; stdcall; + get_dictionary: function(self: PCefValue): PCefDictionaryValue; stdcall; + get_list: function(self: PCefValue): PCefListValue; stdcall; + set_null: function(self: PCefValue): Integer; stdcall; + set_bool: function(self: PCefValue; value: Integer): Integer; stdcall; + set_int: function(self: PCefValue; value: Integer): Integer; stdcall; + set_double: function(self: PCefValue; value: Double): Integer; stdcall; + set_string: function(self: PCefValue; const value: PCefString): Integer; stdcall; + set_binary: function(self: PCefValue; value: PCefBinaryValue): Integer; stdcall; + set_dictionary: function(self: PCefValue; value: PCefDictionaryValue): Integer; stdcall; + set_list: function(self: PCefValue; value: PCefListValue): Integer; stdcall; + end; + + // /include/capi/cef_values_capi.h (cef_dictionary_value_t) + TCefDictionaryValue = record + base: TCefBase; + is_valid: function(self: PCefDictionaryValue): Integer; stdcall; + is_owned: function(self: PCefDictionaryValue): Integer; stdcall; + is_read_only: function(self: PCefDictionaryValue): Integer; stdcall; + is_same: function(self, that: PCefDictionaryValue): Integer; stdcall; + is_equal: function(self, that: PCefDictionaryValue): Integer; stdcall; + copy: function(self: PCefDictionaryValue; exclude_empty_children: Integer): PCefDictionaryValue; stdcall; + get_size: function(self: PCefDictionaryValue): NativeUInt; stdcall; + clear: function(self: PCefDictionaryValue): Integer; stdcall; + has_key: function(self: PCefDictionaryValue; const key: PCefString): Integer; stdcall; + get_keys: function(self: PCefDictionaryValue; const keys: TCefStringList): Integer; stdcall; + remove: function(self: PCefDictionaryValue; const key: PCefString): Integer; stdcall; + get_type: function(self: PCefDictionaryValue; const key: PCefString): TCefValueType; stdcall; + get_value: function(self: PCefDictionaryValue; const key: PCefString): PCefValue; stdcall; + get_bool: function(self: PCefDictionaryValue; const key: PCefString): Integer; stdcall; + get_int: function(self: PCefDictionaryValue; const key: PCefString): Integer; stdcall; + get_double: function(self: PCefDictionaryValue; const key: PCefString): Double; stdcall; + get_string: function(self: PCefDictionaryValue; const key: PCefString): PCefStringUserFree; stdcall; + get_binary: function(self: PCefDictionaryValue; const key: PCefString): PCefBinaryValue; stdcall; + get_dictionary: function(self: PCefDictionaryValue; const key: PCefString): PCefDictionaryValue; stdcall; + get_list: function(self: PCefDictionaryValue; const key: PCefString): PCefListValue; stdcall; + set_value: function(self: PCefDictionaryValue; const key: PCefString; value: PCefValue): Integer; stdcall; + set_null: function(self: PCefDictionaryValue; const key: PCefString): Integer; stdcall; + set_bool: function(self: PCefDictionaryValue; const key: PCefString; value: Integer): Integer; stdcall; + set_int: function(self: PCefDictionaryValue; const key: PCefString; value: Integer): Integer; stdcall; + set_double: function(self: PCefDictionaryValue; const key: PCefString; value: Double): Integer; stdcall; + set_string: function(self: PCefDictionaryValue; const key: PCefString; value: PCefString): Integer; stdcall; + set_binary: function(self: PCefDictionaryValue; const key: PCefString; value: PCefBinaryValue): Integer; stdcall; + set_dictionary: function(self: PCefDictionaryValue; const key: PCefString; value: PCefDictionaryValue): Integer; stdcall; + set_list: function(self: PCefDictionaryValue; const key: PCefString; value: PCefListValue): Integer; stdcall; + end; + + // /include/capi/cef_values_capi.h (cef_list_value_t) + TCefListValue = record + base: TCefBase; + is_valid: function(self: PCefListValue): Integer; stdcall; + is_owned: function(self: PCefListValue): Integer; stdcall; + is_read_only: function(self: PCefListValue): Integer; stdcall; + is_same: function(self, that: PCefListValue): Integer; stdcall; + is_equal: function(self, that: PCefListValue): Integer; stdcall; + copy: function(self: PCefListValue): PCefListValue; stdcall; + set_size: function(self: PCefListValue; size: NativeUInt): Integer; stdcall; + get_size: function(self: PCefListValue): NativeUInt; stdcall; + clear: function(self: PCefListValue): Integer; stdcall; + remove: function(self: PCefListValue; index: NativeUInt): Integer; stdcall; + get_type: function(self: PCefListValue; index: NativeUInt): TCefValueType; stdcall; + get_value: function(self: PCefListValue; index: NativeUInt): PCefValue; stdcall; + get_bool: function(self: PCefListValue; index: NativeUInt): Integer; stdcall; + get_int: function(self: PCefListValue; index: NativeUInt): Integer; stdcall; + get_double: function(self: PCefListValue; index: NativeUInt): Double; stdcall; + get_string: function(self: PCefListValue; index: NativeUInt): PCefStringUserFree; stdcall; + get_binary: function(self: PCefListValue; index: NativeUInt): PCefBinaryValue; stdcall; + get_dictionary: function(self: PCefListValue; index: NativeUInt): PCefDictionaryValue; stdcall; + get_list: function(self: PCefListValue; index: NativeUInt): PCefListValue; stdcall; + set_value: function(self: PCefListValue; index: NativeUInt; value: PCefValue): Integer; stdcall; + set_null: function(self: PCefListValue; index: NativeUInt): Integer; stdcall; + set_bool: function(self: PCefListValue; index: NativeUInt; value: Integer): Integer; stdcall; + set_int: function(self: PCefListValue; index: NativeUInt; value: Integer): Integer; stdcall; + set_double: function(self: PCefListValue; index: NativeUInt; value: Double): Integer; stdcall; + set_string: function(self: PCefListValue; index: NativeUInt; value: PCefString): Integer; stdcall; + set_binary: function(self: PCefListValue; index: NativeUInt; value: PCefBinaryValue): Integer; stdcall; + set_dictionary: function(self: PCefListValue; index: NativeUInt; value: PCefDictionaryValue): Integer; stdcall; + set_list: function(self: PCefListValue; index: NativeUInt; value: PCefListValue): Integer; stdcall; + end; + + // /include/capi/cef_string_visitor_capi.h (cef_string_visitor_t) + TCefStringVisitor = record + base: TCefBase; + visit: procedure(self: PCefStringVisitor; const str: PCefString); stdcall; + end; + + TCefPostDataElementArray = array[0..(High(Integer) div SizeOf(PCefPostDataElement)) - 1] of PCefPostDataElement; + + // /include/capi/cef_request_capi.h (cef_post_data_element_t) + TCefPostDataElement = record + base: TCefBase; + is_read_only: function(self: PCefPostDataElement): Integer; stdcall; + set_to_empty: procedure(self: PCefPostDataElement); stdcall; + set_to_file: procedure(self: PCefPostDataElement; const fileName: PCefString); stdcall; + set_to_bytes: procedure(self: PCefPostDataElement; size: NativeUInt; const bytes: Pointer); stdcall; + get_type: function(self: PCefPostDataElement): TCefPostDataElementType; stdcall; + get_file: function(self: PCefPostDataElement): PCefStringUserFree; stdcall; + get_bytes_count: function(self: PCefPostDataElement): NativeUInt; stdcall; + get_bytes: function(self: PCefPostDataElement; size: NativeUInt; bytes: Pointer): NativeUInt; stdcall; + end; + + // /include/capi/cef_request_capi.h (cef_post_data_t) + TCefPostData = record + base: TCefBase; + is_read_only: function(self: PCefPostData):Integer; stdcall; + has_excluded_elements: function(self: PCefPostData): Integer; stdcall; + get_element_count: function(self: PCefPostData): NativeUInt; stdcall; + get_elements: procedure(self: PCefPostData; elementsCount: PNativeUInt; elements: PCefPostDataElementArray); stdcall; + remove_element: function(self: PCefPostData; element: PCefPostDataElement): Integer; stdcall; + add_element: function(self: PCefPostData; element: PCefPostDataElement): Integer; stdcall; + remove_elements: procedure(self: PCefPostData); stdcall; + end; + + // /include/capi/cef_request_capi.h (cef_request_t) + TCefRequest = record + base: TCefBase; + is_read_only: function(self: PCefRequest): Integer; stdcall; + get_url: function(self: PCefRequest): PCefStringUserFree; stdcall; + set_url: procedure(self: PCefRequest; const url: PCefString); stdcall; + get_method: function(self: PCefRequest): PCefStringUserFree; stdcall; + set_method: procedure(self: PCefRequest; const method: PCefString); stdcall; + set_referrer: procedure(self: PCefRequest; const referrer_url: PCefString; policy: TCefReferrerPolicy); stdcall; + get_referrer_url: function(self: PCefRequest): PCefStringUserFree; stdcall; + get_referrer_policy: function(self: PCefRequest): TCefReferrerPolicy; stdcall; + get_post_data: function(self: PCefRequest): PCefPostData; stdcall; + set_post_data: procedure(self: PCefRequest; postData: PCefPostData); stdcall; + get_header_map: procedure(self: PCefRequest; headerMap: TCefStringMultimap); stdcall; + set_header_map: procedure(self: PCefRequest; headerMap: TCefStringMultimap); stdcall; + set_: procedure(self: PCefRequest; const url, method: PCefString; postData: PCefPostData; headerMap: TCefStringMultimap); stdcall; + get_flags: function(self: PCefRequest): Integer; stdcall; + set_flags: procedure(self: PCefRequest; flags: Integer); stdcall; + get_first_party_for_cookies: function(self: PCefRequest): PCefStringUserFree; stdcall; + set_first_party_for_cookies: procedure(self: PCefRequest; const url: PCefString); stdcall; + get_resource_type: function(self: PCefRequest): TCefResourceType; stdcall; + get_transition_type: function(self: PCefRequest): TCefTransitionType; stdcall; + get_identifier: function(self: PCefRequest): UInt64; stdcall; + end; + + // /include/capi/cef_task_capi.h (cef_task_t) + TCefTask = record + base: TCefBase; + execute: procedure(self: PCefTask); stdcall; + end; + + // /include/capi/cef_dom_capi.h (cef_domvisitor_t) + TCefDomVisitor = record + base: TCefBase; + visit: procedure(self: PCefDomVisitor; document: PCefDomDocument); stdcall; + end; + + // /include/capi/cef_menu_model_capi.h (cef_menu_model_t) + TCefMenuModel = record + base: TCefBase; + clear: function(self: PCefMenuModel): Integer; stdcall; + get_count: function(self: PCefMenuModel): Integer; stdcall; + add_separator: function(self: PCefMenuModel): Integer; stdcall; + add_item: function(self: PCefMenuModel; command_id: Integer; const text: PCefString): Integer; stdcall; + add_check_item: function(self: PCefMenuModel; command_id: Integer; const text: PCefString): Integer; stdcall; + add_radio_item: function(self: PCefMenuModel; command_id: Integer; const text: PCefString; group_id: Integer): Integer; stdcall; + add_sub_menu: function(self: PCefMenuModel; command_id: Integer; const text: PCefString): PCefMenuModel; stdcall; + insert_separator_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + insert_item_at: function(self: PCefMenuModel; index, command_id: Integer; const text: PCefString): Integer; stdcall; + insert_check_item_at: function(self: PCefMenuModel; index, command_id: Integer; const text: PCefString): Integer; stdcall; + insert_radio_item_at: function(self: PCefMenuModel; index, command_id: Integer; const text: PCefString; group_id: Integer): Integer; stdcall; + insert_sub_menu_at: function(self: PCefMenuModel; index, command_id: Integer; const text: PCefString): PCefMenuModel; stdcall; + remove: function(self: PCefMenuModel; command_id: Integer): Integer; stdcall; + remove_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + get_index_of: function(self: PCefMenuModel; command_id: Integer): Integer; stdcall; + get_command_id_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + set_command_id_at: function(self: PCefMenuModel; index, command_id: Integer): Integer; stdcall; + get_label: function(self: PCefMenuModel; command_id: Integer): PCefStringUserFree; stdcall; + get_label_at: function(self: PCefMenuModel; index: Integer): PCefStringUserFree; stdcall; + set_label: function(self: PCefMenuModel; command_id: Integer; const text: PCefString): Integer; stdcall; + set_label_at: function(self: PCefMenuModel; index: Integer; const text: PCefString): Integer; stdcall; + get_type: function(self: PCefMenuModel; command_id: Integer): TCefMenuItemType; stdcall; + get_type_at: function(self: PCefMenuModel; index: Integer): TCefMenuItemType; stdcall; + get_group_id: function(self: PCefMenuModel; command_id: Integer): Integer; stdcall; + get_group_id_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + set_group_id: function(self: PCefMenuModel; command_id, group_id: Integer): Integer; stdcall; + set_group_id_at: function(self: PCefMenuModel; index, group_id: Integer): Integer; stdcall; + get_sub_menu: function(self: PCefMenuModel; command_id: Integer): PCefMenuModel; stdcall; + get_sub_menu_at: function(self: PCefMenuModel; index: Integer): PCefMenuModel; stdcall; + is_visible: function(self: PCefMenuModel; command_id: Integer): Integer; stdcall; + is_visible_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + set_visible: function(self: PCefMenuModel; command_id, visible: Integer): Integer; stdcall; + set_visible_at: function(self: PCefMenuModel; index, visible: Integer): Integer; stdcall; + is_enabled: function(self: PCefMenuModel; command_id: Integer): Integer; stdcall; + is_enabled_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + set_enabled: function(self: PCefMenuModel; command_id, enabled: Integer): Integer; stdcall; + set_enabled_at: function(self: PCefMenuModel; index, enabled: Integer): Integer; stdcall; + is_checked: function(self: PCefMenuModel; command_id: Integer): Integer; stdcall; + is_checked_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + set_checked: function(self: PCefMenuModel; command_id, checked: Integer): Integer; stdcall; + set_checked_at: function(self: PCefMenuModel; index, checked: Integer): Integer; stdcall; + has_accelerator: function(self: PCefMenuModel; command_id: Integer): Integer; stdcall; + has_accelerator_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + set_accelerator: function(self: PCefMenuModel; command_id, key_code, shift_pressed, ctrl_pressed, alt_pressed: Integer): Integer; stdcall; + set_accelerator_at: function(self: PCefMenuModel; index, key_code, shift_pressed, ctrl_pressed, alt_pressed: Integer): Integer; stdcall; + remove_accelerator: function(self: PCefMenuModel; command_id: Integer): Integer; stdcall; + remove_accelerator_at: function(self: PCefMenuModel; index: Integer): Integer; stdcall; + get_accelerator: function(self: PCefMenuModel; command_id: Integer; key_code, shift_pressed, ctrl_pressed, alt_pressed: PInteger): Integer; stdcall; + get_accelerator_at: function(self: PCefMenuModel; index: Integer; key_code, shift_pressed, ctrl_pressed, alt_pressed: PInteger): Integer; stdcall; + end; + + // /include/capi/cef_context_menu_handler_capi.h (cef_context_menu_params_t) + TCefContextMenuParams = record + base: TCefBase; + get_xcoord: function(self: PCefContextMenuParams): Integer; stdcall; + get_ycoord: function(self: PCefContextMenuParams): Integer; stdcall; + get_type_flags: function(self: PCefContextMenuParams): Integer; stdcall; + get_link_url: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + get_unfiltered_link_url: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + get_source_url: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + has_image_contents: function(self: PCefContextMenuParams): Integer; stdcall; + get_title_text: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + get_page_url: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + get_frame_url: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + get_frame_charset: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + get_media_type: function(self: PCefContextMenuParams): TCefContextMenuMediaType; stdcall; + get_media_state_flags: function(self: PCefContextMenuParams): Integer; stdcall; + get_selection_text: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + get_misspelled_word: function(self: PCefContextMenuParams): PCefStringUserFree; stdcall; + get_dictionary_suggestions: function(self: PCefContextMenuParams; suggestions: TCefStringList): Integer; stdcall; + is_editable: function(self: PCefContextMenuParams): Integer; stdcall; + is_spell_check_enabled: function(self: PCefContextMenuParams): Integer; stdcall; + get_edit_state_flags: function(self: PCefContextMenuParams): Integer; stdcall; + is_custom_menu: function(self: PCefContextMenuParams): Integer; stdcall; + is_pepper_menu: function(self: PCefContextMenuParams): Integer; stdcall; + end; + + // /include/capi/cef_download_item_capi.h (cef_download_item_t) + TCefDownloadItem = record + base: TCefBase; + is_valid: function(self: PCefDownloadItem): Integer; stdcall; + is_in_progress: function(self: PCefDownloadItem): Integer; stdcall; + is_complete: function(self: PCefDownloadItem): Integer; stdcall; + is_canceled: function(self: PCefDownloadItem): Integer; stdcall; + get_current_speed: function(self: PCefDownloadItem): Int64; stdcall; + get_percent_complete: function(self: PCefDownloadItem): Integer; stdcall; + get_total_bytes: function(self: PCefDownloadItem): Int64; stdcall; + get_received_bytes: function(self: PCefDownloadItem): Int64; stdcall; + get_start_time: function(self: PCefDownloadItem): TCefTime; stdcall; + get_end_time: function(self: PCefDownloadItem): TCefTime; stdcall; + get_full_path: function(self: PCefDownloadItem): PCefStringUserFree; stdcall; + get_id: function(self: PCefDownloadItem): Cardinal; stdcall; + get_url: function(self: PCefDownloadItem): PCefStringUserFree; stdcall; + get_original_url: function(self: PCefDownloadItem): PCefStringUserFree; stdcall; + get_suggested_file_name: function(self: PCefDownloadItem): PCefStringUserFree; stdcall; + get_content_disposition: function(self: PCefDownloadItem): PCefStringUserFree; stdcall; + get_mime_type: function(self: PCefDownloadItem): PCefStringUserFree; stdcall; + end; + + // /include/capi/cef_download_handler_capi.h (cef_before_download_callback_t) + TCefBeforeDownloadCallback = record + base: TCefBase; + cont: procedure(self: PCefBeforeDownloadCallback; const download_path: PCefString; show_dialog: Integer); stdcall; + end; + + // /include/capi/cef_download_handler_capi.h (cef_download_item_callback_t) + TCefDownloadItemCallback = record + base: TCefBase; + cancel: procedure(self: PCefDownloadItemCallback); stdcall; + pause: procedure(self: PCefDownloadItemCallback); stdcall; + resume: procedure(self: PCefDownloadItemCallback); stdcall; + end; + + // /include/capi/cef_dom_capi.h (cef_domnode_t) + TCefDomNode = record + base: TCefBase; + get_type: function(self: PCefDomNode): TCefDomNodeType; stdcall; + is_text: function(self: PCefDomNode): Integer; stdcall; + is_element: function(self: PCefDomNode): Integer; stdcall; + is_editable: function(self: PCefDomNode): Integer; stdcall; + is_form_control_element: function(self: PCefDomNode): Integer; stdcall; + get_form_control_element_type: function(self: PCefDomNode): PCefStringUserFree; stdcall; + is_same: function(self, that: PCefDomNode): Integer; stdcall; + get_name: function(self: PCefDomNode): PCefStringUserFree; stdcall; + get_value: function(self: PCefDomNode): PCefStringUserFree; stdcall; + set_value: function(self: PCefDomNode; const value: PCefString): Integer; stdcall; + get_as_markup: function(self: PCefDomNode): PCefStringUserFree; stdcall; + get_document: function(self: PCefDomNode): PCefDomDocument; stdcall; + get_parent: function(self: PCefDomNode): PCefDomNode; stdcall; + get_previous_sibling: function(self: PCefDomNode): PCefDomNode; stdcall; + get_next_sibling: function(self: PCefDomNode): PCefDomNode; stdcall; + has_children: function(self: PCefDomNode): Integer; stdcall; + get_first_child: function(self: PCefDomNode): PCefDomNode; stdcall; + get_last_child: function(self: PCefDomNode): PCefDomNode; stdcall; + get_element_tag_name: function(self: PCefDomNode): PCefStringUserFree; stdcall; + has_element_attributes: function(self: PCefDomNode): Integer; stdcall; + has_element_attribute: function(self: PCefDomNode; const attrName: PCefString): Integer; stdcall; + get_element_attribute: function(self: PCefDomNode; const attrName: PCefString): PCefStringUserFree; stdcall; + get_element_attributes: procedure(self: PCefDomNode; attrMap: TCefStringMap); stdcall; + set_element_attribute: function(self: PCefDomNode; const attrName, value: PCefString): Integer; stdcall; + get_element_inner_text: function(self: PCefDomNode): PCefStringUserFree; stdcall; + get_element_bounds: function(self: PCefDomNode): TCefRect; stdcall; + end; + + // /include/capi/cef_dom_capi.h (cef_domdocument_t) + TCefDomDocument = record + base: TCefBase; + get_type: function(self: PCefDomDocument): TCefDomDocumentType; stdcall; + get_document: function(self: PCefDomDocument): PCefDomNode; stdcall; + get_body: function(self: PCefDomDocument): PCefDomNode; stdcall; + get_head: function(self: PCefDomDocument): PCefDomNode; stdcall; + get_title: function(self: PCefDomDocument): PCefStringUserFree; stdcall; + get_element_by_id: function(self: PCefDomDocument; const id: PCefString): PCefDomNode; stdcall; + get_focused_node: function(self: PCefDomDocument): PCefDomNode; stdcall; + has_selection: function(self: PCefDomDocument): Integer; stdcall; + get_selection_start_offset: function(self: PCefDomDocument): Integer; stdcall; + get_selection_end_offset: function(self: PCefDomDocument): Integer; stdcall; + get_selection_as_markup: function(self: PCefDomDocument): PCefStringUserFree; stdcall; + get_selection_as_text: function(self: PCefDomDocument): PCefStringUserFree; stdcall; + get_base_url: function(self: PCefDomDocument): PCefStringUserFree; stdcall; + get_complete_url: function(self: PCefDomDocument; const partialURL: PCefString): PCefStringUserFree; stdcall; + end; + + PCefV8ValueArray = array[0..(High(Integer) div SizeOf(Pointer)) - 1] of PCefV8Value; + + // /include/capi/cef_v8_capi.h (cef_v8handler_t) + TCefv8Handler = record + base: TCefBase; + execute: function(self: PCefv8Handler; const name: PCefString; obj: PCefv8Value; argumentsCount: NativeUInt; const arguments: PPCefV8Value; var retval: PCefV8Value; var exception: TCefString): Integer; stdcall; + end; + + // /include/capi/cef_v8_capi.h (cef_v8exception_t) + TCefV8Exception = record + base: TCefBase; + get_message: function(self: PCefV8Exception): PCefStringUserFree; stdcall; + get_source_line: function(self: PCefV8Exception): PCefStringUserFree; stdcall; + get_script_resource_name: function(self: PCefV8Exception): PCefStringUserFree; stdcall; + get_line_number: function(self: PCefV8Exception): Integer; stdcall; + get_start_position: function(self: PCefV8Exception): Integer; stdcall; + get_end_position: function(self: PCefV8Exception): Integer; stdcall; + get_start_column: function(self: PCefV8Exception): Integer; stdcall; + get_end_column: function(self: PCefV8Exception): Integer; stdcall; + end; + + // /include/capi/cef_v8_capi.h (cef_v8value_t) + TCefv8Value = record + base: TCefBase; + is_valid: function(self: PCefv8Value): Integer; stdcall; + is_undefined: function(self: PCefv8Value): Integer; stdcall; + is_null: function(self: PCefv8Value): Integer; stdcall; + is_bool: function(self: PCefv8Value): Integer; stdcall; + is_int: function(self: PCefv8Value): Integer; stdcall; + is_uint: function(self: PCefv8Value): Integer; stdcall; + is_double: function(self: PCefv8Value): Integer; stdcall; + is_date: function(self: PCefv8Value): Integer; stdcall; + is_string: function(self: PCefv8Value): Integer; stdcall; + is_object: function(self: PCefv8Value): Integer; stdcall; + is_array: function(self: PCefv8Value): Integer; stdcall; + is_function: function(self: PCefv8Value): Integer; stdcall; + is_same: function(self, that: PCefv8Value): Integer; stdcall; + get_bool_value: function(self: PCefv8Value): Integer; stdcall; + get_int_value: function(self: PCefv8Value): Integer; stdcall; + get_uint_value: function(self: PCefv8Value): Cardinal; stdcall; + get_double_value: function(self: PCefv8Value): Double; stdcall; + get_date_value: function(self: PCefv8Value): TCefTime; stdcall; + get_string_value: function(self: PCefv8Value): PCefStringUserFree; stdcall; + is_user_created: function(self: PCefv8Value): Integer; stdcall; + has_exception: function(self: PCefv8Value): Integer; stdcall; + get_exception: function(self: PCefv8Value): PCefV8Exception; stdcall; + clear_exception: function(self: PCefv8Value): Integer; stdcall; + will_rethrow_exceptions: function(self: PCefv8Value): Integer; stdcall; + set_rethrow_exceptions: function(self: PCefv8Value; rethrow: Integer): Integer; stdcall; + has_value_bykey: function(self: PCefv8Value; const key: PCefString): Integer; stdcall; + has_value_byindex: function(self: PCefv8Value; index: Integer): Integer; stdcall; + delete_value_bykey: function(self: PCefv8Value; const key: PCefString): Integer; stdcall; + delete_value_byindex: function(self: PCefv8Value; index: Integer): Integer; stdcall; + get_value_bykey: function(self: PCefv8Value; const key: PCefString): PCefv8Value; stdcall; + get_value_byindex: function(self: PCefv8Value; index: Integer): PCefv8Value; stdcall; + set_value_bykey: function(self: PCefv8Value; const key: PCefString; value: PCefv8Value; attribute: Integer): Integer; stdcall; + set_value_byindex: function(self: PCefv8Value; index: Integer; value: PCefv8Value): Integer; stdcall; + set_value_byaccessor: function(self: PCefv8Value; const key: PCefString; settings: Integer; attribute: Integer): Integer; stdcall; + get_keys: function(self: PCefv8Value; keys: TCefStringList): Integer; stdcall; + set_user_data: function(self: PCefv8Value; user_data: PCefBase): Integer; stdcall; + get_user_data: function(self: PCefv8Value): PCefBase; stdcall; + get_externally_allocated_memory: function(self: PCefv8Value): Integer; stdcall; + adjust_externally_allocated_memory: function(self: PCefv8Value; change_in_bytes: Integer): Integer; stdcall; + get_array_length: function(self: PCefv8Value): Integer; stdcall; + get_function_name: function(self: PCefv8Value): PCefStringUserFree; stdcall; + get_function_handler: function(self: PCefv8Value): PCefv8Handler; stdcall; + execute_function: function(self: PCefv8Value; obj: PCefv8Value; argumentsCount: NativeUInt; const arguments: PPCefV8Value): PCefv8Value; stdcall; + execute_function_with_context: function(self: PCefv8Value; context: PCefv8Context; obj: PCefv8Value; argumentsCount: NativeUInt; const arguments: PPCefV8Value): PCefv8Value; stdcall; + end; + + // /include/capi/cef_v8_capi.h (cef_v8context_t) + TCefV8Context = record + base: TCefBase; + get_task_runner: function(self: PCefv8Context): PCefTask; stdcall; + is_valid: function(self: PCefv8Context): Integer; stdcall; + get_browser: function(self: PCefv8Context): PCefBrowser; stdcall; + get_frame: function(self: PCefv8Context): PCefFrame; stdcall; + get_global: function(self: PCefv8Context): PCefv8Value; stdcall; + enter: function(self: PCefv8Context): Integer; stdcall; + exit: function(self: PCefv8Context): Integer; stdcall; + is_same: function(self, that: PCefv8Context): Integer; stdcall; + eval: function(self: PCefv8Context; const code: PCefString; const script_url: PCefString; start_line: integer; var retval: PCefv8Value; var exception: PCefV8Exception): Integer; stdcall; + end; + + // /include/capi/cef_v8_capi.h (cef_v8interceptor_t) + TCefV8Interceptor = record + base : TCefBase; + get_byname : function(self: PCefV8Interceptor; const name: PCefString; const obj: PCefV8Value; out retval: PCefv8Value; exception: PCefString): integer; stdcall; + get_byindex : function(self: PCefV8Interceptor; index: integer; const obj: PCefV8Value; out retval: PCefv8Value; exception: PCefString): integer; stdcall; + set_byname : function(self: PCefV8Interceptor; const name: PCefString; const obj: PCefV8Value; value: PCefv8Value; exception: PCefString): integer; stdcall; + set_byindex : function(self: PCefV8Interceptor; index: integer; const obj: PCefV8Value; value: PCefv8Value; exception: PCefString): integer; stdcall; + end; + + // /include/capi/cef_v8_capi.h (cef_v8accessor_t) + TCefV8Accessor = record + base: TCefBase; + get: function(self: PCefV8Accessor; const name: PCefString; obj: PCefv8Value; out retval: PCefv8Value; exception: PCefString): Integer; stdcall; + put: function(self: PCefV8Accessor; const name: PCefString; obj: PCefv8Value; value: PCefv8Value; exception: PCefString): Integer; stdcall; + end; + + // /include/capi/cef_frame_capi.h (cef_frame_t) + TCefFrame = record + base: TCefBase; + is_valid: function(self: PCefFrame): Integer; stdcall; + undo: procedure(self: PCefFrame); stdcall; + redo: procedure(self: PCefFrame); stdcall; + cut: procedure(self: PCefFrame); stdcall; + copy: procedure(self: PCefFrame); stdcall; + paste: procedure(self: PCefFrame); stdcall; + del: procedure(self: PCefFrame); stdcall; + select_all: procedure(self: PCefFrame); stdcall; + view_source: procedure(self: PCefFrame); stdcall; + get_source: procedure(self: PCefFrame; visitor: PCefStringVisitor); stdcall; + get_text: procedure(self: PCefFrame; visitor: PCefStringVisitor); stdcall; + load_request: procedure(self: PCefFrame; request: PCefRequest); stdcall; + load_url: procedure(self: PCefFrame; const url: PCefString); stdcall; + load_string: procedure(self: PCefFrame; const stringVal, url: PCefString); stdcall; + execute_java_script: procedure(self: PCefFrame; const code, script_url: PCefString; start_line: Integer); stdcall; + is_main: function(self: PCefFrame): Integer; stdcall; + is_focused: function(self: PCefFrame): Integer; stdcall; + get_name: function(self: PCefFrame): PCefStringUserFree; stdcall; + get_identifier: function(self: PCefFrame): Int64; stdcall; + get_parent: function(self: PCefFrame): PCefFrame; stdcall; + get_url: function(self: PCefFrame): PCefStringUserFree; stdcall; + get_browser: function(self: PCefFrame): PCefBrowser; stdcall; + get_v8context: function(self: PCefFrame): PCefv8Context; stdcall; + visit_dom: procedure(self: PCefFrame; visitor: PCefDomVisitor); stdcall; + end; + + // /include/capi/cef_context_menu_handler_capi.h (cef_context_menu_handler_t) + TCefContextMenuHandler = record + base: TCefBase; + on_before_context_menu: procedure(self: PCefContextMenuHandler; browser: PCefBrowser; frame: PCefFrame; params: PCefContextMenuParams; model: PCefMenuModel); stdcall; + run_context_menu: function(self: PCefContextMenuHandler; browser: PCefBrowser; frame: PCefFrame; params: PCefContextMenuParams; model: PCefMenuModel; callback: PCefRunContextMenuCallback): Integer; stdcall; + on_context_menu_command: function(self: PCefContextMenuHandler; browser: PCefBrowser; frame: PCefFrame; params: PCefContextMenuParams; command_id: Integer; event_flags: Integer): Integer; stdcall; + on_context_menu_dismissed: procedure(self: PCefContextMenuHandler; browser: PCefBrowser; frame: PCefFrame); stdcall; + end; + + // /include/capi/cef_client_capi.h (cef_client_t) + TCefClient = record + base: TCefBase; + get_context_menu_handler: function(self: PCefClient): PCefContextMenuHandler; stdcall; + get_dialog_handler: function(self: PCefClient): PCefDialogHandler; stdcall; + get_display_handler: function(self: PCefClient): PCefDisplayHandler; stdcall; + get_download_handler: function(self: PCefClient): PCefDownloadHandler; stdcall; + get_drag_handler: function(self: PCefClient): PCefDragHandler; stdcall; + get_find_handler: function(self: PCefClient): PCefFindHandler; stdcall; + get_focus_handler: function(self: PCefClient): PCefFocusHandler; stdcall; + get_geolocation_handler: function(self: PCefClient): PCefGeolocationHandler; stdcall; + get_jsdialog_handler: function(self: PCefClient): PCefJsDialogHandler; stdcall; + get_keyboard_handler: function(self: PCefClient): PCefKeyboardHandler; stdcall; + get_life_span_handler: function(self: PCefClient): PCefLifeSpanHandler; stdcall; + get_load_handler: function(self: PCefClient): PCefLoadHandler; stdcall; + get_render_handler: function(self: PCefClient): PCefRenderHandler; stdcall; + get_request_handler: function(self: PCefClient): PCefRequestHandler; stdcall; + on_process_message_received: function(self: PCefClient; browser: PCefBrowser; source_process: TCefProcessId; message: PCefProcessMessage): Integer; stdcall; + end; + + // /include/capi/cef_browser_capi.h (cef_browser_host_t) + TCefBrowserHost = record + base: TCefBase; + get_browser: function(self: PCefBrowserHost): PCefBrowser; stdcall; + close_browser: procedure(self: PCefBrowserHost; force_close: Integer); stdcall; + try_close_browser: function(self: PCefBrowserHost): Integer; stdcall; + set_focus: procedure(self: PCefBrowserHost; focus: Integer); stdcall; + get_window_handle: function(self: PCefBrowserHost): TCefWindowHandle; stdcall; + get_opener_window_handle: function(self: PCefBrowserHost): TCefWindowHandle; stdcall; + has_view: function(self: PCefBrowserHost): Integer; stdcall; + get_client: function(self: PCefBrowserHost): PCefClient; stdcall; + get_request_context: function(self: PCefBrowserHost): PCefRequestContext; stdcall; + get_zoom_level: function(self: PCefBrowserHost): Double; stdcall; + set_zoom_level: procedure(self: PCefBrowserHost; zoomLevel: Double); stdcall; + run_file_dialog: procedure(self: PCefBrowserHost; mode: TCefFileDialogMode; const title, default_file_path: PCefString; accept_filters: TCefStringList; selected_accept_filter: Integer; callback: PCefRunFileDialogCallback); stdcall; + start_download: procedure(self: PCefBrowserHost; const url: PCefString); stdcall; + download_image: procedure(self: PCefBrowserHost; const image_url: PCefString; is_favicon: Integer; max_image_size: Cardinal; bypass_cache: Integer; callback: PCefDownloadImageCallback); stdcall; + print: procedure(self: PCefBrowserHost); stdcall; + print_to_pdf: procedure(self: PCefBrowserHost; const path: PCefString; const settings: PCefPdfPrintSettings; callback: PCefPdfPrintCallback); stdcall; + find: procedure(self: PCefBrowserHost; identifier: Integer; const searchText: PCefString; forward, matchCase, findNext: Integer); stdcall; + stop_finding: procedure(self: PCefBrowserHost; clearSelection: Integer); stdcall; + show_dev_tools: procedure(self: PCefBrowserHost; const windowInfo: PCefWindowInfo; client: PCefClient; const settings: PCefBrowserSettings; const inspect_element_at: PCefPoint); stdcall; + close_dev_tools: procedure(self: PCefBrowserHost); stdcall; + has_dev_tools: function(self: PCefBrowserHost): Integer; stdcall; + get_navigation_entries: procedure(self: PCefBrowserHost; visitor: PCefNavigationEntryVisitor; current_only: Integer); stdcall; + set_mouse_cursor_change_disabled: procedure(self: PCefBrowserHost; disabled: Integer); stdcall; + is_mouse_cursor_change_disabled: function(self: PCefBrowserHost): Integer; stdcall; + replace_misspelling: procedure(self: PCefBrowserHost; const word: PCefString); stdcall; + add_word_to_dictionary: procedure(self: PCefBrowserHost; const word: PCefString); stdcall; + is_window_rendering_disabled: function(self: PCefBrowserHost): Integer; stdcall; + was_resized: procedure(self: PCefBrowserHost); stdcall; + was_hidden: procedure(self: PCefBrowserHost; hidden: Integer); stdcall; + notify_screen_info_changed: procedure(self: PCefBrowserHost); stdcall; + invalidate: procedure(self: PCefBrowserHost; kind: TCefPaintElementType); stdcall; + send_key_event: procedure(self: PCefBrowserHost; const event: PCefKeyEvent); stdcall; + send_mouse_click_event: procedure(self: PCefBrowserHost; const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp, clickCount: Integer); stdcall; + send_mouse_move_event: procedure(self: PCefBrowserHost; const event: PCefMouseEvent; mouseLeave: Integer); stdcall; + send_mouse_wheel_event: procedure(self: PCefBrowserHost; const event: PCefMouseEvent; deltaX, deltaY: Integer); stdcall; + send_focus_event: procedure(self: PCefBrowserHost; setFocus: Integer); stdcall; + send_capture_lost_event: procedure(self: PCefBrowserHost); stdcall; + notify_move_or_resize_started: procedure(self: PCefBrowserHost); stdcall; + get_windowless_frame_rate: function(self: PCefBrowserHost): Integer; stdcall; + set_windowless_frame_rate: procedure(self: PCefBrowserHost; frame_rate: Integer); stdcall; + ime_set_composition: procedure(self: PCefBrowserHost; const text: PCefString; underlinesCount : NativeUInt; const underlines : PCefCompositionUnderline; const replacement_range, selection_range : PCefRange); stdcall; + ime_commit_text: procedure(self: PCefBrowserHost; const text: PCefString; const replacement_range : PCefRange; relative_cursor_pos : integer); stdcall; + ime_finish_composing_text: procedure(self: PCefBrowserHost; keep_selection : integer); stdcall; + ime_cancel_composition: procedure(self: PCefBrowserHost); stdcall; + drag_target_drag_enter: procedure(self: PCefBrowserHost; drag_data: PCefDragData; const event: PCefMouseEvent; allowed_ops: TCefDragOperations); stdcall; + drag_target_drag_over: procedure(self: PCefBrowserHost; const event: PCefMouseEvent; allowed_ops: TCefDragOperations); stdcall; + drag_target_drag_leave: procedure(self: PCefBrowserHost); stdcall; + drag_target_drop: procedure(self: PCefBrowserHost; event: PCefMouseEvent); stdcall; + drag_source_ended_at: procedure(self: PCefBrowserHost; x, y: Integer; op: TCefDragOperation); stdcall; + drag_source_system_drag_ended: procedure(self: PCefBrowserHost); stdcall; + get_visible_navigation_entry: function(self: PCefBrowserHost): PCefNavigationEntry; stdcall; + end; + + // /include/capi/cef_browser_capi.h (cef_browser_t) + TCefBrowser = record + base: TCefBase; + get_host: function(self: PCefBrowser): PCefBrowserHost; stdcall; + can_go_back: function(self: PCefBrowser): Integer; stdcall; + go_back: procedure(self: PCefBrowser); stdcall; + can_go_forward: function(self: PCefBrowser): Integer; stdcall; + go_forward: procedure(self: PCefBrowser); stdcall; + is_loading: function(self: PCefBrowser): Integer; stdcall; + reload: procedure(self: PCefBrowser); stdcall; + reload_ignore_cache: procedure(self: PCefBrowser); stdcall; + stop_load: procedure(self: PCefBrowser); stdcall; + get_identifier : function(self: PCefBrowser): Integer; stdcall; + is_same: function(self, that: PCefBrowser): Integer; stdcall; + is_popup: function(self: PCefBrowser): Integer; stdcall; + has_document: function(self: PCefBrowser): Integer; stdcall; + get_main_frame: function(self: PCefBrowser): PCefFrame; stdcall; + get_focused_frame: function(self: PCefBrowser): PCefFrame; stdcall; + get_frame_byident: function(self: PCefBrowser; identifier: Int64): PCefFrame; stdcall; + get_frame: function(self: PCefBrowser; const name: PCefString): PCefFrame; stdcall; + get_frame_count: function(self: PCefBrowser): NativeUInt; stdcall; + get_frame_identifiers: procedure(self: PCefBrowser; identifiersCount: PNativeUInt; identifiers: PInt64); stdcall; + get_frame_names: procedure(self: PCefBrowser; names: TCefStringList); stdcall; + send_process_message: function(self: PCefBrowser; target_process: TCefProcessId; message: PCefProcessMessage): Integer; stdcall; + end; + + // /include/capi/cef_print_handler_capi.h (cef_print_handler_t) + TCefPrintHandler = record + base: TCefBase; + on_print_start: procedure(self: PCefPrintHandler; browser: PCefBrowser); stdcall; + on_print_settings: procedure(self: PCefPrintHandler; settings: PCefPrintSettings; get_defaults: Integer); stdcall; + on_print_dialog: function(self: PCefPrintHandler; has_selection: Integer; callback: PCefPrintDialogCallback): Integer; stdcall; + on_print_job: function(self: PCefPrintHandler; const document_name, pdf_file_path: PCefString; callback: PCefPrintJobCallback): Integer; stdcall; + on_print_reset: procedure(self: PCefPrintHandler); stdcall; + get_pdf_paper_size: function(self: PCefPrintHandler; device_units_per_inch: Integer): TCefSize; stdcall; + end; + + // /include/capi/cef_resource_bundle_handler_capi.h (cef_resource_bundle_handler_t) + TCefResourceBundleHandler = record + base: TCefBase; + get_localized_string: function(self: PCefResourceBundleHandler; string_id: Integer; string_val: PCefString): Integer; stdcall; + get_data_resource: function(self: PCefResourceBundleHandler; resource_id: Integer; var data: Pointer; var data_size: NativeUInt): Integer; stdcall; + get_data_resource_for_scale: function(self: PCefResourceBundleHandler; resource_id: Integer; scale_factor: TCefScaleFactor; out data: Pointer; data_size: NativeUInt): Integer; stdcall; + end; + + // /include/capi/cef_browser_process_handler_capi.h (cef_browser_process_handler_t) + TCefBrowserProcessHandler = record + base: TCefBase; + on_context_initialized: procedure(self: PCefBrowserProcessHandler); stdcall; + on_before_child_process_launch: procedure(self: PCefBrowserProcessHandler; command_line: PCefCommandLine); stdcall; + on_render_process_thread_created: procedure(self: PCefBrowserProcessHandler; extra_info: PCefListValue); stdcall; + get_print_handler: function(self: PCefBrowserProcessHandler): PCefPrintHandler; stdcall; + on_schedule_message_pump_work: procedure(self: PCefBrowserProcessHandler; delay_ms: Int64); stdcall; + end; + + // /include/capi/cef_app_capi.h (cef_app_t) + TCefApp = record + base: TCefBase; + on_before_command_line_processing: procedure(self: PCefApp; const process_type: PCefString; command_line: PCefCommandLine); stdcall; + on_register_custom_schemes: procedure(self: PCefApp; registrar: PCefSchemeRegistrar); stdcall; + get_resource_bundle_handler: function(self: PCefApp): PCefResourceBundleHandler; stdcall; + get_browser_process_handler: function(self: PCefApp): PCefBrowserProcessHandler; stdcall; + get_render_process_handler: function(self: PCefApp): PCefRenderProcessHandler; stdcall; + end; + +implementation + +end. diff --git a/uCEFUrlRequest.pas b/uCEFUrlRequest.pas new file mode 100644 index 00000000..90698fb1 --- /dev/null +++ b/uCEFUrlRequest.pas @@ -0,0 +1,107 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFUrlRequest; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefUrlRequestRef = class(TCefBaseRef, ICefUrlRequest) + protected + function GetRequest: ICefRequest; + function GetRequestStatus: TCefUrlRequestStatus; + function GetRequestError: Integer; + function GetResponse: ICefResponse; + procedure Cancel; + public + class function UnWrap(data: Pointer): ICefUrlRequest; + class function New(const request: ICefRequest; const client: ICefUrlRequestClient; + const requestContext: ICefRequestContext): ICefUrlRequest; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFRequest, uCEFResponse; + +procedure TCefUrlRequestRef.Cancel; +begin + PCefUrlRequest(FData).cancel(PCefUrlRequest(FData)); +end; + +class function TCefUrlRequestRef.New(const request: ICefRequest; const client: ICefUrlRequestClient; + const requestContext: ICefRequestContext): ICefUrlRequest; +begin + Result := UnWrap(cef_urlrequest_create(CefGetData(request), CefGetData(client), CefGetData(requestContext))); +end; + +function TCefUrlRequestRef.GetRequest: ICefRequest; +begin + Result := TCefRequestRef.UnWrap(PCefUrlRequest(FData).get_request(PCefUrlRequest(FData))); +end; + +function TCefUrlRequestRef.GetRequestError: Integer; +begin + Result := PCefUrlRequest(FData).get_request_error(PCefUrlRequest(FData)); +end; + +function TCefUrlRequestRef.GetRequestStatus: TCefUrlRequestStatus; +begin + Result := PCefUrlRequest(FData).get_request_status(PCefUrlRequest(FData)); +end; + +function TCefUrlRequestRef.GetResponse: ICefResponse; +begin + Result := TCefResponseRef.UnWrap(PCefUrlRequest(FData).get_response(PCefUrlRequest(FData))); +end; + +class function TCefUrlRequestRef.UnWrap(data: Pointer): ICefUrlRequest; +begin + if data <> nil then + Result := Create(data) as ICefUrlRequest else + Result := nil; +end; + +end. diff --git a/uCEFUrlrequestClient.pas b/uCEFUrlrequestClient.pas new file mode 100644 index 00000000..7a2d9dbc --- /dev/null +++ b/uCEFUrlrequestClient.pas @@ -0,0 +1,150 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFUrlrequestClient; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefUrlrequestClientOwn = class(TCefBaseOwn, ICefUrlrequestClient) + protected + procedure OnRequestComplete(const request: ICefUrlRequest); virtual; + procedure OnUploadProgress(const request: ICefUrlRequest; current, total: Int64); virtual; + procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); virtual; + procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); virtual; + function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; + const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; + public + constructor Create; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFUrlRequest, uCEFAuthCallback; + + +procedure cef_url_request_client_on_request_complete(self: PCefUrlRequestClient; request: PCefUrlRequest); stdcall; +begin + with TCefUrlrequestClientOwn(CefGetObject(self)) do + OnRequestComplete(TCefUrlRequestRef.UnWrap(request)); +end; + +procedure cef_url_request_client_on_upload_progress(self: PCefUrlRequestClient; + request: PCefUrlRequest; current, total: Int64); stdcall; +begin + with TCefUrlrequestClientOwn(CefGetObject(self)) do + OnUploadProgress(TCefUrlRequestRef.UnWrap(request), current, total); +end; + +procedure cef_url_request_client_on_download_progress(self: PCefUrlRequestClient; + request: PCefUrlRequest; current, total: Int64); stdcall; +begin + with TCefUrlrequestClientOwn(CefGetObject(self)) do + OnDownloadProgress(TCefUrlRequestRef.UnWrap(request), current, total); +end; + +procedure cef_url_request_client_on_download_data(self: PCefUrlRequestClient; + request: PCefUrlRequest; const data: Pointer; data_length: NativeUInt); stdcall; +begin + with TCefUrlrequestClientOwn(CefGetObject(self)) do + OnDownloadData(TCefUrlRequestRef.UnWrap(request), data, data_length); +end; + +function cef_url_request_client_get_auth_credentials(self: PCefUrlRequestClient; + isProxy: Integer; const host: PCefString; port: Integer; const realm, + scheme: PCefString; callback: PCefAuthCallback): Integer; stdcall; +begin + with TCefUrlrequestClientOwn(CefGetObject(self)) do + Result := Ord(OnGetAuthCredentials(isProxy <> 0, CefString(host), port, + CefString(realm), CefString(scheme), TCefAuthCallbackRef.UnWrap(callback))); +end; + + +constructor TCefUrlrequestClientOwn.Create; +begin + inherited CreateData(SizeOf(TCefUrlrequestClient)); + with PCefUrlrequestClient(FData)^ do + begin + on_request_complete := cef_url_request_client_on_request_complete; + on_upload_progress := cef_url_request_client_on_upload_progress; + on_download_progress := cef_url_request_client_on_download_progress; + on_download_data := cef_url_request_client_on_download_data; + get_auth_credentials := cef_url_request_client_get_auth_credentials; + end; +end; + +procedure TCefUrlrequestClientOwn.OnDownloadData(const request: ICefUrlRequest; + data: Pointer; dataLength: NativeUInt); +begin + +end; + +procedure TCefUrlrequestClientOwn.OnDownloadProgress( + const request: ICefUrlRequest; current, total: Int64); +begin + +end; + +function TCefUrlrequestClientOwn.OnGetAuthCredentials(isProxy: Boolean; + const host: ustring; port: Integer; const realm, scheme: ustring; + const callback: ICefAuthCallback): Boolean; +begin + Result := False; +end; + +procedure TCefUrlrequestClientOwn.OnRequestComplete( + const request: ICefUrlRequest); +begin + +end; + +procedure TCefUrlrequestClientOwn.OnUploadProgress( + const request: ICefUrlRequest; current, total: Int64); +begin + +end; + +end. diff --git a/uCEFV8Exception.pas b/uCEFV8Exception.pas new file mode 100644 index 00000000..de33356c --- /dev/null +++ b/uCEFV8Exception.pas @@ -0,0 +1,119 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFV8Exception; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefV8ExceptionRef = class(TCefBaseRef, ICefV8Exception) + protected + function GetMessage: ustring; + function GetSourceLine: ustring; + function GetScriptResourceName: ustring; + function GetLineNumber: Integer; + function GetStartPosition: Integer; + function GetEndPosition: Integer; + function GetStartColumn: Integer; + function GetEndColumn: Integer; + + public + class function UnWrap(data: Pointer): ICefV8Exception; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +function TCefV8ExceptionRef.GetEndColumn: Integer; +begin + Result := PCefV8Exception(FData)^.get_end_column(FData); +end; + +function TCefV8ExceptionRef.GetEndPosition: Integer; +begin + Result := PCefV8Exception(FData)^.get_end_position(FData); +end; + +function TCefV8ExceptionRef.GetLineNumber: Integer; +begin + Result := PCefV8Exception(FData)^.get_line_number(FData); +end; + +function TCefV8ExceptionRef.GetMessage: ustring; +begin + Result := CefStringFreeAndGet(PCefV8Exception(FData)^.get_message(FData)); +end; + +function TCefV8ExceptionRef.GetScriptResourceName: ustring; +begin + Result := CefStringFreeAndGet(PCefV8Exception(FData)^.get_script_resource_name(FData)); +end; + +function TCefV8ExceptionRef.GetSourceLine: ustring; +begin + Result := CefStringFreeAndGet(PCefV8Exception(FData)^.get_source_line(FData)); +end; + +function TCefV8ExceptionRef.GetStartColumn: Integer; +begin + Result := PCefV8Exception(FData)^.get_start_column(FData); +end; + +function TCefV8ExceptionRef.GetStartPosition: Integer; +begin + Result := PCefV8Exception(FData)^.get_start_position(FData); +end; + +class function TCefV8ExceptionRef.UnWrap(data: Pointer): ICefV8Exception; +begin + if data <> nil then + Result := Create(data) as ICefV8Exception else + Result := nil; +end; + +end. diff --git a/uCEFValue.pas b/uCEFValue.pas new file mode 100644 index 00000000..03c93a69 --- /dev/null +++ b/uCEFValue.pas @@ -0,0 +1,211 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFValue; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefValueRef = class(TCefBaseRef, ICefValue) + protected + function IsValid: Boolean; + function IsOwned: Boolean; + function IsReadOnly: Boolean; + function IsSame(const that: ICefValue): Boolean; + function IsEqual(const that: ICefValue): Boolean; + function Copy: ICefValue; + function GetType: TCefValueType; + function GetBool: Boolean; + function GetInt: Integer; + function GetDouble: Double; + function GetString: ustring; + function GetBinary: ICefBinaryValue; + function GetDictionary: ICefDictionaryValue; + function GetList: ICefListValue; + function SetNull: Boolean; + function SetBool(value: Integer): Boolean; + function SetInt(value: Integer): Boolean; + function SetDouble(value: Double): Boolean; + function SetString(const value: ustring): Boolean; + function SetBinary(const value: ICefBinaryValue): Boolean; + function SetDictionary(const value: ICefDictionaryValue): Boolean; + function SetList(const value: ICefListValue): Boolean; + + public + class function UnWrap(data: Pointer): ICefValue; + class function New: ICefValue; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue, uCEFListValue, uCEFDictionaryValue; + +function TCefValueRef.Copy: ICefValue; +begin + Result := UnWrap(PCefValue(FData).copy(FData)); +end; + +function TCefValueRef.GetBinary: ICefBinaryValue; +begin + Result := TCefBinaryValueRef.UnWrap(PCefValue(FData).get_binary(FData)); +end; + +function TCefValueRef.GetBool: Boolean; +begin + Result := PCefValue(FData).get_bool(FData) <> 0; +end; + +function TCefValueRef.GetDictionary: ICefDictionaryValue; +begin + Result := TCefDictionaryValueRef.UnWrap(PCefValue(FData).get_dictionary(FData)); +end; + +function TCefValueRef.GetDouble: Double; +begin + Result := PCefValue(FData).get_double(FData); +end; + +function TCefValueRef.GetInt: Integer; +begin + Result := PCefValue(FData).get_int(FData); +end; + +function TCefValueRef.GetList: ICefListValue; +begin + Result := TCefListValueRef.UnWrap(PCefValue(FData).get_list(FData)); +end; + +function TCefValueRef.GetString: ustring; +begin + Result := CefStringFreeAndGet(PCefValue(FData).get_string(FData)); +end; + +function TCefValueRef.GetType: TCefValueType; +begin + Result := PCefValue(FData).get_type(FData); +end; + +function TCefValueRef.IsEqual(const that: ICefValue): Boolean; +begin + Result := PCefValue(FData).is_equal(FData, CefGetData(that)) <> 0; +end; + +function TCefValueRef.IsOwned: Boolean; +begin + Result := PCefValue(FData).is_owned(FData) <> 0; +end; + +function TCefValueRef.IsReadOnly: Boolean; +begin + Result := PCefValue(FData).is_read_only(FData) <> 0; +end; + +function TCefValueRef.IsSame(const that: ICefValue): Boolean; +begin + Result := PCefValue(FData).is_same(FData, CefGetData(that)) <> 0; +end; + +function TCefValueRef.IsValid: Boolean; +begin + Result := PCefValue(FData).is_valid(FData) <> 0; +end; + +class function TCefValueRef.New: ICefValue; +begin + Result := UnWrap(cef_value_create()); +end; + +function TCefValueRef.SetBinary(const value: ICefBinaryValue): Boolean; +begin + Result := PCefValue(FData).set_binary(FData, CefGetData(value)) <> 0; +end; + +function TCefValueRef.SetBool(value: Integer): Boolean; +begin + Result := PCefValue(FData).set_bool(FData, value) <> 0; +end; + +function TCefValueRef.SetDictionary(const value: ICefDictionaryValue): Boolean; +begin + Result := PCefValue(FData).set_dictionary(FData, CefGetData(value)) <> 0; +end; + +function TCefValueRef.SetDouble(value: Double): Boolean; +begin + Result := PCefValue(FData).set_double(FData, value) <> 0; +end; + +function TCefValueRef.SetInt(value: Integer): Boolean; +begin + Result := PCefValue(FData).set_int(FData, value) <> 0; +end; + +function TCefValueRef.SetList(const value: ICefListValue): Boolean; +begin + Result := PCefValue(FData).set_list(FData, CefGetData(value)) <> 0; +end; + +function TCefValueRef.SetNull: Boolean; +begin + Result := PCefValue(FData).set_null(FData) <> 0; +end; + +function TCefValueRef.SetString(const value: ustring): Boolean; +var + s: TCefString; +begin + s := CefString(value); + Result := PCefValue(FData).set_string(FData, @s) <> 0; +end; + +class function TCefValueRef.UnWrap(data: Pointer): ICefValue; +begin + if data <> nil then + Result := Create(data) as ICefValue else + Result := nil; +end; + +end. diff --git a/uCEFWaitableEvent.pas b/uCEFWaitableEvent.pas new file mode 100644 index 00000000..914970be --- /dev/null +++ b/uCEFWaitableEvent.pas @@ -0,0 +1,107 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWaitableEvent; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefWaitableEventRef = class(TCefBaseRef, ICefWaitableEvent) + protected + procedure Reset; + procedure Signal; + function IsSignaled : boolean; + procedure Wait; + function TimedWait(max_ms: int64): boolean; + + public + class function UnWrap(data: Pointer): ICefWaitableEvent; + class function New(automatic_reset, initially_signaled : integer): ICefWaitableEvent; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefWaitableEventRef.Reset; +begin + PCefWaitableEvent(FData).reset(FData); +end; + +procedure TCefWaitableEventRef.Signal; +begin + PCefWaitableEvent(FData).signal(FData); +end; + +function TCefWaitableEventRef.IsSignaled : boolean; +begin + Result := (PCefWaitableEvent(FData).is_signaled(FData) <> 0); +end; + +procedure TCefWaitableEventRef.Wait; +begin + PCefWaitableEvent(FData).wait(FData); +end; + +function TCefWaitableEventRef.TimedWait(max_ms: int64): boolean; +begin + Result := (PCefWaitableEvent(FData).timed_wait(FData, max_ms) <> 0); +end; + +class function TCefWaitableEventRef.UnWrap(data: Pointer): ICefWaitableEvent; +begin + if (data <> nil) then + Result := Create(data) as ICefWaitableEvent + else + Result := nil; +end; + +class function TCefWaitableEventRef.New(automatic_reset, initially_signaled : integer): ICefWaitableEvent; +begin + Result := UnWrap(cef_waitable_event_create(automatic_reset, initially_signaled)); +end; + +end. diff --git a/uCEFWebPluginInfo.pas b/uCEFWebPluginInfo.pas new file mode 100644 index 00000000..76c21eb6 --- /dev/null +++ b/uCEFWebPluginInfo.pas @@ -0,0 +1,94 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWebPluginInfo; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefWebPluginInfoRef = class(TCefBaseRef, ICefWebPluginInfo) + protected + function GetName: ustring; + function GetPath: ustring; + function GetVersion: ustring; + function GetDescription: ustring; + + public + class function UnWrap(data: Pointer): ICefWebPluginInfo; + end; + +implementation + +uses + uCEFMiscFunctions; + +function TCefWebPluginInfoRef.GetDescription: ustring; +begin + Result := CefStringFreeAndGet(PCefWebPluginInfo(FData)^.get_description(PCefWebPluginInfo(FData))); +end; + +function TCefWebPluginInfoRef.GetName: ustring; +begin + Result := CefStringFreeAndGet(PCefWebPluginInfo(FData)^.get_name(PCefWebPluginInfo(FData))); +end; + +function TCefWebPluginInfoRef.GetPath: ustring; +begin + Result := CefStringFreeAndGet(PCefWebPluginInfo(FData)^.get_path(PCefWebPluginInfo(FData))); +end; + +function TCefWebPluginInfoRef.GetVersion: ustring; +begin + Result := CefStringFreeAndGet(PCefWebPluginInfo(FData)^.get_version(PCefWebPluginInfo(FData))); +end; + +class function TCefWebPluginInfoRef.UnWrap(data: Pointer): ICefWebPluginInfo; +begin + if data <> nil then + Result := Create(data) as ICefWebPluginInfo else + Result := nil; +end; + +end. diff --git a/uCEFWebPluginInfoVisitor.pas b/uCEFWebPluginInfoVisitor.pas new file mode 100644 index 00000000..81bfb025 --- /dev/null +++ b/uCEFWebPluginInfoVisitor.pas @@ -0,0 +1,109 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWebPluginInfoVisitor; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefWebPluginInfoVisitorOwn = class(TCefBaseOwn, ICefWebPluginInfoVisitor) + protected + function Visit(const info: ICefWebPluginInfo; count, total: Integer): Boolean; virtual; + + public + constructor Create; virtual; + end; + + TCefWebPluginInfoVisitorProc = reference to function(const info: ICefWebPluginInfo; count, total: Integer): Boolean; + + TCefFastWebPluginInfoVisitor = class(TCefWebPluginInfoVisitorOwn) + protected + FProc: TCefWebPluginInfoVisitorProc; + + function Visit(const info: ICefWebPluginInfo; count, total: Integer): Boolean; override; + + public + constructor Create(const proc: TCefWebPluginInfoVisitorProc); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFWebPluginInfo; + +function cef_web_plugin_info_visitor_visit(self: PCefWebPluginInfoVisitor; info: PCefWebPluginInfo; count, total: Integer): Integer; stdcall; +begin + with TCefWebPluginInfoVisitorOwn(CefGetObject(self)) do + Result := Ord(Visit(TCefWebPluginInfoRef.UnWrap(info), count, total)); +end; + +constructor TCefWebPluginInfoVisitorOwn.Create; +begin + inherited CreateData(SizeOf(TCefWebPluginInfoVisitor)); + PCefWebPluginInfoVisitor(FData).visit := cef_web_plugin_info_visitor_visit; +end; + +function TCefWebPluginInfoVisitorOwn.Visit(const info: ICefWebPluginInfo; count, + total: Integer): Boolean; +begin + Result := False; +end; + +// TCefFastWebPluginInfoVisitor + +constructor TCefFastWebPluginInfoVisitor.Create( + const proc: TCefWebPluginInfoVisitorProc); +begin + inherited Create; + FProc := proc; +end; + +function TCefFastWebPluginInfoVisitor.Visit(const info: ICefWebPluginInfo; + count, total: Integer): Boolean; +begin + Result := FProc(info, count, total); +end; + +end. diff --git a/uCEFWebPluginUnstableCallback.pas b/uCEFWebPluginUnstableCallback.pas new file mode 100644 index 00000000..e3238ddb --- /dev/null +++ b/uCEFWebPluginUnstableCallback.pas @@ -0,0 +1,110 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWebPluginUnstableCallback; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefWebPluginIsUnstableProc = reference to procedure(const path: ustring; unstable: Boolean); + + TCefWebPluginUnstableCallbackOwn = class(TCefBaseOwn, ICefWebPluginUnstableCallback) + protected + procedure IsUnstable(const path: ustring; unstable: Boolean); virtual; + + public + constructor Create; virtual; + end; + + TCefFastWebPluginUnstableCallback = class(TCefWebPluginUnstableCallbackOwn) + protected + FCallback: TCefWebPluginIsUnstableProc; + procedure IsUnstable(const path: ustring; unstable: Boolean); override; + + public + constructor Create(const callback: TCefWebPluginIsUnstableProc); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure cef_web_plugin_unstable_callback_is_unstable(self: PCefWebPluginUnstableCallback; + const path: PCefString; + unstable: Integer); stdcall; +begin + with TCefWebPluginUnstableCallbackOwn(CefGetObject(self)) do + IsUnstable(CefString(path), unstable <> 0); +end; + +// TCefWebPluginUnstableCallbackOwn + +constructor TCefWebPluginUnstableCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefWebPluginUnstableCallback)); + + PCefWebPluginUnstableCallback(FData).is_unstable := cef_web_plugin_unstable_callback_is_unstable; +end; + +procedure TCefWebPluginUnstableCallbackOwn.IsUnstable(const path: ustring; unstable: Boolean); +begin + // +end; + +// TCefFastWebPluginUnstableCallback + +constructor TCefFastWebPluginUnstableCallback.Create(const callback: TCefWebPluginIsUnstableProc); +begin + FCallback := callback; +end; + +procedure TCefFastWebPluginUnstableCallback.IsUnstable(const path: ustring; unstable: Boolean); +begin + FCallback(path, unstable); +end; + + +end. diff --git a/uCEFWindowParent.pas b/uCEFWindowParent.pas new file mode 100644 index 00000000..0b4789f5 --- /dev/null +++ b/uCEFWindowParent.pas @@ -0,0 +1,141 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWindowParent; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + WinApi.Windows, WinApi.Messages, System.Classes, Vcl.Controls, + uCEFTypes, uCEFInterfaces; + +type + TCEFWindowParent = class(TWinControl) + protected + function GetChildWindowHandle : THandle; virtual; + + procedure WndProc(var aMessage: TMessage); override; + procedure Resize; override; + + public + procedure UpdateSize; + property ChildWindowHandle : THandle read GetChildWindowHandle; + + published + property Align; + property Anchors; + property Color; + property Constraints; + property TabStop; + property TabOrder; + property Visible; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFClient, uCEFConstants; + +function TCEFWindowParent.GetChildWindowHandle : THandle; +begin + Result := GetWindow(Handle, GW_CHILD); +end; + +procedure TCEFWindowParent.Resize; +begin + inherited Resize; + + UpdateSize; +end; + +procedure TCEFWindowParent.UpdateSize; +var + TempRect : TRect; + hdwp: THandle; + TempHandle : THandle; +begin + TempHandle := ChildWindowHandle; + if (TempHandle = 0) then Exit; + + TempRect := GetClientRect; + hdwp := BeginDeferWindowPos(1); + + try + hdwp := DeferWindowPos(hdwp, TempHandle, 0, + TempRect.left, TempRect.top, TempRect.right - TempRect.left, TempRect.bottom - TempRect.top, + SWP_NOZORDER); + finally + EndDeferWindowPos(hdwp); + end; +end; + +procedure TCEFWindowParent.WndProc(var aMessage: TMessage); +var + TempHandle : THandle; +begin + case aMessage.Msg of + WM_SETFOCUS: + begin + TempHandle := ChildWindowHandle; + if (TempHandle <> 0) then PostMessage(TempHandle, WM_SETFOCUS, aMessage.WParam, 0); + inherited WndProc(aMessage); + end; + + WM_ERASEBKGND: + begin + TempHandle := ChildWindowHandle; + if (csDesigning in ComponentState) or (TempHandle = 0) then inherited WndProc(aMessage); + end; + + CM_WANTSPECIALKEY: + if not(TWMKey(aMessage).CharCode in [VK_LEFT .. VK_DOWN, VK_RETURN, VK_ESCAPE]) then + aMessage.Result := 1 + else + inherited WndProc(aMessage); + + WM_GETDLGCODE : aMessage.Result := DLGC_WANTARROWS or DLGC_WANTCHARS; + + else inherited WndProc(aMessage); + end; +end; + +end. diff --git a/uCEFWriteHandler.pas b/uCEFWriteHandler.pas new file mode 100644 index 00000000..3b617469 --- /dev/null +++ b/uCEFWriteHandler.pas @@ -0,0 +1,139 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWriteHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefWriteHandlerOwn = class(TCefBaseOwn, ICefWriteHandler) + protected + function Write(const ptr: Pointer; size, n: NativeUInt): NativeUInt; virtual; + function Seek(offset: Int64; whence: Integer): Integer; virtual; + function Tell: Int64; virtual; + function Flush: Integer; virtual; + function MayBlock: Boolean; virtual; + public + constructor Create; virtual; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + + +function cef_write_handler_write(self: PCefWriteHandler; const ptr: Pointer; + size, n: NativeUInt): NativeUInt; stdcall; +begin + with TCefWriteHandlerOwn(CefGetObject(self)) do + Result:= Write(ptr, size, n); +end; + +function cef_write_handler_seek(self: PCefWriteHandler; offset: Int64; + whence: Integer): Integer; stdcall; +begin + with TCefWriteHandlerOwn(CefGetObject(self)) do + Result := Seek(offset, whence); +end; + +function cef_write_handler_tell(self: PCefWriteHandler): Int64; stdcall; +begin + with TCefWriteHandlerOwn(CefGetObject(self)) do + Result := Tell(); +end; + +function cef_write_handler_flush(self: PCefWriteHandler): Integer; stdcall; +begin + with TCefWriteHandlerOwn(CefGetObject(self)) do + Result := Flush(); +end; + +function cef_write_handler_may_block(self: PCefWriteHandler): Integer; stdcall; +begin + with TCefWriteHandlerOwn(CefGetObject(self)) do + Result := Ord(MayBlock); +end; + +constructor TCefWriteHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefWriteHandler)); + with PCefWriteHandler(FData)^ do + begin + write := cef_write_handler_write; + seek := cef_write_handler_seek; + tell := cef_write_handler_tell; + flush := cef_write_handler_flush; + may_block := cef_write_handler_may_block; + end; +end; + +function TCefWriteHandlerOwn.Flush: Integer; +begin + Result := 0; +end; + +function TCefWriteHandlerOwn.MayBlock: Boolean; +begin + Result := False; +end; + +function TCefWriteHandlerOwn.Seek(offset: Int64; whence: Integer): Integer; +begin + Result := 0; +end; + +function TCefWriteHandlerOwn.Tell: Int64; +begin + Result := 0; +end; + +function TCefWriteHandlerOwn.Write(const ptr: Pointer; size, + n: NativeUInt): NativeUInt; +begin + Result := 0; +end; + +end. diff --git a/uCEFX509CertPrincipal.pas b/uCEFX509CertPrincipal.pas new file mode 100644 index 00000000..bb0eaf82 --- /dev/null +++ b/uCEFX509CertPrincipal.pas @@ -0,0 +1,215 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFX509CertPrincipal; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefX509CertPrincipalRef = class(TCefBaseRef, ICefX509CertPrincipal) + protected + function GetDisplayName: ustring; + function GetCommonName: ustring; + function GetLocalityName: ustring; + function GetStateOrProvinceName: ustring; + function GetCountryName: ustring; + procedure GetStreetAddresses(addresses: TStrings); + procedure GetOrganizationNames(names: TStrings); + procedure GetOrganizationUnitNames(names: TStrings); + procedure GetDomainComponents(components: TStrings); + + public + class function UnWrap(data: Pointer): ICefX509CertPrincipal; + end; + +implementation + +uses + WinApi.Windows, System.SysUtils, + uCEFMiscFunctions, uCEFLibFunctions; + +function TCefX509CertPrincipalRef.GetDisplayName: ustring; +begin + Result := CefStringFreeAndGet(PCefX509CertPrincipal(FData).get_display_name(FData)); +end; + +function TCefX509CertPrincipalRef.GetCommonName: ustring; +begin + Result := CefStringFreeAndGet(PCefX509CertPrincipal(FData).get_common_name(FData)); +end; + +function TCefX509CertPrincipalRef.GetLocalityName: ustring; +begin + Result := CefStringFreeAndGet(PCefX509CertPrincipal(FData).get_locality_name(FData)); +end; + +function TCefX509CertPrincipalRef.GetStateOrProvinceName: ustring; +begin + Result := CefStringFreeAndGet(PCefX509CertPrincipal(FData).get_state_or_province_name(FData)); +end; + +function TCefX509CertPrincipalRef.GetCountryName: ustring; +begin + Result := CefStringFreeAndGet(PCefX509CertPrincipal(FData).get_country_name(FData)); +end; + +procedure TCefX509CertPrincipalRef.GetStreetAddresses(addresses: TStrings); +var + TempList : TCefStringList; +begin + TempList := nil; + + try + try + if (addresses <> nil) then + begin + TempList := cef_string_list_alloc; + PCefX509CertPrincipal(FData).get_street_addresses(FData, TempList); + CefStringListToStringList(TempList, addresses); + end; + except + on e : exception do + begin + {$IFDEF DEBUG} + OutputDebugString(PWideChar('TCefX509CertPrincipalRef.GetStreetAddresses error: ' + e.Message + chr(0))); + {$ENDIF} + end; + end; + finally + if (TempList <> nil) then cef_string_list_free(TempList); + end; +end; + +procedure TCefX509CertPrincipalRef.GetOrganizationNames(names: TStrings); +var + TempList : TCefStringList; +begin + TempList := nil; + + try + try + if (names <> nil) then + begin + TempList := cef_string_list_alloc; + PCefX509CertPrincipal(FData).get_organization_names(FData, TempList); + CefStringListToStringList(TempList, names); + end; + except + on e : exception do + begin + {$IFDEF DEBUG} + OutputDebugString(PWideChar('TCefX509CertPrincipalRef.GetOrganizationNames error: ' + e.Message + chr(0))); + {$ENDIF} + end; + end; + finally + if (TempList <> nil) then cef_string_list_free(TempList); + end; +end; + +procedure TCefX509CertPrincipalRef.GetOrganizationUnitNames(names: TStrings); +var + TempList : TCefStringList; +begin + TempList := nil; + + try + try + if (names <> nil) then + begin + TempList := cef_string_list_alloc; + PCefX509CertPrincipal(FData).get_organization_unit_names(FData, TempList); + CefStringListToStringList(TempList, names); + end; + except + on e : exception do + begin + {$IFDEF DEBUG} + OutputDebugString(PWideChar('TCefX509CertPrincipalRef.GetOrganizationUnitNames error: ' + e.Message + chr(0))); + {$ENDIF} + end; + end; + finally + if (TempList <> nil) then cef_string_list_free(TempList); + end; +end; + +procedure TCefX509CertPrincipalRef.GetDomainComponents(components: TStrings); +var + TempList : TCefStringList; +begin + TempList := nil; + + try + try + if (components <> nil) then + begin + TempList := cef_string_list_alloc; + PCefX509CertPrincipal(FData).get_domain_components(FData, TempList); + CefStringListToStringList(TempList, components); + end; + except + on e : exception do + begin + {$IFDEF DEBUG} + OutputDebugString(PWideChar('TCefX509CertPrincipalRef.GetDomainComponents error: ' + e.Message + chr(0))); + {$ENDIF} + end; + end; + finally + if (TempList <> nil) then cef_string_list_free(TempList); + end; +end; + +class function TCefX509CertPrincipalRef.UnWrap(data: Pointer): ICefX509CertPrincipal; +begin + if (data <> nil) then + Result := Create(data) as ICefX509CertPrincipal + else + Result := nil; +end; + +end. diff --git a/uCEFX509Certificate.pas b/uCEFX509Certificate.pas new file mode 100644 index 00000000..1efc8436 --- /dev/null +++ b/uCEFX509Certificate.pas @@ -0,0 +1,154 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFX509Certificate; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCEFX509CertificateRef = class(TCefBaseRef, ICefX509Certificate) + protected + function GetSubject: ICefX509CertPrincipal; + function GetIssuer: ICefX509CertPrincipal; + function GetSerialNumber: ICefBinaryValue; + function GetValidStart: TCefTime; + function GetValidExpiry: TCefTime; + function GetDerEncoded: ICefBinaryValue; + function GetPemEncoded: ICefBinaryValue; + function GetIssuerChainSize: NativeUInt; + function GetDEREncodedIssuerChain(chainCount: NativeUInt): IInterfaceList; + function GetPEMEncodedIssuerChain(chainCount: NativeUInt): IInterfaceList; + + public + class function UnWrap(data: Pointer): ICefX509Certificate; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue, uCEFX509CertPrincipal; + +function TCEFX509CertificateRef.GetSubject: ICefX509CertPrincipal; +begin + Result := TCefX509CertPrincipalRef.UnWrap(PCefX509Certificate(FData).get_subject(FData)); +end; + +function TCEFX509CertificateRef.GetIssuer: ICefX509CertPrincipal; +begin + Result := TCefX509CertPrincipalRef.UnWrap(PCefX509Certificate(FData).get_issuer(FData)); +end; + +function TCEFX509CertificateRef.GetSerialNumber: ICefBinaryValue; +begin + Result := TCefBinaryValueRef.UnWrap(PCefX509Certificate(FData).get_serial_number(FData)); +end; + +function TCEFX509CertificateRef.GetValidStart: TCefTime; +begin + Result := PCefX509Certificate(FData).get_valid_start(FData); +end; + +function TCEFX509CertificateRef.GetValidExpiry: TCefTime; +begin + Result := PCefX509Certificate(FData).get_valid_expiry(FData); +end; + +function TCEFX509CertificateRef.GetDerEncoded: ICefBinaryValue; +begin + Result := TCefBinaryValueRef.UnWrap(PCefX509Certificate(FData).get_derencoded(FData)); +end; + +function TCEFX509CertificateRef.GetPemEncoded: ICefBinaryValue; +begin + Result := TCefBinaryValueRef.UnWrap(PCefX509Certificate(FData).get_pemencoded(FData)); +end; + +function TCEFX509CertificateRef.GetIssuerChainSize: NativeUInt; +begin + Result := PCefX509Certificate(FData).get_issuer_chain_size(FData); +end; + +function TCEFX509CertificateRef.GetDEREncodedIssuerChain(chainCount: NativeUInt): IInterfaceList; +var + arr: PPCefBinaryValue; + i: Integer; +begin + Result := TInterfaceList.Create; + GetMem(arr, chainCount * SizeOf(Pointer)); + try + PCefX509Certificate(FData).get_derencoded_issuer_chain(FData, chainCount, arr); + for i := 0 to chainCount - 1 do + Result.Add(TCefBinaryValueRef.UnWrap(PPointerArray(arr)[i])); + finally + FreeMem(arr); + end; +end; + +function TCEFX509CertificateRef.GetPEMEncodedIssuerChain(chainCount: NativeUInt): IInterfaceList; +var + arr: PPCefBinaryValue; + i: Integer; +begin + Result := TInterfaceList.Create; + GetMem(arr, chainCount * SizeOf(Pointer)); + try + PCefX509Certificate(FData).get_pemencoded_issuer_chain(FData, chainCount, arr); + for i := 0 to chainCount - 1 do + Result.Add(TCefBinaryValueRef.UnWrap(PPointerArray(arr)[i])); + finally + FreeMem(arr); + end; +end; + +class function TCEFX509CertificateRef.UnWrap(data: Pointer): ICefX509Certificate; +begin + if (data <> nil) then + Result := Create(data) as ICefX509Certificate + else + Result := nil; +end; + +end. diff --git a/uCEFXmlReader.pas b/uCEFXmlReader.pas new file mode 100644 index 00000000..7b4e68e0 --- /dev/null +++ b/uCEFXmlReader.pas @@ -0,0 +1,272 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFXmlReader; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefXmlReaderRef = class(TCefBaseRef, ICefXmlReader) + protected + function MoveToNextNode: Boolean; + function Close: Boolean; + function HasError: Boolean; + function GetError: ustring; + function GetType: TCefXmlNodeType; + function GetDepth: Integer; + function GetLocalName: ustring; + function GetPrefix: ustring; + function GetQualifiedName: ustring; + function GetNamespaceUri: ustring; + function GetBaseUri: ustring; + function GetXmlLang: ustring; + function IsEmptyElement: Boolean; + function HasValue: Boolean; + function GetValue: ustring; + function HasAttributes: Boolean; + function GetAttributeCount: NativeUInt; + function GetAttributeByIndex(index: Integer): ustring; + function GetAttributeByQName(const qualifiedName: ustring): ustring; + function GetAttributeByLName(const localName, namespaceURI: ustring): ustring; + function GetInnerXml: ustring; + function GetOuterXml: ustring; + function GetLineNumber: Integer; + function MoveToAttributeByIndex(index: Integer): Boolean; + function MoveToAttributeByQName(const qualifiedName: ustring): Boolean; + function MoveToAttributeByLName(const localName, namespaceURI: ustring): Boolean; + function MoveToFirstAttribute: Boolean; + function MoveToNextAttribute: Boolean; + function MoveToCarryingElement: Boolean; + public + class function UnWrap(data: Pointer): ICefXmlReader; + class function New(const stream: ICefStreamReader; + encodingType: TCefXmlEncodingType; const URI: ustring): ICefXmlReader; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +function TCefXmlReaderRef.Close: Boolean; +begin + Result := PCefXmlReader(FData).close(FData) <> 0; +end; + +class function TCefXmlReaderRef.New(const stream: ICefStreamReader; + encodingType: TCefXmlEncodingType; const URI: ustring): ICefXmlReader; +var + u: TCefString; +begin + u := CefString(URI); + Result := UnWrap(cef_xml_reader_create(CefGetData(stream), encodingType, @u)); +end; + +function TCefXmlReaderRef.GetAttributeByIndex(index: Integer): ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_attribute_byindex(FData, index)); +end; + +function TCefXmlReaderRef.GetAttributeByLName(const localName, + namespaceURI: ustring): ustring; +var + l, n: TCefString; +begin + l := CefString(localName); + n := CefString(namespaceURI); + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_attribute_bylname(FData, @l, @n)); +end; + +function TCefXmlReaderRef.GetAttributeByQName( + const qualifiedName: ustring): ustring; +var + q: TCefString; +begin + q := CefString(qualifiedName); + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_attribute_byqname(FData, @q)); +end; + +function TCefXmlReaderRef.GetAttributeCount: NativeUInt; +begin + Result := PCefXmlReader(FData).get_attribute_count(FData); +end; + +function TCefXmlReaderRef.GetBaseUri: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_base_uri(FData)); +end; + +function TCefXmlReaderRef.GetDepth: Integer; +begin + Result := PCefXmlReader(FData).get_depth(FData); +end; + +function TCefXmlReaderRef.GetError: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_error(FData)); +end; + +function TCefXmlReaderRef.GetInnerXml: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_inner_xml(FData)); +end; + +function TCefXmlReaderRef.GetLineNumber: Integer; +begin + Result := PCefXmlReader(FData).get_line_number(FData); +end; + +function TCefXmlReaderRef.GetLocalName: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_local_name(FData)); +end; + +function TCefXmlReaderRef.GetNamespaceUri: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_namespace_uri(FData)); +end; + +function TCefXmlReaderRef.GetOuterXml: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_outer_xml(FData)); +end; + +function TCefXmlReaderRef.GetPrefix: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_prefix(FData)); +end; + +function TCefXmlReaderRef.GetQualifiedName: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_qualified_name(FData)); +end; + +function TCefXmlReaderRef.GetType: TCefXmlNodeType; +begin + Result := PCefXmlReader(FData).get_type(FData); +end; + +function TCefXmlReaderRef.GetValue: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_value(FData)); +end; + +function TCefXmlReaderRef.GetXmlLang: ustring; +begin + Result := CefStringFreeAndGet(PCefXmlReader(FData).get_xml_lang(FData)); +end; + +function TCefXmlReaderRef.HasAttributes: Boolean; +begin + Result := PCefXmlReader(FData).has_attributes(FData) <> 0; +end; + +function TCefXmlReaderRef.HasError: Boolean; +begin + Result := PCefXmlReader(FData).has_error(FData) <> 0; +end; + +function TCefXmlReaderRef.HasValue: Boolean; +begin + Result := PCefXmlReader(FData).has_value(FData) <> 0; +end; + +function TCefXmlReaderRef.IsEmptyElement: Boolean; +begin + Result := PCefXmlReader(FData).is_empty_element(FData) <> 0; +end; + +function TCefXmlReaderRef.MoveToAttributeByIndex(index: Integer): Boolean; +begin + Result := PCefXmlReader(FData).move_to_attribute_byindex(FData, index) <> 0; +end; + +function TCefXmlReaderRef.MoveToAttributeByLName(const localName, + namespaceURI: ustring): Boolean; +var + l, n: TCefString; +begin + l := CefString(localName); + n := CefString(namespaceURI); + Result := PCefXmlReader(FData).move_to_attribute_bylname(FData, @l, @n) <> 0; +end; + +function TCefXmlReaderRef.MoveToAttributeByQName( + const qualifiedName: ustring): Boolean; +var + q: TCefString; +begin + q := CefString(qualifiedName); + Result := PCefXmlReader(FData).move_to_attribute_byqname(FData, @q) <> 0; +end; + +function TCefXmlReaderRef.MoveToCarryingElement: Boolean; +begin + Result := PCefXmlReader(FData).move_to_carrying_element(FData) <> 0; +end; + +function TCefXmlReaderRef.MoveToFirstAttribute: Boolean; +begin + Result := PCefXmlReader(FData).move_to_first_attribute(FData) <> 0; +end; + +function TCefXmlReaderRef.MoveToNextAttribute: Boolean; +begin + Result := PCefXmlReader(FData).move_to_next_attribute(FData) <> 0; +end; + +function TCefXmlReaderRef.MoveToNextNode: Boolean; +begin + Result := PCefXmlReader(FData).move_to_next_node(FData) <> 0; +end; + +class function TCefXmlReaderRef.UnWrap(data: Pointer): ICefXmlReader; +begin + if data <> nil then + Result := Create(data) as ICefXmlReader else + Result := nil; +end; + +end. diff --git a/uCEFZipReader.pas b/uCEFZipReader.pas new file mode 100644 index 00000000..d4ea3815 --- /dev/null +++ b/uCEFZipReader.pas @@ -0,0 +1,155 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFZipReader; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefZipReaderRef = class(TCefBaseRef, ICefZipReader) + protected + function MoveToFirstFile: Boolean; + function MoveToNextFile: Boolean; + function MoveToFile(const fileName: ustring; caseSensitive: Boolean): Boolean; + function Close: Boolean; + function GetFileName: ustring; + function GetFileSize: Int64; + function GetFileLastModified: TCefTime; + function OpenFile(const password: ustring): Boolean; + function CloseFile: Boolean; + function ReadFile(buffer: Pointer; bufferSize: NativeUInt): Integer; + function Tell: Int64; + function Eof: Boolean; + public + class function UnWrap(data: Pointer): ICefZipReader; + class function New(const stream: ICefStreamReader): ICefZipReader; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +function TCefZipReaderRef.Close: Boolean; +begin + Result := PCefZipReader(FData).close(FData) <> 0; +end; + +function TCefZipReaderRef.CloseFile: Boolean; +begin + Result := PCefZipReader(FData).close_file(FData) <> 0; +end; + +class function TCefZipReaderRef.New(const stream: ICefStreamReader): ICefZipReader; +begin + Result := UnWrap(cef_zip_reader_create(CefGetData(stream))); +end; + +function TCefZipReaderRef.Eof: Boolean; +begin + Result := PCefZipReader(FData).eof(FData) <> 0; +end; + +function TCefZipReaderRef.GetFileLastModified: TCefTime; +begin + Result := PCefZipReader(FData).get_file_last_modified(FData); +end; + +function TCefZipReaderRef.GetFileName: ustring; +begin + Result := CefStringFreeAndGet(PCefZipReader(FData).get_file_name(FData)); +end; + +function TCefZipReaderRef.GetFileSize: Int64; +begin + Result := PCefZipReader(FData).get_file_size(FData); +end; + +function TCefZipReaderRef.MoveToFile(const fileName: ustring; + caseSensitive: Boolean): Boolean; +var + f: TCefString; +begin + f := CefString(fileName); + Result := PCefZipReader(FData).move_to_file(FData, @f, Ord(caseSensitive)) <> 0; +end; + +function TCefZipReaderRef.MoveToFirstFile: Boolean; +begin + Result := PCefZipReader(FData).move_to_first_file(FData) <> 0; +end; + +function TCefZipReaderRef.MoveToNextFile: Boolean; +begin + Result := PCefZipReader(FData).move_to_next_file(FData) <> 0; +end; + +function TCefZipReaderRef.OpenFile(const password: ustring): Boolean; +var + p: TCefString; +begin + p := CefString(password); + Result := PCefZipReader(FData).open_file(FData, @p) <> 0; +end; + +function TCefZipReaderRef.ReadFile(buffer: Pointer; + bufferSize: NativeUInt): Integer; +begin + Result := PCefZipReader(FData).read_file(FData, buffer, buffersize); +end; + +function TCefZipReaderRef.Tell: Int64; +begin + Result := PCefZipReader(FData).tell(FData); +end; + +class function TCefZipReaderRef.UnWrap(data: Pointer): ICefZipReader; +begin + if data <> nil then + Result := Create(data) as ICefZipReader else + Result := nil; +end; + +end. diff --git a/uCEFv8Accessor.pas b/uCEFv8Accessor.pas new file mode 100644 index 00000000..d8623f86 --- /dev/null +++ b/uCEFv8Accessor.pas @@ -0,0 +1,135 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFv8Accessor; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes, uCEFv8Types; + +type + TCefV8AccessorOwn = class(TCefBaseOwn, ICefV8Accessor) + protected + function Get(const name: ustring; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; virtual; + function Put(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): Boolean; virtual; + + public + constructor Create; virtual; + end; + + TCefFastV8Accessor = class(TCefV8AccessorOwn) + protected + FGetter: TCefV8AccessorGetterProc; + FSetter: TCefV8AccessorSetterProc; + + function Get(const name: ustring; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; override; + function Put(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): Boolean; override; + + public + constructor Create(const getter: TCefV8AccessorGetterProc; const setter: TCefV8AccessorSetterProc); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFv8Value; + +function cef_v8_accessor_get(self: PCefV8Accessor; const name: PCefString; obj: PCefv8Value; out retval: PCefv8Value; exception: PCefString): Integer; stdcall; +var + ret: ICefv8Value; +begin + Result := Ord(TCefV8AccessorOwn(CefGetObject(self)).Get(CefString(name), TCefv8ValueRef.UnWrap(obj), ret, CefString(exception))); + retval := CefGetData(ret); +end; + +function cef_v8_accessor_put(self: PCefV8Accessor; const name: PCefString; obj: PCefv8Value; value: PCefv8Value; exception: PCefString): Integer; stdcall; +begin + Result := Ord(TCefV8AccessorOwn(CefGetObject(self)).Put(CefString(name), TCefv8ValueRef.UnWrap(obj), TCefv8ValueRef.UnWrap(value), CefString(exception))); +end; + +// TCefV8AccessorOwn + +constructor TCefV8AccessorOwn.Create; +begin + inherited CreateData(SizeOf(TCefV8Accessor)); + PCefV8Accessor(FData)^.get := cef_v8_accessor_get; + PCefV8Accessor(FData)^.put := cef_v8_accessor_put; +end; + +function TCefV8AccessorOwn.Get(const name: ustring; const obj: ICefv8Value; + out value: ICefv8Value; const exception: ustring): Boolean; +begin + Result := False; +end; + +function TCefV8AccessorOwn.Put(const name: ustring; const obj, + value: ICefv8Value; const exception: ustring): Boolean; +begin + Result := False; +end; + +// TCefFastV8Accessor + +constructor TCefFastV8Accessor.Create(const getter: TCefV8AccessorGetterProc; const setter: TCefV8AccessorSetterProc); +begin + FGetter := getter; + FSetter := setter; +end; + +function TCefFastV8Accessor.Get(const name: ustring; const obj: ICefv8Value; + out value: ICefv8Value; const exception: ustring): Boolean; +begin + if Assigned(FGetter) then + Result := FGetter(name, obj, value, exception) else + Result := False; +end; + +function TCefFastV8Accessor.Put(const name: ustring; const obj, + value: ICefv8Value; const exception: ustring): Boolean; +begin + if Assigned(FSetter) then + Result := FSetter(name, obj, value, exception) else + Result := False; +end; + +end. diff --git a/uCEFv8Context.pas b/uCEFv8Context.pas new file mode 100644 index 00000000..4040797d --- /dev/null +++ b/uCEFv8Context.pas @@ -0,0 +1,153 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFv8Context; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefv8ContextRef = class(TCefBaseRef, ICefv8Context) + protected + function GetTaskRunner: ICefTaskRunner; + function IsValid: Boolean; + function GetBrowser: ICefBrowser; + function GetFrame: ICefFrame; + function GetGlobal: ICefv8Value; + function Enter: Boolean; + function Exit: Boolean; + function IsSame(const that: ICefv8Context): Boolean; + function Eval(const code: ustring; const script_url: ustring; start_line: integer; var retval: ICefv8Value; var exception: ICefV8Exception): Boolean; + + public + class function UnWrap(data: Pointer): ICefv8Context; + class function Current: ICefv8Context; + class function Entered: ICefv8Context; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFv8Value, uCEFTaskRunner, uCEFv8Exception; + +class function TCefv8ContextRef.Current: ICefv8Context; +begin + Result := UnWrap(cef_v8context_get_current_context) +end; + +function TCefv8ContextRef.Enter: Boolean; +begin + Result := PCefv8Context(FData)^.enter(PCefv8Context(FData)) <> 0; +end; + +class function TCefv8ContextRef.Entered: ICefv8Context; +begin + Result := UnWrap(cef_v8context_get_entered_context) +end; + +function TCefv8ContextRef.Exit: Boolean; +begin + Result := PCefv8Context(FData)^.exit(PCefv8Context(FData)) <> 0; +end; + +function TCefv8ContextRef.GetBrowser: ICefBrowser; +begin + Result := TCefBrowserRef.UnWrap(PCefv8Context(FData)^.get_browser(PCefv8Context(FData))); +end; + +function TCefv8ContextRef.GetFrame: ICefFrame; +begin + Result := TCefFrameRef.UnWrap(PCefv8Context(FData)^.get_frame(PCefv8Context(FData))) +end; + +function TCefv8ContextRef.GetGlobal: ICefv8Value; +begin + Result := TCefv8ValueRef.UnWrap(PCefv8Context(FData)^.get_global(PCefv8Context(FData))); +end; + +function TCefv8ContextRef.GetTaskRunner: ICefTaskRunner; +begin + Result := TCefTaskRunnerRef.UnWrap(PCefv8Context(FData)^.get_task_runner(FData)); +end; + +function TCefv8ContextRef.IsSame(const that: ICefv8Context): Boolean; +begin + Result := PCefv8Context(FData)^.is_same(PCefv8Context(FData), CefGetData(that)) <> 0; +end; + +function TCefv8ContextRef.IsValid: Boolean; +begin + Result := PCefv8Context(FData)^.is_valid(FData) <> 0; +end; + +function TCefv8ContextRef.Eval(const code: ustring; + const script_url: ustring; + start_line: integer; + var retval: ICefv8Value; + var exception: ICefV8Exception): Boolean; +var + TempCode, TempScriptURL : TCefString; + TempValue : PCefv8Value; + TempException : PCefV8Exception; +begin + TempCode := CefString(code); + TempScriptURL := CefString(script_url); + TempValue := nil; + TempException := nil; + + Result := (PCefv8Context(FData)^.eval(PCefv8Context(FData), @TempCode, @TempScriptURL, start_line, TempValue, TempException) <> 0); + + retval := TCefv8ValueRef.UnWrap(TempValue); + exception := TCefV8ExceptionRef.UnWrap(TempException); +end; + +class function TCefv8ContextRef.UnWrap(data: Pointer): ICefv8Context; +begin + if (data <> nil) then + Result := Create(data) as ICefv8Context + else + Result := nil; +end; + +end. diff --git a/uCEFv8Handler.pas b/uCEFv8Handler.pas new file mode 100644 index 00000000..e069b49e --- /dev/null +++ b/uCEFv8Handler.pas @@ -0,0 +1,896 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFv8Handler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Rtti, System.TypInfo, System.Variants, System.SysUtils, + System.Classes, System.Math, System.SyncObjs, WinApi.Windows, + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefv8HandlerRef = class(TCefBaseRef, ICefv8Handler) + protected + function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; + + public + class function UnWrap(data: Pointer): ICefv8Handler; + end; + + TCefv8HandlerOwn = class(TCefBaseOwn, ICefv8Handler) + protected + function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; virtual; + + public + constructor Create; virtual; + end; + + TCefRTTIExtension = class(TCefv8HandlerOwn) + protected + FValue: TValue; + FCtx: TRttiContext; + FSyncMainThread: Boolean; + + function GetValue(pi: PTypeInfo; const v: ICefv8Value; var ret: TValue): Boolean; + function SetValue(const v: TValue; var ret: ICefv8Value): Boolean; + {$IFDEF CPUX64} + class function StrToPtr(const str: ustring): Pointer; + class function PtrToStr(p: Pointer): ustring; + {$ENDIF} + function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; override; + + public + constructor Create(const value: TValue; SyncMainThread: Boolean = False); reintroduce; + destructor Destroy; override; + class procedure Register(const name: string; const value: TValue; SyncMainThread: Boolean = False); + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFv8Value; + +function cef_v8_handler_execute(self: PCefv8Handler; + const name: PCefString; obj: PCefv8Value; argumentsCount: NativeUInt; + const arguments: PPCefV8Value; var retval: PCefV8Value; + var exception: TCefString): Integer; stdcall; +var + args: TCefv8ValueArray; + i: NativeInt; + ret: ICefv8Value; + exc: ustring; +begin + SetLength(args, argumentsCount); + for i := 0 to argumentsCount - 1 do + args[i] := TCefv8ValueRef.UnWrap(arguments[i]); + + Result := -Ord(TCefv8HandlerOwn(CefGetObject(self)).Execute( + CefString(name), TCefv8ValueRef.UnWrap(obj), args, ret, exc)); + retval := CefGetData(ret); + ret := nil; + exception := CefString(exc); +end; + +function TCefv8HandlerRef.Execute(const name: ustring; const obj: ICefv8Value; + const arguments: TCefv8ValueArray; var retval: ICefv8Value; + var exception: ustring): Boolean; +var + args: array of PCefV8Value; + i: Integer; + ret: PCefV8Value; + exc: TCefString; + n: TCefString; +begin + SetLength(args, Length(arguments)); + for i := 0 to Length(arguments) - 1 do + args[i] := CefGetData(arguments[i]); + ret := nil; + FillChar(exc, SizeOf(exc), 0); + n := CefString(name); + Result := PCefv8Handler(FData)^.execute(PCefv8Handler(FData), @n, + CefGetData(obj), Length(arguments), @args, ret, exc) <> 0; + retval := TCefv8ValueRef.UnWrap(ret); + exception := CefStringClearAndGet(exc); +end; + +class function TCefv8HandlerRef.UnWrap(data: Pointer): ICefv8Handler; +begin + if data <> nil then + Result := Create(data) as ICefv8Handler else + Result := nil; +end; + +// TCefv8HandlerOwn + +constructor TCefv8HandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefv8Handler)); + + with PCefv8Handler(FData)^ do execute := cef_v8_handler_execute; +end; + +function TCefv8HandlerOwn.Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; +begin + Result := False; +end; + +// TCefRTTIExtension + +constructor TCefRTTIExtension.Create(const value: TValue; SyncMainThread: Boolean); +begin + inherited Create; + FCtx := TRttiContext.Create; + FSyncMainThread := SyncMainThread; + FValue := value; +end; + +destructor TCefRTTIExtension.Destroy; +begin + FCtx.Free; + inherited; +end; + +function TCefRTTIExtension.GetValue(pi: PTypeInfo; const v: ICefv8Value; var ret: TValue): Boolean; + function ProcessInt: Boolean; + var + sv: record + case byte of + 0: (ub: Byte); + 1: (sb: ShortInt); + 2: (uw: Word); + 3: (sw: SmallInt); + 4: (si: Integer); + 5: (ui: Cardinal); + end; + pd: PTypeData; + begin + pd := GetTypeData(pi); + if (v.IsInt or v.IsBool) and (v.GetIntValue >= pd.MinValue) and (v.GetIntValue <= pd.MaxValue) then + begin + case pd.OrdType of + otSByte: sv.sb := v.GetIntValue; + otUByte: sv.ub := v.GetIntValue; + otSWord: sv.sw := v.GetIntValue; + otUWord: sv.uw := v.GetIntValue; + otSLong: sv.si := v.GetIntValue; + otULong: sv.ui := v.GetIntValue; + end; + TValue.Make(@sv, pi, ret); + end else + Exit(False); + Result := True; + end; + + function ProcessInt64: Boolean; + var + i: Int64; + begin + i := StrToInt64(v.GetStringValue); // hack + TValue.Make(@i, pi, ret); + Result := True; + end; + + function ProcessUString: Boolean; + var + vus: string; + begin + if v.IsString then + begin + vus := v.GetStringValue; + TValue.Make(@vus, pi, ret); + end else + Exit(False); + Result := True; + end; + + function ProcessLString: Boolean; + var + vas: AnsiString; + begin + if v.IsString then + begin + vas := AnsiString(v.GetStringValue); + TValue.Make(@vas, pi, ret); + end else + Exit(False); + Result := True; + end; + + function ProcessWString: Boolean; + var + vws: WideString; + begin + if v.IsString then + begin + vws := v.GetStringValue; + TValue.Make(@vws, pi, ret); + end else + Exit(False); + Result := True; + end; + + function ProcessFloat: Boolean; + var + sv: record + case byte of + 0: (fs: Single); + 1: (fd: Double); + 2: (fe: Extended); + 3: (fc: Comp); + 4: (fcu: Currency); + end; + begin + if v.IsDouble or v.IsInt then + begin + case GetTypeData(pi).FloatType of + ftSingle: sv.fs := v.GetDoubleValue; + ftDouble: sv.fd := v.GetDoubleValue; + ftExtended: sv.fe := v.GetDoubleValue; + ftComp: sv.fc := v.GetDoubleValue; + ftCurr: sv.fcu := v.GetDoubleValue; + end; + TValue.Make(@sv, pi, ret); + end else + if v.IsDate then + begin + sv.fd := v.GetDateValue; + TValue.Make(@sv, pi, ret); + end else + Exit(False); + Result := True; + end; + + function ProcessSet: Boolean; + var + sv: record + case byte of + 0: (ub: Byte); + 1: (sb: ShortInt); + 2: (uw: Word); + 3: (sw: SmallInt); + 4: (si: Integer); + 5: (ui: Cardinal); + end; + begin + if v.IsInt then + begin + case GetTypeData(pi).OrdType of + otSByte: sv.sb := v.GetIntValue; + otUByte: sv.ub := v.GetIntValue; + otSWord: sv.sw := v.GetIntValue; + otUWord: sv.uw := v.GetIntValue; + otSLong: sv.si := v.GetIntValue; + otULong: sv.ui := v.GetIntValue; + end; + TValue.Make(@sv, pi, ret); + end else + Exit(False); + Result := True; + end; + + function ProcessVariant: Boolean; + var + vr: Variant; + i: Integer; + vl: TValue; + begin + VarClear(vr); + if v.IsString then vr := v.GetStringValue else + if v.IsBool then vr := v.GetBoolValue else + if v.IsInt then vr := v.GetIntValue else + if v.IsDouble then vr := v.GetDoubleValue else + if v.IsUndefined then TVarData(vr).VType := varEmpty else + if v.IsNull then TVarData(vr).VType := varNull else + if v.IsArray then + begin + vr := VarArrayCreate([0, v.GetArrayLength], varVariant); + for i := 0 to v.GetArrayLength - 1 do + begin + if not GetValue(pi, v.GetValueByIndex(i), vl) then Exit(False); + VarArrayPut(vr, vl.AsVariant, i); + end; + end else + Exit(False); + TValue.Make(@vr, pi, ret); + Result := True; + end; + + function ProcessObject: Boolean; + var + ud: ICefv8Value; + i: Pointer; + td: PTypeData; + rt: TRttiType; + begin + if v.IsObject then + begin + ud := v.GetUserData; + if (ud = nil) then Exit(False); +{$IFDEF CPUX64} + rt := StrToPtr(ud.GetValueByIndex(0).GetStringValue); +{$ELSE} + rt := TRttiType(ud.GetValueByIndex(0).GetIntValue); +{$ENDIF} + td := GetTypeData(rt.Handle); + + if (rt.TypeKind = tkClass) and td.ClassType.InheritsFrom(GetTypeData(pi).ClassType) then + begin +{$IFDEF CPUX64} + i := StrToPtr(ud.GetValueByIndex(1).GetStringValue); +{$ELSE} + i := Pointer(ud.GetValueByIndex(1).GetIntValue); +{$ENDIF} + + TValue.Make(@i, pi, ret); + end else + Exit(False); + end else + Exit(False); + Result := True; + end; + + function ProcessClass: Boolean; + var + ud: ICefv8Value; + i: Pointer; + rt: TRttiType; + begin + if v.IsObject then + begin + ud := v.GetUserData; + if (ud = nil) then Exit(False); +{$IFDEF CPUX64} + rt := StrToPtr(ud.GetValueByIndex(0).GetStringValue); +{$ELSE} + rt := TRttiType(ud.GetValueByIndex(0).GetIntValue); +{$ENDIF} + + if (rt.TypeKind = tkClassRef) then + begin +{$IFDEF CPUX64} + i := StrToPtr(ud.GetValueByIndex(1).GetStringValue); +{$ELSE} + i := Pointer(ud.GetValueByIndex(1).GetIntValue); +{$ENDIF} + TValue.Make(@i, pi, ret); + end else + Exit(False); + end else + Exit(False); + Result := True; + end; + + function ProcessRecord: Boolean; + var + r: TRttiField; + f: TValue; + rec: Pointer; + begin + if v.IsObject then + begin + TValue.Make(nil, pi, ret); + rec := TValueData(ret).FValueData.GetReferenceToRawData; + for r in FCtx.GetType(pi).GetFields do + begin + if not GetValue(r.FieldType.Handle, v.GetValueByKey(r.Name), f) then + Exit(False); + r.SetValue(rec, f); + end; + Result := True; + end else + Result := False; + end; + + function ProcessInterface: Boolean; + begin + if pi = TypeInfo(ICefV8Value) then + begin + TValue.Make(@v, pi, ret); + Result := True; + end else + Result := False; // todo + end; +begin + case pi.Kind of + tkInteger, tkEnumeration: Result := ProcessInt; + tkInt64: Result := ProcessInt64; + tkUString: Result := ProcessUString; + tkLString: Result := ProcessLString; + tkWString: Result := ProcessWString; + tkFloat: Result := ProcessFloat; + tkSet: Result := ProcessSet; + tkVariant: Result := ProcessVariant; + tkClass: Result := ProcessObject; + tkClassRef: Result := ProcessClass; + tkRecord: Result := ProcessRecord; + tkInterface: Result := ProcessInterface; + else + Result := False; + end; +end; + +function TCefRTTIExtension.SetValue(const v: TValue; var ret: ICefv8Value): Boolean; + + function ProcessRecord: Boolean; + var + rf: TRttiField; + vl: TValue; + ud, v8: ICefv8Value; + rec: Pointer; + rt: TRttiType; + begin + ud := TCefv8ValueRef.NewArray(1); + rt := FCtx.GetType(v.TypeInfo); +{$IFDEF CPUX64} + ud.SetValueByIndex(0, TCefv8ValueRef.NewString(PtrToStr(rt))); +{$ELSE} + ud.SetValueByIndex(0, TCefv8ValueRef.NewInt(Integer(rt))); +{$ENDIF} + ret := TCefv8ValueRef.NewObject(nil, nil); + ret.SetUserData(ud); + + rec := TValueData(v).FValueData.GetReferenceToRawData; + + if FSyncMainThread then + begin + v8 := ret; + TThread.Synchronize(nil, procedure + var + rf: TRttiField; + o: ICefv8Value; + begin + for rf in rt.GetFields do + begin + vl := rf.GetValue(rec); + SetValue(vl, o); + v8.SetValueByKey(rf.Name, o, []); + end; + end) + end else + for rf in FCtx.GetType(v.TypeInfo).GetFields do + begin + vl := rf.GetValue(rec); + if not SetValue(vl, v8) then + Exit(False); + ret.SetValueByKey(rf.Name, v8, []); + end; + Result := True; + end; + + function ProcessObject: Boolean; + var + m: TRttiMethod; + p: TRttiProperty; + fl: TRttiField; + f: ICefv8Value; + _r, _g, _s, ud: ICefv8Value; + _a: TCefv8ValueArray; + rt: TRttiType; + begin + rt := FCtx.GetType(v.TypeInfo); + + ud := TCefv8ValueRef.NewArray(2); +{$IFDEF CPUX64} + ud.SetValueByIndex(0, TCefv8ValueRef.NewString(PtrToStr(rt))); + ud.SetValueByIndex(1, TCefv8ValueRef.NewString(PtrToStr(v.AsObject))); +{$ELSE} + ud.SetValueByIndex(0, TCefv8ValueRef.NewInt(Integer(rt))); + ud.SetValueByIndex(1, TCefv8ValueRef.NewInt(Integer(v.AsObject))); +{$ENDIF} + ret := TCefv8ValueRef.NewObject(nil, nil); // todo + ret.SetUserData(ud); + + for m in rt.GetMethods do + if m.Visibility > mvProtected then + begin + f := TCefv8ValueRef.NewFunction(m.Name, Self); + ret.SetValueByKey(m.Name, f, []); + end; + + for p in rt.GetProperties do + if (p.Visibility > mvProtected) then + begin + if _g = nil then _g := ret.GetValueByKey('__defineGetter__'); + if _s = nil then _s := ret.GetValueByKey('__defineSetter__'); + SetLength(_a, 2); + _a[0] := TCefv8ValueRef.NewString(p.Name); + if p.IsReadable then + begin + _a[1] := TCefv8ValueRef.NewFunction('$pg' + p.Name, Self); + _r := _g.ExecuteFunction(ret, _a); + end; + if p.IsWritable then + begin + _a[1] := TCefv8ValueRef.NewFunction('$ps' + p.Name, Self); + _r := _s.ExecuteFunction(ret, _a); + end; + end; + + for fl in rt.GetFields do + if (fl.Visibility > mvProtected) then + begin + if _g = nil then _g := ret.GetValueByKey('__defineGetter__'); + if _s = nil then _s := ret.GetValueByKey('__defineSetter__'); + + SetLength(_a, 2); + _a[0] := TCefv8ValueRef.NewString(fl.Name); + _a[1] := TCefv8ValueRef.NewFunction('$vg' + fl.Name, Self); + _r := _g.ExecuteFunction(ret, _a); + _a[1] := TCefv8ValueRef.NewFunction('$vs' + fl.Name, Self); + _r := _s.ExecuteFunction(ret, _a); + end; + + Result := True; + end; + + function ProcessClass: Boolean; + var + m: TRttiMethod; + f, ud: ICefv8Value; + c: TClass; + rt: TRttiType; + begin + c := v.AsClass; + rt := FCtx.GetType(c); + + ud := TCefv8ValueRef.NewArray(2); +{$IFDEF CPUX64} + ud.SetValueByIndex(0, TCefv8ValueRef.NewString(PtrToStr(rt))); + ud.SetValueByIndex(1, TCefv8ValueRef.NewString(PtrToStr(c))); +{$ELSE} + ud.SetValueByIndex(0, TCefv8ValueRef.NewInt(Integer(rt))); + ud.SetValueByIndex(1, TCefv8ValueRef.NewInt(Integer(c))); +{$ENDIF} + ret := TCefv8ValueRef.NewObject(nil, nil); // todo + ret.SetUserData(ud); + + if c <> nil then + begin + for m in rt.GetMethods do + if (m.Visibility > mvProtected) and (m.MethodKind in [mkClassProcedure, mkClassFunction]) then + begin + f := TCefv8ValueRef.NewFunction(m.Name, Self); + ret.SetValueByKey(m.Name, f, []); + end; + end; + + Result := True; + end; + + function ProcessVariant: Boolean; + var + vr: Variant; + begin + vr := v.AsVariant; + case TVarData(vr).VType of + varSmallint, varInteger, varShortInt: + ret := TCefv8ValueRef.NewInt(vr); + varByte, varWord, varLongWord: + ret := TCefv8ValueRef.NewUInt(vr); + varUString, varOleStr, varString: + ret := TCefv8ValueRef.NewString(vr); + varSingle, varDouble, varCurrency, varUInt64, varInt64: + ret := TCefv8ValueRef.NewDouble(vr); + varBoolean: + ret := TCefv8ValueRef.NewBool(vr); + varNull: + ret := TCefv8ValueRef.NewNull; + varEmpty: + ret := TCefv8ValueRef.NewUndefined; + else + ret := nil; + Exit(False) + end; + Result := True; + end; + + function ProcessInterface: Boolean; + var + m: TRttiMethod; + f: ICefv8Value; + ud: ICefv8Value; + rt: TRttiType; + begin + + if TypeInfo(ICefV8Value) = v.TypeInfo then + begin + ret := ICefV8Value(v.AsInterface); + Result := True; + end else + begin + rt := FCtx.GetType(v.TypeInfo); + + + ud := TCefv8ValueRef.NewArray(2); + {$IFDEF CPUX64} + ud.SetValueByIndex(0, TCefv8ValueRef.NewString(PtrToStr(rt))); + ud.SetValueByIndex(1, TCefv8ValueRef.NewString(PtrToStr(Pointer(v.AsInterface)))); + {$ELSE} + ud.SetValueByIndex(0, TCefv8ValueRef.NewInt(Integer(rt))); + ud.SetValueByIndex(1, TCefv8ValueRef.NewInt(Integer(v.AsInterface))); + {$ENDIF} + ret := TCefv8ValueRef.NewObject(nil, nil); + ret.SetUserData(ud); + + for m in rt.GetMethods do + if m.Visibility > mvProtected then + begin + f := TCefv8ValueRef.NewFunction(m.Name, Self); + ret.SetValueByKey(m.Name, f, []); + end; + + Result := True; + end; + end; + + function ProcessFloat: Boolean; + begin + if v.TypeInfo = TypeInfo(TDateTime) then + ret := TCefv8ValueRef.NewDate(TValueData(v).FAsDouble) else + ret := TCefv8ValueRef.NewDouble(v.AsExtended); + Result := True; + end; + +begin + case v.TypeInfo.Kind of + tkUString, tkLString, tkWString, tkChar, tkWChar: + ret := TCefv8ValueRef.NewString(v.AsString); + tkInteger: ret := TCefv8ValueRef.NewInt(v.AsInteger); + tkEnumeration: + if v.TypeInfo = TypeInfo(Boolean) then + ret := TCefv8ValueRef.NewBool(v.AsBoolean) else + ret := TCefv8ValueRef.NewInt(TValueData(v).FAsSLong); + tkFloat: if not ProcessFloat then Exit(False); + tkInt64: ret := TCefv8ValueRef.NewDouble(v.AsInt64); + tkClass: if not ProcessObject then Exit(False); + tkClassRef: if not ProcessClass then Exit(False); + tkRecord: if not ProcessRecord then Exit(False); + tkVariant: if not ProcessVariant then Exit(False); + tkInterface: if not ProcessInterface then Exit(False); + else + Exit(False) + end; + Result := True; +end; + +class procedure TCefRTTIExtension.Register(const name: string; const value: TValue; SyncMainThread: Boolean); +begin + CefRegisterExtension(name, + format('__defineSetter__(''%s'', function(v){native function $s();$s(v)});__defineGetter__(''%0:s'', function(){native function $g();return $g()});', [name]), + TCefRTTIExtension.Create(value, SyncMainThread) as ICefv8Handler); +end; + +{$IFDEF CPUX64} +class function TCefRTTIExtension.StrToPtr(const str: ustring): Pointer; +begin + HexToBin(PWideChar(str), @Result, SizeOf(Result)); +end; + +class function TCefRTTIExtension.PtrToStr(p: Pointer): ustring; +begin + SetLength(Result, SizeOf(p)*2); + BinToHex(@p, PWideChar(Result), SizeOf(p)); +end; +{$ENDIF} + +function TCefRTTIExtension.Execute(const name: ustring; const obj: ICefv8Value; + const arguments: TCefv8ValueArray; var retval: ICefv8Value; + var exception: ustring): Boolean; +var + p: PChar; + ud: ICefv8Value; + rt: TRttiType; + val: TObject; + cls: TClass; + m: TRttiMethod; + pr: TRttiProperty; + vl: TRttiField; + args: array of TValue; + prm: TArray; + i: Integer; + ret: TValue; +begin + Result := True; + p := PChar(name); + m := nil; + if obj <> nil then + begin + ud := obj.GetUserData; + if ud <> nil then + begin +{$IFDEF CPUX64} + rt := StrToPtr(ud.GetValueByIndex(0).GetStringValue); +{$ELSE} + rt := TRttiType(ud.GetValueByIndex(0).GetIntValue); +{$ENDIF} + case rt.TypeKind of + tkClass: + begin +{$IFDEF CPUX64} + val := StrToPtr(ud.GetValueByIndex(1).GetStringValue); +{$ELSE} + val := TObject(ud.GetValueByIndex(1).GetIntValue); +{$ENDIF} + cls := GetTypeData(rt.Handle).ClassType; + + if p^ = '$' then + begin + inc(p); + case p^ of + 'p': + begin + inc(p); + case p^ of + 'g': + begin + inc(p); + pr := rt.GetProperty(p); + if FSyncMainThread then + begin + TThread.Synchronize(nil, procedure begin + ret := pr.GetValue(val); + end); + Exit(SetValue(ret, retval)); + end else + Exit(SetValue(pr.GetValue(val), retval)); + end; + 's': + begin + inc(p); + pr := rt.GetProperty(p); + if GetValue(pr.PropertyType.Handle, arguments[0], ret) then + begin + if FSyncMainThread then + TThread.Synchronize(nil, procedure begin + pr.SetValue(val, ret) end) else + pr.SetValue(val, ret); + Exit(True); + end else + Exit(False); + end; + end; + end; + 'v': + begin + inc(p); + case p^ of + 'g': + begin + inc(p); + vl := rt.GetField(p); + if FSyncMainThread then + begin + TThread.Synchronize(nil, procedure begin + ret := vl.GetValue(val); + end); + Exit(SetValue(ret, retval)); + end else + Exit(SetValue(vl.GetValue(val), retval)); + end; + 's': + begin + inc(p); + vl := rt.GetField(p); + if GetValue(vl.FieldType.Handle, arguments[0], ret) then + begin + if FSyncMainThread then + TThread.Synchronize(nil, procedure begin + vl.SetValue(val, ret) end) else + vl.SetValue(val, ret); + Exit(True); + end else + Exit(False); + end; + end; + end; + end; + end else + m := rt.GetMethod(name); + end; + tkClassRef: + begin + val := nil; +{$IFDEF CPUX64} + cls := StrToPtr(ud.GetValueByIndex(1).GetStringValue); +{$ELSE} + cls := TClass(ud.GetValueByIndex(1).GetIntValue); +{$ENDIF} + m := FCtx.GetType(cls).GetMethod(name); + end; + else + m := nil; + cls := nil; + val := nil; + end; + + prm := m.GetParameters; + i := Length(prm); + if i = Length(arguments) then + begin + SetLength(args, i); + for i := 0 to i - 1 do + if not GetValue(prm[i].ParamType.Handle, arguments[i], args[i]) then + Exit(False); + + case m.MethodKind of + mkClassProcedure, mkClassFunction: + if FSyncMainThread then + TThread.Synchronize(nil, procedure begin + ret := m.Invoke(cls, args) end) else + ret := m.Invoke(cls, args); + mkProcedure, mkFunction: + if (val <> nil) then + begin + if FSyncMainThread then + TThread.Synchronize(nil, procedure begin + ret := m.Invoke(val, args) end) else + ret := m.Invoke(val, args); + end else + Exit(False) + else + Exit(False); + end; + + if m.MethodKind in [mkClassFunction, mkFunction] then + if not SetValue(ret, retval) then + Exit(False); + end else + Exit(False); + end else + if p^ = '$' then + begin + inc(p); + case p^ of + 'g': SetValue(FValue, retval); + 's': GetValue(FValue.TypeInfo, arguments[0], FValue); + else + Exit(False); + end; + end else + Exit(False); + end else + Exit(False); +end; + +end. diff --git a/uCEFv8Interceptor.pas b/uCEFv8Interceptor.pas new file mode 100644 index 00000000..e98d208d --- /dev/null +++ b/uCEFv8Interceptor.pas @@ -0,0 +1,192 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFv8Interceptor; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes, uCEFv8Types; + +type + TCefV8InterceptorOwn = class(TCefBaseOwn, ICefV8Interceptor) + protected + function GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; virtual; + function GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; virtual; + function SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; virtual; + function SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; virtual; + + public + constructor Create; virtual; + end; + + TCefFastV8Interceptor = class(TCefV8InterceptorOwn) + protected + FGetterByName : TCefV8InterceptorGetterByNameProc; + FSetterByName : TCefV8InterceptorSetterByNameProc; + FGetterByIndex : TCefV8InterceptorGetterByIndexProc; + FSetterByIndex : TCefV8InterceptorSetterByIndexProc; + + function GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; override; + function GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; override; + function SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; override; + function SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; override; + + public + constructor Create(const getterbyname : TCefV8InterceptorGetterByNameProc; + const setterbyname : TCefV8InterceptorSetterByNameProc; + const getterbyindex : TCefV8InterceptorGetterByIndexProc; + const setterbyindex : TCefV8InterceptorSetterByIndexProc); reintroduce; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFv8Value; + +function cef_v8_interceptor_get_byname(self: PCefV8Interceptor; const name: PCefString; const obj: PCefV8Value; out retval: PCefv8Value; exception: PCefString): Integer; stdcall; +var + ret: ICefv8Value; +begin + Result := Ord(TCefV8InterceptorOwn(CefGetObject(self)).GetByName(CefString(name), TCefv8ValueRef.UnWrap(obj), ret, CefString(exception))); + retval := CefGetData(ret); +end; + +function cef_v8_interceptor_get_byindex(self: PCefV8Interceptor; index: integer; const obj: PCefV8Value; out retval: PCefv8Value; exception: PCefString): integer; stdcall; +var + ret: ICefv8Value; +begin + Result := Ord(TCefV8InterceptorOwn(CefGetObject(self)).GetByIndex(index, TCefv8ValueRef.UnWrap(obj), ret, CefString(exception))); + retval := CefGetData(ret); +end; + +function cef_v8_interceptor_set_byname(self: PCefV8Interceptor; const name: PCefString; const obj: PCefV8Value; value: PCefv8Value; exception: PCefString): integer; stdcall; +begin + Result := Ord(TCefV8InterceptorOwn(CefGetObject(self)).SetByName(CefString(name), TCefv8ValueRef.UnWrap(obj), TCefv8ValueRef.UnWrap(value), CefString(exception))); +end; + +function cef_v8_interceptor_set_byindex(self: PCefV8Interceptor; index: integer; const obj: PCefV8Value; value: PCefv8Value; exception: PCefString): integer; stdcall; +begin + Result := Ord(TCefV8InterceptorOwn(CefGetObject(self)).SetByIndex(index, TCefv8ValueRef.UnWrap(obj), TCefv8ValueRef.UnWrap(value), CefString(exception))); +end; + +// TCefV8InterceptorOwn + +constructor TCefV8InterceptorOwn.Create; +begin + inherited CreateData(SizeOf(TCefV8InterceptorOwn)); + + with PCefV8Interceptor(FData)^ do + begin + get_byname := cef_v8_interceptor_get_byname; + get_byindex := cef_v8_interceptor_get_byindex; + set_byname := cef_v8_interceptor_set_byname; + set_byindex := cef_v8_interceptor_set_byindex; + end; +end; + +function TCefV8InterceptorOwn.GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; +begin + Result := False; +end; + +function TCefV8InterceptorOwn.GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; +begin + Result := False; +end; + +function TCefV8InterceptorOwn.SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; +begin + Result := False; +end; + +function TCefV8InterceptorOwn.SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; +begin + Result := False; +end; + +// TCefFastV8Interceptor + +constructor TCefFastV8Interceptor.Create(const getterbyname : TCefV8InterceptorGetterByNameProc; + const setterbyname : TCefV8InterceptorSetterByNameProc; + const getterbyindex : TCefV8InterceptorGetterByIndexProc; + const setterbyindex : TCefV8InterceptorSetterByIndexProc); +begin + FGetterByName := getterbyname; + FSetterByName := setterbyname; + FGetterByIndex := getterbyindex; + FSetterByIndex := setterbyindex; +end; + +function TCefFastV8Interceptor.GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; +begin + if assigned(FGetterByName) then + Result := FGetterByName(name, obj, retval, exception) + else + Result := False; +end; + +function TCefFastV8Interceptor.GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; +begin + if assigned(FGetterByIndex) then + Result := FGetterByIndex(index, obj, retval, exception) + else + Result := False; +end; + +function TCefFastV8Interceptor.SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; +begin + if assigned(FSetterByName) then + Result := FSetterByName(name, obj, value, exception) + else + Result := False; +end; + +function TCefFastV8Interceptor.SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; +begin + if assigned(FSetterByIndex) then + Result := FSetterByIndex(index, obj, value, exception) + else + Result := False; +end; + +end. diff --git a/uCEFv8StackFrame.pas b/uCEFv8StackFrame.pas new file mode 100644 index 00000000..46971412 --- /dev/null +++ b/uCEFv8StackFrame.pas @@ -0,0 +1,117 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFv8StackFrame; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefV8StackFrameRef = class(TCefBaseRef, ICefV8StackFrame) + protected + function IsValid: Boolean; + function GetScriptName: ustring; + function GetScriptNameOrSourceUrl: ustring; + function GetFunctionName: ustring; + function GetLineNumber: Integer; + function GetColumn: Integer; + function IsEval: Boolean; + function IsConstructor: Boolean; + public + class function UnWrap(data: Pointer): ICefV8StackFrame; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +function TCefV8StackFrameRef.GetColumn: Integer; +begin + Result := PCefV8StackFrame(FData).get_column(FData); +end; + +function TCefV8StackFrameRef.GetFunctionName: ustring; +begin + Result := CefStringFreeAndGet(PCefV8StackFrame(FData).get_function_name(FData)); +end; + +function TCefV8StackFrameRef.GetLineNumber: Integer; +begin + Result := PCefV8StackFrame(FData).get_line_number(FData); +end; + +function TCefV8StackFrameRef.GetScriptName: ustring; +begin + Result := CefStringFreeAndGet(PCefV8StackFrame(FData).get_script_name(FData)); +end; + +function TCefV8StackFrameRef.GetScriptNameOrSourceUrl: ustring; +begin + Result := CefStringFreeAndGet(PCefV8StackFrame(FData).get_script_name_or_source_url(FData)); +end; + +function TCefV8StackFrameRef.IsConstructor: Boolean; +begin + Result := PCefV8StackFrame(FData).is_constructor(FData) <> 0; +end; + +function TCefV8StackFrameRef.IsEval: Boolean; +begin + Result := PCefV8StackFrame(FData).is_eval(FData) <> 0; +end; + +function TCefV8StackFrameRef.IsValid: Boolean; +begin + Result := PCefV8StackFrame(FData).is_valid(FData) <> 0; +end; + +class function TCefV8StackFrameRef.UnWrap(data: Pointer): ICefV8StackFrame; +begin + if data <> nil then + Result := Create(data) as ICefV8StackFrame else + Result := nil; +end; + +end. diff --git a/uCEFv8StackTrace.pas b/uCEFv8StackTrace.pas new file mode 100644 index 00000000..7003d86f --- /dev/null +++ b/uCEFv8StackTrace.pas @@ -0,0 +1,93 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFv8StackTrace; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + uCEFBase, uCEFInterfaces, uCEFTypes; + +type + TCefV8StackTraceRef = class(TCefBaseRef, ICefV8StackTrace) + protected + function IsValid: Boolean; + function GetFrameCount: Integer; + function GetFrame(index: Integer): ICefV8StackFrame; + public + class function UnWrap(data: Pointer): ICefV8StackTrace; + class function Current(frameLimit: Integer): ICefV8StackTrace; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFv8StackFrame; + +class function TCefV8StackTraceRef.Current(frameLimit: Integer): ICefV8StackTrace; +begin + Result := UnWrap(cef_v8stack_trace_get_current(frameLimit)); +end; + +function TCefV8StackTraceRef.GetFrame(index: Integer): ICefV8StackFrame; +begin + Result := TCefV8StackFrameRef.UnWrap(PCefV8StackTrace(FData).get_frame(FData, index)); +end; + +function TCefV8StackTraceRef.GetFrameCount: Integer; +begin + Result := PCefV8StackTrace(FData).get_frame_count(FData); +end; + +function TCefV8StackTraceRef.IsValid: Boolean; +begin + Result := PCefV8StackTrace(FData).is_valid(FData) <> 0; +end; + +class function TCefV8StackTraceRef.UnWrap(data: Pointer): ICefV8StackTrace; +begin + if data <> nil then + Result := Create(data) as ICefV8StackTrace else + Result := nil; +end; + +end. diff --git a/uCEFv8Types.pas b/uCEFv8Types.pas new file mode 100644 index 00000000..aa868150 --- /dev/null +++ b/uCEFv8Types.pas @@ -0,0 +1,62 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFv8Types; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFInterfaces, uCEFTypes; + +type + TCefV8AccessorGetterProc = reference to function(const name: ustring; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; + TCefV8AccessorSetterProc = reference to function(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): Boolean; + + TCefV8InterceptorGetterByNameProc = reference to function(const name: ustring; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; + TCefV8InterceptorSetterByNameProc = reference to function(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): Boolean; + TCefV8InterceptorGetterByIndexProc = reference to function(index: integer; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; + TCefV8InterceptorSetterByIndexProc = reference to function(index: integer; const obj, value: ICefv8Value; const exception: ustring): Boolean; + +implementation + +end. diff --git a/uCEFv8Value.pas b/uCEFv8Value.pas new file mode 100644 index 00000000..a6b10aef --- /dev/null +++ b/uCEFv8Value.pas @@ -0,0 +1,488 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi 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. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFv8Value; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +interface + +uses + System.Classes, + uCEFBase, uCEFInterfaces, uCEFTypes, uCEFv8Types; + +type + TCefv8ValueRef = class(TCefBaseRef, ICefv8Value) + protected + function IsValid: Boolean; + function IsUndefined: Boolean; + function IsNull: Boolean; + function IsBool: Boolean; + function IsInt: Boolean; + function IsUInt: Boolean; + function IsDouble: Boolean; + function IsDate: Boolean; + function IsString: Boolean; + function IsObject: Boolean; + function IsArray: Boolean; + function IsFunction: Boolean; + function IsSame(const that: ICefv8Value): Boolean; + function GetBoolValue: Boolean; + function GetIntValue: Integer; + function GetUIntValue: Cardinal; + function GetDoubleValue: Double; + function GetDateValue: TDateTime; + function GetStringValue: ustring; + function IsUserCreated: Boolean; + function HasException: Boolean; + function GetException: ICefV8Exception; + function ClearException: Boolean; + function WillRethrowExceptions: Boolean; + function SetRethrowExceptions(rethrow: Boolean): Boolean; + function HasValueByKey(const key: ustring): Boolean; + function HasValueByIndex(index: Integer): Boolean; + function DeleteValueByKey(const key: ustring): Boolean; + function DeleteValueByIndex(index: Integer): Boolean; + function GetValueByKey(const key: ustring): ICefv8Value; + function GetValueByIndex(index: Integer): ICefv8Value; + function SetValueByKey(const key: ustring; const value: ICefv8Value; attribute: TCefV8PropertyAttributes): Boolean; + function SetValueByIndex(index: Integer; const value: ICefv8Value): Boolean; + function SetValueByAccessor(const key: ustring; settings: TCefV8AccessControls; attribute: TCefV8PropertyAttributes): Boolean; + function GetKeys(const keys: TStrings): Integer; + function SetUserData(const data: ICefv8Value): Boolean; + function GetUserData: ICefv8Value; + function GetExternallyAllocatedMemory: Integer; + function AdjustExternallyAllocatedMemory(changeInBytes: Integer): Integer; + function GetArrayLength: Integer; + function GetFunctionName: ustring; + function GetFunctionHandler: ICefv8Handler; + function ExecuteFunction(const obj: ICefv8Value; const arguments: TCefv8ValueArray): ICefv8Value; + function ExecuteFunctionWithContext(const context: ICefv8Context; const obj: ICefv8Value; const arguments: TCefv8ValueArray): ICefv8Value; + + public + class function UnWrap(data: Pointer): ICefv8Value; + class function NewUndefined: ICefv8Value; + class function NewNull: ICefv8Value; + class function NewBool(value: Boolean): ICefv8Value; + class function NewInt(value: Integer): ICefv8Value; + class function NewUInt(value: Cardinal): ICefv8Value; + class function NewDouble(value: Double): ICefv8Value; + class function NewDate(value: TDateTime): ICefv8Value; + class function NewString(const str: ustring): ICefv8Value; + class function NewObject(const Accessor: ICefV8Accessor; const Interceptor: ICefV8Interceptor): ICefv8Value; + class function NewObjectProc(const getter: TCefV8AccessorGetterProc; + const setter: TCefV8AccessorSetterProc; + const getterbyname : TCefV8InterceptorGetterByNameProc; + const setterbyname : TCefV8InterceptorSetterByNameProc; + const getterbyindex : TCefV8InterceptorGetterByIndexProc; + const setterbyindex : TCefV8InterceptorSetterByIndexProc): ICefv8Value; + class function NewArray(len: Integer): ICefv8Value; + class function NewFunction(const name: ustring; const handler: ICefv8Handler): ICefv8Value; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFv8Accessor, uCEFv8Handler, uCEFv8Exception, uCEFv8Interceptor; + +function TCefv8ValueRef.AdjustExternallyAllocatedMemory(changeInBytes: Integer): Integer; +begin + Result := PCefV8Value(FData)^.adjust_externally_allocated_memory(PCefV8Value(FData), changeInBytes); +end; + +class function TCefv8ValueRef.NewArray(len: Integer): ICefv8Value; +begin + Result := UnWrap(cef_v8value_create_array(len)); +end; + +class function TCefv8ValueRef.NewBool(value: Boolean): ICefv8Value; +begin + Result := UnWrap(cef_v8value_create_bool(Ord(value))); +end; + +class function TCefv8ValueRef.NewDate(value: TDateTime): ICefv8Value; +var + dt: TCefTime; +begin + dt := DateTimeToCefTime(value); + Result := UnWrap(cef_v8value_create_date(@dt)); +end; + +class function TCefv8ValueRef.NewDouble(value: Double): ICefv8Value; +begin + Result := UnWrap(cef_v8value_create_double(value)); +end; + +class function TCefv8ValueRef.NewFunction(const name: ustring; + const handler: ICefv8Handler): ICefv8Value; +var + n: TCefString; +begin + n := CefString(name); + Result := UnWrap(cef_v8value_create_function(@n, CefGetData(handler))); +end; + +class function TCefv8ValueRef.NewInt(value: Integer): ICefv8Value; +begin + Result := UnWrap(cef_v8value_create_int(value)); +end; + +class function TCefv8ValueRef.NewUInt(value: Cardinal): ICefv8Value; +begin + Result := UnWrap(cef_v8value_create_uint(value)); +end; + +class function TCefv8ValueRef.NewNull: ICefv8Value; +begin + Result := UnWrap(cef_v8value_create_null); +end; + +class function TCefv8ValueRef.NewObject(const Accessor: ICefV8Accessor; const Interceptor: ICefV8Interceptor): ICefv8Value; +begin + Result := UnWrap(cef_v8value_create_object(CefGetData(Accessor), CefGetData(Interceptor))); +end; + +class function TCefv8ValueRef.NewObjectProc(const getter: TCefV8AccessorGetterProc; + const setter: TCefV8AccessorSetterProc; + const getterbyname : TCefV8InterceptorGetterByNameProc; + const setterbyname : TCefV8InterceptorSetterByNameProc; + const getterbyindex : TCefV8InterceptorGetterByIndexProc; + const setterbyindex : TCefV8InterceptorSetterByIndexProc): ICefv8Value; +begin + Result := NewObject(TCefFastV8Accessor.Create(getter, setter) as ICefV8Accessor, + TCefFastV8Interceptor.Create(getterbyname, setterbyname, getterbyindex, setterbyindex) as ICefV8Interceptor); +end; + +class function TCefv8ValueRef.NewString(const str: ustring): ICefv8Value; +var + s: TCefString; +begin + s := CefString(str); + Result := UnWrap(cef_v8value_create_string(@s)); +end; + +class function TCefv8ValueRef.NewUndefined: ICefv8Value; +begin + Result := UnWrap(cef_v8value_create_undefined); +end; + +function TCefv8ValueRef.DeleteValueByIndex(index: Integer): Boolean; +begin + Result := PCefV8Value(FData)^.delete_value_byindex(PCefV8Value(FData), index) <> 0; +end; + +function TCefv8ValueRef.DeleteValueByKey(const key: ustring): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefV8Value(FData)^.delete_value_bykey(PCefV8Value(FData), @k) <> 0; +end; + +function TCefv8ValueRef.ExecuteFunction(const obj: ICefv8Value; + const arguments: TCefv8ValueArray): ICefv8Value; +var + args: PPCefV8Value; + i: Integer; +begin + GetMem(args, SizeOf(PCefV8Value) * Length(arguments)); + try + for i := 0 to Length(arguments) - 1 do + args[i] := CefGetData(arguments[i]); + Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData)^.execute_function(PCefV8Value(FData), + CefGetData(obj), Length(arguments), args)); + finally + FreeMem(args); + end; +end; + +function TCefv8ValueRef.ExecuteFunctionWithContext(const context: ICefv8Context; + const obj: ICefv8Value; const arguments: TCefv8ValueArray): ICefv8Value; +var + args: PPCefV8Value; + i: Integer; +begin + GetMem(args, SizeOf(PCefV8Value) * Length(arguments)); + try + for i := 0 to Length(arguments) - 1 do + args[i] := CefGetData(arguments[i]); + Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData)^.execute_function_with_context(PCefV8Value(FData), + CefGetData(context), CefGetData(obj), Length(arguments), args)); + finally + FreeMem(args); + end; +end; + +function TCefv8ValueRef.GetArrayLength: Integer; +begin + Result := PCefV8Value(FData)^.get_array_length(PCefV8Value(FData)); +end; + +function TCefv8ValueRef.GetBoolValue: Boolean; +begin + Result := PCefV8Value(FData)^.get_bool_value(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.GetDateValue: TDateTime; +begin + Result := CefTimeToDateTime(PCefV8Value(FData)^.get_date_value(PCefV8Value(FData))); +end; + +function TCefv8ValueRef.GetDoubleValue: Double; +begin + Result := PCefV8Value(FData)^.get_double_value(PCefV8Value(FData)); +end; + +function TCefv8ValueRef.GetExternallyAllocatedMemory: Integer; +begin + Result := PCefV8Value(FData)^.get_externally_allocated_memory(PCefV8Value(FData)); +end; + +function TCefv8ValueRef.GetFunctionHandler: ICefv8Handler; +begin + Result := TCefv8HandlerRef.UnWrap(PCefV8Value(FData)^.get_function_handler(PCefV8Value(FData))); +end; + +function TCefv8ValueRef.GetFunctionName: ustring; +begin + Result := CefStringFreeAndGet(PCefV8Value(FData)^.get_function_name(PCefV8Value(FData))) +end; + +function TCefv8ValueRef.GetIntValue: Integer; +begin + Result := PCefV8Value(FData)^.get_int_value(PCefV8Value(FData)) +end; + +function TCefv8ValueRef.GetUIntValue: Cardinal; +begin + Result := PCefV8Value(FData)^.get_uint_value(PCefV8Value(FData)) +end; + +function TCefv8ValueRef.GetKeys(const keys: TStrings): Integer; +var + list: TCefStringList; + i: Integer; + str: TCefString; +begin + list := cef_string_list_alloc; + try + Result := PCefV8Value(FData)^.get_keys(PCefV8Value(FData), list); + FillChar(str, SizeOf(str), 0); + for i := 0 to cef_string_list_size(list) - 1 do + begin + FillChar(str, SizeOf(str), 0); + cef_string_list_value(list, i, @str); + keys.Add(CefStringClearAndGet(str)); + end; + finally + cef_string_list_free(list); + end; +end; + +function TCefv8ValueRef.SetUserData(const data: ICefv8Value): Boolean; +begin + Result := PCefV8Value(FData)^.set_user_data(PCefV8Value(FData), CefGetData(data)) <> 0; +end; + +function TCefv8ValueRef.GetStringValue: ustring; +begin + Result := CefStringFreeAndGet(PCefV8Value(FData)^.get_string_value(PCefV8Value(FData))); +end; + +function TCefv8ValueRef.IsUserCreated: Boolean; +begin + Result := PCefV8Value(FData)^.is_user_created(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsValid: Boolean; +begin + Result := PCefV8Value(FData)^.is_valid(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.HasException: Boolean; +begin + Result := PCefV8Value(FData)^.has_exception(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.GetException: ICefV8Exception; +begin + Result := TCefV8ExceptionRef.UnWrap(PCefV8Value(FData)^.get_exception(PCefV8Value(FData))); +end; + +function TCefv8ValueRef.ClearException: Boolean; +begin + Result := PCefV8Value(FData)^.clear_exception(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.WillRethrowExceptions: Boolean; +begin + Result := PCefV8Value(FData)^.will_rethrow_exceptions(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.SetRethrowExceptions(rethrow: Boolean): Boolean; +begin + Result := PCefV8Value(FData)^.set_rethrow_exceptions(PCefV8Value(FData), Ord(rethrow)) <> 0; +end; + +function TCefv8ValueRef.GetUserData: ICefv8Value; +begin + Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData)^.get_user_data(PCefV8Value(FData))); +end; + +function TCefv8ValueRef.GetValueByIndex(index: Integer): ICefv8Value; +begin + Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData)^.get_value_byindex(PCefV8Value(FData), index)) +end; + +function TCefv8ValueRef.GetValueByKey(const key: ustring): ICefv8Value; +var + k: TCefString; +begin + k := CefString(key); + Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData)^.get_value_bykey(PCefV8Value(FData), @k)) +end; + +function TCefv8ValueRef.HasValueByIndex(index: Integer): Boolean; +begin + Result := PCefV8Value(FData)^.has_value_byindex(PCefV8Value(FData), index) <> 0; +end; + +function TCefv8ValueRef.HasValueByKey(const key: ustring): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result := PCefV8Value(FData)^.has_value_bykey(PCefV8Value(FData), @k) <> 0; +end; + +function TCefv8ValueRef.IsArray: Boolean; +begin + Result := PCefV8Value(FData)^.is_array(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsBool: Boolean; +begin + Result := PCefV8Value(FData)^.is_bool(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsDate: Boolean; +begin + Result := PCefV8Value(FData)^.is_date(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsDouble: Boolean; +begin + Result := PCefV8Value(FData)^.is_double(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsFunction: Boolean; +begin + Result := PCefV8Value(FData)^.is_function(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsInt: Boolean; +begin + Result := PCefV8Value(FData)^.is_int(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsUInt: Boolean; +begin + Result := PCefV8Value(FData)^.is_uint(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsNull: Boolean; +begin + Result := PCefV8Value(FData)^.is_null(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsObject: Boolean; +begin + Result := PCefV8Value(FData)^.is_object(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsSame(const that: ICefv8Value): Boolean; +begin + Result := PCefV8Value(FData)^.is_same(PCefV8Value(FData), CefGetData(that)) <> 0; +end; + +function TCefv8ValueRef.IsString: Boolean; +begin + Result := PCefV8Value(FData)^.is_string(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.IsUndefined: Boolean; +begin + Result := PCefV8Value(FData)^.is_undefined(PCefV8Value(FData)) <> 0; +end; + +function TCefv8ValueRef.SetValueByAccessor(const key: ustring; + settings: TCefV8AccessControls; attribute: TCefV8PropertyAttributes): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result:= PCefV8Value(FData)^.set_value_byaccessor(PCefV8Value(FData), @k, + PByte(@settings)^, PByte(@attribute)^) <> 0; +end; + +function TCefv8ValueRef.SetValueByIndex(index: Integer; + const value: ICefv8Value): Boolean; +begin + Result:= PCefV8Value(FData)^.set_value_byindex(PCefV8Value(FData), index, CefGetData(value)) <> 0; +end; + +function TCefv8ValueRef.SetValueByKey(const key: ustring; + const value: ICefv8Value; attribute: TCefV8PropertyAttributes): Boolean; +var + k: TCefString; +begin + k := CefString(key); + Result:= PCefV8Value(FData)^.set_value_bykey(PCefV8Value(FData), @k, + CefGetData(value), PByte(@attribute)^) <> 0; +end; + +class function TCefv8ValueRef.UnWrap(data: Pointer): ICefv8Value; +begin + if data <> nil then + Result := Create(data) as ICefv8Value else + Result := nil; +end; + +end.