1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-04-17 06:57:13 +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,27 +195,26 @@ end;
procedure TSimpleServerFrm.ShowPostDataInfo(const aPostData : ICefPostData); procedure TSimpleServerFrm.ShowPostDataInfo(const aPostData : ICefPostData);
var var
i, j : integer; i : integer;
TempLen : NativeUInt; TempLen : NativeUInt;
TempList : IInterfaceList;
TempElement : ICefPostDataElement;
TempBytes : TBytes; TempBytes : TBytes;
TempArray : TCefPostDataElementArray;
begin begin
if (aPostData = nil) then exit; TempArray := nil;
try
try
if (aPostData <> nil) and (aPostData.GetElementCount > 0) then
begin
aPostData.GetElements(aPostData.GetElementCount, TempArray);
i := 0; i := 0;
j := aPostData.GetCount; while (i < length(TempArray)) do
TempList := aPostData.GetElements(j);
while (i < j) do
begin begin
TempElement := TempList.Items[i] as ICefPostDataElement; if (TempArray[i].GetBytesCount > 0) then
if (TempElement.GetBytesCount > 0) then
begin begin
SetLength(TempBytes, TempElement.GetBytesCount); SetLength(TempBytes, TempArray[i].GetBytesCount);
TempLen := TempElement.GetBytes(TempElement.GetBytesCount, @TempBytes[0]); TempLen := TempArray[i].GetBytes(TempArray[i].GetBytesCount, @TempBytes[0]);
if (TempLen > 0) then if (TempLen > 0) then
begin begin
@ -226,6 +225,25 @@ begin
inc(i); inc(i);
end; end;
i := 0;
while (i < length(TempArray)) do
begin
TempArray[i] := nil;
inc(i);
end;
end;
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; end;
function TSimpleServerFrm.BufferToString(const aBuffer : TBytes) : string; function TSimpleServerFrm.BufferToString(const aBuffer : TBytes) : string;

View File

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

View File

@ -15,7 +15,7 @@ object SimpleServerFrm: TSimpleServerFrm
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '2.0.2.0' LCLVersion = '2.0.4.0'
object ButtonPnl: TPanel object ButtonPnl: TPanel
Left = 0 Left = 0
Height = 94 Height = 94

View File

@ -197,27 +197,26 @@ end;
procedure TSimpleServerFrm.ShowPostDataInfo(const aPostData : ICefPostData); procedure TSimpleServerFrm.ShowPostDataInfo(const aPostData : ICefPostData);
var var
i, j : integer; i : integer;
TempLen : NativeUInt; TempLen : NativeUInt;
TempList : IInterfaceList;
TempElement : ICefPostDataElement;
TempBytes : TBytes; TempBytes : TBytes;
TempArray : TCefPostDataElementArray;
begin begin
if (aPostData = nil) then exit; TempArray := nil;
try
try
if (aPostData <> nil) and (aPostData.GetElementCount > 0) then
begin
aPostData.GetElements(aPostData.GetElementCount, TempArray);
i := 0; i := 0;
j := aPostData.GetCount; while (i < length(TempArray)) do
TempList := aPostData.GetElements(j);
while (i < j) do
begin begin
TempElement := TempList.Items[i] as ICefPostDataElement; if (TempArray[i].GetBytesCount > 0) then
if (TempElement.GetBytesCount > 0) then
begin begin
SetLength(TempBytes, TempElement.GetBytesCount); SetLength(TempBytes, TempArray[i].GetBytesCount);
TempLen := TempElement.GetBytes(TempElement.GetBytesCount, @TempBytes[0]); TempLen := TempArray[i].GetBytes(TempArray[i].GetBytesCount, @TempBytes[0]);
if (TempLen > 0) then if (TempLen > 0) then
begin begin
@ -228,8 +227,28 @@ begin
inc(i); inc(i);
end; end;
i := 0;
while (i < length(TempArray)) do
begin
TempArray[i] := nil;
inc(i);
end;
end;
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; end;
function TSimpleServerFrm.BufferToString(const aBuffer : TBytes) : string; function TSimpleServerFrm.BufferToString(const aBuffer : TBytes) : string;
var var
i, j : integer; i, j : integer;

View File

@ -3163,7 +3163,8 @@ begin
assigned(FOnResourceResponse) or assigned(FOnResourceResponse) or
assigned(FOnGetResourceResponseFilter) or assigned(FOnGetResourceResponseFilter) or
assigned(FOnResourceLoadComplete) or assigned(FOnResourceLoadComplete) or
assigned(FOnProtocolExecution); assigned(FOnProtocolExecution) or
MustCreateCookieAccessFilter;
end; end;
function TChromium.MustCreateCookieAccessFilter : boolean; function TChromium.MustCreateCookieAccessFilter : boolean;

View File

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