1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2024-11-24 08:02:15 +02:00

Fixed CookieAccessFilter events not being triggered

Fixed SimpleServer demo to call the updated ICefPostData function names
This commit is contained in:
Salvador Díaz Fau 2019-10-04 16:49:53 +02:00
parent 437c3bf4c0
commit 7b82de6abe
6 changed files with 87 additions and 48 deletions

View File

@ -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;

View File

@ -8,8 +8,8 @@
<Unit0>
<Filename Value="SimpleServer.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<TopLine Value="38"/>
<CursorPos X="65" Y="54"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
@ -20,9 +20,10 @@
<ComponentName Value="SimpleServerFrm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="113"/>
<CursorPos X="46" Y="290"/>
<TopLine Value="194"/>
<CursorPos Y="250"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 33,
"InternalVersion" : 34,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "76.1.13.0"
}