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

Added TChromium.OnCookieVisitorDestroyed

- Removed TChromium.OnGetResourceRequestHandler
- Added TChromium.OnGetResourceRequestHandler_ReqHdlr
- Added TChromium.OnGetResourceRequestHandler_ReqCtxHdlr
- Modified the CookieVisitor demo to use TChromium.OnCookieVisitorDestroyed
This commit is contained in:
Salvador Díaz Fau 2019-11-08 14:32:03 +01:00
parent aec9e6b922
commit 427059dd9a
13 changed files with 339 additions and 244 deletions

View File

@ -66,6 +66,7 @@ object CookieVisitorFrm: TCookieVisitorFrm
object Chromium1: TChromium
OnCookiesDeleted = Chromium1CookiesDeleted
OnCookiesVisited = Chromium1CookiesVisited
OnCookieVisitorDestroyed = Chromium1CookieVisitorDestroyed
OnCookieSet = Chromium1CookieSet
OnBeforeContextMenu = Chromium1BeforeContextMenu
OnContextMenuCommand = Chromium1ContextMenuCommand

View File

@ -105,6 +105,8 @@ type
total, aID : Integer; var aDeleteCookie, aResult: Boolean);
procedure Chromium1CookieSet(Sender: TObject; aSuccess: Boolean;
aID: Integer);
procedure Chromium1CookieVisitorDestroyed(Sender: TObject;
aID: Integer);
private
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
@ -336,13 +338,12 @@ begin
AddCookieInfo(TempCookie);
if (count = pred(total)) then
begin
PostMessage(Handle, MINIBROWSER_SHOWCOOKIES, 0, 0);
aResult := False;
end
else
aResult := True;
aResult := (count <> pred(total));
end;
procedure TCookieVisitorFrm.Chromium1CookieVisitorDestroyed(Sender: TObject; aID: Integer);
begin
PostMessage(Handle, MINIBROWSER_SHOWCOOKIES, 0, 0);
end;
procedure TCookieVisitorFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

View File

@ -22,13 +22,13 @@
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="231"/>
<CursorPos X="13" Y="235"/>
<TopLine Value="235"/>
<CursorPos X="3" Y="255"/>
<UsageCount Value="24"/>
<Bookmarks Count="3">
<Item0 Y="350" ID="1"/>
<Item1 X="3" Y="198" ID="2"/>
<Item2 X="66" Y="229" ID="3"/>
<Item0 Y="351" ID="1"/>
<Item1 X="3" Y="199" ID="2"/>
<Item2 X="66" Y="230" ID="3"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -56,123 +56,123 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="252" Column="5" TopLine="249"/>
<Caret Line="64" Column="35" TopLine="42"/>
</Position1>
<Position2>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="64" Column="35" TopLine="42"/>
<Caret Line="85" Column="41" TopLine="61"/>
</Position2>
<Position3>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="85" Column="41" TopLine="61"/>
<Caret Line="356" Column="81" TopLine="334"/>
</Position3>
<Position4>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="356" Column="81" TopLine="334"/>
<Caret Line="223" TopLine="206"/>
</Position4>
<Position5>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="223" TopLine="206"/>
<Caret Line="251" Column="70" TopLine="234"/>
</Position5>
<Position6>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="251" Column="70" TopLine="234"/>
<Caret Line="252" Column="3" TopLine="239"/>
</Position6>
<Position7>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="252" Column="3" TopLine="239"/>
<Caret Line="79" Column="67" TopLine="75"/>
</Position7>
<Position8>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="79" Column="67" TopLine="75"/>
<Caret Line="352" Column="38" TopLine="336"/>
</Position8>
<Position9>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="352" Column="38" TopLine="336"/>
<Caret Line="41" Column="100" TopLine="29"/>
</Position9>
<Position10>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="41" Column="100" TopLine="29"/>
<Caret Line="99" Column="40" TopLine="71"/>
</Position10>
<Position11>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="99" Column="40" TopLine="71"/>
<Caret Line="119" Column="15" TopLine="103"/>
</Position11>
<Position12>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="119" Column="15" TopLine="103"/>
<Caret Line="191" Column="3" TopLine="182"/>
</Position12>
<Position13>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="191" Column="3" TopLine="182"/>
<Caret Line="339" Column="60" TopLine="324"/>
</Position13>
<Position14>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="339" Column="60" TopLine="324"/>
<Caret Line="191" Column="62" TopLine="176"/>
</Position14>
<Position15>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="191" Column="62" TopLine="176"/>
<Caret Line="120" Column="67" TopLine="106"/>
</Position15>
<Position16>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="120" Column="67" TopLine="106"/>
<Caret Line="339" Column="31" TopLine="324"/>
</Position16>
<Position17>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="339" Column="31" TopLine="324"/>
<Caret Line="117" Column="84" TopLine="94"/>
</Position17>
<Position18>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="117" Column="84" TopLine="94"/>
<Caret Line="115" Column="96" TopLine="95"/>
</Position18>
<Position19>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="115" Column="96" TopLine="95"/>
<Caret Line="119" Column="87" TopLine="95"/>
</Position19>
<Position20>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="119" Column="87" TopLine="95"/>
<Caret Line="245" Column="11" TopLine="222"/>
</Position20>
<Position21>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="245" Column="11" TopLine="222"/>
<Caret Line="340" TopLine="325"/>
</Position21>
<Position22>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="340" TopLine="325"/>
<Caret Line="339" Column="74" TopLine="325"/>
</Position22>
<Position23>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="339" Column="74" TopLine="325"/>
<Caret Line="216" Column="51" TopLine="202"/>
</Position23>
<Position24>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="216" Column="51" TopLine="202"/>
<Caret Line="340" Column="68" TopLine="326"/>
</Position24>
<Position25>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="340" Column="68" TopLine="326"/>
<Caret Line="121" Column="15" TopLine="109"/>
</Position25>
<Position26>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="121" Column="15" TopLine="109"/>
<Caret Line="198" Column="5" TopLine="190"/>
</Position26>
<Position27>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="198" Column="5" TopLine="190"/>
<Caret Line="221" Column="66" TopLine="208"/>
</Position27>
<Position28>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="221" Column="66" TopLine="208"/>
<Caret Line="198" Column="28" TopLine="178"/>
</Position28>
<Position29>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="198" Column="28" TopLine="178"/>
<Caret Line="83" Column="72" TopLine="75"/>
</Position29>
<Position30>
<Filename Value="uCookieVisitor.pas"/>
<Caret Line="83" Column="72" TopLine="75"/>
<Caret Line="236" Column="13" TopLine="232"/>
</Position30>
</JumpHistory>
<RunParams>

View File

@ -15,7 +15,7 @@ object CookieVisitorFrm: TCookieVisitorFrm
OnDestroy = FormDestroy
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '2.0.4.0'
LCLVersion = '2.0.6.0'
object AddressBarPnl: TPanel
Left = 0
Height = 21
@ -60,6 +60,7 @@ object CookieVisitorFrm: TCookieVisitorFrm
object Chromium1: TChromium
OnCookiesDeleted = Chromium1CookiesDeleted
OnCookiesVisited = Chromium1CookiesVisited
OnCookieVisitorDestroyed = Chromium1CookieVisitorDestroyed
OnCookieSet = Chromium1CookieSet
OnBeforeContextMenu = Chromium1BeforeContextMenu
OnContextMenuCommand = Chromium1ContextMenuCommand

View File

@ -82,6 +82,7 @@ type
domain, path: ustring; secure, httponly, hasExpires: Boolean;
const creation, lastAccess, expires: TDateTime; count, total, aID: Integer;
var aDeleteCookie, aResult: Boolean);
procedure Chromium1CookieVisitorDestroyed(Sender: TObject; aID: integer);
procedure FormShow(Sender: TObject);
procedure GoBtnClick(Sender: TObject);
procedure Chromium1BeforeContextMenu(Sender: TObject;
@ -236,28 +237,28 @@ procedure TCookieVisitorFrm.Chromium1CookiesVisited(Sender: TObject;
var
TempCookie : TCookie;
begin
aDeleteCookie := False;
aDeleteCookie := False;
TempCookie.name := name_;
TempCookie.value := value;
TempCookie.domain := domain;
TempCookie.path := path;
TempCookie.secure := secure;
TempCookie.httponly := httponly;
TempCookie.creation := creation;
TempCookie.last_access := lastAccess;
TempCookie.has_expires := hasExpires;
TempCookie.expires := expires;
TempCookie.name := name_;
TempCookie.value := value;
TempCookie.domain := domain;
TempCookie.path := path;
TempCookie.secure := secure;
TempCookie.httponly := httponly;
TempCookie.creation := creation;
TempCookie.last_access := lastAccess;
TempCookie.has_expires := hasExpires;
TempCookie.expires := expires;
AddCookieInfo(TempCookie);
AddCookieInfo(TempCookie);
if (count = pred(total)) then
begin
PostMessage(Handle, MINIBROWSER_SHOWCOOKIES, 0, 0);
aResult := False;
end
else
aResult := True;
aResult := (count <> pred(total));
end;
procedure TCookieVisitorFrm.Chromium1CookieVisitorDestroyed(Sender: TObject;
aID: integer);
begin
PostMessage(Handle, MINIBROWSER_SHOWCOOKIES, 0, 0);
end;
procedure TCookieVisitorFrm.CEFSentinel1Close(Sender: TObject);

View File

@ -73,6 +73,7 @@ type
FBrowser : ICefBrowser;
FBrowserId : Integer;
FReqContextHandler : ICefRequestContextHandler;
FResourceRequestHandler : ICefResourceRequestHandler;
FDefaultUrl : ustring;
FOptions : TChromiumOptions;
FFontOptions : TChromiumFontOptions;
@ -184,16 +185,16 @@ type
FOnClose : TOnClose;
// ICefRequestHandler
FOnBeforeBrowse : TOnBeforeBrowse;
FOnOpenUrlFromTab : TOnOpenUrlFromTab;
FOnGetAuthCredentials : TOnGetAuthCredentials;
FOnQuotaRequest : TOnQuotaRequest;
FOnCertificateError : TOnCertificateError;
FOnSelectClientCertificate : TOnSelectClientCertificate;
FOnPluginCrashed : TOnPluginCrashed;
FOnRenderViewReady : TOnRenderViewReady;
FOnRenderProcessTerminated : TOnRenderProcessTerminated;
FOnGetResourceRequestHandler : TOnGetResourceRequestHandler;
FOnBeforeBrowse : TOnBeforeBrowse;
FOnOpenUrlFromTab : TOnOpenUrlFromTab;
FOnGetAuthCredentials : TOnGetAuthCredentials;
FOnQuotaRequest : TOnQuotaRequest;
FOnCertificateError : TOnCertificateError;
FOnSelectClientCertificate : TOnSelectClientCertificate;
FOnPluginCrashed : TOnPluginCrashed;
FOnRenderViewReady : TOnRenderViewReady;
FOnRenderProcessTerminated : TOnRenderProcessTerminated;
FOnGetResourceRequestHandler_ReqHdlr : TOnGetResourceRequestHandler;
// ICefResourceRequestHandler
FOnBeforeResourceLoad : TOnBeforeResourceLoad;
@ -237,8 +238,9 @@ type
FOnFindResult : TOnFindResult;
// ICefRequestContextHandler
FOnRequestContextInitialized : TOnRequestContextInitialized;
FOnBeforePluginLoad : TOnBeforePluginLoad;
FOnRequestContextInitialized : TOnRequestContextInitialized;
FOnBeforePluginLoad : TOnBeforePluginLoad;
FOnGetResourceRequestHandler_ReqCtxHdlr : TOnGetResourceRequestHandler;
// Custom
FOnTextResultAvailable : TOnTextResultAvailableEvent;
@ -254,6 +256,7 @@ type
FOnAllConnectionsClosed : TNotifyEvent;
FOnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread;
FOnCookiesVisited : TOnCookiesVisited;
FOnCookieVisitorDestroyed : TOnCookieVisitorDestroyed;
FOnCookieSet : TOnCookieSet;
{$IFNDEF FPC}
FOnBrowserCompMsg : TOnCompMsgEvent;
@ -323,8 +326,10 @@ type
procedure DestroyClientHandler;
procedure DestroyReqContextHandler;
procedure DestroyResourceRequestHandler;
procedure ClearBrowserReference;
procedure CreateReqContextHandler;
procedure CreateResourceRequestHandler;
procedure InitializeEvents;
procedure InitializeSettings(var aSettings : TCefBrowserSettings);
@ -434,7 +439,7 @@ type
// ICefRequestHandler
function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; virtual;
function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual;
procedure doOnGetResourceRequestHandler(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; var aUseInternalHandler : boolean); virtual;
procedure doGetResourceRequestHandler_ReqHdlr(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;
function doOnGetAuthCredentials(const browser: ICefBrowser; const originUrl: ustring; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual;
function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; virtual;
function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual;
@ -487,7 +492,7 @@ type
// 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;
procedure doGetResourceRequestHandler_ReqCtxHdlr(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;
@ -505,6 +510,7 @@ type
procedure doAllConnectionsClosed; virtual;
procedure doOnExecuteTaskOnCefThread(aTaskID : cardinal); virtual;
procedure doOnCookiesVisited(const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; var aDeleteCookie, aResult : Boolean); virtual;
procedure doOnCookieVisitorDestroyed(aID : integer); virtual;
procedure doOnCookieSet(aSuccess : boolean; aID : integer); virtual;
function MustCreateLoadHandler : boolean; virtual;
function MustCreateFocusHandler : boolean; virtual;
@ -662,6 +668,7 @@ type
property Browser : ICefBrowser read FBrowser;
property CefClient : ICefClient read FHandler;
property ReqContextHandler : ICefRequestContextHandler read FReqContextHandler;
property ResourceRequestHandler : ICefResourceRequestHandler read FResourceRequestHandler;
property CefWindowInfo : TCefWindowInfo read FWindowInfo;
property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry;
property MultithreadApp : boolean read GetMultithreadApp;
@ -733,6 +740,7 @@ type
property OnAllConnectionsClosed : TNotifyEvent read FOnAllConnectionsClosed write FOnAllConnectionsClosed;
property OnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread read FOnExecuteTaskOnCefThread write FOnExecuteTaskOnCefThread;
property OnCookiesVisited : TOnCookiesVisited read FOnCookiesVisited write FOnCookiesVisited;
property OnCookieVisitorDestroyed : TOnCookieVisitorDestroyed read FOnCookieVisitorDestroyed write FOnCookieVisitorDestroyed;
property OnCookieSet : TOnCookieSet read FOnCookieSet write FOnCookieSet;
{$IFNDEF FPC}
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
@ -792,16 +800,16 @@ type
property OnClose : TOnClose read FOnClose write FOnClose;
// ICefRequestHandler
property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse;
property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab;
property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials;
property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest;
property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError;
property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate;
property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed;
property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady;
property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated;
property OnGetResourceRequestHandler : TOnGetResourceRequestHandler read FOnGetResourceRequestHandler write FOnGetResourceRequestHandler;
property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse;
property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab;
property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials;
property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest;
property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError;
property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate;
property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed;
property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady;
property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated;
property OnGetResourceRequestHandler_ReqHdlr : TOnGetResourceRequestHandler read FOnGetResourceRequestHandler_ReqHdlr write FOnGetResourceRequestHandler_ReqHdlr;
// ICefResourceRequestHandler
property OnBeforeResourceLoad : TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad;
@ -845,8 +853,9 @@ type
property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult;
// ICefRequestContextHandler
property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized;
property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad;
property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized;
property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad;
property OnGetResourceRequestHandler_ReqCtxHdlr : TOnGetResourceRequestHandler read FOnGetResourceRequestHandler_ReqCtxHdlr write FOnGetResourceRequestHandler_ReqCtxHdlr;
end;
{$IFDEF FPC}
@ -892,7 +901,7 @@ uses
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, {$IFNDEF FPC}uCEFOLEDragAndDrop,{$ENDIF}
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack, uCEFCookieManager,
uCEFRequestContextHandler, uCEFCookieVisitor, uCEFSetCookieCallback;
uCEFRequestContextHandler, uCEFCookieVisitor, uCEFSetCookieCallback, uCEFResourceRequestHandler;
constructor TChromium.Create(AOwner: TComponent);
begin
@ -905,6 +914,7 @@ begin
FDefaultUrl := 'about:blank';
FHandler := nil;
FReqContextHandler := nil;
FResourceRequestHandler := nil;
FOptions := nil;
FFontOptions := nil;
FDefaultEncoding := '';
@ -1026,6 +1036,7 @@ begin
DestroyClientHandler;
DestroyReqContextHandler;
DestroyResourceRequestHandler;
inherited BeforeDestruction;
end;
@ -1087,6 +1098,27 @@ begin
FReqContextHandler := TCustomRequestContextHandler.Create(self);
end;
procedure TChromium.DestroyResourceRequestHandler;
begin
try
if (FResourceRequestHandler <> nil) then
begin
FResourceRequestHandler.RemoveReferences;
FResourceRequestHandler := nil;
end;
except
on e : exception do
if CustomExceptionHandler('TChromium.DestroyResourceRequestHandler', e) then raise;
end;
end;
procedure TChromium.CreateResourceRequestHandler;
begin
if MustCreateResourceRequestHandler and
(FResourceRequestHandler = nil) then
FResourceRequestHandler := TCustomResourceRequestHandler.Create(self);
end;
procedure TChromium.AfterConstruction;
{$IFDEF FPC}
var
@ -1198,16 +1230,16 @@ begin
FOnClose := nil;
// ICefRequestHandler
FOnBeforeBrowse := nil;
FOnOpenUrlFromTab := nil;
FOnGetAuthCredentials := nil;
FOnQuotaRequest := nil;
FOnCertificateError := nil;
FOnSelectClientCertificate := nil;
FOnPluginCrashed := nil;
FOnRenderViewReady := nil;
FOnRenderProcessTerminated := nil;
FOnGetResourceRequestHandler := nil;
FOnBeforeBrowse := nil;
FOnOpenUrlFromTab := nil;
FOnGetAuthCredentials := nil;
FOnQuotaRequest := nil;
FOnCertificateError := nil;
FOnSelectClientCertificate := nil;
FOnPluginCrashed := nil;
FOnRenderViewReady := nil;
FOnRenderProcessTerminated := nil;
FOnGetResourceRequestHandler_ReqHdlr := nil;
// ICefResourceRequestHandler
FOnBeforeResourceLoad := nil;
@ -1251,8 +1283,9 @@ begin
FOnFindResult := nil;
// ICefRequestContextHandler
FOnRequestContextInitialized := nil;
FOnBeforePluginLoad := nil;
FOnRequestContextInitialized := nil;
FOnBeforePluginLoad := nil;
FOnGetResourceRequestHandler_ReqCtxHdlr := nil;
// Custom
FOnTextResultAvailable := nil;
@ -1268,6 +1301,7 @@ begin
FOnAllConnectionsClosed := nil;
FOnExecuteTaskOnCefThread := nil;
FOnCookiesVisited := nil;
FOnCookieVisitorDestroyed := nil;
FOnCookieSet := nil;
{$IFNDEF FPC}
FOnBrowserCompMsg := nil;
@ -1328,6 +1362,7 @@ begin
begin
GetSettings(FBrowserSettings);
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
CreateResourceRequestHandler;
if (aContext = nil) then
begin
@ -3513,6 +3548,12 @@ begin
aDeleteCookie, aResult);
end;
procedure TChromium.doOnCookieVisitorDestroyed(aID : integer);
begin
if assigned(FOnCookieVisitorDestroyed) then
FOnCookieVisitorDestroyed(self, aID);
end;
procedure TChromium.doOnCookieSet(aSuccess : boolean; aID : integer);
begin
if assigned(FOnCookieSet) then FOnCookieSet(self, aSuccess, aID);
@ -3626,7 +3667,9 @@ end;
function TChromium.MustCreateRequestContextHandler : boolean;
begin
Result := assigned(FOnRequestContextInitialized) or
assigned(FOnBeforePluginLoad);
assigned(FOnBeforePluginLoad) or
assigned(FOnGetResourceRequestHandler_ReqCtxHdlr) or
MustCreateResourceRequestHandler;
end;
{$IFDEF MSWINDOWS}
@ -3886,6 +3929,8 @@ begin
if (browser <> nil) and (FBrowserId = browser.Identifier) then
begin
FInitialized := False;
DestroyResourceRequestHandler;
DestroyReqContextHandler;
ClearBrowserReference;
DestroyClientHandler;
end;
@ -4146,17 +4191,22 @@ begin
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);
procedure TChromium.doGetResourceRequestHandler_ReqCtxHdlr(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;
if (FResourceRequestHandler <> nil) then
aResourceRequestHandler := FResourceRequestHandler;
if Assigned(FOnGetResourceRequestHandler_ReqCtxHdlr) then
FOnGetResourceRequestHandler_ReqCtxHdlr(self, browser, frame, request, is_navigation, is_download,
request_initiator, disable_default_handling,
aResourceRequestHandler);
end;
procedure TChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
@ -4325,20 +4375,22 @@ begin
FOnOpenUrlFromTab(Self, browser, frame, targetUrl, targetDisposition, userGesture, Result);
end;
procedure TChromium.doOnGetResourceRequestHandler(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;
var aUseInternalHandler : boolean);
procedure TChromium.doGetResourceRequestHandler_ReqHdlr(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 Assigned(FOnGetResourceRequestHandler) then
FOnGetResourceRequestHandler(self, browser, frame, request, is_navigation, is_download,
request_initiator, disable_default_handling,
aResourceRequestHandler, aUseInternalHandler);
if (FResourceRequestHandler <> nil) then
aResourceRequestHandler := FResourceRequestHandler;
if Assigned(FOnGetResourceRequestHandler_ReqHdlr) then
FOnGetResourceRequestHandler_ReqHdlr(self, browser, frame, request, is_navigation, is_download,
request_initiator, disable_default_handling,
aResourceRequestHandler);
end;
procedure TChromium.doOnPaint(const browser : ICefBrowser;

View File

@ -118,7 +118,7 @@ type
TOnPluginCrashed = procedure(Sender: TObject; const browser: ICefBrowser; const pluginPath: ustring) of object;
TOnRenderViewReady = procedure(Sender: Tobject; const browser: ICefBrowser) of Object;
TOnRenderProcessTerminated = procedure(Sender: TObject; const browser: ICefBrowser; status: TCefTerminationStatus) of object;
TOnGetResourceRequestHandler = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aExternalResourceRequestHandler : ICefResourceRequestHandler; var aUseInternalResourceRequestHandler : boolean) of object;
TOnGetResourceRequestHandler = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aExternalResourceRequestHandler : ICefResourceRequestHandler) of object;
// ICefResourceRequestHandler
TOnBeforeResourceLoad = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback; out Result: TCefReturnValue) of object;
@ -164,6 +164,7 @@ type
// 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;
// ICefRequestContextHandler uses the same TOnGetResourceRequestHandler event type defined for ICefRequestHandler
// Custom
TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object;
@ -175,6 +176,7 @@ type
TOnDownloadImageFinishedEvent = procedure(Sender: TObject; const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage) of object;
TOnExecuteTaskOnCefThread = procedure(Sender: TObject; aTaskID : cardinal) of object;
TOnCookiesVisited = procedure(Sender: TObject; const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; var aDeleteCookie, aResult : Boolean) of object;
TOnCookieVisitorDestroyed = procedure(Sender: TObject; aID : integer) of object;
TOnCookieSet = procedure(Sender: TObject; aSuccess : boolean; aID : integer) of object;
{$IFDEF MSWINDOWS}
TOnCompMsgEvent = procedure(var aMessage: TMessage; var aHandled: Boolean) of object;

View File

@ -178,9 +178,18 @@ end;
destructor TCefCustomCookieVisitor.Destroy;
begin
FEvents := nil;
inherited Destroy;
try
try
if (FEvents <> nil) then
IChromiumEvents(FEvents).doOnCookieVisitorDestroyed(FID);
except
on e : exception do
if CustomExceptionHandler('TCefCustomCookieVisitor.Destroy', e) then raise;
end;
finally
FEvents := nil;
inherited Destroy;
end;
end;
function TCefCustomCookieVisitor.visit(const name, value, domain, path: ustring;

View File

@ -62,6 +62,7 @@ type
FBrowser : ICefBrowser;
FBrowserId : Integer;
FReqContextHandler : ICefRequestContextHandler;
FResourceRequestHandler : ICefResourceRequestHandler;
FDefaultUrl : ustring;
FOptions : TChromiumOptions;
FFontOptions : TChromiumFontOptions;
@ -170,16 +171,16 @@ type
FOnClose : TOnClose;
// ICefRequestHandler
FOnBeforeBrowse : TOnBeforeBrowse;
FOnOpenUrlFromTab : TOnOpenUrlFromTab;
FOnGetAuthCredentials : TOnGetAuthCredentials;
FOnQuotaRequest : TOnQuotaRequest;
FOnCertificateError : TOnCertificateError;
FOnSelectClientCertificate : TOnSelectClientCertificate;
FOnPluginCrashed : TOnPluginCrashed;
FOnRenderViewReady : TOnRenderViewReady;
FOnRenderProcessTerminated : TOnRenderProcessTerminated;
FOnGetResourceRequestHandler : TOnGetResourceRequestHandler;
FOnBeforeBrowse : TOnBeforeBrowse;
FOnOpenUrlFromTab : TOnOpenUrlFromTab;
FOnGetAuthCredentials : TOnGetAuthCredentials;
FOnQuotaRequest : TOnQuotaRequest;
FOnCertificateError : TOnCertificateError;
FOnSelectClientCertificate : TOnSelectClientCertificate;
FOnPluginCrashed : TOnPluginCrashed;
FOnRenderViewReady : TOnRenderViewReady;
FOnRenderProcessTerminated : TOnRenderProcessTerminated;
FOnGetResourceRequestHandler_ReqHdlr : TOnGetResourceRequestHandler;
// ICefResourceRequestHandler
FOnBeforeResourceLoad : TOnBeforeResourceLoad;
@ -221,8 +222,9 @@ type
FOnFindResult : TOnFindResult;
// ICefRequestContextHandler
FOnRequestContextInitialized : TOnRequestContextInitialized;
FOnBeforePluginLoad : TOnBeforePluginLoad;
FOnRequestContextInitialized : TOnRequestContextInitialized;
FOnBeforePluginLoad : TOnBeforePluginLoad;
FOnGetResourceRequestHandler_ReqCtxHdlr : TOnGetResourceRequestHandler;
// Custom
FOnTextResultAvailable : TOnTextResultAvailableEvent;
@ -237,6 +239,7 @@ type
FOnAllConnectionsClosed : TNotifyEvent;
FOnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread;
FOnCookiesVisited : TOnCookiesVisited;
FOnCookieVisitorDestroyed : TOnCookieVisitorDestroyed;
FOnCookieSet : TOnCookieSet;
{$IFDEF MSWINDOWS}
FOnBrowserCompMsg : TOnCompMsgEvent;
@ -306,8 +309,10 @@ type
procedure DestroyClientHandler;
procedure DestroyReqContextHandler;
procedure DestroyResourceRequestHandler;
procedure ClearBrowserReference;
procedure CreateReqContextHandler;
procedure CreateResourceRequestHandler;
procedure InitializeEvents;
procedure InitializeSettings(var aSettings : TCefBrowserSettings);
@ -401,7 +406,7 @@ type
// ICefRequestHandler
function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; virtual;
function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual;
procedure doOnGetResourceRequestHandler(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; var aUseInternalHandler : boolean); virtual;
procedure doGetResourceRequestHandler_ReqHdlr(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;
function doOnGetAuthCredentials(const browser: ICefBrowser; const originUrl: ustring; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual;
function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; virtual;
function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual;
@ -454,7 +459,7 @@ type
// 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;
procedure doGetResourceRequestHandler_ReqCtxHdlr(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;
@ -472,6 +477,7 @@ type
procedure doAllConnectionsClosed; virtual;
procedure doOnExecuteTaskOnCefThread(aTaskID : cardinal); virtual;
procedure doOnCookiesVisited(const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; var aDeleteCookie, aResult : Boolean); virtual;
procedure doOnCookieVisitorDestroyed(aID : integer); virtual;
procedure doOnCookieSet(aSuccess : boolean; aID : integer); virtual;
function MustCreateLoadHandler : boolean; virtual;
function MustCreateFocusHandler : boolean; virtual;
@ -622,6 +628,7 @@ type
property Browser : ICefBrowser read FBrowser;
property CefClient : ICefClient read FHandler;
property ReqContextHandler : ICefRequestContextHandler read FReqContextHandler;
property ResourceRequestHandler : ICefResourceRequestHandler read FResourceRequestHandler;
property CefWindowInfo : TCefWindowInfo read FWindowInfo;
property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry;
property MultithreadApp : boolean read GetMultithreadApp;
@ -692,6 +699,7 @@ type
property OnAllConnectionsClosed : TNotifyEvent read FOnAllConnectionsClosed write FOnAllConnectionsClosed;
property OnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread read FOnExecuteTaskOnCefThread write FOnExecuteTaskOnCefThread;
property OnCookiesVisited : TOnCookiesVisited read FOnCookiesVisited write FOnCookiesVisited;
property OnCookieVisitorDestroyed : TOnCookieVisitorDestroyed read FOnCookieVisitorDestroyed write FOnCookieVisitorDestroyed;
property OnCookieSet : TOnCookieSet read FOnCookieSet write FOnCookieSet;
{$IFDEF MSWINDOWS}
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
@ -751,16 +759,16 @@ type
property OnClose : TOnClose read FOnClose write FOnClose;
// ICefRequestHandler
property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse;
property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab;
property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials;
property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest;
property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError;
property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate;
property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed;
property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady;
property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated;
property OnGetResourceRequestHandler : TOnGetResourceRequestHandler read FOnGetResourceRequestHandler write FOnGetResourceRequestHandler;
property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse;
property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab;
property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials;
property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest;
property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError;
property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate;
property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed;
property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady;
property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated;
property OnGetResourceRequestHandler_ReqHdlr : TOnGetResourceRequestHandler read FOnGetResourceRequestHandler_ReqHdlr write FOnGetResourceRequestHandler_ReqHdlr;
// ICefResourceRequestHandler
property OnBeforeResourceLoad : TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad;
@ -802,8 +810,9 @@ type
property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult;
// ICefRequestContextHandler
property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized;
property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad;
property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized;
property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad;
property OnGetResourceRequestHandler_ReqCtxHdlr : TOnGetResourceRequestHandler read FOnGetResourceRequestHandler_ReqCtxHdlr write FOnGetResourceRequestHandler_ReqCtxHdlr;
end;
// *********************************************************
@ -841,7 +850,8 @@ uses
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, uCEFCookieManager,
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
uCEFListValue, uCEFNavigationEntryVisitor, uCEFDownloadImageCallBack,
uCEFRequestContextHandler, uCEFCookieVisitor, uCEFSetCookieCallback;
uCEFRequestContextHandler, uCEFCookieVisitor, uCEFSetCookieCallback,
uCEFResourceRequestHandler;
constructor TFMXChromium.Create(AOwner: TComponent);
begin
@ -853,6 +863,7 @@ begin
FDefaultUrl := 'about:blank';
FHandler := nil;
FReqContextHandler := nil;
FResourceRequestHandler := nil;
FOptions := nil;
FFontOptions := nil;
FDefaultEncoding := '';
@ -960,6 +971,7 @@ begin
DestroyClientHandler;
DestroyReqContextHandler;
DestroyResourceRequestHandler;
inherited BeforeDestruction;
end;
@ -1005,6 +1017,27 @@ begin
FReqContextHandler := TCustomRequestContextHandler.Create(self);
end;
procedure TFMXChromium.DestroyResourceRequestHandler;
begin
try
if (FResourceRequestHandler <> nil) then
begin
FResourceRequestHandler.RemoveReferences;
FResourceRequestHandler := nil;
end;
except
on e : exception do
if CustomExceptionHandler('TFMXChromium.DestroyResourceRequestHandler', e) then raise;
end;
end;
procedure TFMXChromium.CreateResourceRequestHandler;
begin
if MustCreateResourceRequestHandler and
(FResourceRequestHandler = nil) then
FResourceRequestHandler := TCustomResourceRequestHandler.Create(self);
end;
procedure TFMXChromium.AfterConstruction;
begin
inherited AfterConstruction;
@ -1104,16 +1137,16 @@ begin
FOnClose := nil;
// ICefRequestHandler
FOnBeforeBrowse := nil;
FOnOpenUrlFromTab := nil;
FOnGetAuthCredentials := nil;
FOnQuotaRequest := nil;
FOnCertificateError := nil;
FOnSelectClientCertificate := nil;
FOnPluginCrashed := nil;
FOnRenderViewReady := nil;
FOnRenderProcessTerminated := nil;
FOnGetResourceRequestHandler := nil;
FOnBeforeBrowse := nil;
FOnOpenUrlFromTab := nil;
FOnGetAuthCredentials := nil;
FOnQuotaRequest := nil;
FOnCertificateError := nil;
FOnSelectClientCertificate := nil;
FOnPluginCrashed := nil;
FOnRenderViewReady := nil;
FOnRenderProcessTerminated := nil;
FOnGetResourceRequestHandler_ReqHdlr := nil;
// ICefResourceRequestHandler
FOnBeforeResourceLoad := nil;
@ -1155,8 +1188,9 @@ begin
FOnFindResult := nil;
// ICefRequestContextHandler
FOnRequestContextInitialized := nil;
FOnBeforePluginLoad := nil;
FOnRequestContextInitialized := nil;
FOnBeforePluginLoad := nil;
FOnGetResourceRequestHandler_ReqCtxHdlr := nil;
// Custom
FOnTextResultAvailable := nil;
@ -1171,6 +1205,7 @@ begin
FOnAllConnectionsClosed := nil;
FOnExecuteTaskOnCefThread := nil;
FOnCookiesVisited := nil;
FOnCookieVisitorDestroyed := nil;
FOnCookieSet := nil;
end;
@ -1263,6 +1298,7 @@ begin
begin
GetSettings(FBrowserSettings);
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
CreateResourceRequestHandler;
if (aContext = nil) then
begin
@ -3255,6 +3291,12 @@ begin
aDeleteCookie, aResult);
end;
procedure TFMXChromium.doOnCookieVisitorDestroyed(aID : integer);
begin
if assigned(FOnCookieVisitorDestroyed) then
FOnCookieVisitorDestroyed(self, aID);
end;
procedure TFMXChromium.doOnCookieSet(aSuccess : boolean; aID : integer);
begin
if assigned(FOnCookieSet) then FOnCookieSet(self, aSuccess, aID);
@ -3368,7 +3410,9 @@ end;
function TFMXChromium.MustCreateRequestContextHandler : boolean;
begin
Result := assigned(FOnRequestContextInitialized) or
assigned(FOnBeforePluginLoad);
assigned(FOnBeforePluginLoad) or
assigned(FOnGetResourceRequestHandler_ReqCtxHdlr) or
MustCreateResourceRequestHandler;
end;
procedure TFMXChromium.doTextResultAvailable(const aText : ustring);
@ -3516,6 +3560,7 @@ begin
if (browser <> nil) and (FBrowserId = browser.Identifier) then
begin
FInitialized := False;
DestroyResourceRequestHandler;
DestroyReqContextHandler;
ClearBrowserReference;
DestroyClientHandler;
@ -3777,17 +3822,22 @@ begin
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);
procedure TFMXChromium.doGetResourceRequestHandler_ReqCtxHdlr(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;
if (FResourceRequestHandler <> nil) then
aResourceRequestHandler := FResourceRequestHandler;
if Assigned(FOnGetResourceRequestHandler_ReqCtxHdlr) then
FOnGetResourceRequestHandler_ReqCtxHdlr(self, browser, frame, request, is_navigation, is_download,
request_initiator, disable_default_handling,
aResourceRequestHandler);
end;
procedure TFMXChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
@ -3956,20 +4006,22 @@ begin
FOnOpenUrlFromTab(Self, browser, frame, targetUrl, targetDisposition, userGesture, Result);
end;
procedure TFMXChromium.doOnGetResourceRequestHandler(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;
var aUseInternalHandler : boolean);
procedure TFMXChromium.doGetResourceRequestHandler_ReqHdlr(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 Assigned(FOnGetResourceRequestHandler) then
FOnGetResourceRequestHandler(self, browser, frame, request, is_navigation, is_download,
request_initiator, disable_default_handling,
aResourceRequestHandler, aUseInternalHandler);
if (FResourceRequestHandler <> nil) then
aResourceRequestHandler := FResourceRequestHandler;
if Assigned(FOnGetResourceRequestHandler_ReqHdlr) then
FOnGetResourceRequestHandler_ReqHdlr(self, browser, frame, request, is_navigation, is_download,
request_initiator, disable_default_handling,
aResourceRequestHandler);
end;
procedure TFMXChromium.doOnPaint(const browser : ICefBrowser;

View File

@ -324,7 +324,7 @@ type
// ICefRequestHandler
function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean;
function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean;
procedure doOnGetResourceRequestHandler(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; var aUseInternalHandler : boolean);
procedure doGetResourceRequestHandler_ReqHdlr(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);
function doOnGetAuthCredentials(const browser: ICefBrowser; const originUrl: ustring; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean;
function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean;
function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean;
@ -377,7 +377,7 @@ type
// 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);
procedure doGetResourceRequestHandler_ReqCtxHdlr(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);
@ -395,6 +395,7 @@ type
procedure doAllConnectionsClosed;
procedure doOnExecuteTaskOnCefThread(aTaskID : cardinal);
procedure doOnCookiesVisited(const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; var aDeleteCookie, aResult : Boolean);
procedure doOnCookieVisitorDestroyed(aID : integer);
procedure doOnCookieSet(aSuccess : boolean; aID : integer);
function MustCreateLoadHandler : boolean;
function MustCreateFocusHandler : boolean;

View File

@ -353,14 +353,14 @@ procedure TCustomRequestContextHandler.GetResourceRequestHandler(const browser
var aResourceRequestHandler : ICefResourceRequestHandler);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doGetResourceRequestHandler(browser,
frame,
request,
is_navigation,
is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler)
IChromiumEvents(FEvents).doGetResourceRequestHandler_ReqCtxHdlr(browser,
frame,
request,
is_navigation,
is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler)
else
inherited GetResourceRequestHandler(browser,
frame,

View File

@ -73,8 +73,7 @@ type
TCustomRequestHandler = class(TCefRequestHandlerOwn)
protected
FEvents : Pointer;
FResourceRequestHandler : ICefResourceRequestHandler;
FEvents : Pointer;
function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; override;
function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; override;
@ -87,8 +86,6 @@ type
procedure OnRenderViewReady(const browser: ICefBrowser); override;
procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); override;
procedure InitializeVars;
public
constructor Create(const events : IChromiumEvents); reintroduce; virtual;
procedure BeforeDestruction; override;
@ -105,7 +102,7 @@ uses
{$ENDIF}
uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFRequest, uCEFRequestCallback,
uCEFResponse, uCEFAuthCallback, uCEFSslInfo, uCEFSelectClientCertificateCallback, uCEFX509Certificate,
uCEFApplication, uCEFResourceRequestHandler;
uCEFApplication;
function cef_request_handler_on_before_browse(self : PCefRequestHandler;
browser : PCefBrowser;
@ -461,17 +458,12 @@ constructor TCustomRequestHandler.Create(const events : IChromiumEvents);
begin
inherited Create;
InitializeVars;
FEvents := Pointer(events);
if (events <> nil) and events.MustCreateResourceRequestHandler then
FResourceRequestHandler := TCustomResourceRequestHandler.Create(events);
end;
procedure TCustomRequestHandler.BeforeDestruction;
begin
InitializeVars;
FEvents := nil;
inherited BeforeDestruction;
end;
@ -479,14 +471,6 @@ end;
procedure TCustomRequestHandler.RemoveReferences;
begin
FEvents := nil;
if (FResourceRequestHandler <> nil) then FResourceRequestHandler.RemoveReferences;
end;
procedure TCustomRequestHandler.InitializeVars;
begin
FResourceRequestHandler := nil;
FEvents := nil;
end;
function TCustomRequestHandler.GetAuthCredentials(const browser : ICefBrowser;
@ -548,31 +532,22 @@ procedure TCustomRequestHandler.GetResourceRequestHandler(const browser
const request_initiator : ustring;
var disable_default_handling : boolean;
var aResourceRequestHandler : ICefResourceRequestHandler);
var
TempUseInternalHandler : boolean;
begin
if (FEvents <> nil) then
begin
TempUseInternalHandler := True;
IChromiumEvents(FEvents).doOnGetResourceRequestHandler(browser, frame, request,
is_navigation, is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler,
TempUseInternalHandler);
if TempUseInternalHandler then
begin
if (FResourceRequestHandler <> nil) then
aResourceRequestHandler := FResourceRequestHandler
else
aResourceRequestHandler := nil;
end;
end
IChromiumEvents(FEvents).doGetResourceRequestHandler_ReqHdlr(browser,
frame,
request,
is_navigation,
is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler)
else
inherited GetResourceRequestHandler(browser, frame, request,
is_navigation, is_download,
inherited GetResourceRequestHandler(browser,
frame,
request,
is_navigation,
is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler);

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 56,
"InternalVersion" : 57,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "78.3.1.0"
}