You've already forked CEF4Delphi
							
							
				mirror of
				https://github.com/salvadordf/CEF4Delphi.git
				synced 2025-10-30 23:07:52 +02:00 
			
		
		
		
	rest of the initial commit
This commit is contained in:
		
							
								
								
									
										127
									
								
								uCEFDeleteCookiesCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								uCEFDeleteCookiesCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										130
									
								
								uCEFDialogHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								uCEFDialogHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
|  | ||||
							
								
								
									
										340
									
								
								uCEFDictionaryValue.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										340
									
								
								uCEFDictionaryValue.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										269
									
								
								uCEFDisplayHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										269
									
								
								uCEFDisplayHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										160
									
								
								uCEFDomDocument.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										160
									
								
								uCEFDomDocument.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										241
									
								
								uCEFDomNode.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										241
									
								
								uCEFDomNode.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										131
									
								
								uCEFDomVisitor.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								uCEFDomVisitor.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										171
									
								
								uCEFDownLoadItem.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										171
									
								
								uCEFDownLoadItem.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										142
									
								
								uCEFDownloadHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								uCEFDownloadHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										97
									
								
								uCEFDownloadImageCallBack.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								uCEFDownloadImageCallBack.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										87
									
								
								uCEFDownloadItemCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								uCEFDownloadItemCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										247
									
								
								uCEFDragData.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										247
									
								
								uCEFDragData.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										132
									
								
								uCEFDragHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								uCEFDragHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										82
									
								
								uCEFEndTracingCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								uCEFEndTracingCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										97
									
								
								uCEFFileDialogCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								uCEFFileDialogCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										101
									
								
								uCEFFindHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								uCEFFindHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										148
									
								
								uCEFFocusHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								uCEFFocusHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
|  | ||||
							
								
								
									
										244
									
								
								uCEFFrame.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										244
									
								
								uCEFFrame.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										76
									
								
								uCEFGeolocationCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								uCEFGeolocationCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										138
									
								
								uCEFGeolocationHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										138
									
								
								uCEFGeolocationHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										113
									
								
								uCEFGetGeolocationCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								uCEFGetGeolocationCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										173
									
								
								uCEFImage.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										173
									
								
								uCEFImage.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										1732
									
								
								uCEFInterfaces.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1732
									
								
								uCEFInterfaces.pas
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										81
									
								
								uCEFJsDialogCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								uCEFJsDialogCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										192
									
								
								uCEFJsDialogHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										192
									
								
								uCEFJsDialogHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										137
									
								
								uCEFKeyboardHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								uCEFKeyboardHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										301
									
								
								uCEFLibFunctions.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										301
									
								
								uCEFLibFunctions.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										206
									
								
								uCEFLifeSpanHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										206
									
								
								uCEFLifeSpanHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										247
									
								
								uCEFListValue.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										247
									
								
								uCEFListValue.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										166
									
								
								uCEFLoadHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										166
									
								
								uCEFLoadHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										440
									
								
								uCEFMenuModel.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										440
									
								
								uCEFMenuModel.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										126
									
								
								uCEFMenuModelDelegate.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								uCEFMenuModelDelegate.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										416
									
								
								uCEFMiscFunctions.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										416
									
								
								uCEFMiscFunctions.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										131
									
								
								uCEFNavigationEntry.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								uCEFNavigationEntry.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										110
									
								
								uCEFNavigationEntryVisitor.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								uCEFNavigationEntryVisitor.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										124
									
								
								uCEFPDFPrintCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								uCEFPDFPrintCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										100
									
								
								uCEFPDFPrintOptions.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								uCEFPDFPrintOptions.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										134
									
								
								uCEFPostData.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								uCEFPostData.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										304
									
								
								uCEFPostDataElement.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										304
									
								
								uCEFPostDataElement.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										233
									
								
								uCEFPrintSettings.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										233
									
								
								uCEFPrintSettings.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										109
									
								
								uCEFProcessMessage.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								uCEFProcessMessage.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										113
									
								
								uCEFRegisterCDMCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								uCEFRegisterCDMCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										58
									
								
								uCEFRegisterComponents.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								uCEFRegisterComponents.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										370
									
								
								uCEFRenderHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										370
									
								
								uCEFRenderHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										249
									
								
								uCEFRenderProcessHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										249
									
								
								uCEFRenderProcessHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										213
									
								
								uCEFRequest.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										213
									
								
								uCEFRequest.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										83
									
								
								uCEFRequestCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								uCEFRequestCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										252
									
								
								uCEFRequestContext.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										252
									
								
								uCEFRequestContext.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										176
									
								
								uCEFRequestContextHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										176
									
								
								uCEFRequestContextHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										570
									
								
								uCEFRequestHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										570
									
								
								uCEFRequestHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										95
									
								
								uCEFResolveCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								uCEFResolveCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										101
									
								
								uCEFResourceBundle.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								uCEFResourceBundle.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										157
									
								
								uCEFResourceBundleHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										157
									
								
								uCEFResourceBundleHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										161
									
								
								uCEFResourceHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										161
									
								
								uCEFResourceHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										157
									
								
								uCEFResponse.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										157
									
								
								uCEFResponse.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										88
									
								
								uCEFResponseFilter.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								uCEFResponseFilter.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										83
									
								
								uCEFRunContextMenuCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								uCEFRunContextMenuCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										124
									
								
								uCEFRunFileDialogCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								uCEFRunFileDialogCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										102
									
								
								uCEFSSLStatus.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								uCEFSSLStatus.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										93
									
								
								uCEFSchemeHandlerFactory.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								uCEFSchemeHandlerFactory.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										79
									
								
								uCEFSchemeRegistrar.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								uCEFSchemeRegistrar.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										79
									
								
								uCEFSelectClientCertificateCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								uCEFSelectClientCertificateCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										101
									
								
								uCEFSetCookieCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								uCEFSetCookieCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										85
									
								
								uCEFSslInfo.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								uCEFSslInfo.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										129
									
								
								uCEFStreamReader.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								uCEFStreamReader.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										115
									
								
								uCEFStreamWriter.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								uCEFStreamWriter.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										135
									
								
								uCEFStringMap.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								uCEFStringMap.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										146
									
								
								uCEFStringMultimap.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								uCEFStringMultimap.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										132
									
								
								uCEFStringVisitor.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								uCEFStringVisitor.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										217
									
								
								uCEFTask.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										217
									
								
								uCEFTask.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										113
									
								
								uCEFTaskRunner.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								uCEFTaskRunner.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										103
									
								
								uCEFThread.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								uCEFThread.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										2524
									
								
								uCEFTypes.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2524
									
								
								uCEFTypes.pas
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										107
									
								
								uCEFUrlRequest.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								uCEFUrlRequest.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										150
									
								
								uCEFUrlrequestClient.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								uCEFUrlrequestClient.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										119
									
								
								uCEFV8Exception.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								uCEFV8Exception.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										211
									
								
								uCEFValue.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										211
									
								
								uCEFValue.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										107
									
								
								uCEFWaitableEvent.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								uCEFWaitableEvent.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										94
									
								
								uCEFWebPluginInfo.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								uCEFWebPluginInfo.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										109
									
								
								uCEFWebPluginInfoVisitor.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								uCEFWebPluginInfoVisitor.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										110
									
								
								uCEFWebPluginUnstableCallback.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								uCEFWebPluginUnstableCallback.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										141
									
								
								uCEFWindowParent.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										141
									
								
								uCEFWindowParent.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										139
									
								
								uCEFWriteHandler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										139
									
								
								uCEFWriteHandler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										215
									
								
								uCEFX509CertPrincipal.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										215
									
								
								uCEFX509CertPrincipal.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										154
									
								
								uCEFX509Certificate.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										154
									
								
								uCEFX509Certificate.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										272
									
								
								uCEFXmlReader.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										272
									
								
								uCEFXmlReader.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										155
									
								
								uCEFZipReader.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								uCEFZipReader.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										135
									
								
								uCEFv8Accessor.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								uCEFv8Accessor.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										153
									
								
								uCEFv8Context.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								uCEFv8Context.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										896
									
								
								uCEFv8Handler.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										896
									
								
								uCEFv8Handler.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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<TRttiParameter>; | ||||
|   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. | ||||
							
								
								
									
										192
									
								
								uCEFv8Interceptor.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										192
									
								
								uCEFv8Interceptor.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										117
									
								
								uCEFv8StackFrame.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								uCEFv8StackFrame.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										93
									
								
								uCEFv8StackTrace.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								uCEFv8StackTrace.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										62
									
								
								uCEFv8Types.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								uCEFv8Types.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
							
								
								
									
										488
									
								
								uCEFv8Value.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										488
									
								
								uCEFv8Value.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <hgourvest@gmail.com> | ||||
|  * 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. | ||||
		Reference in New Issue
	
	Block a user