mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-02-12 10:26:05 +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:
parent
096b2c9a4b
commit
9391d68ee0
@ -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 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 :
|
||||
* [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_77.1.12%2Bgc63c001%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)
|
||||
* [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.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.
|
||||
|
@ -290,6 +290,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
OnCertificateError = Chromium1CertificateError
|
||||
OnBeforeResourceLoad = Chromium1BeforeResourceLoad
|
||||
OnResourceResponse = Chromium1ResourceResponse
|
||||
OnBeforePluginLoad = Chromium1BeforePluginLoad
|
||||
Left = 32
|
||||
Top = 224
|
||||
end
|
||||
|
@ -228,6 +228,10 @@ type
|
||||
procedure Flushcookies1Click(Sender: TObject);
|
||||
procedure Chromium1CookiesFlushed(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
|
||||
FResponse : TStringList;
|
||||
@ -443,6 +447,22 @@ begin
|
||||
callback.cont(TempFullPath, False);
|
||||
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;
|
||||
const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const request: ICefRequest; const callback: ICefRequestCallback;
|
||||
|
@ -22,12 +22,12 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="383"/>
|
||||
<CursorPos Y="400"/>
|
||||
<TopLine Value="995"/>
|
||||
<CursorPos Y="1002"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Bookmarks Count="2">
|
||||
<Item0 X="41" Y="989" ID="1"/>
|
||||
<Item1 Y="400" ID="2"/>
|
||||
<Item0 X="41" Y="993" ID="1"/>
|
||||
<Item1 Y="404" ID="2"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -191,15 +191,15 @@
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="992" Column="5" TopLine="1038"/>
|
||||
<Caret Line="401" TopLine="396"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="401" TopLine="396"/>
|
||||
<Caret Line="989" Column="44" TopLine="989"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="989" Column="44" TopLine="989"/>
|
||||
<Caret Line="406" Column="110" TopLine="387"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
|
@ -263,6 +263,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
OnCertificateError = Chromium1CertificateError
|
||||
OnBeforeResourceLoad = Chromium1BeforeResourceLoad
|
||||
OnResourceResponse = Chromium1ResourceResponse
|
||||
OnBeforePluginLoad = Chromium1BeforePluginLoad
|
||||
left = 32
|
||||
top = 224
|
||||
end
|
||||
|
@ -125,6 +125,10 @@ type
|
||||
N5: TMenuItem;
|
||||
Memoryinfo1: TMenuItem;
|
||||
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 Chromium1DownloadImageFinished(Sender: TObject;
|
||||
const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage);
|
||||
@ -989,6 +993,22 @@ begin
|
||||
PostMessage(Handle, WM_CLOSE, 0, 0);
|
||||
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);
|
||||
begin
|
||||
showmessage('The cookies were flushed successfully');
|
||||
|
@ -8,7 +8,7 @@
|
||||
<Unit0>
|
||||
<Filename Value="PopupBrowser2.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="42"/>
|
||||
<TopLine Value="38"/>
|
||||
<CursorPos X="61" Y="64"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
@ -22,8 +22,8 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="320"/>
|
||||
<CursorPos X="17" Y="344"/>
|
||||
<TopLine Value="307"/>
|
||||
<CursorPos Y="328"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -35,9 +35,9 @@
|
||||
<ComponentName Value="ChildForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="82"/>
|
||||
<CursorPos Y="184"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="52"/>
|
||||
<CursorPos X="54" Y="97"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -52,10 +52,11 @@
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\..\..\source\uCEFChromium.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="1016"/>
|
||||
<CursorPos Y="1028"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="3887"/>
|
||||
<CursorPos X="61" Y="3906"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\..\..\source\uCEFMiscFunctions.pas"/>
|
||||
@ -83,123 +84,123 @@
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="295" Column="27" TopLine="280"/>
|
||||
<Caret Line="224" Column="25" TopLine="204"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="298" Column="15" TopLine="280"/>
|
||||
<Caret Line="277" Column="13" TopLine="257"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="86" Column="15" TopLine="75"/>
|
||||
<Caret Line="292" Column="19" TopLine="272"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="223" Column="26" TopLine="203"/>
|
||||
<Caret Line="294" Column="19" TopLine="274"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="224" Column="25" TopLine="204"/>
|
||||
<Caret Line="295" Column="19" TopLine="275"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="277" Column="13" TopLine="257"/>
|
||||
<Caret Line="298" Column="15" TopLine="278"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="292" Column="19" TopLine="272"/>
|
||||
<Caret Line="86" Column="15" TopLine="75"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="294" Column="19" TopLine="274"/>
|
||||
<Caret Line="223" Column="26" TopLine="203"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="295" Column="19" TopLine="275"/>
|
||||
<Caret Line="224" Column="25" TopLine="204"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="298" Column="15" TopLine="278"/>
|
||||
<Caret Line="277" Column="13" TopLine="257"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="86" Column="15" TopLine="75"/>
|
||||
<Caret Line="292" TopLine="281"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="223" Column="26" TopLine="203"/>
|
||||
<Caret Line="295" TopLine="281"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="224" Column="25" TopLine="204"/>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="62" Column="23" TopLine="54"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="277" Column="13" TopLine="257"/>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="222" Column="3" TopLine="220"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="292" TopLine="281"/>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="77" Column="22" TopLine="48"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="295" TopLine="281"/>
|
||||
<Caret Line="286" Column="54" TopLine="260"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="62" Column="23" TopLine="54"/>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="98" Column="33" TopLine="77"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="222" Column="3" TopLine="220"/>
|
||||
<Caret Line="78" Column="22" TopLine="71"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="77" Column="22" TopLine="48"/>
|
||||
<Caret Line="253" Column="14" TopLine="231"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="286" Column="54" TopLine="260"/>
|
||||
<Caret Line="76" Column="384" TopLine="70"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="98" Column="33" TopLine="77"/>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="250" Column="32" TopLine="223"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="78" Column="22" TopLine="71"/>
|
||||
<Caret Line="62" Column="384" TopLine="51"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="253" Column="14" TopLine="231"/>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="199" Column="59" TopLine="183"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="76" Column="384" TopLine="70"/>
|
||||
<Caret Line="344" Column="17" TopLine="320"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="250" Column="32" TopLine="223"/>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="346" Column="19" TopLine="322"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="uChildForm.pas"/>
|
||||
<Caret Line="62" Column="384" TopLine="51"/>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="197" Column="72" TopLine="182"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="199" Column="59" TopLine="183"/>
|
||||
<Caret Line="352" Column="56" TopLine="322"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="344" Column="17" TopLine="320"/>
|
||||
<Caret Line="332" TopLine="310"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="346" Column="19" TopLine="322"/>
|
||||
<Caret Line="334" Column="51" TopLine="310"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="197" Column="72" TopLine="182"/>
|
||||
<Caret Line="67" TopLine="49"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
|
@ -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="77" Minor="1" Release="12"/>
|
||||
<Version Major="77" Minor="1" Release="13"/>
|
||||
<Files Count="144">
|
||||
<Item1>
|
||||
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
||||
|
@ -62,7 +62,7 @@ uses
|
||||
const
|
||||
CEF_SUPPORTED_VERSION_MAJOR = 77;
|
||||
CEF_SUPPORTED_VERSION_MINOR = 1;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 12;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 13;
|
||||
CEF_SUPPORTED_VERSION_BUILD = 0;
|
||||
|
||||
CEF_CHROMEELF_VERSION_MAJOR = 77;
|
||||
@ -158,7 +158,6 @@ type
|
||||
FStatus : TCefAplicationStatus;
|
||||
FMissingLibFiles : string;
|
||||
FProcessType : TCefProcessType;
|
||||
FShutdownWaitTime : cardinal;
|
||||
FWidevinePath : ustring;
|
||||
FMustFreeLibrary : boolean;
|
||||
FAutoplayPolicy : TCefAutoplayPolicy;
|
||||
@ -433,7 +432,6 @@ type
|
||||
property OsmodalLoop : boolean write SetOsmodalLoop;
|
||||
property Status : TCefAplicationStatus read FStatus;
|
||||
property MissingLibFiles : string read FMissingLibFiles;
|
||||
property ShutdownWaitTime : cardinal read FShutdownWaitTime write FShutdownWaitTime;
|
||||
property WidevinePath : ustring read FWidevinePath write FWidevinePath;
|
||||
property MustFreeLibrary : boolean read FMustFreeLibrary write FMustFreeLibrary;
|
||||
property AutoplayPolicy : TCefAutoplayPolicy read FAutoplayPolicy write FAutoplayPolicy;
|
||||
@ -606,7 +604,6 @@ begin
|
||||
FDisableGPUCache := True;
|
||||
FLocalesRequired := '';
|
||||
FProcessType := ParseProcessType;
|
||||
FShutdownWaitTime := 0;
|
||||
FWidevinePath := '';
|
||||
FMustFreeLibrary := False;
|
||||
FAutoplayPolicy := appDefault;
|
||||
@ -694,12 +691,7 @@ end;
|
||||
destructor TCefApplication.Destroy;
|
||||
begin
|
||||
try
|
||||
if (FProcessType = ptBrowser) then
|
||||
begin
|
||||
if (FShutdownWaitTime > 0) then sleep(FShutdownWaitTime);
|
||||
|
||||
ShutDown;
|
||||
end;
|
||||
if (FProcessType = ptBrowser) then ShutDown;
|
||||
|
||||
FreeLibcefLibrary;
|
||||
|
||||
@ -1030,7 +1022,7 @@ end;
|
||||
|
||||
procedure TCefApplication.SetOsmodalLoop(aValue : boolean);
|
||||
begin
|
||||
if FLibLoaded then cef_set_osmodal_loop(Ord(aValue));
|
||||
if (FStatus = asInitialized) then cef_set_osmodal_loop(Ord(aValue));
|
||||
end;
|
||||
|
||||
procedure TCefApplication.UpdateDeviceScaleFactor;
|
||||
@ -1041,8 +1033,11 @@ end;
|
||||
procedure TCefApplication.ShutDown;
|
||||
begin
|
||||
try
|
||||
FStatus := asShuttingDown;
|
||||
if FLibLoaded then cef_shutdown();
|
||||
if (FStatus = asInitialized) then
|
||||
begin
|
||||
FStatus := asShuttingDown;
|
||||
cef_shutdown();
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefApplication.ShutDown', e) then raise;
|
||||
@ -2000,7 +1995,7 @@ begin
|
||||
FStatus := asErrorDLLVersion;
|
||||
TempString := 'Unsupported CEF version !' +
|
||||
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;
|
||||
|
||||
ShowErrorMessageDlg(TempString);
|
||||
|
@ -72,6 +72,7 @@ type
|
||||
FHandler : ICefClient;
|
||||
FBrowser : ICefBrowser;
|
||||
FBrowserId : Integer;
|
||||
FReqContextHandler : ICefRequestContextHandler;
|
||||
FDefaultUrl : ustring;
|
||||
FOptions : TChromiumOptions;
|
||||
FFontOptions : TChromiumFontOptions;
|
||||
@ -237,6 +238,10 @@ type
|
||||
// ICefFindHandler
|
||||
FOnFindResult : TOnFindResult;
|
||||
|
||||
// ICefRequestContextHandler
|
||||
FOnRequestContextInitialized : TOnRequestContextInitialized;
|
||||
FOnBeforePluginLoad : TOnBeforePluginLoad;
|
||||
|
||||
// Custom
|
||||
FOnTextResultAvailable : TOnTextResultAvailableEvent;
|
||||
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
|
||||
@ -311,14 +316,16 @@ type
|
||||
procedure SetSafeSearch(aValue : boolean);
|
||||
procedure SetYouTubeRestrict(aValue : integer);
|
||||
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 CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): Boolean;
|
||||
|
||||
procedure DestroyClientHandler;
|
||||
|
||||
procedure DestroyReqContextHandler;
|
||||
procedure ClearBrowserReference;
|
||||
procedure CreateReqContextHandler;
|
||||
|
||||
procedure InitializeEvents;
|
||||
procedure InitializeSettings(var aSettings : TCefBrowserSettings);
|
||||
@ -478,6 +485,11 @@ type
|
||||
// ICefFindHandler
|
||||
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
|
||||
procedure doCookiesDeleted(numDeleted : integer); virtual;
|
||||
procedure doPdfPrintFinished(aResultOK : boolean); virtual;
|
||||
@ -507,6 +519,7 @@ type
|
||||
function MustCreateFindHandler : boolean; virtual;
|
||||
function MustCreateResourceRequestHandler : boolean; virtual;
|
||||
function MustCreateCookieAccessFilter : boolean; virtual;
|
||||
function MustCreateRequestContextHandler : boolean; virtual;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -636,6 +649,7 @@ type
|
||||
property BrowserId : integer read FBrowserId;
|
||||
property Browser : ICefBrowser read FBrowser;
|
||||
property CefClient : ICefClient read FHandler;
|
||||
property ReqContextHandler : ICefRequestContextHandler read FReqContextHandler;
|
||||
property CefWindowInfo : TCefWindowInfo read FWindowInfo;
|
||||
property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry;
|
||||
property MultithreadApp : boolean read GetMultithreadApp;
|
||||
@ -816,6 +830,10 @@ type
|
||||
|
||||
// ICefFindHandler
|
||||
property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult;
|
||||
|
||||
// ICefRequestContextHandler
|
||||
property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized;
|
||||
property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
@ -833,7 +851,8 @@ uses
|
||||
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
|
||||
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, {$IFNDEF FPC}uCEFOLEDragAndDrop,{$ENDIF}
|
||||
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
|
||||
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack, uCEFCookieManager;
|
||||
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack, uCEFCookieManager,
|
||||
uCEFRequestContextHandler;
|
||||
|
||||
constructor TChromium.Create(AOwner: TComponent);
|
||||
begin
|
||||
@ -845,6 +864,7 @@ begin
|
||||
FIsOSR := False;
|
||||
FDefaultUrl := 'about:blank';
|
||||
FHandler := nil;
|
||||
FReqContextHandler := nil;
|
||||
FOptions := nil;
|
||||
FFontOptions := nil;
|
||||
FDefaultEncoding := '';
|
||||
@ -967,6 +987,7 @@ begin
|
||||
{$ENDIF}
|
||||
|
||||
DestroyClientHandler;
|
||||
DestroyReqContextHandler;
|
||||
|
||||
inherited BeforeDestruction;
|
||||
end;
|
||||
@ -1007,6 +1028,27 @@ begin
|
||||
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;
|
||||
{$IFDEF FPC}
|
||||
var
|
||||
@ -1170,6 +1212,10 @@ begin
|
||||
// ICefFindHandler
|
||||
FOnFindResult := nil;
|
||||
|
||||
// ICefRequestContextHandler
|
||||
FOnRequestContextInitialized := nil;
|
||||
FOnBeforePluginLoad := nil;
|
||||
|
||||
// Custom
|
||||
FOnTextResultAvailable := nil;
|
||||
FOnPdfPrintFinished := nil;
|
||||
@ -1216,36 +1262,57 @@ function TChromium.CreateBrowser( aParentHandle : HWND;
|
||||
const aWindowName : ustring;
|
||||
const aContext : ICefRequestContext;
|
||||
const aExtraInfo : ICefDictionaryValue) : boolean;
|
||||
var
|
||||
TempNewContext, TempGlobalContext : ICefRequestContext;
|
||||
begin
|
||||
Result := False;
|
||||
Result := False;
|
||||
TempNewContext := nil;
|
||||
|
||||
try
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// even if you use a custom request context.
|
||||
// If you create a browser in the initialization of your app, make sure you call this
|
||||
// function when GlobalCEFApp.GlobalContextInitialized is TRUE.
|
||||
// Use the GlobalCEFApp.OnContextInitialized event to know when
|
||||
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||
try
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// even if you use a custom request context.
|
||||
// If you create a browser in the initialization of your app, make sure you call this
|
||||
// function when GlobalCEFApp.GlobalContextInitialized is TRUE.
|
||||
// Use the GlobalCEFApp.OnContextInitialized event to know when
|
||||
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||
|
||||
if not(csDesigning in ComponentState) and
|
||||
not(FClosing) and
|
||||
(FBrowser = nil) and
|
||||
(FBrowserId = 0) and
|
||||
(GlobalCEFApp <> nil) and
|
||||
GlobalCEFApp.GlobalContextInitialized and
|
||||
CreateClientHandler(aParentHandle = 0) then
|
||||
begin
|
||||
GetSettings(FBrowserSettings);
|
||||
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
|
||||
if not(csDesigning in ComponentState) and
|
||||
not(FClosing) and
|
||||
(FBrowser = nil) and
|
||||
(FBrowserId = 0) and
|
||||
(GlobalCEFApp <> nil) and
|
||||
GlobalCEFApp.GlobalContextInitialized and
|
||||
CreateClientHandler(aParentHandle = 0) then
|
||||
begin
|
||||
GetSettings(FBrowserSettings);
|
||||
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
|
||||
|
||||
if GlobalCEFApp.MultiThreadedMessageLoop then
|
||||
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext)
|
||||
else
|
||||
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext);
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TChromium.CreateBrowser', e) then raise;
|
||||
if (aContext = nil) then
|
||||
begin
|
||||
CreateReqContextHandler;
|
||||
|
||||
if (FReqContextHandler <> nil) then
|
||||
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('TChromium.CreateBrowser', e) then raise;
|
||||
end;
|
||||
finally
|
||||
TempGlobalContext := nil;
|
||||
TempNewContext := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2087,6 +2154,20 @@ begin
|
||||
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);
|
||||
begin
|
||||
if (FWebRTCIPHandlingPolicy <> aValue) then
|
||||
@ -3311,6 +3392,12 @@ begin
|
||||
assigned(FOnCanSaveCookie);
|
||||
end;
|
||||
|
||||
function TChromium.MustCreateRequestContextHandler : boolean;
|
||||
begin
|
||||
Result := assigned(FOnRequestContextInitialized) or
|
||||
assigned(FOnBeforePluginLoad);
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure TChromium.PrefsAvailableMsg(var aMessage : TMessage);
|
||||
begin
|
||||
@ -3810,6 +3897,37 @@ begin
|
||||
FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate);
|
||||
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);
|
||||
begin
|
||||
if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen);
|
||||
|
@ -161,6 +161,10 @@ type
|
||||
// ICefFindHandler
|
||||
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
|
||||
TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object;
|
||||
TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object;
|
||||
|
@ -61,6 +61,7 @@ type
|
||||
FHandler : ICefClient;
|
||||
FBrowser : ICefBrowser;
|
||||
FBrowserId : Integer;
|
||||
FReqContextHandler : ICefRequestContextHandler;
|
||||
FDefaultUrl : ustring;
|
||||
FOptions : TChromiumOptions;
|
||||
FFontOptions : TChromiumFontOptions;
|
||||
@ -221,6 +222,10 @@ type
|
||||
// ICefFindHandler
|
||||
FOnFindResult : TOnFindResult;
|
||||
|
||||
// ICefRequestContextHandler
|
||||
FOnRequestContextInitialized : TOnRequestContextInitialized;
|
||||
FOnBeforePluginLoad : TOnBeforePluginLoad;
|
||||
|
||||
// Custom
|
||||
FOnTextResultAvailable : TOnTextResultAvailableEvent;
|
||||
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
|
||||
@ -294,14 +299,16 @@ type
|
||||
procedure SetSafeSearch(aValue : boolean);
|
||||
procedure SetYouTubeRestrict(aValue : integer);
|
||||
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 CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean;
|
||||
|
||||
procedure DestroyClientHandler;
|
||||
|
||||
procedure DestroyReqContextHandler;
|
||||
procedure ClearBrowserReference;
|
||||
procedure CreateReqContextHandler;
|
||||
|
||||
procedure InitializeEvents;
|
||||
procedure InitializeSettings(var aSettings : TCefBrowserSettings);
|
||||
@ -445,6 +452,11 @@ type
|
||||
// ICefFindHandler
|
||||
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
|
||||
procedure doCookiesDeleted(numDeleted : integer); virtual;
|
||||
procedure doPdfPrintFinished(aResultOK : boolean); virtual;
|
||||
@ -474,6 +486,7 @@ type
|
||||
function MustCreateFindHandler : boolean; virtual;
|
||||
function MustCreateResourceRequestHandler : boolean; virtual;
|
||||
function MustCreateCookieAccessFilter : boolean; virtual;
|
||||
function MustCreateRequestContextHandler : boolean; virtual;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -596,6 +609,7 @@ type
|
||||
property BrowserId : integer read FBrowserId;
|
||||
property Browser : ICefBrowser read FBrowser;
|
||||
property CefClient : ICefClient read FHandler;
|
||||
property ReqContextHandler : ICefRequestContextHandler read FReqContextHandler;
|
||||
property CefWindowInfo : TCefWindowInfo read FWindowInfo;
|
||||
property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry;
|
||||
property MultithreadApp : boolean read GetMultithreadApp;
|
||||
@ -773,6 +787,10 @@ type
|
||||
|
||||
// ICefFindHandler
|
||||
property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult;
|
||||
|
||||
// ICefRequestContextHandler
|
||||
property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized;
|
||||
property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -782,7 +800,8 @@ uses
|
||||
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
|
||||
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, uCEFCookieManager,
|
||||
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
|
||||
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack;
|
||||
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack,
|
||||
uCEFRequestContextHandler;
|
||||
|
||||
constructor TFMXChromium.Create(AOwner: TComponent);
|
||||
begin
|
||||
@ -793,6 +812,7 @@ begin
|
||||
FInitialized := False;
|
||||
FDefaultUrl := 'about:blank';
|
||||
FHandler := nil;
|
||||
FReqContextHandler := nil;
|
||||
FOptions := nil;
|
||||
FFontOptions := nil;
|
||||
FDefaultEncoding := '';
|
||||
@ -901,6 +921,7 @@ begin
|
||||
{$ENDIF}
|
||||
|
||||
DestroyClientHandler;
|
||||
DestroyReqContextHandler;
|
||||
|
||||
inherited BeforeDestruction;
|
||||
end;
|
||||
@ -925,6 +946,27 @@ begin
|
||||
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;
|
||||
begin
|
||||
inherited AfterConstruction;
|
||||
@ -1074,6 +1116,10 @@ begin
|
||||
// ICefFindHandler
|
||||
FOnFindResult := nil;
|
||||
|
||||
// ICefRequestContextHandler
|
||||
FOnRequestContextInitialized := nil;
|
||||
FOnBeforePluginLoad := nil;
|
||||
|
||||
// Custom
|
||||
FOnTextResultAvailable := nil;
|
||||
FOnPdfPrintFinished := nil;
|
||||
@ -1090,36 +1136,57 @@ end;
|
||||
function TFMXChromium.CreateBrowser(const aWindowName : ustring;
|
||||
const aContext : ICefRequestContext;
|
||||
const aExtraInfo : ICefDictionaryValue) : boolean;
|
||||
var
|
||||
TempNewContext, TempGlobalContext : ICefRequestContext;
|
||||
begin
|
||||
Result := False;
|
||||
Result := False;
|
||||
TempNewContext := nil;
|
||||
|
||||
try
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// even if you use a custom request context.
|
||||
// If you create a browser in the initialization of your app, make sure you call this
|
||||
// function when GlobalCEFApp.GlobalContextInitialized is TRUE.
|
||||
// Use the GlobalCEFApp.OnContextInitialized event to know when
|
||||
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||
try
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// even if you use a custom request context.
|
||||
// If you create a browser in the initialization of your app, make sure you call this
|
||||
// function when GlobalCEFApp.GlobalContextInitialized is TRUE.
|
||||
// Use the GlobalCEFApp.OnContextInitialized event to know when
|
||||
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||
|
||||
if not(csDesigning in ComponentState) and
|
||||
not(FClosing) and
|
||||
(FBrowser = nil) and
|
||||
(FBrowserId = 0) and
|
||||
(GlobalCEFApp <> nil) and
|
||||
GlobalCEFApp.GlobalContextInitialized and
|
||||
CreateClientHandler then
|
||||
begin
|
||||
GetSettings(FBrowserSettings);
|
||||
WindowInfoAsWindowless(FWindowInfo, 0, aWindowName);
|
||||
if not(csDesigning in ComponentState) and
|
||||
not(FClosing) and
|
||||
(FBrowser = nil) and
|
||||
(FBrowserId = 0) and
|
||||
(GlobalCEFApp <> nil) and
|
||||
GlobalCEFApp.GlobalContextInitialized and
|
||||
CreateClientHandler then
|
||||
begin
|
||||
GetSettings(FBrowserSettings);
|
||||
WindowInfoAsWindowless(FWindowInfo, 0, aWindowName);
|
||||
|
||||
if GlobalCEFApp.MultiThreadedMessageLoop then
|
||||
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext)
|
||||
else
|
||||
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext);
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TFMXChromium.CreateBrowser', e) then raise;
|
||||
if (aContext = nil) then
|
||||
begin
|
||||
CreateReqContextHandler;
|
||||
|
||||
if (FReqContextHandler <> nil) then
|
||||
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;
|
||||
|
||||
@ -1129,36 +1196,60 @@ function TFMXChromium.CreateBrowser( aParentHandle : HWND;
|
||||
const aWindowName : ustring;
|
||||
const aContext : ICefRequestContext;
|
||||
const aExtraInfo : ICefDictionaryValue) : boolean;
|
||||
var
|
||||
TempNewContext, TempGlobalContext : ICefRequestContext;
|
||||
begin
|
||||
Result := False;
|
||||
Result := False;
|
||||
TempNewContext := nil;
|
||||
TempGlobalContext := nil;
|
||||
|
||||
try
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// even if you use a custom request context.
|
||||
// If you create a browser in the initialization of your app, make sure you call this
|
||||
// function when GlobalCEFApp.GlobalContextInitialized is TRUE.
|
||||
// Use the GlobalCEFApp.OnContextInitialized event to know when
|
||||
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||
try
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// even if you use a custom request context.
|
||||
// If you create a browser in the initialization of your app, make sure you call this
|
||||
// function when GlobalCEFApp.GlobalContextInitialized is TRUE.
|
||||
// Use the GlobalCEFApp.OnContextInitialized event to know when
|
||||
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||
|
||||
if not(csDesigning in ComponentState) and
|
||||
not(FClosing) and
|
||||
(FBrowser = nil) and
|
||||
(FBrowserId = 0) and
|
||||
(GlobalCEFApp <> nil) and
|
||||
GlobalCEFApp.GlobalContextInitialized and
|
||||
CreateClientHandler(aParentHandle = 0) then
|
||||
begin
|
||||
GetSettings(FBrowserSettings);
|
||||
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
|
||||
if not(csDesigning in ComponentState) and
|
||||
not(FClosing) and
|
||||
(FBrowser = nil) and
|
||||
(FBrowserId = 0) and
|
||||
(GlobalCEFApp <> nil) and
|
||||
GlobalCEFApp.GlobalContextInitialized and
|
||||
CreateClientHandler(aParentHandle = 0) then
|
||||
begin
|
||||
GetSettings(FBrowserSettings);
|
||||
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
|
||||
|
||||
if GlobalCEFApp.MultiThreadedMessageLoop then
|
||||
Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext)
|
||||
else
|
||||
Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, aContext);
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TFMXChromium.CreateBrowser', e) then raise;
|
||||
if (aContext = nil) then
|
||||
begin
|
||||
CreateReqContextHandler;
|
||||
|
||||
if (FReqContextHandler = nil) then
|
||||
TempNewContext := nil
|
||||
else
|
||||
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;
|
||||
|
||||
@ -1862,6 +1953,20 @@ begin
|
||||
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);
|
||||
begin
|
||||
if (FWebRTCIPHandlingPolicy <> aValue) then
|
||||
@ -3029,6 +3134,12 @@ begin
|
||||
assigned(FOnCanSaveCookie);
|
||||
end;
|
||||
|
||||
function TFMXChromium.MustCreateRequestContextHandler : boolean;
|
||||
begin
|
||||
Result := assigned(FOnRequestContextInitialized) or
|
||||
assigned(FOnBeforePluginLoad);
|
||||
end;
|
||||
|
||||
procedure TFMXChromium.doTextResultAvailable(const aText : ustring);
|
||||
begin
|
||||
if assigned(FOnTextResultAvailable) then FOnTextResultAvailable(self, aText);
|
||||
@ -3174,6 +3285,7 @@ begin
|
||||
if (browser <> nil) and (FBrowserId = browser.Identifier) then
|
||||
begin
|
||||
FInitialized := False;
|
||||
DestroyReqContextHandler;
|
||||
ClearBrowserReference;
|
||||
DestroyClientHandler;
|
||||
end;
|
||||
@ -3416,6 +3528,37 @@ begin
|
||||
FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate);
|
||||
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);
|
||||
begin
|
||||
if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen);
|
||||
|
@ -374,6 +374,11 @@ type
|
||||
// ICefFindHandler
|
||||
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
|
||||
procedure doCookiesDeleted(numDeleted : integer);
|
||||
procedure doPdfPrintFinished(aResultOK : boolean);
|
||||
@ -1971,8 +1976,10 @@ type
|
||||
ICefRequestContextHandler = interface(ICefBaseRefCounted)
|
||||
['{76EB1FA7-78DF-4FD5-ABB3-1CDD3E73A140}']
|
||||
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 RemoveReferences; // custom procedure to clear all references
|
||||
end;
|
||||
|
||||
// TCefResolveCallback
|
||||
|
@ -55,9 +55,11 @@ type
|
||||
TCefRequestContextHandlerRef = class(TCefBaseRefCountedRef, ICefRequestContextHandler)
|
||||
protected
|
||||
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 RemoveReferences; virtual;
|
||||
|
||||
public
|
||||
class function UnWrap(data: Pointer): ICefRequestContextHandler;
|
||||
end;
|
||||
@ -65,13 +67,29 @@ type
|
||||
TCefRequestContextHandlerOwn = class(TCefBaseRefCountedOwn, ICefRequestContextHandler)
|
||||
protected
|
||||
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 RemoveReferences; virtual;
|
||||
|
||||
public
|
||||
constructor Create; virtual;
|
||||
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
|
||||
|
||||
uses
|
||||
@ -100,9 +118,11 @@ function cef_request_context_handler_on_before_plugin_load( self
|
||||
plugin_policy : PCefPluginPolicy): Integer; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
TempPolicy : TCefPluginPolicy;
|
||||
begin
|
||||
Result := Ord(False);
|
||||
TempObject := CefGetObject(self);
|
||||
TempPolicy := plugin_policy^;
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then
|
||||
Result := Ord(TCefRequestContextHandlerOwn(TempObject).OnBeforePluginLoad(CefString(mime_type),
|
||||
@ -110,7 +130,8 @@ begin
|
||||
(is_main_frame <> 0),
|
||||
CefString(top_origin_url),
|
||||
TCefWebPluginInfoRef.UnWrap(plugin_info),
|
||||
plugin_policy));
|
||||
TempPolicy));
|
||||
plugin_policy^ := TempPolicy;
|
||||
end;
|
||||
|
||||
function cef_request_context_handler_get_resource_request_handler( self : PCefRequestContextHandler;
|
||||
@ -171,7 +192,7 @@ function TCefRequestContextHandlerOwn.OnBeforePluginLoad(const mimeType : us
|
||||
isMainFrame : boolean;
|
||||
const topOriginUrl : ustring;
|
||||
const pluginInfo : ICefWebPluginInfo;
|
||||
pluginPolicy : PCefPluginPolicy): Boolean;
|
||||
var pluginPolicy : TCefPluginPolicy): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
@ -188,6 +209,12 @@ begin
|
||||
aResourceRequestHandler := nil;
|
||||
end;
|
||||
|
||||
procedure TCefRequestContextHandlerOwn.RemoveReferences;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// TCefRequestContextHandlerRef
|
||||
|
||||
procedure TCefRequestContextHandlerRef.OnRequestContextInitialized(const request_context: ICefRequestContext);
|
||||
@ -200,7 +227,7 @@ function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : us
|
||||
isMainFrame : boolean;
|
||||
const topOriginUrl : ustring;
|
||||
const pluginInfo : ICefWebPluginInfo;
|
||||
pluginPolicy : PCefPluginPolicy): Boolean;
|
||||
var pluginPolicy : TCefPluginPolicy): Boolean;
|
||||
var
|
||||
TempType, TempPluginURL, TempOriginURL : TCefString;
|
||||
begin
|
||||
@ -214,7 +241,7 @@ begin
|
||||
ord(isMainFrame),
|
||||
@TempOriginURL,
|
||||
CefGetData(pluginInfo),
|
||||
pluginPolicy) <> 0;
|
||||
@pluginPolicy) <> 0;
|
||||
end;
|
||||
|
||||
|
||||
@ -250,6 +277,11 @@ begin
|
||||
aResourceRequestHandler := nil;
|
||||
end;
|
||||
|
||||
procedure TCefRequestContextHandlerRef.RemoveReferences;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
class function TCefRequestContextHandlerRef.UnWrap(data: Pointer): ICefRequestContextHandler;
|
||||
begin
|
||||
if (data <> nil) then
|
||||
@ -258,4 +290,87 @@ begin
|
||||
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,
|
||||
is_navigation,
|
||||
is_download,
|
||||
request_initiator,
|
||||
disable_default_handling,
|
||||
aResourceRequestHandler);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 41,
|
||||
"ForceNotify" : false,
|
||||
"InternalVersion" : 42,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "77.1.12.0"
|
||||
"Version" : "77.1.13.0"
|
||||
}
|
||||
],
|
||||
"UpdatePackageData" : {
|
||||
|
Loading…
x
Reference in New Issue
Block a user