mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-02-02 10:25:26 +02:00
Update to CEF 74.1.16
- Copied the GlobalCEFApp_OnWebKitInitializedEvent fix for D2007 made by jepp to other demos. - Added TChromium.DownloadImage and TChromium.OnDownloadImageFinished to download images - Added a TChromium.DownloadImage example to the MiniBrowser demo. - Modified some parameters in TCefImageRef
This commit is contained in:
parent
dc56584556
commit
59f3441b1e
@ -3,10 +3,10 @@ CEF4Delphi is an open source project created by Salvador D
|
||||
|
||||
CEF4Delphi is based on DCEF3, made by Henri Gourvest. The original license of DCEF3 still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file.
|
||||
|
||||
CEF4Delphi uses CEF 74.1.14 which includes Chromium 74.0.3729.131.
|
||||
CEF4Delphi uses CEF 74.1.16 which includes Chromium 74.0.3729.131.
|
||||
The CEF binaries used by CEF4Delphi are available for download at spotify :
|
||||
* [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_74.1.14%2Bg50c3c5c%2Bchromium-74.0.3729.131_windows32.tar.bz2)
|
||||
* [64 bits](http://opensource.spotify.com/cefbuilds/cef_binary_74.1.14%2Bg50c3c5c%2Bchromium-74.0.3729.131_windows64.tar.bz2)
|
||||
* [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_74.1.16%2Bge20b240%2Bchromium-74.0.3729.131_windows32.tar.bz2)
|
||||
* [64 bits](http://opensource.spotify.com/cefbuilds/cef_binary_74.1.16%2Bge20b240%2Bchromium-74.0.3729.131_windows64.tar.bz2)
|
||||
|
||||
|
||||
CEF4Delphi was developed and tested on Delphi 10.3 Rio and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2 and Lazarus 2.0.2/FPC 3.0.4. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components.
|
||||
|
@ -92,6 +92,8 @@ type
|
||||
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
|
||||
procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP;
|
||||
procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
|
||||
|
||||
{$IFNDEF DELPHI12_UP}class procedure GlobalCEFApp_OnWebKitInitializedEvent;{$ENDIF}
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
@ -120,7 +122,8 @@ uses
|
||||
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
|
||||
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
{$IFDEF DELPHI12_UP}procedure
|
||||
{$ELSE}class procedure TJSSimpleExtensionFrm.{$ENDIF}GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
TempHandler : ICefv8Handler;
|
||||
@ -146,7 +149,8 @@ end;
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnWebKitInitialized := GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
GlobalCEFApp.OnWebKitInitialized := {$IFNDEF DELPHI12_UP}TJSSimpleExtensionFrm.{$ENDIF}
|
||||
GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
end;
|
||||
|
||||
procedure TJSExtensionWithFunctionFrm.GoBtnClick(Sender: TObject);
|
||||
|
@ -88,6 +88,8 @@ type
|
||||
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
|
||||
procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP;
|
||||
procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
|
||||
|
||||
{$IFNDEF DELPHI12_UP}class procedure GlobalCEFApp_OnWebKitInitializedEvent;{$ENDIF}
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
@ -119,7 +121,8 @@ uses
|
||||
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
|
||||
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
{$IFDEF DELPHI12_UP}procedure
|
||||
{$ELSE}class procedure TJSSimpleExtensionFrm.{$ENDIF}GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
TempHandler : ICefv8Handler;
|
||||
@ -149,7 +152,8 @@ end;
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnWebKitInitialized := GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
GlobalCEFApp.OnWebKitInitialized := {$IFNDEF DELPHI12_UP}TJSSimpleExtensionFrm.{$ENDIF}
|
||||
GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
end;
|
||||
|
||||
procedure TJSExtensionWithObjectParameterFrm.GoBtnClick(Sender: TObject);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// ************************************************************************
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
@ -88,6 +88,7 @@ type
|
||||
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
|
||||
procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP;
|
||||
procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
|
||||
|
||||
{$IFNDEF DELPHI12_UP}class procedure GlobalCEFApp_OnWebKitInitializedEvent;{$ENDIF}
|
||||
public
|
||||
{ Public declarations }
|
||||
|
@ -137,6 +137,9 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
'https://www.w3schools.com/js/tryit.asp?filename=tryjs_win_close'
|
||||
'https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert'
|
||||
'https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_assign'
|
||||
|
||||
'https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_styl' +
|
||||
'e_backgroundcolor'
|
||||
'https://www.w3schools.com/html/html5_video.asp'
|
||||
'http://www.adobe.com/software/flash/about/'
|
||||
'http://isflashinstalled.com/'
|
||||
@ -264,6 +267,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
OnPrefsAvailable = Chromium1PrefsAvailable
|
||||
OnResolvedHostAvailable = Chromium1ResolvedHostAvailable
|
||||
OnNavigationVisitorResultAvailable = Chromium1NavigationVisitorResultAvailable
|
||||
OnDownloadImageFinished = Chromium1DownloadImageFinished
|
||||
OnRenderCompMsg = Chromium1RenderCompMsg
|
||||
OnLoadEnd = Chromium1LoadEnd
|
||||
OnLoadError = Chromium1LoadError
|
||||
@ -347,6 +351,10 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
Caption = 'Resolve host...'
|
||||
OnClick = Resolvehost1Click
|
||||
end
|
||||
object Downloadimage1: TMenuItem
|
||||
Caption = 'Download image...'
|
||||
OnClick = Downloadimage1Click
|
||||
end
|
||||
object N5: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
|
@ -122,6 +122,7 @@ type
|
||||
OpenfilewithaDAT1: TMenuItem;
|
||||
N5: TMenuItem;
|
||||
Memoryinfo1: TMenuItem;
|
||||
Downloadimage1: TMenuItem;
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure BackBtnClick(Sender: TObject);
|
||||
procedure ForwardBtnClick(Sender: TObject);
|
||||
@ -215,6 +216,10 @@ type
|
||||
procedure Chromium1NavigationVisitorResultAvailable(
|
||||
const entry: ICefNavigationEntry; current: Boolean; index, total: Integer;
|
||||
var aResult: Boolean);
|
||||
procedure Downloadimage1Click(Sender: TObject);
|
||||
procedure Chromium1DownloadImageFinished(Sender: TObject;
|
||||
const imageUrl: ustring; httpStatusCode: Integer;
|
||||
const image: ICefImage);
|
||||
|
||||
protected
|
||||
FResponse : TStringList;
|
||||
@ -1216,6 +1221,82 @@ begin
|
||||
ShowDevTools;
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Downloadimage1Click(Sender: TObject);
|
||||
var
|
||||
TempURL : string;
|
||||
begin
|
||||
TempURL := InputBox('Download Image', 'URL:', 'https://www.briskbard.com/images/logo.png');
|
||||
|
||||
if (length(TempURL) > 0) then
|
||||
Chromium1.DownloadImage(TempURL, False, 0, False);
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Chromium1DownloadImageFinished( Sender : TObject;
|
||||
const imageUrl : ustring;
|
||||
httpStatusCode : Integer;
|
||||
const image : ICefImage);
|
||||
var
|
||||
TempBinValue : ICefBinaryValue;
|
||||
TempWidth : integer;
|
||||
TempHeight : integer;
|
||||
TempBuffer : TBytes;
|
||||
TempPointer : pointer;
|
||||
TempSize : NativeUInt;
|
||||
TempStream : TFileStream;
|
||||
TempParts : TUrlParts;
|
||||
i : integer;
|
||||
begin
|
||||
TempStream := nil;
|
||||
|
||||
try
|
||||
try
|
||||
if (httpStatusCode = 200) and (image <> nil) and not(image.IsEmpty) then
|
||||
begin
|
||||
TempBinValue := image.GetAsPng(1, True, TempWidth, TempHeight);
|
||||
|
||||
if (TempBinValue <> nil) and
|
||||
TempBinValue.IsValid then
|
||||
begin
|
||||
TempSize := TempBinValue.Size;
|
||||
|
||||
SaveDialog1.DefaultExt := 'png';
|
||||
SaveDialog1.Filter := 'PNG files (*.png)|*.PNG';
|
||||
|
||||
CefParseUrl(imageUrl, TempParts);
|
||||
i := LastDelimiter('/', TempParts.path);
|
||||
|
||||
// TODO : The file name should be sanitized.
|
||||
if (i > 0) then
|
||||
SaveDialog1.FileName := copy(TempParts.path, succ(i), length(TempParts.path))
|
||||
else
|
||||
SaveDialog1.FileName := TempParts.path;
|
||||
|
||||
if (TempSize > 0) and
|
||||
SaveDialog1.Execute and
|
||||
(length(SaveDialog1.FileName) > 0) then
|
||||
begin
|
||||
SetLength(TempBuffer, TempSize);
|
||||
TempPointer := @TempBuffer[0];
|
||||
TempSize := TempBinValue.GetData(TempPointer, TempSize, 0);
|
||||
|
||||
if (TempSize > 0) then
|
||||
begin
|
||||
TempStream := TFileStream.Create(SaveDialog1.FileName, fmCreate);
|
||||
TempStream.Write(TempBuffer, TempSize);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('Chromium1DownloadImageFinishedEvent', e) then raise;
|
||||
end;
|
||||
finally
|
||||
if (TempStream <> nil) then FreeAndNil(TempStream);
|
||||
SetLength(TempBuffer, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.ShowDevTools(aPoint : TPoint);
|
||||
begin
|
||||
Splitter1.Visible := True;
|
||||
|
@ -1,22 +1,22 @@
|
||||
object ChildForm: TChildForm
|
||||
Left = 224
|
||||
Height = 600
|
||||
Top = 175
|
||||
Left = 45
|
||||
Height = 503
|
||||
Top = 239
|
||||
Width = 800
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'ChildForm'
|
||||
ClientHeight = 600
|
||||
ClientHeight = 503
|
||||
ClientWidth = 800
|
||||
OnClose = FormClose
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
LCLVersion = '2.0.0.4'
|
||||
LCLVersion = '2.0.2.0'
|
||||
object CEFWindowParent1: TCEFWindowParent
|
||||
Left = 0
|
||||
Height = 600
|
||||
Height = 503
|
||||
Top = 0
|
||||
Width = 800
|
||||
Align = alClient
|
||||
|
@ -21,7 +21,7 @@
|
||||
</CompilerOptions>
|
||||
<Description Value="CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC."/>
|
||||
<License Value="MPL 1.1"/>
|
||||
<Version Major="74" Minor="1" Release="14"/>
|
||||
<Version Major="74" Minor="1" Release="16"/>
|
||||
<Files Count="139">
|
||||
<Item1>
|
||||
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
||||
|
@ -62,7 +62,7 @@ uses
|
||||
const
|
||||
CEF_SUPPORTED_VERSION_MAJOR = 74;
|
||||
CEF_SUPPORTED_VERSION_MINOR = 1;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 14;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 16;
|
||||
CEF_SUPPORTED_VERSION_BUILD = 0;
|
||||
|
||||
CEF_CHROMEELF_VERSION_MAJOR = 74;
|
||||
|
@ -240,6 +240,7 @@ type
|
||||
FOnCookiesDeleted : TOnCookiesDeletedEvent;
|
||||
FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent;
|
||||
FOnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent;
|
||||
FOnDownloadImageFinished : TOnDownloadImageFinishedEvent;
|
||||
{$IFNDEF FPC}
|
||||
FOnBrowserCompMsg : TOnCompMsgEvent;
|
||||
FOnWidgetCompMsg : TOnCompMsgEvent;
|
||||
@ -486,6 +487,7 @@ type
|
||||
function doSavePreferences : boolean; virtual;
|
||||
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual;
|
||||
function doNavigationVisitorResultAvailable(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer) : boolean; virtual;
|
||||
procedure doDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage);
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -513,6 +515,7 @@ type
|
||||
procedure ReloadIgnoreCache;
|
||||
procedure StopLoad;
|
||||
procedure StartDownload(const aURL : ustring);
|
||||
procedure DownloadImage(const imageUrl: ustring; isFavicon: Boolean; maxImageSize: cardinal; bypassCache: Boolean);
|
||||
|
||||
procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer);
|
||||
function DeleteCookies(const url : ustring = ''; const cookieName : ustring = '') : boolean;
|
||||
@ -663,6 +666,7 @@ type
|
||||
property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted;
|
||||
property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable;
|
||||
property OnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent read FOnNavigationVisitorResultAvailable write FOnNavigationVisitorResultAvailable;
|
||||
property OnDownloadImageFinished : TOnDownloadImageFinishedEvent read FOnDownloadImageFinished write FOnDownloadImageFinished;
|
||||
{$IFNDEF FPC}
|
||||
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
||||
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
||||
@ -790,7 +794,7 @@ uses
|
||||
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
|
||||
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, {$IFNDEF FPC}uCEFOLEDragAndDrop,{$ENDIF}
|
||||
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
|
||||
uCEFListValue, uCEFNavigationEntryVisitor;
|
||||
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack;
|
||||
|
||||
constructor TChromium.Create(AOwner: TComponent);
|
||||
begin
|
||||
@ -1144,6 +1148,7 @@ begin
|
||||
FOnCookiesDeleted := nil;
|
||||
FOnResolvedHostAvailable := nil;
|
||||
FOnNavigationVisitorResultAvailable := nil;
|
||||
FOnDownloadImageFinished := nil;
|
||||
{$IFNDEF FPC}
|
||||
FOnBrowserCompMsg := nil;
|
||||
FOnWidgetCompMsg := nil;
|
||||
@ -1727,6 +1732,25 @@ begin
|
||||
if Initialized then FBrowser.Host.StartDownload(aURL);
|
||||
end;
|
||||
|
||||
// Use the OnDownloadImageFinished event to receive the image
|
||||
procedure TChromium.DownloadImage(const imageUrl : ustring;
|
||||
isFavicon : boolean;
|
||||
maxImageSize : cardinal;
|
||||
bypassCache : boolean);
|
||||
var
|
||||
TempCallback : ICefDownloadImageCallback;
|
||||
begin
|
||||
try
|
||||
if Initialized and (FBrowser.Host <> nil) then
|
||||
begin
|
||||
TempCallback := TCefCustomDownloadImageCallback.Create(self);
|
||||
FBrowser.Host.DownloadImage(imageUrl, isFavicon, maxImageSize, bypassCache, TempCallback);
|
||||
end;
|
||||
finally
|
||||
TempCallback := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromium.GetIsLoading : boolean;
|
||||
begin
|
||||
Result := Initialized and FBrowser.IsLoading;
|
||||
@ -2950,6 +2974,14 @@ begin
|
||||
FOnNavigationVisitorResultAvailable(entry, current, index, total, Result);
|
||||
end;
|
||||
|
||||
procedure TChromium.doDownloadImageFinished(const imageUrl : ustring;
|
||||
httpStatusCode : Integer;
|
||||
const image : ICefImage);
|
||||
begin
|
||||
if assigned(FOnDownloadImageFinished) then
|
||||
FOnDownloadImageFinished(self, imageUrl, httpStatusCode, image);
|
||||
end;
|
||||
|
||||
function TChromium.MustCreateLoadHandler : boolean;
|
||||
begin
|
||||
Result := assigned(FOnLoadStart) or
|
||||
|
@ -168,8 +168,9 @@ type
|
||||
TOnCookiesDeletedEvent = procedure(Sender: TObject; numDeleted : integer) of object;
|
||||
TOnResolvedIPsAvailableEvent = procedure(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings) of object;
|
||||
TOnNavigationVisitorResultAvailableEvent = procedure(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer; var aResult : boolean) of object;
|
||||
TOnDownloadImageFinishedEvent = procedure(Sender: TObject; const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage) of object;
|
||||
{$IFDEF MSWINDOWS}
|
||||
TOnCompMsgEvent = procedure (var aMessage: TMessage; var aHandled: Boolean) of object;
|
||||
TOnCompMsgEvent = procedure(var aMessage: TMessage; var aHandled: Boolean) of object;
|
||||
{$ENDIF}
|
||||
|
||||
implementation
|
||||
|
@ -70,11 +70,31 @@ type
|
||||
constructor Create(const proc: TOnDownloadImageFinishedProc); reintroduce;
|
||||
end;
|
||||
|
||||
TCefCustomDownloadImageCallback = class(TCefDownloadImageCallbackOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
|
||||
procedure OnDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.SysUtils,
|
||||
{$ELSE}
|
||||
SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFImage;
|
||||
|
||||
|
||||
// TCefDownloadImageCallbackOwn
|
||||
|
||||
procedure cef_download_image_callback_on_download_image_finished( self : PCefDownloadImageCallback;
|
||||
const image_url : PCefString;
|
||||
http_status_code : Integer;
|
||||
@ -98,6 +118,9 @@ begin
|
||||
on_download_image_finished := {$IFDEF FPC}@{$ENDIF}cef_download_image_callback_on_download_image_finished;
|
||||
end;
|
||||
|
||||
|
||||
// TCefFastDownloadImageCallback
|
||||
|
||||
constructor TCefFastDownloadImageCallback.Create(const proc: TOnDownloadImageFinishedProc);
|
||||
begin
|
||||
inherited Create;
|
||||
@ -111,5 +134,37 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
// TCefCustomDownloadImageCallback
|
||||
|
||||
constructor TCefCustomDownloadImageCallback.Create(const aEvents : IChromiumEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
end;
|
||||
|
||||
destructor TCefCustomDownloadImageCallback.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCefCustomDownloadImageCallback.OnDownloadImageFinished(const imageUrl : ustring;
|
||||
httpStatusCode : Integer;
|
||||
const image : ICefImage);
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then IChromiumEvents(FEvents).doDownloadImageFinished(imageUrl, httpStatusCode, image);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefCustomDownloadImageCallback.OnDownloadImageFinished', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -223,6 +223,7 @@ type
|
||||
FOnCookiesDeleted : TOnCookiesDeletedEvent;
|
||||
FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent;
|
||||
FOnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent;
|
||||
FOnDownloadImageFinished : TOnDownloadImageFinishedEvent;
|
||||
{$IFDEF MSWINDOWS}
|
||||
FOnBrowserCompMsg : TOnCompMsgEvent;
|
||||
FOnWidgetCompMsg : TOnCompMsgEvent;
|
||||
@ -453,6 +454,7 @@ type
|
||||
function doSavePreferences : boolean; virtual;
|
||||
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual;
|
||||
function doNavigationVisitorResultAvailable(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer) : boolean; virtual;
|
||||
procedure doDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage);
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -480,6 +482,7 @@ type
|
||||
procedure ReloadIgnoreCache;
|
||||
procedure StopLoad;
|
||||
procedure StartDownload(const aURL : ustring);
|
||||
procedure DownloadImage(const imageUrl: ustring; isFavicon: Boolean; maxImageSize: cardinal; bypassCache: Boolean);
|
||||
|
||||
procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer);
|
||||
function DeleteCookies(const url : ustring = ''; const cookieName : ustring = '') : boolean;
|
||||
@ -619,6 +622,7 @@ type
|
||||
property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted;
|
||||
property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable;
|
||||
property OnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent read FOnNavigationVisitorResultAvailable write FOnNavigationVisitorResultAvailable;
|
||||
property OnDownloadImageFinishedEvent : TOnDownloadImageFinishedEvent read FOnDownloadImageFinished write FOnDownloadImageFinished;
|
||||
{$IFDEF MSWINDOWS}
|
||||
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
||||
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
||||
@ -736,7 +740,7 @@ uses
|
||||
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
|
||||
uCEFApplication, uCEFProcessMessage, uCEFRequestContext,
|
||||
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
|
||||
uCEFListValue, uCEFNavigationEntryVisitor;
|
||||
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack;
|
||||
|
||||
constructor TFMXChromium.Create(AOwner: TComponent);
|
||||
begin
|
||||
@ -1045,6 +1049,7 @@ begin
|
||||
FOnCookiesDeleted := nil;
|
||||
FOnResolvedHostAvailable := nil;
|
||||
FOnNavigationVisitorResultAvailable := nil;
|
||||
FOnDownloadImageFinished := nil;
|
||||
end;
|
||||
|
||||
function TFMXChromium.CreateBrowser(const aWindowName : ustring;
|
||||
@ -1512,6 +1517,25 @@ begin
|
||||
if Initialized then FBrowser.Host.StartDownload(aURL);
|
||||
end;
|
||||
|
||||
// Use the OnDownloadImageFinished event to receive the image
|
||||
procedure TFMXChromium.DownloadImage(const imageUrl : ustring;
|
||||
isFavicon : boolean;
|
||||
maxImageSize : cardinal;
|
||||
bypassCache : boolean);
|
||||
var
|
||||
TempCallback : ICefDownloadImageCallback;
|
||||
begin
|
||||
try
|
||||
if Initialized and (FBrowser.Host <> nil) then
|
||||
begin
|
||||
TempCallback := TCefCustomDownloadImageCallback.Create(self);
|
||||
FBrowser.Host.DownloadImage(imageUrl, isFavicon, maxImageSize, bypassCache, TempCallback);
|
||||
end;
|
||||
finally
|
||||
TempCallback := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TFMXChromium.GetIsLoading : boolean;
|
||||
begin
|
||||
Result := Initialized and FBrowser.IsLoading;
|
||||
@ -2681,6 +2705,14 @@ begin
|
||||
FOnNavigationVisitorResultAvailable(entry, current, index, total, Result);
|
||||
end;
|
||||
|
||||
procedure TFMXChromium.doDownloadImageFinished(const imageUrl : ustring;
|
||||
httpStatusCode : Integer;
|
||||
const image : ICefImage);
|
||||
begin
|
||||
if assigned(FOnDownloadImageFinished) then
|
||||
FOnDownloadImageFinished(self, imageUrl, httpStatusCode, image);
|
||||
end;
|
||||
|
||||
function TFMXChromium.MustCreateLoadHandler : boolean;
|
||||
begin
|
||||
Result := assigned(FOnLoadStart) or
|
||||
|
@ -68,10 +68,10 @@ type
|
||||
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;
|
||||
function GetRepresentationInfo(scaleFactor: Single; var actualScaleFactor: Single; var pixelWidth, pixelHeight: Integer): Boolean;
|
||||
function GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
function GetAsPng(scaleFactor: Single; withTransparency: Boolean; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
function GetAsJpeg(scaleFactor: Single; quality: Integer; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
public
|
||||
class function UnWrap(data: Pointer): ICefImage;
|
||||
class function New: ICefImage;
|
||||
@ -103,19 +103,19 @@ 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;
|
||||
function TCefImageRef.GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
begin
|
||||
Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_bitmap(FData, scaleFactor, colorType, alphaType, pixelWidth, pixelHeight));
|
||||
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;
|
||||
function TCefImageRef.GetAsJpeg(scaleFactor: Single; quality: Integer; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
begin
|
||||
Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_jpeg(FData, scaleFactor, quality, pixelWidth, pixelHeight));
|
||||
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;
|
||||
function TCefImageRef.GetAsPng(scaleFactor: Single; withTransparency: Boolean; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
begin
|
||||
Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_png(FData, scaleFactor, Ord(withTransparency), pixelWidth, pixelHeight));
|
||||
Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_png(FData, scaleFactor, Ord(withTransparency), @pixelWidth, @pixelHeight));
|
||||
end;
|
||||
|
||||
function TCefImageRef.GetHeight: NativeUInt;
|
||||
@ -123,9 +123,9 @@ begin
|
||||
Result := PCefImage(FData)^.get_height(FData);
|
||||
end;
|
||||
|
||||
function TCefImageRef.GetRepresentationInfo(scaleFactor: Single; actualScaleFactor: PSingle; pixelWidth, pixelHeight: PInteger): Boolean;
|
||||
function TCefImageRef.GetRepresentationInfo(scaleFactor: Single; var actualScaleFactor: Single; var pixelWidth, pixelHeight: Integer): Boolean;
|
||||
begin
|
||||
Result := PCefImage(FData)^.get_representation_info(FData, scaleFactor, actualScaleFactor, pixelWidth, pixelHeight) <> 0;
|
||||
Result := PCefImage(FData)^.get_representation_info(FData, scaleFactor, @actualScaleFactor, @pixelWidth, @pixelHeight) <> 0;
|
||||
end;
|
||||
|
||||
function TCefImageRef.GetWidth: NativeUInt;
|
||||
|
@ -379,6 +379,8 @@ type
|
||||
function doSavePreferences : boolean;
|
||||
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings);
|
||||
function doNavigationVisitorResultAvailable(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer) : boolean;
|
||||
procedure doDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage);
|
||||
|
||||
end;
|
||||
|
||||
IServerEvents = interface
|
||||
@ -2132,10 +2134,10 @@ type
|
||||
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;
|
||||
function GetRepresentationInfo(scaleFactor: Single; var actualScaleFactor: Single; var pixelWidth, pixelHeight: Integer): Boolean;
|
||||
function GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
function GetAsPng(scaleFactor: Single; withTransparency: Boolean; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
function GetAsJpeg(scaleFactor: Single; quality: Integer; var pixelWidth, pixelHeight: Integer): ICefBinaryValue;
|
||||
|
||||
property Width : NativeUInt read GetWidth;
|
||||
property Height : NativeUInt read GetHeight;
|
||||
|
@ -1057,7 +1057,6 @@ begin
|
||||
TempList := TStringList.Create;
|
||||
TempList.Add(TempDir + CHROMEELF_DLL);
|
||||
TempList.Add(TempDir + LIBCEF_DLL);
|
||||
TempList.Add(TempDir + 'd3dcompiler_43.dll');
|
||||
TempList.Add(TempDir + 'd3dcompiler_47.dll');
|
||||
TempList.Add(TempDir + 'libEGL.dll');
|
||||
TempList.Add(TempDir + 'libGLESv2.dll');
|
||||
|
@ -2,9 +2,9 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 7,
|
||||
"InternalVersion" : 8,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "74.1.14.0"
|
||||
"Version" : "74.1.16.0"
|
||||
}
|
||||
],
|
||||
"UpdatePackageData" : {
|
||||
|
Loading…
x
Reference in New Issue
Block a user