From 7b82de6abeded044fc7ff40c35b4bfa013596704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Fri, 4 Oct 2019 16:49:53 +0200 Subject: [PATCH 1/2] Fixed CookieAccessFilter events not being triggered Fixed SimpleServer demo to call the updated ICefPostData function names --- .../Delphi_VCL/SimpleServer/uSimpleServer.pas | 60 +++++++++++------- demos/Lazarus/SimpleServer/SimpleServer.lps | 7 ++- demos/Lazarus/SimpleServer/uSimpleServer.lfm | 2 +- demos/Lazarus/SimpleServer/uSimpleServer.pas | 61 ++++++++++++------- source/uCEFChromium.pas | 3 +- update_CEF4Delphi.json | 2 +- 6 files changed, 87 insertions(+), 48 deletions(-) diff --git a/demos/Delphi_VCL/SimpleServer/uSimpleServer.pas b/demos/Delphi_VCL/SimpleServer/uSimpleServer.pas index 9bc581b4..de8835eb 100644 --- a/demos/Delphi_VCL/SimpleServer/uSimpleServer.pas +++ b/demos/Delphi_VCL/SimpleServer/uSimpleServer.pas @@ -195,37 +195,55 @@ end; procedure TSimpleServerFrm.ShowPostDataInfo(const aPostData : ICefPostData); var - i, j : integer; + i : integer; TempLen : NativeUInt; - TempList : IInterfaceList; - TempElement : ICefPostDataElement; TempBytes : TBytes; + TempArray : TCefPostDataElementArray; begin - if (aPostData = nil) then exit; + TempArray := nil; - i := 0; - j := aPostData.GetCount; - - TempList := aPostData.GetElements(j); - - while (i < j) do - begin - TempElement := TempList.Items[i] as ICefPostDataElement; - - if (TempElement.GetBytesCount > 0) then + try + try + if (aPostData <> nil) and (aPostData.GetElementCount > 0) then begin - SetLength(TempBytes, TempElement.GetBytesCount); - TempLen := TempElement.GetBytes(TempElement.GetBytesCount, @TempBytes[0]); + aPostData.GetElements(aPostData.GetElementCount, TempArray); - if (TempLen > 0) then + i := 0; + while (i < length(TempArray)) do begin - ConnectionLogMem.Lines.Add('Post contents length : ' + inttostr(TempLen)); - ConnectionLogMem.Lines.Add('Post contents sample : ' + BufferToString(TempBytes)); + if (TempArray[i].GetBytesCount > 0) then + begin + SetLength(TempBytes, TempArray[i].GetBytesCount); + TempLen := TempArray[i].GetBytes(TempArray[i].GetBytesCount, @TempBytes[0]); + + if (TempLen > 0) then + begin + ConnectionLogMem.Lines.Add('Post contents length : ' + inttostr(TempLen)); + ConnectionLogMem.Lines.Add('Post contents sample : ' + BufferToString(TempBytes)); + end; + end; + + inc(i); + end; + + i := 0; + while (i < length(TempArray)) do + begin + TempArray[i] := nil; + inc(i); end; end; - - inc(i); + except + on e : exception do + if CustomExceptionHandler('TSimpleServerFrm.ShowPostDataInfo', e) then raise; end; + finally + if (TempArray <> nil) then + begin + Finalize(TempArray); + TempArray := nil; + end; + end; end; function TSimpleServerFrm.BufferToString(const aBuffer : TBytes) : string; diff --git a/demos/Lazarus/SimpleServer/SimpleServer.lps b/demos/Lazarus/SimpleServer/SimpleServer.lps index 3d002d06..cabea2ef 100644 --- a/demos/Lazarus/SimpleServer/SimpleServer.lps +++ b/demos/Lazarus/SimpleServer/SimpleServer.lps @@ -8,8 +8,8 @@ - + @@ -20,9 +20,10 @@ + - - + + diff --git a/demos/Lazarus/SimpleServer/uSimpleServer.lfm b/demos/Lazarus/SimpleServer/uSimpleServer.lfm index 0445eac4..e31ae509 100644 --- a/demos/Lazarus/SimpleServer/uSimpleServer.lfm +++ b/demos/Lazarus/SimpleServer/uSimpleServer.lfm @@ -15,7 +15,7 @@ object SimpleServerFrm: TSimpleServerFrm OnCloseQuery = FormCloseQuery OnCreate = FormCreate Position = poScreenCenter - LCLVersion = '2.0.2.0' + LCLVersion = '2.0.4.0' object ButtonPnl: TPanel Left = 0 Height = 94 diff --git a/demos/Lazarus/SimpleServer/uSimpleServer.pas b/demos/Lazarus/SimpleServer/uSimpleServer.pas index a30aed12..7b179dee 100644 --- a/demos/Lazarus/SimpleServer/uSimpleServer.pas +++ b/demos/Lazarus/SimpleServer/uSimpleServer.pas @@ -197,39 +197,58 @@ end; procedure TSimpleServerFrm.ShowPostDataInfo(const aPostData : ICefPostData); var - i, j : integer; + i : integer; TempLen : NativeUInt; - TempList : IInterfaceList; - TempElement : ICefPostDataElement; TempBytes : TBytes; + TempArray : TCefPostDataElementArray; begin - if (aPostData = nil) then exit; + TempArray := nil; - i := 0; - j := aPostData.GetCount; - - TempList := aPostData.GetElements(j); - - while (i < j) do - begin - TempElement := TempList.Items[i] as ICefPostDataElement; - - if (TempElement.GetBytesCount > 0) then + try + try + if (aPostData <> nil) and (aPostData.GetElementCount > 0) then begin - SetLength(TempBytes, TempElement.GetBytesCount); - TempLen := TempElement.GetBytes(TempElement.GetBytesCount, @TempBytes[0]); + aPostData.GetElements(aPostData.GetElementCount, TempArray); - if (TempLen > 0) then + i := 0; + while (i < length(TempArray)) do begin - ConnectionLogMem.Lines.Add('Post contents length : ' + inttostr(TempLen)); - ConnectionLogMem.Lines.Add('Post contents sample : ' + BufferToString(TempBytes)); + if (TempArray[i].GetBytesCount > 0) then + begin + SetLength(TempBytes, TempArray[i].GetBytesCount); + TempLen := TempArray[i].GetBytes(TempArray[i].GetBytesCount, @TempBytes[0]); + + if (TempLen > 0) then + begin + ConnectionLogMem.Lines.Add('Post contents length : ' + inttostr(TempLen)); + ConnectionLogMem.Lines.Add('Post contents sample : ' + BufferToString(TempBytes)); + end; + end; + + inc(i); + end; + + i := 0; + while (i < length(TempArray)) do + begin + TempArray[i] := nil; + inc(i); end; end; - - inc(i); + except + on e : exception do + if CustomExceptionHandler('TSimpleServerFrm.ShowPostDataInfo', e) then raise; end; + finally + if (TempArray <> nil) then + begin + Finalize(TempArray); + TempArray := nil; + end; + end; end; + function TSimpleServerFrm.BufferToString(const aBuffer : TBytes) : string; var i, j : integer; diff --git a/source/uCEFChromium.pas b/source/uCEFChromium.pas index 8fa9b820..72ee1598 100644 --- a/source/uCEFChromium.pas +++ b/source/uCEFChromium.pas @@ -3163,7 +3163,8 @@ begin assigned(FOnResourceResponse) or assigned(FOnGetResourceResponseFilter) or assigned(FOnResourceLoadComplete) or - assigned(FOnProtocolExecution); + assigned(FOnProtocolExecution) or + MustCreateCookieAccessFilter; end; function TChromium.MustCreateCookieAccessFilter : boolean; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 91dc2f25..20b60941 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 33, + "InternalVersion" : 34, "Name" : "cef4delphi_lazarus.lpk", "Version" : "76.1.13.0" } From 567af390ef878a1c5249700c5b3b367c1c641a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Fri, 4 Oct 2019 16:54:34 +0200 Subject: [PATCH 2/2] Fixed CookieAccessFilter events not being triggered in TFMXChromium --- source/uCEFFMXChromium.pas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/uCEFFMXChromium.pas b/source/uCEFFMXChromium.pas index 3c843f02..a6be1e61 100644 --- a/source/uCEFFMXChromium.pas +++ b/source/uCEFFMXChromium.pas @@ -2882,7 +2882,8 @@ begin assigned(FOnResourceResponse) or assigned(FOnGetResourceResponseFilter) or assigned(FOnResourceLoadComplete) or - assigned(FOnProtocolExecution); + assigned(FOnProtocolExecution) or + MustCreateCookieAccessFilter; end; function TFMXChromium.MustCreateCookieAccessFilter : boolean;