You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-08-04 21:32:54 +02:00
Update to CEF 89.0.17
Added an option make simple text replacements in the ResponseFilterBrowser demo
This commit is contained in:
16
README.md
16
README.md
@@ -3,15 +3,15 @@ CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chro
|
||||
|
||||
CEF4Delphi is based on DCEF3 and fpCEF3. The original license of those projects still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file.
|
||||
|
||||
CEF4Delphi uses CEF 89.0.15 which includes Chromium 89.0.4389.90.
|
||||
CEF4Delphi uses CEF 89.0.17 which includes Chromium 89.0.4389.114.
|
||||
The CEF binaries used by CEF4Delphi are available for download at spotify :
|
||||
* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.15%2Bgdef70e4%2Bchromium-89.0.4389.90_windows32.tar.bz2)
|
||||
* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.15%2Bgdef70e4%2Bchromium-89.0.4389.90_windows64.tar.bz2)
|
||||
* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.15%2Bgdef70e4%2Bchromium-89.0.4389.90_linux32.tar.bz2)
|
||||
* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.15%2Bgdef70e4%2Bchromium-89.0.4389.90_linux64.tar.bz2)
|
||||
* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.15%2Bgdef70e4%2Bchromium-89.0.4389.90_linuxarm.tar.bz2)
|
||||
* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.15%2Bgdef70e4%2Bchromium-89.0.4389.90_linuxarm64.tar.bz2)
|
||||
* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.15%2Bgdef70e4%2Bchromium-89.0.4389.90_macosx64.tar.bz2)
|
||||
* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.17%2Bge7bbb1d%2Bchromium-89.0.4389.114_windows32.tar.bz2)
|
||||
* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.17%2Bge7bbb1d%2Bchromium-89.0.4389.114_windows64.tar.bz2)
|
||||
* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.17%2Bge7bbb1d%2Bchromium-89.0.4389.114_linux32.tar.bz2)
|
||||
* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.17%2Bge7bbb1d%2Bchromium-89.0.4389.114_linux64.tar.bz2)
|
||||
* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.17%2Bge7bbb1d%2Bchromium-89.0.4389.114_linuxarm.tar.bz2)
|
||||
* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.17%2Bge7bbb1d%2Bchromium-89.0.4389.114_linuxarm64.tar.bz2)
|
||||
* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.17%2Bge7bbb1d%2Bchromium-89.0.4389.114_macosx64.tar.bz2)
|
||||
|
||||
CEF4Delphi was developed and tested on Delphi 10.4.2 and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2, Delphi 10.3 and Lazarus 2.0.12/FPC 3.2.0. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components.
|
||||
|
||||
|
@@ -3,7 +3,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
||||
Top = 0
|
||||
Caption = 'Initializing browser. Please wait...'
|
||||
ClientHeight = 710
|
||||
ClientWidth = 1038
|
||||
ClientWidth = 1054
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
@@ -21,7 +21,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
||||
object Splitter1: TSplitter
|
||||
Left = 0
|
||||
Top = 477
|
||||
Width = 1038
|
||||
Width = 1054
|
||||
Height = 3
|
||||
Cursor = crVSplit
|
||||
Align = alBottom
|
||||
@@ -31,8 +31,8 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
||||
object AddressPnl: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1038
|
||||
Height = 49
|
||||
Width = 1054
|
||||
Height = 67
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
Enabled = False
|
||||
@@ -41,34 +41,37 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
||||
Padding.Right = 5
|
||||
Padding.Bottom = 5
|
||||
TabOrder = 0
|
||||
DesignSize = (
|
||||
1054
|
||||
67)
|
||||
object AddressEdt: TEdit
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 724
|
||||
Height = 39
|
||||
Width = 735
|
||||
Height = 21
|
||||
Margins.Right = 5
|
||||
Align = alClient
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
ReadOnly = True
|
||||
TabOrder = 0
|
||||
Text = 'https://www.briskbard.com/'
|
||||
ExplicitHeight = 21
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 729
|
||||
Left = 745
|
||||
Top = 5
|
||||
Width = 304
|
||||
Height = 39
|
||||
Height = 57
|
||||
Align = alRight
|
||||
BevelOuter = bvNone
|
||||
Padding.Left = 5
|
||||
TabOrder = 1
|
||||
ExplicitLeft = 729
|
||||
ExplicitHeight = 39
|
||||
object GoBtn: TButton
|
||||
Left = 5
|
||||
Top = 0
|
||||
Width = 63
|
||||
Height = 39
|
||||
Height = 21
|
||||
Margins.Left = 5
|
||||
Align = alLeft
|
||||
Caption = 'Go'
|
||||
TabOrder = 0
|
||||
OnClick = GoBtnClick
|
||||
@@ -76,7 +79,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
||||
object RscNameEdt: TEdit
|
||||
Left = 176
|
||||
Top = 0
|
||||
Width = 129
|
||||
Width = 122
|
||||
Height = 21
|
||||
TabOrder = 1
|
||||
Text = 'script.js'
|
||||
@@ -99,38 +102,51 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
||||
Caption = 'Replace logo'
|
||||
TabOrder = 3
|
||||
end
|
||||
object ReplaceTextBtn: TRadioButton
|
||||
Left = 74
|
||||
Top = 40
|
||||
Width = 96
|
||||
Height = 17
|
||||
Caption = 'Replace text'
|
||||
TabOrder = 4
|
||||
end
|
||||
end
|
||||
end
|
||||
object CEFWindowParent1: TCEFWindowParent
|
||||
Left = 0
|
||||
Top = 49
|
||||
Width = 1038
|
||||
Height = 428
|
||||
Top = 67
|
||||
Width = 1054
|
||||
Height = 410
|
||||
Align = alClient
|
||||
TabOrder = 1
|
||||
ExplicitTop = 49
|
||||
ExplicitWidth = 1038
|
||||
ExplicitHeight = 428
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 0
|
||||
Top = 480
|
||||
Width = 1038
|
||||
Width = 1054
|
||||
Height = 230
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 2
|
||||
ExplicitWidth = 1038
|
||||
object Memo1: TMemo
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1038
|
||||
Width = 1054
|
||||
Height = 211
|
||||
Align = alClient
|
||||
ReadOnly = True
|
||||
ScrollBars = ssBoth
|
||||
TabOrder = 0
|
||||
ExplicitWidth = 1038
|
||||
end
|
||||
object StatusBar1: TStatusBar
|
||||
Left = 0
|
||||
Top = 211
|
||||
Width = 1038
|
||||
Width = 1054
|
||||
Height = 19
|
||||
Panels = <
|
||||
item
|
||||
@@ -145,6 +161,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
||||
item
|
||||
Width = 200
|
||||
end>
|
||||
ExplicitWidth = 1038
|
||||
end
|
||||
end
|
||||
object Timer1: TTimer
|
||||
|
@@ -72,6 +72,7 @@ type
|
||||
StatusBar1: TStatusBar;
|
||||
CopyScriptBtn: TRadioButton;
|
||||
ReplaceLogoBtn: TRadioButton;
|
||||
ReplaceTextBtn: TRadioButton;
|
||||
|
||||
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium1GetResourceResponseFilter(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; out Result: ICefResponseFilter);
|
||||
@@ -118,6 +119,7 @@ type
|
||||
|
||||
procedure CopyScript(data_in: Pointer; data_in_size: NativeUInt; var data_in_read: NativeUInt; data_out: Pointer; data_out_size : NativeUInt; var data_out_written: NativeUInt; var aResult : TCefResponseFilterStatus);
|
||||
procedure ReplaceLogo(data_in: Pointer; data_in_size: NativeUInt; var data_in_read: NativeUInt; data_out: Pointer; data_out_size : NativeUInt; var data_out_written: NativeUInt; var aResult : TCefResponseFilterStatus);
|
||||
procedure ReplaceBufferText(data_in: Pointer; data_in_size: NativeUInt; var data_in_read: NativeUInt; data_out: Pointer; data_out_size : NativeUInt; var data_out_written: NativeUInt; var aResult : TCefResponseFilterStatus);
|
||||
procedure UpdateRscEncoding(const aMimeType, aContentType : string);
|
||||
function IsMyResource(const aRequest : ICefRequest) : boolean;
|
||||
procedure CheckResponseHeaders(const response : ICefResponse);
|
||||
@@ -207,7 +209,11 @@ begin
|
||||
if CopyScriptBtn.Checked then
|
||||
CopyScript(data_in, data_in_size, data_in_read, data_out, data_out_size, data_out_written, aResult)
|
||||
else
|
||||
ReplaceLogo(data_in, data_in_size, data_in_read, data_out, data_out_size, data_out_written, aResult);
|
||||
if ReplaceLogoBtn.Checked then
|
||||
ReplaceLogo(data_in, data_in_size, data_in_read, data_out, data_out_size, data_out_written, aResult)
|
||||
else
|
||||
if ReplaceTextBtn.Checked then
|
||||
ReplaceBufferText(data_in, data_in_size, data_in_read, data_out, data_out_size, data_out_written, aResult);
|
||||
end;
|
||||
|
||||
procedure TResponseFilterBrowserFrm.CopyScript( data_in : Pointer;
|
||||
@@ -332,6 +338,82 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TResponseFilterBrowserFrm.ReplaceBufferText( data_in : Pointer;
|
||||
data_in_size : NativeUInt;
|
||||
var data_in_read : NativeUInt;
|
||||
data_out : Pointer;
|
||||
data_out_size : NativeUInt;
|
||||
var data_out_written : NativeUInt;
|
||||
var aResult : TCefResponseFilterStatus);
|
||||
const
|
||||
// To keep this demo as simple as possible we replace strings with the same length
|
||||
REPLACE_TEXT : AnsiString = 'Save time and effort with BriskBard';
|
||||
NEW_TEXT : AnsiString = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
|
||||
var
|
||||
TempAnsiString : AnsiString;
|
||||
TempChar : PAnsiChar;
|
||||
i : integer;
|
||||
begin
|
||||
try
|
||||
try
|
||||
FStreamCS.Acquire;
|
||||
|
||||
if FFilterInit then
|
||||
begin
|
||||
// This event will be called repeatedly until the input buffer has been fully read.
|
||||
// When there's no more data then data_in is nil and you can show the stream contents.
|
||||
|
||||
if (data_in = nil) then
|
||||
begin
|
||||
// This is the last filter call
|
||||
data_in_read := 0; // data_in_size is 0 too in this situation
|
||||
data_out_written := 0;
|
||||
aResult := RESPONSE_FILTER_DONE;
|
||||
FRscCompleted := True;
|
||||
end
|
||||
else
|
||||
if (data_out <> nil) then
|
||||
begin
|
||||
// The filter may call this function several times because it splits the resource contents in several chunks.
|
||||
// If you replace a long string it could be part of 2 or more chunks and this demo would not find it.
|
||||
|
||||
aResult := RESPONSE_FILTER_DONE;
|
||||
data_out_written := min(data_in_size, data_out_size);
|
||||
data_in_read := data_out_written;
|
||||
|
||||
if (data_out_written > 0) then
|
||||
begin
|
||||
// We assume that this is a UTF8 or Ansi string.
|
||||
// We use deprecated ansi string functions to search and replace strings but we should
|
||||
// be decoding the buffer contents to a normal string, replace the text, encode the
|
||||
// new string and copy it to the output buffer (data_out).
|
||||
|
||||
SetLength(TempAnsiString, data_out_written);
|
||||
Move(data_in^, TempAnsiString[1], data_out_written);
|
||||
TempChar := AnsiStrPos(PAnsiChar(TempAnsiString), PAnsiChar(REPLACE_TEXT));
|
||||
|
||||
if (TempChar <> nil) then
|
||||
begin
|
||||
i := (IntPtr(TempChar) - IntPtr(PAnsiChar(TempAnsiString))) div SizeOf(AnsiChar) + 1;
|
||||
TempAnsiString := copy(TempAnsiString, 1, pred(i)) + NEW_TEXT + copy(TempAnsiString, i + length(REPLACE_TEXT), data_out_written);
|
||||
end;
|
||||
|
||||
Move(TempAnsiString[1], data_out^, data_out_written);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
begin
|
||||
aResult := RESPONSE_FILTER_ERROR;
|
||||
if CustomExceptionHandler('TResponseFilterBrowserFrm.ReplaceBufferText', e) then raise;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
FStreamCS.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TResponseFilterBrowserFrm.IsMyResource(const aRequest : ICefRequest) : boolean;
|
||||
var
|
||||
TempName : string;
|
||||
@@ -346,8 +428,13 @@ begin
|
||||
Result := (pos(TempName, aRequest.URL) > 0);
|
||||
end
|
||||
else
|
||||
Result := (aRequest <> nil) and
|
||||
(CompareText(aRequest.URL, 'https://www.briskbard.com/images/logo.png') = 0);
|
||||
if ReplaceLogoBtn.Checked then
|
||||
Result := (aRequest <> nil) and
|
||||
(CompareText(aRequest.URL, 'https://www.briskbard.com/images/logo.png') = 0)
|
||||
else
|
||||
if ReplaceTextBtn.Checked then
|
||||
Result := (aRequest <> nil) and
|
||||
(CompareText(aRequest.URL, 'https://www.briskbard.com/index.php?lang=en') = 0);
|
||||
end;
|
||||
|
||||
procedure TResponseFilterBrowserFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
@@ -532,7 +619,8 @@ begin
|
||||
FRscMimeType := aMimeType;
|
||||
|
||||
{$IFDEF DELPHI15_UP}
|
||||
if (aMimeType = 'application/json') or
|
||||
if (aMimeType = 'text/html') or
|
||||
(aMimeType = 'application/json') or
|
||||
(aMimeType = 'text/json') or
|
||||
(aMimeType = 'text/javascript') or
|
||||
(aMimeType = 'application/javascript') then
|
||||
@@ -634,8 +722,8 @@ end;
|
||||
// This procedure handles the stream contents after it's fully downloaded
|
||||
procedure TResponseFilterBrowserFrm.StreamCopyCompleteMsg(var aMessage : TMessage);
|
||||
var
|
||||
LAS: AnsiString;
|
||||
LS: String;
|
||||
TempAnsiString : AnsiString;
|
||||
TempString : String;
|
||||
begin
|
||||
try
|
||||
FStreamCS.Acquire;
|
||||
@@ -655,17 +743,17 @@ begin
|
||||
begin
|
||||
StatusBar1.Panels[1].Text := 'Stream size : ' + inttostr(FStream.Size);
|
||||
|
||||
SetLength(LAS, FStream.Size);
|
||||
FStream.Read(LAS[1], FStream.Size);
|
||||
SetLength(TempAnsiString, FStream.Size);
|
||||
FStream.Read(TempAnsiString[1], FStream.Size);
|
||||
|
||||
if (FRscEncoding = TEncoding.UTF8) then
|
||||
LS := UTF8Decode(LAS) // UTF8 Here
|
||||
TempString := UTF8Decode(TempAnsiString) // UTF8 Here
|
||||
else
|
||||
LS := string(LAS); // Others encoding text
|
||||
TempString := string(TempAnsiString); // Others encoding text
|
||||
|
||||
Memo1.Lines.Add(LS);
|
||||
Memo1.Lines.Add(TempString);
|
||||
|
||||
StatusBar1.Panels[2].Text := 'Decoded size : ' + inttostr(length(LS));
|
||||
StatusBar1.Panels[2].Text := 'Decoded size : ' + inttostr(length(TempString));
|
||||
end
|
||||
else
|
||||
Memo1.Lines.LoadFromStream(FStream); // Image or others
|
||||
@@ -680,7 +768,8 @@ begin
|
||||
Memo1.Lines.Clear;
|
||||
end
|
||||
else
|
||||
StatusBar1.Panels[1].Text := 'Stream size : ' + inttostr(FStream.Size);
|
||||
if ReplaceLogoBtn.Checked then
|
||||
StatusBar1.Panels[1].Text := 'Stream size : ' + inttostr(FStream.Size);
|
||||
finally
|
||||
FStreamCS.Release;
|
||||
end;
|
||||
|
@@ -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="89" Release="15"/>
|
||||
<Version Major="89" Release="17"/>
|
||||
<Files Count="201">
|
||||
<Item1>
|
||||
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
||||
|
@@ -66,13 +66,13 @@ uses
|
||||
const
|
||||
CEF_SUPPORTED_VERSION_MAJOR = 89;
|
||||
CEF_SUPPORTED_VERSION_MINOR = 0;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 15;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 17;
|
||||
CEF_SUPPORTED_VERSION_BUILD = 0;
|
||||
|
||||
CEF_CHROMEELF_VERSION_MAJOR = 89;
|
||||
CEF_CHROMEELF_VERSION_MINOR = 0;
|
||||
CEF_CHROMEELF_VERSION_RELEASE = 4389;
|
||||
CEF_CHROMEELF_VERSION_BUILD = 90;
|
||||
CEF_CHROMEELF_VERSION_BUILD = 114;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
LIBCEF_DLL = 'libcef.dll';
|
||||
|
@@ -2,9 +2,9 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 272,
|
||||
"InternalVersion" : 273,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "89.0.15.0"
|
||||
"Version" : "89.0.17.0"
|
||||
}
|
||||
],
|
||||
"UpdatePackageData" : {
|
||||
|
Reference in New Issue
Block a user