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

CefRegisterSchemeHandlerFactory bug fix

CefRegisterSchemeHandlerFactory can have an empty DomainName and a nil handler.
This commit is contained in:
Salvador Díaz Fau 2018-06-11 18:38:51 +02:00
parent 33946d12d5
commit b701fc99e8
2 changed files with 22 additions and 9 deletions

View File

@ -151,7 +151,7 @@ procedure CefDebugLog(const aMessage : string);
procedure OutputDebugMessage(const aMessage : string);
function CustomExceptionHandler(const aFunctionName : string; const aException : exception) : boolean;
function CefRegisterSchemeHandlerFactory(const SchemeName, HostName: ustring; const handler: TCefResourceHandlerClass): Boolean;
function CefRegisterSchemeHandlerFactory(const SchemeName, DomainName : ustring; const handler: TCefResourceHandlerClass = nil): Boolean;
function CefClearSchemeHandlerFactories : boolean;
function CefAddCrossOriginWhitelistEntry(const SourceOrigin, TargetProtocol, TargetDomain: ustring; AllowTargetSubdomains: Boolean): Boolean;
@ -670,21 +670,31 @@ begin
end;
function CefRegisterSchemeHandlerFactory(const SchemeName : ustring;
const HostName : ustring;
const DomainName : ustring;
const handler : TCefResourceHandlerClass) : boolean;
var
TempScheme, TempHostName : TCefString;
TempScheme, TempDomainName : TCefString;
TempFactory : ICefSchemeHandlerFactory;
TempDomainNamePtr : PCefString;
begin
Result := False;
try
if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then
if (GlobalCEFApp <> nil) and
GlobalCEFApp.LibLoaded and
(length(SchemeName) > 0) then
begin
if (length(DomainName) > 0) then
begin
TempDomainName := CefString(DomainName);
TempDomainNamePtr := @TempDomainName;
end
else
TempDomainNamePtr := nil;
TempScheme := CefString(SchemeName);
TempHostName := CefString(HostName);
TempFactory := TCefSchemeHandlerFactoryOwn.Create(handler);
Result := cef_register_scheme_handler_factory(@TempScheme, @TempHostName, TempFactory.Wrap) <> 0;
Result := cef_register_scheme_handler_factory(@TempScheme, TempDomainNamePtr, TempFactory.Wrap) <> 0;
end;
finally
TempFactory := nil;

View File

@ -101,7 +101,10 @@ function TCefSchemeHandlerFactoryOwn.New(const browser : ICefBrowser;
const schemeName : ustring;
const request : ICefRequest): ICefResourceHandler;
begin
Result := FClass.Create(browser, frame, schemeName, request);
if (FClass <> nil) then
Result := FClass.Create(browser, frame, schemeName, request)
else
Result := nil;
end;