1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-08-14 21:42:50 +02:00

Update to CEF 77.1.13

- Added TChromium.OnRequestContextInitialized
- Added TChromium.OnBeforePluginLoad
- Added TChromium.ReqContextHandler
- Removed GlobalCEFApp.ShutdownWaitTime
This commit is contained in:
Salvador Díaz Fau
2019-10-11 17:51:16 +02:00
parent 096b2c9a4b
commit 9391d68ee0
15 changed files with 588 additions and 163 deletions

View File

@@ -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 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 77.1.12 which includes Chromium 77.0.3865.90. CEF4Delphi uses CEF 77.1.13 which includes Chromium 77.0.3865.90.
The CEF binaries used by CEF4Delphi are available for download at spotify : The CEF binaries used by CEF4Delphi are available for download at spotify :
* [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_77.1.12%2Bgc63c001%2Bchromium-77.0.3865.90_windows32.tar.bz2) * [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_77.1.13%2Bg676b147%2Bchromium-77.0.3865.90_windows32.tar.bz2)
* [64 bits](http://opensource.spotify.com/cefbuilds/cef_binary_77.1.12%2Bgc63c001%2Bchromium-77.0.3865.90_windows64.tar.bz2) * [64 bits](http://opensource.spotify.com/cefbuilds/cef_binary_77.1.13%2Bg676b147%2Bchromium-77.0.3865.90_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.4/FPC 3.0.4. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components. 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.4/FPC 3.0.4. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components.

View File

@@ -290,6 +290,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnCertificateError = Chromium1CertificateError OnCertificateError = Chromium1CertificateError
OnBeforeResourceLoad = Chromium1BeforeResourceLoad OnBeforeResourceLoad = Chromium1BeforeResourceLoad
OnResourceResponse = Chromium1ResourceResponse OnResourceResponse = Chromium1ResourceResponse
OnBeforePluginLoad = Chromium1BeforePluginLoad
Left = 32 Left = 32
Top = 224 Top = 224
end end

View File

@@ -228,6 +228,10 @@ type
procedure Flushcookies1Click(Sender: TObject); procedure Flushcookies1Click(Sender: TObject);
procedure Chromium1CookiesFlushed(Sender: TObject); procedure Chromium1CookiesFlushed(Sender: TObject);
procedure CEFSentinel1Close(Sender: TObject); procedure CEFSentinel1Close(Sender: TObject);
procedure Chromium1BeforePluginLoad(Sender: TObject; const mimeType,
pluginUrl: ustring; isMainFrame: Boolean;
const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo;
var pluginPolicy: TCefPluginPolicy; var aResult: Boolean);
protected protected
FResponse : TStringList; FResponse : TStringList;
@@ -443,6 +447,22 @@ begin
callback.cont(TempFullPath, False); callback.cont(TempFullPath, False);
end; end;
procedure TMiniBrowserFrm.Chromium1BeforePluginLoad(Sender: TObject;
const mimeType, pluginUrl: ustring; isMainFrame: Boolean;
const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo;
var pluginPolicy: TCefPluginPolicy; var aResult: Boolean);
begin
// Always allow the PDF plugin to load.
if (pluginPolicy <> PLUGIN_POLICY_ALLOW) and
(CompareText(mimeType, 'application/pdf') = 0) then
begin
pluginPolicy := PLUGIN_POLICY_ALLOW;
aResult := True;
end
else
aResult := False;
end;
procedure TMiniBrowserFrm.Chromium1BeforeResourceLoad(Sender: TObject; procedure TMiniBrowserFrm.Chromium1BeforeResourceLoad(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame; const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const callback: ICefRequestCallback; const request: ICefRequest; const callback: ICefRequestCallback;

View File

@@ -22,12 +22,12 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<TopLine Value="383"/> <TopLine Value="995"/>
<CursorPos Y="400"/> <CursorPos Y="1002"/>
<UsageCount Value="20"/> <UsageCount Value="20"/>
<Bookmarks Count="2"> <Bookmarks Count="2">
<Item0 X="41" Y="989" ID="1"/> <Item0 X="41" Y="993" ID="1"/>
<Item1 Y="400" ID="2"/> <Item1 Y="404" ID="2"/>
</Bookmarks> </Bookmarks>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@@ -191,15 +191,15 @@
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="uMiniBrowser.pas"/> <Filename Value="uMiniBrowser.pas"/>
<Caret Line="992" Column="5" TopLine="1038"/> <Caret Line="401" TopLine="396"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="uMiniBrowser.pas"/> <Filename Value="uMiniBrowser.pas"/>
<Caret Line="401" TopLine="396"/> <Caret Line="989" Column="44" TopLine="989"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="uMiniBrowser.pas"/> <Filename Value="uMiniBrowser.pas"/>
<Caret Line="989" Column="44" TopLine="989"/> <Caret Line="406" Column="110" TopLine="387"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
<RunParams> <RunParams>

View File

@@ -263,6 +263,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnCertificateError = Chromium1CertificateError OnCertificateError = Chromium1CertificateError
OnBeforeResourceLoad = Chromium1BeforeResourceLoad OnBeforeResourceLoad = Chromium1BeforeResourceLoad
OnResourceResponse = Chromium1ResourceResponse OnResourceResponse = Chromium1ResourceResponse
OnBeforePluginLoad = Chromium1BeforePluginLoad
left = 32 left = 32
top = 224 top = 224
end end

View File

@@ -125,6 +125,10 @@ type
N5: TMenuItem; N5: TMenuItem;
Memoryinfo1: TMenuItem; Memoryinfo1: TMenuItem;
procedure CEFSentinel1Close(Sender: TObject); procedure CEFSentinel1Close(Sender: TObject);
procedure Chromium1BeforePluginLoad(Sender: TObject; const mimeType,
pluginUrl: ustring; isMainFrame: boolean; const topOriginUrl: ustring;
const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy;
var aResult: boolean);
procedure Chromium1CookiesFlushed(Sender: TObject); procedure Chromium1CookiesFlushed(Sender: TObject);
procedure Chromium1DownloadImageFinished(Sender: TObject; procedure Chromium1DownloadImageFinished(Sender: TObject;
const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage);
@@ -989,6 +993,22 @@ begin
PostMessage(Handle, WM_CLOSE, 0, 0); PostMessage(Handle, WM_CLOSE, 0, 0);
end; end;
procedure TMiniBrowserFrm.Chromium1BeforePluginLoad(Sender: TObject;
const mimeType, pluginUrl: ustring; isMainFrame: boolean;
const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo;
var pluginPolicy: TCefPluginPolicy; var aResult: boolean);
begin
// Always allow the PDF plugin to load.
if (pluginPolicy <> PLUGIN_POLICY_ALLOW) and
(CompareText(mimeType, 'application/pdf') = 0) then
begin
pluginPolicy := PLUGIN_POLICY_ALLOW;
aResult := True;
end
else
aResult := False;
end;
procedure TMiniBrowserFrm.CookiesFlushedMsg(var aMessage : TMessage); procedure TMiniBrowserFrm.CookiesFlushedMsg(var aMessage : TMessage);
begin begin
showmessage('The cookies were flushed successfully'); showmessage('The cookies were flushed successfully');

View File

@@ -8,7 +8,7 @@
<Unit0> <Unit0>
<Filename Value="PopupBrowser2.lpr"/> <Filename Value="PopupBrowser2.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<TopLine Value="42"/> <TopLine Value="38"/>
<CursorPos X="61" Y="64"/> <CursorPos X="61" Y="64"/>
<UsageCount Value="22"/> <UsageCount Value="22"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@@ -22,8 +22,8 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<TopLine Value="320"/> <TopLine Value="307"/>
<CursorPos X="17" Y="344"/> <CursorPos Y="328"/>
<UsageCount Value="22"/> <UsageCount Value="22"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@@ -35,9 +35,9 @@
<ComponentName Value="ChildForm"/> <ComponentName Value="ChildForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="2"/> <EditorIndex Value="3"/>
<TopLine Value="82"/> <TopLine Value="52"/>
<CursorPos Y="184"/> <CursorPos X="54" Y="97"/>
<UsageCount Value="22"/> <UsageCount Value="22"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@@ -52,10 +52,11 @@
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="..\..\..\source\uCEFChromium.pas"/> <Filename Value="..\..\..\source\uCEFChromium.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="2"/>
<TopLine Value="1016"/> <TopLine Value="3887"/>
<CursorPos Y="1028"/> <CursorPos X="61" Y="3906"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="..\..\..\source\uCEFMiscFunctions.pas"/> <Filename Value="..\..\..\source\uCEFMiscFunctions.pas"/>
@@ -83,123 +84,123 @@
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="295" Column="27" TopLine="280"/> <Caret Line="224" Column="25" TopLine="204"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="298" Column="15" TopLine="280"/> <Caret Line="277" Column="13" TopLine="257"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="86" Column="15" TopLine="75"/> <Caret Line="292" Column="19" TopLine="272"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="223" Column="26" TopLine="203"/> <Caret Line="294" Column="19" TopLine="274"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="224" Column="25" TopLine="204"/> <Caret Line="295" Column="19" TopLine="275"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="277" Column="13" TopLine="257"/> <Caret Line="298" Column="15" TopLine="278"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="292" Column="19" TopLine="272"/> <Caret Line="86" Column="15" TopLine="75"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="294" Column="19" TopLine="274"/> <Caret Line="223" Column="26" TopLine="203"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="295" Column="19" TopLine="275"/> <Caret Line="224" Column="25" TopLine="204"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="298" Column="15" TopLine="278"/> <Caret Line="277" Column="13" TopLine="257"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="86" Column="15" TopLine="75"/> <Caret Line="292" TopLine="281"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="223" Column="26" TopLine="203"/> <Caret Line="295" TopLine="281"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="uMainForm.pas"/> <Filename Value="uChildForm.pas"/>
<Caret Line="224" Column="25" TopLine="204"/> <Caret Line="62" Column="23" TopLine="54"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="uMainForm.pas"/> <Filename Value="uChildForm.pas"/>
<Caret Line="277" Column="13" TopLine="257"/> <Caret Line="222" Column="3" TopLine="220"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="uMainForm.pas"/> <Filename Value="uChildForm.pas"/>
<Caret Line="292" TopLine="281"/> <Caret Line="77" Column="22" TopLine="48"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="295" TopLine="281"/> <Caret Line="286" Column="54" TopLine="260"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="uChildForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="62" Column="23" TopLine="54"/> <Caret Line="98" Column="33" TopLine="77"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="uChildForm.pas"/> <Filename Value="uChildForm.pas"/>
<Caret Line="222" Column="3" TopLine="220"/> <Caret Line="78" Column="22" TopLine="71"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="uChildForm.pas"/> <Filename Value="uChildForm.pas"/>
<Caret Line="77" Column="22" TopLine="48"/> <Caret Line="253" Column="14" TopLine="231"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="286" Column="54" TopLine="260"/> <Caret Line="76" Column="384" TopLine="70"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="uMainForm.pas"/> <Filename Value="uChildForm.pas"/>
<Caret Line="98" Column="33" TopLine="77"/> <Caret Line="250" Column="32" TopLine="223"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="uChildForm.pas"/> <Filename Value="uChildForm.pas"/>
<Caret Line="78" Column="22" TopLine="71"/> <Caret Line="62" Column="384" TopLine="51"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="uChildForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="253" Column="14" TopLine="231"/> <Caret Line="199" Column="59" TopLine="183"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="76" Column="384" TopLine="70"/> <Caret Line="344" Column="17" TopLine="320"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="uChildForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="250" Column="32" TopLine="223"/> <Caret Line="346" Column="19" TopLine="322"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="uChildForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="62" Column="384" TopLine="51"/> <Caret Line="197" Column="72" TopLine="182"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="199" Column="59" TopLine="183"/> <Caret Line="352" Column="56" TopLine="322"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="344" Column="17" TopLine="320"/> <Caret Line="332" TopLine="310"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="346" Column="19" TopLine="322"/> <Caret Line="334" Column="51" TopLine="310"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="197" Column="72" TopLine="182"/> <Caret Line="67" TopLine="49"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
<RunParams> <RunParams>

View File

@@ -21,7 +21,7 @@
</CompilerOptions> </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."/> <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"/> <License Value="MPL 1.1"/>
<Version Major="77" Minor="1" Release="12"/> <Version Major="77" Minor="1" Release="13"/>
<Files Count="144"> <Files Count="144">
<Item1> <Item1>
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/> <Filename Value="..\source\uCEFAccessibilityHandler.pas"/>

View File

@@ -62,7 +62,7 @@ uses
const const
CEF_SUPPORTED_VERSION_MAJOR = 77; CEF_SUPPORTED_VERSION_MAJOR = 77;
CEF_SUPPORTED_VERSION_MINOR = 1; CEF_SUPPORTED_VERSION_MINOR = 1;
CEF_SUPPORTED_VERSION_RELEASE = 12; CEF_SUPPORTED_VERSION_RELEASE = 13;
CEF_SUPPORTED_VERSION_BUILD = 0; CEF_SUPPORTED_VERSION_BUILD = 0;
CEF_CHROMEELF_VERSION_MAJOR = 77; CEF_CHROMEELF_VERSION_MAJOR = 77;
@@ -158,7 +158,6 @@ type
FStatus : TCefAplicationStatus; FStatus : TCefAplicationStatus;
FMissingLibFiles : string; FMissingLibFiles : string;
FProcessType : TCefProcessType; FProcessType : TCefProcessType;
FShutdownWaitTime : cardinal;
FWidevinePath : ustring; FWidevinePath : ustring;
FMustFreeLibrary : boolean; FMustFreeLibrary : boolean;
FAutoplayPolicy : TCefAutoplayPolicy; FAutoplayPolicy : TCefAutoplayPolicy;
@@ -433,7 +432,6 @@ type
property OsmodalLoop : boolean write SetOsmodalLoop; property OsmodalLoop : boolean write SetOsmodalLoop;
property Status : TCefAplicationStatus read FStatus; property Status : TCefAplicationStatus read FStatus;
property MissingLibFiles : string read FMissingLibFiles; property MissingLibFiles : string read FMissingLibFiles;
property ShutdownWaitTime : cardinal read FShutdownWaitTime write FShutdownWaitTime;
property WidevinePath : ustring read FWidevinePath write FWidevinePath; property WidevinePath : ustring read FWidevinePath write FWidevinePath;
property MustFreeLibrary : boolean read FMustFreeLibrary write FMustFreeLibrary; property MustFreeLibrary : boolean read FMustFreeLibrary write FMustFreeLibrary;
property AutoplayPolicy : TCefAutoplayPolicy read FAutoplayPolicy write FAutoplayPolicy; property AutoplayPolicy : TCefAutoplayPolicy read FAutoplayPolicy write FAutoplayPolicy;
@@ -606,7 +604,6 @@ begin
FDisableGPUCache := True; FDisableGPUCache := True;
FLocalesRequired := ''; FLocalesRequired := '';
FProcessType := ParseProcessType; FProcessType := ParseProcessType;
FShutdownWaitTime := 0;
FWidevinePath := ''; FWidevinePath := '';
FMustFreeLibrary := False; FMustFreeLibrary := False;
FAutoplayPolicy := appDefault; FAutoplayPolicy := appDefault;
@@ -694,12 +691,7 @@ end;
destructor TCefApplication.Destroy; destructor TCefApplication.Destroy;
begin begin
try try
if (FProcessType = ptBrowser) then if (FProcessType = ptBrowser) then ShutDown;
begin
if (FShutdownWaitTime > 0) then sleep(FShutdownWaitTime);
ShutDown;
end;
FreeLibcefLibrary; FreeLibcefLibrary;
@@ -1030,7 +1022,7 @@ end;
procedure TCefApplication.SetOsmodalLoop(aValue : boolean); procedure TCefApplication.SetOsmodalLoop(aValue : boolean);
begin begin
if FLibLoaded then cef_set_osmodal_loop(Ord(aValue)); if (FStatus = asInitialized) then cef_set_osmodal_loop(Ord(aValue));
end; end;
procedure TCefApplication.UpdateDeviceScaleFactor; procedure TCefApplication.UpdateDeviceScaleFactor;
@@ -1041,8 +1033,11 @@ end;
procedure TCefApplication.ShutDown; procedure TCefApplication.ShutDown;
begin begin
try try
FStatus := asShuttingDown; if (FStatus = asInitialized) then
if FLibLoaded then cef_shutdown(); begin
FStatus := asShuttingDown;
cef_shutdown();
end;
except except
on e : exception do on e : exception do
if CustomExceptionHandler('TCefApplication.ShutDown', e) then raise; if CustomExceptionHandler('TCefApplication.ShutDown', e) then raise;
@@ -2000,7 +1995,7 @@ begin
FStatus := asErrorDLLVersion; FStatus := asErrorDLLVersion;
TempString := 'Unsupported CEF version !' + TempString := 'Unsupported CEF version !' +
CRLF + CRLF + CRLF + CRLF +
'Use only the CEF3 binaries specified in the CEF4Delphi Readme.md file at ' + 'Use only the CEF binaries specified in the CEF4Delphi Readme.md file at ' +
CRLF + CEF4DELPHI_URL; CRLF + CEF4DELPHI_URL;
ShowErrorMessageDlg(TempString); ShowErrorMessageDlg(TempString);

View File

@@ -72,6 +72,7 @@ type
FHandler : ICefClient; FHandler : ICefClient;
FBrowser : ICefBrowser; FBrowser : ICefBrowser;
FBrowserId : Integer; FBrowserId : Integer;
FReqContextHandler : ICefRequestContextHandler;
FDefaultUrl : ustring; FDefaultUrl : ustring;
FOptions : TChromiumOptions; FOptions : TChromiumOptions;
FFontOptions : TChromiumFontOptions; FFontOptions : TChromiumFontOptions;
@@ -237,6 +238,10 @@ type
// ICefFindHandler // ICefFindHandler
FOnFindResult : TOnFindResult; FOnFindResult : TOnFindResult;
// ICefRequestContextHandler
FOnRequestContextInitialized : TOnRequestContextInitialized;
FOnBeforePluginLoad : TOnBeforePluginLoad;
// Custom // Custom
FOnTextResultAvailable : TOnTextResultAvailableEvent; FOnTextResultAvailable : TOnTextResultAvailableEvent;
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
@@ -311,14 +316,16 @@ type
procedure SetSafeSearch(aValue : boolean); procedure SetSafeSearch(aValue : boolean);
procedure SetYouTubeRestrict(aValue : integer); procedure SetYouTubeRestrict(aValue : integer);
procedure SetPrintingEnabled(aValue : boolean); procedure SetPrintingEnabled(aValue : boolean);
procedure SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized);
procedure SetOnBeforePluginLoad(const aValue : TOnBeforePluginLoad);
function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean; function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean;
function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): Boolean; function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): Boolean;
procedure DestroyClientHandler; procedure DestroyClientHandler;
procedure DestroyReqContextHandler;
procedure ClearBrowserReference; procedure ClearBrowserReference;
procedure CreateReqContextHandler;
procedure InitializeEvents; procedure InitializeEvents;
procedure InitializeSettings(var aSettings : TCefBrowserSettings); procedure InitializeSettings(var aSettings : TCefBrowserSettings);
@@ -478,6 +485,11 @@ type
// ICefFindHandler // ICefFindHandler
procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual; procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual;
// ICefRequestContextHandler
procedure doOnRequestContextInitialized(const request_context: ICefRequestContext); virtual;
function doOnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; virtual;
procedure doGetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); virtual;
// Custom // Custom
procedure doCookiesDeleted(numDeleted : integer); virtual; procedure doCookiesDeleted(numDeleted : integer); virtual;
procedure doPdfPrintFinished(aResultOK : boolean); virtual; procedure doPdfPrintFinished(aResultOK : boolean); virtual;
@@ -507,6 +519,7 @@ type
function MustCreateFindHandler : boolean; virtual; function MustCreateFindHandler : boolean; virtual;
function MustCreateResourceRequestHandler : boolean; virtual; function MustCreateResourceRequestHandler : boolean; virtual;
function MustCreateCookieAccessFilter : boolean; virtual; function MustCreateCookieAccessFilter : boolean; virtual;
function MustCreateRequestContextHandler : boolean; virtual;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
@@ -636,6 +649,7 @@ type
property BrowserId : integer read FBrowserId; property BrowserId : integer read FBrowserId;
property Browser : ICefBrowser read FBrowser; property Browser : ICefBrowser read FBrowser;
property CefClient : ICefClient read FHandler; property CefClient : ICefClient read FHandler;
property ReqContextHandler : ICefRequestContextHandler read FReqContextHandler;
property CefWindowInfo : TCefWindowInfo read FWindowInfo; property CefWindowInfo : TCefWindowInfo read FWindowInfo;
property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry;
property MultithreadApp : boolean read GetMultithreadApp; property MultithreadApp : boolean read GetMultithreadApp;
@@ -816,6 +830,10 @@ type
// ICefFindHandler // ICefFindHandler
property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult; property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult;
// ICefRequestContextHandler
property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized;
property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad;
end; end;
{$IFDEF FPC} {$IFDEF FPC}
@@ -833,7 +851,8 @@ uses
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame, uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, {$IFNDEF FPC}uCEFOLEDragAndDrop,{$ENDIF} uCEFApplication, uCEFProcessMessage, uCEFRequestContext, {$IFNDEF FPC}uCEFOLEDragAndDrop,{$ENDIF}
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor, uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack, uCEFCookieManager; uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack, uCEFCookieManager,
uCEFRequestContextHandler;
constructor TChromium.Create(AOwner: TComponent); constructor TChromium.Create(AOwner: TComponent);
begin begin
@@ -845,6 +864,7 @@ begin
FIsOSR := False; FIsOSR := False;
FDefaultUrl := 'about:blank'; FDefaultUrl := 'about:blank';
FHandler := nil; FHandler := nil;
FReqContextHandler := nil;
FOptions := nil; FOptions := nil;
FFontOptions := nil; FFontOptions := nil;
FDefaultEncoding := ''; FDefaultEncoding := '';
@@ -967,6 +987,7 @@ begin
{$ENDIF} {$ENDIF}
DestroyClientHandler; DestroyClientHandler;
DestroyReqContextHandler;
inherited BeforeDestruction; inherited BeforeDestruction;
end; end;
@@ -1007,6 +1028,27 @@ begin
end; end;
end; end;
procedure TChromium.DestroyReqContextHandler;
begin
try
if (FReqContextHandler <> nil) then
begin
FReqContextHandler.RemoveReferences;
FReqContextHandler := nil;
end;
except
on e : exception do
if CustomExceptionHandler('TChromium.DestroyReqContextHandler', e) then raise;
end;
end;
procedure TChromium.CreateReqContextHandler;
begin
if MustCreateRequestContextHandler and
(FReqContextHandler = nil) then
FReqContextHandler := TCustomRequestContextHandler.Create(self);
end;
procedure TChromium.AfterConstruction; procedure TChromium.AfterConstruction;
{$IFDEF FPC} {$IFDEF FPC}
var var
@@ -1170,6 +1212,10 @@ begin
// ICefFindHandler // ICefFindHandler
FOnFindResult := nil; FOnFindResult := nil;
// ICefRequestContextHandler
FOnRequestContextInitialized := nil;
FOnBeforePluginLoad := nil;
// Custom // Custom
FOnTextResultAvailable := nil; FOnTextResultAvailable := nil;
FOnPdfPrintFinished := nil; FOnPdfPrintFinished := nil;
@@ -1216,36 +1262,57 @@ function TChromium.CreateBrowser( aParentHandle : HWND;
const aWindowName : ustring; const aWindowName : ustring;
const aContext : ICefRequestContext; const aContext : ICefRequestContext;
const aExtraInfo : ICefDictionaryValue) : boolean; const aExtraInfo : ICefDictionaryValue) : boolean;
var
TempNewContext, TempGlobalContext : ICefRequestContext;
begin begin
Result := False; Result := False;
TempNewContext := nil;
try try
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser try
// even if you use a custom request context. // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
// If you create a browser in the initialization of your app, make sure you call this // even if you use a custom request context.
// function when GlobalCEFApp.GlobalContextInitialized is TRUE. // If you create a browser in the initialization of your app, make sure you call this
// Use the GlobalCEFApp.OnContextInitialized event to know when // function when GlobalCEFApp.GlobalContextInitialized is TRUE.
// GlobalCEFApp.GlobalContextInitialized is set to TRUE. // Use the GlobalCEFApp.OnContextInitialized event to know when
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
if not(csDesigning in ComponentState) and if not(csDesigning in ComponentState) and
not(FClosing) and not(FClosing) and
(FBrowser = nil) and (FBrowser = nil) and
(FBrowserId = 0) and (FBrowserId = 0) and
(GlobalCEFApp <> nil) and (GlobalCEFApp <> nil) and
GlobalCEFApp.GlobalContextInitialized and GlobalCEFApp.GlobalContextInitialized and
CreateClientHandler(aParentHandle = 0) then CreateClientHandler(aParentHandle = 0) then
begin begin
GetSettings(FBrowserSettings); GetSettings(FBrowserSettings);
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName); InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
if GlobalCEFApp.MultiThreadedMessageLoop then if (aContext = nil) then
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext) begin
else CreateReqContextHandler;
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext);
end; if (FReqContextHandler <> nil) then
except begin
on e : exception do TempGlobalContext := TCefRequestContextRef.Global();
if CustomExceptionHandler('TChromium.CreateBrowser', e) then raise; TempNewContext := TCefRequestContextRef.Shared(TempGlobalContext, FReqContextHandler);
end;
end
else
TempNewContext := aContext;
if GlobalCEFApp.MultiThreadedMessageLoop then
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, TempNewContext)
else
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, TempNewContext);
end;
except
on e : exception do
if CustomExceptionHandler('TChromium.CreateBrowser', e) then raise;
end;
finally
TempGlobalContext := nil;
TempNewContext := nil;
end; end;
end; end;
@@ -2087,6 +2154,20 @@ begin
end; end;
end; end;
procedure TChromium.SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized);
begin
FOnRequestContextInitialized := aValue;
CreateReqContextHandler;
end;
procedure TChromium.SetOnBeforePluginLoad(const aValue : TOnBeforePluginLoad);
begin
FOnBeforePluginLoad := aValue;
CreateReqContextHandler;
end;
procedure TChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); procedure TChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy);
begin begin
if (FWebRTCIPHandlingPolicy <> aValue) then if (FWebRTCIPHandlingPolicy <> aValue) then
@@ -3311,6 +3392,12 @@ begin
assigned(FOnCanSaveCookie); assigned(FOnCanSaveCookie);
end; end;
function TChromium.MustCreateRequestContextHandler : boolean;
begin
Result := assigned(FOnRequestContextInitialized) or
assigned(FOnBeforePluginLoad);
end;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
procedure TChromium.PrefsAvailableMsg(var aMessage : TMessage); procedure TChromium.PrefsAvailableMsg(var aMessage : TMessage);
begin begin
@@ -3810,6 +3897,37 @@ begin
FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate); FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate);
end; end;
procedure TChromium.doOnRequestContextInitialized(const request_context: ICefRequestContext);
begin
if assigned(FOnRequestContextInitialized) then FOnRequestContextInitialized(self, request_context);
end;
function TChromium.doOnBeforePluginLoad(const mimeType : ustring;
const pluginUrl : ustring;
isMainFrame : boolean;
const topOriginUrl : ustring;
const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean;
begin
Result := False;
if assigned(FOnBeforePluginLoad) then
FOnBeforePluginLoad(self, mimeType, pluginUrl, isMainFrame, topOriginUrl, pluginInfo, pluginPolicy, Result);
end;
procedure TChromium.doGetResourceRequestHandler(const browser : ICefBrowser;
const frame : ICefFrame;
const request : ICefRequest;
is_navigation : boolean;
is_download : boolean;
const request_initiator : ustring;
var disable_default_handling : boolean;
var aResourceRequestHandler : ICefResourceRequestHandler);
begin
disable_default_handling := False;
aResourceRequestHandler := nil;
end;
procedure TChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); procedure TChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
begin begin
if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen); if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen);

View File

@@ -161,6 +161,10 @@ type
// ICefFindHandler // ICefFindHandler
TOnFindResult = procedure(Sender: TObject; const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean) of Object; TOnFindResult = procedure(Sender: TObject; const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean) of Object;
// ICefRequestContextHandler
TOnRequestContextInitialized = procedure(Sender: TObject; const request_context: ICefRequestContext) of Object;
TOnBeforePluginLoad = procedure(Sender: TObject; const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy; var aResult : boolean) of Object;
// Custom // Custom
TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object; TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object;
TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object; TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object;

View File

@@ -61,6 +61,7 @@ type
FHandler : ICefClient; FHandler : ICefClient;
FBrowser : ICefBrowser; FBrowser : ICefBrowser;
FBrowserId : Integer; FBrowserId : Integer;
FReqContextHandler : ICefRequestContextHandler;
FDefaultUrl : ustring; FDefaultUrl : ustring;
FOptions : TChromiumOptions; FOptions : TChromiumOptions;
FFontOptions : TChromiumFontOptions; FFontOptions : TChromiumFontOptions;
@@ -221,6 +222,10 @@ type
// ICefFindHandler // ICefFindHandler
FOnFindResult : TOnFindResult; FOnFindResult : TOnFindResult;
// ICefRequestContextHandler
FOnRequestContextInitialized : TOnRequestContextInitialized;
FOnBeforePluginLoad : TOnBeforePluginLoad;
// Custom // Custom
FOnTextResultAvailable : TOnTextResultAvailableEvent; FOnTextResultAvailable : TOnTextResultAvailableEvent;
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
@@ -294,14 +299,16 @@ type
procedure SetSafeSearch(aValue : boolean); procedure SetSafeSearch(aValue : boolean);
procedure SetYouTubeRestrict(aValue : integer); procedure SetYouTubeRestrict(aValue : integer);
procedure SetPrintingEnabled(aValue : boolean); procedure SetPrintingEnabled(aValue : boolean);
procedure SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized);
procedure SetOnBeforePluginLoad(const aValue : TOnBeforePluginLoad);
function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean; function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean;
function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean; function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean;
procedure DestroyClientHandler; procedure DestroyClientHandler;
procedure DestroyReqContextHandler;
procedure ClearBrowserReference; procedure ClearBrowserReference;
procedure CreateReqContextHandler;
procedure InitializeEvents; procedure InitializeEvents;
procedure InitializeSettings(var aSettings : TCefBrowserSettings); procedure InitializeSettings(var aSettings : TCefBrowserSettings);
@@ -445,6 +452,11 @@ type
// ICefFindHandler // ICefFindHandler
procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual; procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual;
// ICefRequestContextHandler
procedure doOnRequestContextInitialized(const request_context: ICefRequestContext); virtual;
function doOnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; virtual;
procedure doGetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); virtual;
// Custom // Custom
procedure doCookiesDeleted(numDeleted : integer); virtual; procedure doCookiesDeleted(numDeleted : integer); virtual;
procedure doPdfPrintFinished(aResultOK : boolean); virtual; procedure doPdfPrintFinished(aResultOK : boolean); virtual;
@@ -474,6 +486,7 @@ type
function MustCreateFindHandler : boolean; virtual; function MustCreateFindHandler : boolean; virtual;
function MustCreateResourceRequestHandler : boolean; virtual; function MustCreateResourceRequestHandler : boolean; virtual;
function MustCreateCookieAccessFilter : boolean; virtual; function MustCreateCookieAccessFilter : boolean; virtual;
function MustCreateRequestContextHandler : boolean; virtual;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
@@ -596,6 +609,7 @@ type
property BrowserId : integer read FBrowserId; property BrowserId : integer read FBrowserId;
property Browser : ICefBrowser read FBrowser; property Browser : ICefBrowser read FBrowser;
property CefClient : ICefClient read FHandler; property CefClient : ICefClient read FHandler;
property ReqContextHandler : ICefRequestContextHandler read FReqContextHandler;
property CefWindowInfo : TCefWindowInfo read FWindowInfo; property CefWindowInfo : TCefWindowInfo read FWindowInfo;
property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry;
property MultithreadApp : boolean read GetMultithreadApp; property MultithreadApp : boolean read GetMultithreadApp;
@@ -773,6 +787,10 @@ type
// ICefFindHandler // ICefFindHandler
property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult; property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult;
// ICefRequestContextHandler
property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized;
property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad;
end; end;
implementation implementation
@@ -782,7 +800,8 @@ uses
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame, uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, uCEFCookieManager, uCEFApplication, uCEFProcessMessage, uCEFRequestContext, uCEFCookieManager,
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor, uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack; uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack,
uCEFRequestContextHandler;
constructor TFMXChromium.Create(AOwner: TComponent); constructor TFMXChromium.Create(AOwner: TComponent);
begin begin
@@ -793,6 +812,7 @@ begin
FInitialized := False; FInitialized := False;
FDefaultUrl := 'about:blank'; FDefaultUrl := 'about:blank';
FHandler := nil; FHandler := nil;
FReqContextHandler := nil;
FOptions := nil; FOptions := nil;
FFontOptions := nil; FFontOptions := nil;
FDefaultEncoding := ''; FDefaultEncoding := '';
@@ -901,6 +921,7 @@ begin
{$ENDIF} {$ENDIF}
DestroyClientHandler; DestroyClientHandler;
DestroyReqContextHandler;
inherited BeforeDestruction; inherited BeforeDestruction;
end; end;
@@ -925,6 +946,27 @@ begin
end; end;
end; end;
procedure TFMXChromium.DestroyReqContextHandler;
begin
try
if (FReqContextHandler <> nil) then
begin
FReqContextHandler.RemoveReferences;
FReqContextHandler := nil;
end;
except
on e : exception do
if CustomExceptionHandler('TFMXChromium.DestroyReqContextHandler', e) then raise;
end;
end;
procedure TFMXChromium.CreateReqContextHandler;
begin
if MustCreateRequestContextHandler and
(FReqContextHandler = nil) then
FReqContextHandler := TCustomRequestContextHandler.Create(self);
end;
procedure TFMXChromium.AfterConstruction; procedure TFMXChromium.AfterConstruction;
begin begin
inherited AfterConstruction; inherited AfterConstruction;
@@ -1074,6 +1116,10 @@ begin
// ICefFindHandler // ICefFindHandler
FOnFindResult := nil; FOnFindResult := nil;
// ICefRequestContextHandler
FOnRequestContextInitialized := nil;
FOnBeforePluginLoad := nil;
// Custom // Custom
FOnTextResultAvailable := nil; FOnTextResultAvailable := nil;
FOnPdfPrintFinished := nil; FOnPdfPrintFinished := nil;
@@ -1090,36 +1136,57 @@ end;
function TFMXChromium.CreateBrowser(const aWindowName : ustring; function TFMXChromium.CreateBrowser(const aWindowName : ustring;
const aContext : ICefRequestContext; const aContext : ICefRequestContext;
const aExtraInfo : ICefDictionaryValue) : boolean; const aExtraInfo : ICefDictionaryValue) : boolean;
var
TempNewContext, TempGlobalContext : ICefRequestContext;
begin begin
Result := False; Result := False;
TempNewContext := nil;
try try
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser try
// even if you use a custom request context. // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
// If you create a browser in the initialization of your app, make sure you call this // even if you use a custom request context.
// function when GlobalCEFApp.GlobalContextInitialized is TRUE. // If you create a browser in the initialization of your app, make sure you call this
// Use the GlobalCEFApp.OnContextInitialized event to know when // function when GlobalCEFApp.GlobalContextInitialized is TRUE.
// GlobalCEFApp.GlobalContextInitialized is set to TRUE. // Use the GlobalCEFApp.OnContextInitialized event to know when
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
if not(csDesigning in ComponentState) and if not(csDesigning in ComponentState) and
not(FClosing) and not(FClosing) and
(FBrowser = nil) and (FBrowser = nil) and
(FBrowserId = 0) and (FBrowserId = 0) and
(GlobalCEFApp <> nil) and (GlobalCEFApp <> nil) and
GlobalCEFApp.GlobalContextInitialized and GlobalCEFApp.GlobalContextInitialized and
CreateClientHandler then CreateClientHandler then
begin begin
GetSettings(FBrowserSettings); GetSettings(FBrowserSettings);
WindowInfoAsWindowless(FWindowInfo, 0, aWindowName); WindowInfoAsWindowless(FWindowInfo, 0, aWindowName);
if GlobalCEFApp.MultiThreadedMessageLoop then if (aContext = nil) then
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext) begin
else CreateReqContextHandler;
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext);
end; if (FReqContextHandler <> nil) then
except begin
on e : exception do TempGlobalContext := TCefRequestContextRef.Global();
if CustomExceptionHandler('TFMXChromium.CreateBrowser', e) then raise; TempNewContext := TCefRequestContextRef.Shared(TempGlobalContext, FReqContextHandler);
end;
end
else
TempNewContext := aContext;
if GlobalCEFApp.MultiThreadedMessageLoop then
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, TempNewContext)
else
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, TempNewContext);
end;
except
on e : exception do
if CustomExceptionHandler('TFMXChromium.CreateBrowser', e) then raise;
end;
finally
TempGlobalContext := nil;
TempNewContext := nil;
end; end;
end; end;
@@ -1129,36 +1196,60 @@ function TFMXChromium.CreateBrowser( aParentHandle : HWND;
const aWindowName : ustring; const aWindowName : ustring;
const aContext : ICefRequestContext; const aContext : ICefRequestContext;
const aExtraInfo : ICefDictionaryValue) : boolean; const aExtraInfo : ICefDictionaryValue) : boolean;
var
TempNewContext, TempGlobalContext : ICefRequestContext;
begin begin
Result := False; Result := False;
TempNewContext := nil;
TempGlobalContext := nil;
try try
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser try
// even if you use a custom request context. // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
// If you create a browser in the initialization of your app, make sure you call this // even if you use a custom request context.
// function when GlobalCEFApp.GlobalContextInitialized is TRUE. // If you create a browser in the initialization of your app, make sure you call this
// Use the GlobalCEFApp.OnContextInitialized event to know when // function when GlobalCEFApp.GlobalContextInitialized is TRUE.
// GlobalCEFApp.GlobalContextInitialized is set to TRUE. // Use the GlobalCEFApp.OnContextInitialized event to know when
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
if not(csDesigning in ComponentState) and if not(csDesigning in ComponentState) and
not(FClosing) and not(FClosing) and
(FBrowser = nil) and (FBrowser = nil) and
(FBrowserId = 0) and (FBrowserId = 0) and
(GlobalCEFApp <> nil) and (GlobalCEFApp <> nil) and
GlobalCEFApp.GlobalContextInitialized and GlobalCEFApp.GlobalContextInitialized and
CreateClientHandler(aParentHandle = 0) then CreateClientHandler(aParentHandle = 0) then
begin begin
GetSettings(FBrowserSettings); GetSettings(FBrowserSettings);
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName); InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
if GlobalCEFApp.MultiThreadedMessageLoop then if (aContext = nil) then
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext) begin
else CreateReqContextHandler;
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext);
end; if (FReqContextHandler = nil) then
except TempNewContext := nil
on e : exception do else
if CustomExceptionHandler('TFMXChromium.CreateBrowser', e) then raise; begin
TempGlobalContext := TCefRequestContextRef.Global();
TempNewContext := TCefRequestContextRef.Shared(TempGlobalContext, FReqContextHandler);
end;
end
else
TempNewContext := aContext;
if GlobalCEFApp.MultiThreadedMessageLoop then
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, TempNewContext)
else
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, TempNewContext);
end;
except
on e : exception do
if CustomExceptionHandler('TFMXChromium.CreateBrowser', e) then raise;
end;
finally
TempGlobalContext := nil;
TempNewContext := nil;
end; end;
end; end;
@@ -1862,6 +1953,20 @@ begin
end; end;
end; end;
procedure TFMXChromium.SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized);
begin
FOnRequestContextInitialized := aValue;
CreateReqContextHandler;
end;
procedure TFMXChromium.SetOnBeforePluginLoad(const aValue : TOnBeforePluginLoad);
begin
FOnBeforePluginLoad := aValue;
CreateReqContextHandler;
end;
procedure TFMXChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); procedure TFMXChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy);
begin begin
if (FWebRTCIPHandlingPolicy <> aValue) then if (FWebRTCIPHandlingPolicy <> aValue) then
@@ -3029,6 +3134,12 @@ begin
assigned(FOnCanSaveCookie); assigned(FOnCanSaveCookie);
end; end;
function TFMXChromium.MustCreateRequestContextHandler : boolean;
begin
Result := assigned(FOnRequestContextInitialized) or
assigned(FOnBeforePluginLoad);
end;
procedure TFMXChromium.doTextResultAvailable(const aText : ustring); procedure TFMXChromium.doTextResultAvailable(const aText : ustring);
begin begin
if assigned(FOnTextResultAvailable) then FOnTextResultAvailable(self, aText); if assigned(FOnTextResultAvailable) then FOnTextResultAvailable(self, aText);
@@ -3174,6 +3285,7 @@ begin
if (browser <> nil) and (FBrowserId = browser.Identifier) then if (browser <> nil) and (FBrowserId = browser.Identifier) then
begin begin
FInitialized := False; FInitialized := False;
DestroyReqContextHandler;
ClearBrowserReference; ClearBrowserReference;
DestroyClientHandler; DestroyClientHandler;
end; end;
@@ -3416,6 +3528,37 @@ begin
FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate); FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate);
end; end;
procedure TFMXChromium.doOnRequestContextInitialized(const request_context: ICefRequestContext);
begin
if assigned(FOnRequestContextInitialized) then FOnRequestContextInitialized(self, request_context);
end;
function TFMXChromium.doOnBeforePluginLoad(const mimeType : ustring;
const pluginUrl : ustring;
isMainFrame : boolean;
const topOriginUrl : ustring;
const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean;
begin
Result := False;
if assigned(FOnBeforePluginLoad) then
FOnBeforePluginLoad(self, mimeType, pluginUrl, isMainFrame, topOriginUrl, pluginInfo, pluginPolicy, Result);
end;
procedure TFMXChromium.doGetResourceRequestHandler(const browser : ICefBrowser;
const frame : ICefFrame;
const request : ICefRequest;
is_navigation : boolean;
is_download : boolean;
const request_initiator : ustring;
var disable_default_handling : boolean;
var aResourceRequestHandler : ICefResourceRequestHandler);
begin
disable_default_handling := False;
aResourceRequestHandler := nil;
end;
procedure TFMXChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); procedure TFMXChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
begin begin
if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen); if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen);

View File

@@ -374,6 +374,11 @@ type
// ICefFindHandler // ICefFindHandler
procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean);
// ICefRequestContextHandler
procedure doOnRequestContextInitialized(const request_context: ICefRequestContext);
function doOnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean;
procedure doGetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler);
// Custom // Custom
procedure doCookiesDeleted(numDeleted : integer); procedure doCookiesDeleted(numDeleted : integer);
procedure doPdfPrintFinished(aResultOK : boolean); procedure doPdfPrintFinished(aResultOK : boolean);
@@ -1971,8 +1976,10 @@ type
ICefRequestContextHandler = interface(ICefBaseRefCounted) ICefRequestContextHandler = interface(ICefBaseRefCounted)
['{76EB1FA7-78DF-4FD5-ABB3-1CDD3E73A140}'] ['{76EB1FA7-78DF-4FD5-ABB3-1CDD3E73A140}']
procedure OnRequestContextInitialized(const request_context: ICefRequestContext); procedure OnRequestContextInitialized(const request_context: ICefRequestContext);
function OnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; function OnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean;
procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler);
procedure RemoveReferences; // custom procedure to clear all references
end; end;
// TCefResolveCallback // TCefResolveCallback

View File

@@ -55,9 +55,11 @@ type
TCefRequestContextHandlerRef = class(TCefBaseRefCountedRef, ICefRequestContextHandler) TCefRequestContextHandlerRef = class(TCefBaseRefCountedRef, ICefRequestContextHandler)
protected protected
procedure OnRequestContextInitialized(const request_context: ICefRequestContext); procedure OnRequestContextInitialized(const request_context: ICefRequestContext);
function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean;
procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler);
procedure RemoveReferences; virtual;
public public
class function UnWrap(data: Pointer): ICefRequestContextHandler; class function UnWrap(data: Pointer): ICefRequestContextHandler;
end; end;
@@ -65,13 +67,29 @@ type
TCefRequestContextHandlerOwn = class(TCefBaseRefCountedOwn, ICefRequestContextHandler) TCefRequestContextHandlerOwn = class(TCefBaseRefCountedOwn, ICefRequestContextHandler)
protected protected
procedure OnRequestContextInitialized(const request_context: ICefRequestContext); virtual; procedure OnRequestContextInitialized(const request_context: ICefRequestContext); virtual;
function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; virtual; function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; virtual;
procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); virtual; procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); virtual;
procedure RemoveReferences; virtual;
public public
constructor Create; virtual; constructor Create; virtual;
end; end;
TCustomRequestContextHandler = class(TCefRequestContextHandlerOwn)
protected
FEvents : Pointer;
procedure OnRequestContextInitialized(const request_context: ICefRequestContext); override;
function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; override;
procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); override;
public
constructor Create(const events : IChromiumEvents); reintroduce; virtual;
procedure BeforeDestruction; override;
procedure RemoveReferences; override;
end;
implementation implementation
uses uses
@@ -100,9 +118,11 @@ function cef_request_context_handler_on_before_plugin_load( self
plugin_policy : PCefPluginPolicy): Integer; stdcall; plugin_policy : PCefPluginPolicy): Integer; stdcall;
var var
TempObject : TObject; TempObject : TObject;
TempPolicy : TCefPluginPolicy;
begin begin
Result := Ord(False); Result := Ord(False);
TempObject := CefGetObject(self); TempObject := CefGetObject(self);
TempPolicy := plugin_policy^;
if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then
Result := Ord(TCefRequestContextHandlerOwn(TempObject).OnBeforePluginLoad(CefString(mime_type), Result := Ord(TCefRequestContextHandlerOwn(TempObject).OnBeforePluginLoad(CefString(mime_type),
@@ -110,7 +130,8 @@ begin
(is_main_frame <> 0), (is_main_frame <> 0),
CefString(top_origin_url), CefString(top_origin_url),
TCefWebPluginInfoRef.UnWrap(plugin_info), TCefWebPluginInfoRef.UnWrap(plugin_info),
plugin_policy)); TempPolicy));
plugin_policy^ := TempPolicy;
end; end;
function cef_request_context_handler_get_resource_request_handler( self : PCefRequestContextHandler; function cef_request_context_handler_get_resource_request_handler( self : PCefRequestContextHandler;
@@ -171,7 +192,7 @@ function TCefRequestContextHandlerOwn.OnBeforePluginLoad(const mimeType : us
const pluginUrl : ustring; const pluginUrl : ustring;
isMainFrame : boolean; isMainFrame : boolean;
const topOriginUrl : ustring; const topOriginUrl : ustring;
const pluginInfo : ICefWebPluginInfo; const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean; var pluginPolicy : TCefPluginPolicy): Boolean;
begin begin
Result := False; Result := False;
@@ -188,6 +209,12 @@ begin
begin begin
aResourceRequestHandler := nil; aResourceRequestHandler := nil;
end; end;
procedure TCefRequestContextHandlerOwn.RemoveReferences;
begin
//
end;
// TCefRequestContextHandlerRef // TCefRequestContextHandlerRef
@@ -200,7 +227,7 @@ function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : us
function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : ustring; function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : ustring;
const pluginUrl : ustring; const pluginUrl : ustring;
isMainFrame : boolean; isMainFrame : boolean;
const topOriginUrl : ustring; const topOriginUrl : ustring;
const pluginInfo : ICefWebPluginInfo; const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean; var pluginPolicy : TCefPluginPolicy): Boolean;
var var
@@ -214,7 +241,7 @@ begin
@TempType, @TempType,
@TempPluginURL, @TempPluginURL,
ord(isMainFrame), ord(isMainFrame),
@TempOriginURL, @TempOriginURL,
CefGetData(pluginInfo), CefGetData(pluginInfo),
@pluginPolicy) <> 0; @pluginPolicy) <> 0;
end; end;
@@ -250,6 +277,11 @@ begin
disable_default_handling := TempDisableDefaultHandling <> 0; disable_default_handling := TempDisableDefaultHandling <> 0;
if (TempResourceRequestHandler <> nil) then
aResourceRequestHandler := TCefResourceRequestHandlerRef.UnWrap(TempResourceRequestHandler)
else
aResourceRequestHandler := nil; aResourceRequestHandler := nil;
end; end;
@@ -258,4 +290,87 @@ begin
// //
end; end;
class function TCefRequestContextHandlerRef.UnWrap(data: Pointer): ICefRequestContextHandler;
begin
if (data <> nil) then
Result := Create(data) as ICefRequestContextHandler
else
Result := nil;
end;
// TCustomRequestContextHandler
constructor TCustomRequestContextHandler.Create(const events : IChromiumEvents);
begin
inherited Create;
FEvents := Pointer(events);
end;
procedure TCustomRequestContextHandler.BeforeDestruction;
begin
FEvents := nil;
inherited BeforeDestruction;
end;
procedure TCustomRequestContextHandler.RemoveReferences;
begin
FEvents := nil;
end;
procedure TCustomRequestContextHandler.OnRequestContextInitialized(const request_context: ICefRequestContext);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doOnRequestContextInitialized(request_context)
else
inherited OnRequestContextInitialized(request_context);
end;
function TCustomRequestContextHandler.OnBeforePluginLoad(const mimeType : ustring;
const pluginUrl : ustring;
isMainFrame : boolean;
const topOriginUrl : ustring;
const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean;
begin
if (FEvents <> nil) then
Result := IChromiumEvents(FEvents).doOnBeforePluginLoad(mimeType,
pluginUrl,
isMainFrame,
topOriginUrl,
pluginInfo,
pluginPolicy)
else
Result := inherited OnBeforePluginLoad(mimeType,
pluginUrl,
isMainFrame,
topOriginUrl,
pluginInfo,
pluginPolicy);
end;
procedure TCustomRequestContextHandler.GetResourceRequestHandler(const browser : ICefBrowser;
const frame : ICefFrame;
const request : ICefRequest;
is_navigation : boolean;
is_download : boolean;
const request_initiator : ustring;
var disable_default_handling : boolean;
var aResourceRequestHandler : ICefResourceRequestHandler);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doGetResourceRequestHandler(browser,
frame,
request,
is_navigation,
is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler)
else
inherited GetResourceRequestHandler(browser,
frame,
request, request,

View File

@@ -1,10 +1,10 @@
{ {
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : true, "ForceNotify" : false,
"InternalVersion" : 41, "InternalVersion" : 42,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "77.1.12.0" "Version" : "77.1.13.0"
} }
], ],
"UpdatePackageData" : { "UpdatePackageData" : {