1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-12 22:07:39 +02:00

Update to CEF 90.6.4

Added try..except blocks to TCustomRequestContextHandler and TCustomResourceRequestHandler events.
This commit is contained in:
Salvador Díaz Fau
2021-05-05 14:41:13 +02:00
parent d24eec2794
commit ff05abbe1b
6 changed files with 139 additions and 103 deletions

View File

@ -36,8 +36,8 @@
*)
unit uCEFRequestContextHandler;
{$IFDEF FPC}
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ENDIF}
@ -49,6 +49,11 @@ unit uCEFRequestContextHandler;
interface
uses
{$IFDEF DELPHI16_UP}
System.SysUtils,
{$ELSE}
SysUtils,
{$ENDIF}
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
type
@ -103,10 +108,10 @@ procedure cef_request_context_handler_on_request_context_initialized(self
var
TempObject : TObject;
begin
TempObject := CefGetObject(self);
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then
TCefRequestContextHandlerOwn(TempObject).OnRequestContextInitialized(TCefRequestContextRef.UnWrap(request_context));
TCefRequestContextHandlerOwn(TempObject).OnRequestContextInitialized(TCefRequestContextRef.UnWrap(request_context));
end;
function cef_request_context_handler_on_before_plugin_load( self : PCefRequestContextHandler;
@ -121,9 +126,9 @@ var
TempPolicy : TCefPluginPolicy;
begin
Result := Ord(False);
TempObject := CefGetObject(self);
TempPolicy := plugin_policy^;
TempObject := CefGetObject(self);
TempPolicy := plugin_policy^;
if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then
Result := Ord(TCefRequestContextHandlerOwn(TempObject).OnBeforePluginLoad(CefString(mime_type),
CefString(plugin_url),
@ -149,9 +154,9 @@ var
begin
Result := nil;
TempResourceRequestHandler := nil;
TempObject := CefGetObject(self);
TempDisableDefHandling := disable_default_handling^ <> 0;
TempObject := CefGetObject(self);
TempDisableDefHandling := disable_default_handling^ <> 0;
if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then
try
TCefRequestContextHandlerOwn(TempObject).GetResourceRequestHandler(TCefBrowserRef.UnWrap(browser),
@ -184,7 +189,7 @@ end;
procedure TCefRequestContextHandlerOwn.OnRequestContextInitialized(const request_context: ICefRequestContext);
begin
//
end;
function TCefRequestContextHandlerOwn.OnBeforePluginLoad(const mimeType : ustring;
@ -206,12 +211,12 @@ procedure TCefRequestContextHandlerOwn.GetResourceRequestHandler(const browser
var disable_default_handling : boolean;
var aResourceRequestHandler : ICefResourceRequestHandler);
begin
begin
aResourceRequestHandler := nil;
end;
procedure TCefRequestContextHandlerOwn.RemoveReferences;
begin
begin
//
end;
@ -219,7 +224,8 @@ end;
procedure TCefRequestContextHandlerRef.OnRequestContextInitialized(const request_context: ICefRequestContext);
begin
begin
PCefRequestContextHandler(FData)^.on_request_context_initialized(PCefRequestContextHandler(FData), CefGetData(request_context));
end;
function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : ustring;
@ -259,27 +265,28 @@ var
TempResourceRequestHandler : PCefResourceRequestHandler;
begin
TempRequestInitiator := CefString(request_initiator);
begin
TempRequestInitiator := CefString(request_initiator);
TempDisableDefaultHandling := ord(disable_default_handling);
TempResourceRequestHandler := PCefRequestContextHandler(FData)^.get_resource_request_handler(PCefRequestContextHandler(FData),
CefGetData(browser),
TempDisableDefaultHandling := ord(disable_default_handling);
TempResourceRequestHandler := PCefRequestContextHandler(FData)^.get_resource_request_handler(PCefRequestContextHandler(FData),
CefGetData(browser),
CefGetData(frame),
CefGetData(request),
ord(is_navigation),
ord(is_download),
@TempRequestInitiator,
@TempDisableDefaultHandling);
CefGetData(request),
ord(is_navigation),
ord(is_download),
@TempRequestInitiator,
@TempDisableDefaultHandling);
disable_default_handling := TempDisableDefaultHandling <> 0;
if (TempResourceRequestHandler <> nil) then
aResourceRequestHandler := TCefResourceRequestHandlerRef.UnWrap(TempResourceRequestHandler)
else
aResourceRequestHandler := nil;
disable_default_handling := TempDisableDefaultHandling <> 0;
end;
procedure TCefRequestContextHandlerRef.RemoveReferences;
begin
//
end;
class function TCefRequestContextHandlerRef.UnWrap(data: Pointer): ICefRequestContextHandler;
@ -314,10 +321,13 @@ end;
procedure TCustomRequestContextHandler.OnRequestContextInitialized(const request_context: ICefRequestContext);
begin
procedure TCustomRequestContextHandler.RemoveReferences;
begin
FEvents := nil;
try
if (FEvents <> nil) then
IChromiumEvents(FEvents).doOnRequestContextInitialized(request_context);
except
on e : exception do
if CustomExceptionHandler('TCustomRequestContextHandler.OnRequestContextInitialized', e) then raise;
end;
end;
function TCustomRequestContextHandler.OnBeforePluginLoad(const mimeType : ustring;
@ -327,20 +337,20 @@ function TCustomRequestContextHandler.OnBeforePluginLoad(const mimeType : us
const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean;
begin
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,
Result := False;
try
if (FEvents <> nil) then
Result := IChromiumEvents(FEvents).doOnBeforePluginLoad(mimeType,
pluginUrl,
isMainFrame,
topOriginUrl,
pluginInfo,
pluginPolicy);
except
on e : exception do
if CustomExceptionHandler('TCustomRequestContextHandler.OnBeforePluginLoad', e) then raise;
end;
end;
procedure TCustomRequestContextHandler.GetResourceRequestHandler(const browser : ICefBrowser;
@ -352,24 +362,20 @@ procedure TCustomRequestContextHandler.GetResourceRequestHandler(const browser
var disable_default_handling : boolean;
var aResourceRequestHandler : ICefResourceRequestHandler);
begin
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_ReqCtxHdlr(browser,
frame,
request,
is_navigation,
is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler)
try
if (FEvents <> nil) then
IChromiumEvents(FEvents).doGetResourceRequestHandler_ReqCtxHdlr(browser,
frame,
request,
is_navigation,
is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler);
except
on e : exception do
if CustomExceptionHandler('TCustomRequestContextHandler.GetResourceRequestHandler', e) then raise;
end;
end;