1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-11-23 21:34:53 +02:00

Update to CEF 77.1.13

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

View File

@@ -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
const pluginUrl : ustring;
isMainFrame : boolean;
const topOriginUrl : ustring;
const pluginInfo : ICefWebPluginInfo;
const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean;
begin
Result := False;
@@ -188,6 +209,12 @@ begin
begin
aResourceRequestHandler := nil;
end;
procedure TCefRequestContextHandlerOwn.RemoveReferences;
begin
//
end;
// TCefRequestContextHandlerRef
@@ -200,7 +227,7 @@ function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : us
function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : ustring;
const pluginUrl : ustring;
isMainFrame : boolean;
const topOriginUrl : ustring;
const topOriginUrl : ustring;
const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean;
var
@@ -214,7 +241,7 @@ begin
@TempType,
@TempPluginURL,
ord(isMainFrame),
@TempOriginURL,
@TempOriginURL,
CefGetData(pluginInfo),
@pluginPolicy) <> 0;
end;
@@ -250,6 +277,11 @@ begin
disable_default_handling := TempDisableDefaultHandling <> 0;
if (TempResourceRequestHandler <> nil) then
aResourceRequestHandler := TCefResourceRequestHandlerRef.UnWrap(TempResourceRequestHandler)
else
aResourceRequestHandler := nil;
end;
@@ -258,4 +290,87 @@ begin
//
end;
class function TCefRequestContextHandlerRef.UnWrap(data: Pointer): ICefRequestContextHandler;
begin
if (data <> nil) then
Result := Create(data) as ICefRequestContextHandler
else
Result := nil;
end;
// TCustomRequestContextHandler
constructor TCustomRequestContextHandler.Create(const events : IChromiumEvents);
begin
inherited Create;
FEvents := Pointer(events);
end;
procedure TCustomRequestContextHandler.BeforeDestruction;
begin
FEvents := nil;
inherited BeforeDestruction;
end;
procedure TCustomRequestContextHandler.RemoveReferences;
begin
FEvents := nil;
end;
procedure TCustomRequestContextHandler.OnRequestContextInitialized(const request_context: ICefRequestContext);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doOnRequestContextInitialized(request_context)
else
inherited OnRequestContextInitialized(request_context);
end;
function TCustomRequestContextHandler.OnBeforePluginLoad(const mimeType : ustring;
const pluginUrl : ustring;
isMainFrame : boolean;
const topOriginUrl : ustring;
const pluginInfo : ICefWebPluginInfo;
var pluginPolicy : TCefPluginPolicy): Boolean;
begin
if (FEvents <> nil) then
Result := IChromiumEvents(FEvents).doOnBeforePluginLoad(mimeType,
pluginUrl,
isMainFrame,
topOriginUrl,
pluginInfo,
pluginPolicy)
else
Result := inherited OnBeforePluginLoad(mimeType,
pluginUrl,
isMainFrame,
topOriginUrl,
pluginInfo,
pluginPolicy);
end;
procedure TCustomRequestContextHandler.GetResourceRequestHandler(const browser : ICefBrowser;
const frame : ICefFrame;
const request : ICefRequest;
is_navigation : boolean;
is_download : boolean;
const request_initiator : ustring;
var disable_default_handling : boolean;
var aResourceRequestHandler : ICefResourceRequestHandler);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doGetResourceRequestHandler(browser,
frame,
request,
is_navigation,
is_download,
request_initiator,
disable_default_handling,
aResourceRequestHandler)
else
inherited GetResourceRequestHandler(browser,
frame,
request,