You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-06-12 22:07:39 +02:00
Added TCEFApplication.CustomFlashPath property
Added TCEFApplication.CustomFlashPath property. Added default values to some parameters in CheckLocales and CheckResources o keep backwards compatibility.
This commit is contained in:
@ -7,4 +7,5 @@ del /s /q *.~*
|
|||||||
rmdir Win32\Debug
|
rmdir Win32\Debug
|
||||||
rmdir Win32\Release
|
rmdir Win32\Release
|
||||||
rmdir Win32
|
rmdir Win32
|
||||||
rmdir __history
|
rmdir __history
|
||||||
|
rmdir __recovery
|
@ -83,6 +83,7 @@ type
|
|||||||
FLocalesRequired : ustring;
|
FLocalesRequired : ustring;
|
||||||
FLogFile : ustring;
|
FLogFile : ustring;
|
||||||
FBrowserSubprocessPath : ustring;
|
FBrowserSubprocessPath : ustring;
|
||||||
|
FCustomFlashPath : ustring;
|
||||||
FFrameworkDirPath : ustring;
|
FFrameworkDirPath : ustring;
|
||||||
FLogSeverity : TCefLogSeverity;
|
FLogSeverity : TCefLogSeverity;
|
||||||
FJavaScriptFlags : ustring;
|
FJavaScriptFlags : ustring;
|
||||||
@ -132,7 +133,7 @@ type
|
|||||||
FRenderProcessHandler : ICefRenderProcessHandler;
|
FRenderProcessHandler : ICefRenderProcessHandler;
|
||||||
FAppSettings : TCefSettings;
|
FAppSettings : TCefSettings;
|
||||||
FDeviceScaleFactor : single;
|
FDeviceScaleFactor : single;
|
||||||
FCheckDevToolsResources : boolean;
|
FCheckDevToolsResources : boolean;
|
||||||
|
|
||||||
procedure SetFrameworkDirPath(const aValue : ustring);
|
procedure SetFrameworkDirPath(const aValue : ustring);
|
||||||
procedure SetResourcesDirPath(const aValue : ustring);
|
procedure SetResourcesDirPath(const aValue : ustring);
|
||||||
@ -193,6 +194,7 @@ type
|
|||||||
function SingleExeProcessing : boolean;
|
function SingleExeProcessing : boolean;
|
||||||
function CheckCEFLibrary : boolean;
|
function CheckCEFLibrary : boolean;
|
||||||
procedure DeleteDirContents(const aDirectory : string);
|
procedure DeleteDirContents(const aDirectory : string);
|
||||||
|
function FindFlashDLL(var aFileName : string) : boolean;
|
||||||
procedure ShowErrorMessageDlg(const aError : string); virtual;
|
procedure ShowErrorMessageDlg(const aError : string); virtual;
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -271,6 +273,7 @@ type
|
|||||||
property DeviceScaleFactor : single read FDeviceScaleFactor;
|
property DeviceScaleFactor : single read FDeviceScaleFactor;
|
||||||
property CheckDevToolsResources : boolean read FCheckDevToolsResources write FCheckDevToolsResources;
|
property CheckDevToolsResources : boolean read FCheckDevToolsResources write FCheckDevToolsResources;
|
||||||
property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired;
|
property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired;
|
||||||
|
property CustomFlashPath : ustring read FCustomFlashPath write FCustomFlashPath;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
|
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
|
||||||
@ -328,6 +331,7 @@ begin
|
|||||||
FLocale := '';
|
FLocale := '';
|
||||||
FLogFile := '';
|
FLogFile := '';
|
||||||
FBrowserSubprocessPath := '';
|
FBrowserSubprocessPath := '';
|
||||||
|
FCustomFlashPath := '';
|
||||||
FFrameworkDirPath := '';
|
FFrameworkDirPath := '';
|
||||||
FLogSeverity := LOGSEVERITY_DISABLE;
|
FLogSeverity := LOGSEVERITY_DISABLE;
|
||||||
FJavaScriptFlags := '';
|
FJavaScriptFlags := '';
|
||||||
@ -465,10 +469,7 @@ end;
|
|||||||
|
|
||||||
function TCefApplication.GetChromeVersion : string;
|
function TCefApplication.GetChromeVersion : string;
|
||||||
begin
|
begin
|
||||||
Result := inttostr(FChromeVersionInfo.MajorVer) + '.' +
|
Result := FileVersionInfoToString(FChromeVersionInfo);
|
||||||
inttostr(FChromeVersionInfo.MinorVer) + '.' +
|
|
||||||
inttostr(FChromeVersionInfo.Release) + '.' +
|
|
||||||
inttostr(FChromeVersionInfo.Build);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCefApplication.GetLibCefPath : string;
|
function TCefApplication.GetLibCefPath : string;
|
||||||
@ -773,6 +774,40 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCefApplication.FindFlashDLL(var aFileName : string) : boolean;
|
||||||
|
var
|
||||||
|
TempSearchRec : TSearchRec;
|
||||||
|
TempProductName, TempPath : string;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
aFileName := '';
|
||||||
|
|
||||||
|
try
|
||||||
|
if (length(FCustomFlashPath) > 0) then
|
||||||
|
begin
|
||||||
|
TempPath := IncludeTrailingPathDelimiter(FCustomFlashPath);
|
||||||
|
|
||||||
|
if (FindFirst(TempPath + '*.dll', faAnyFile, TempSearchRec) = 0) then
|
||||||
|
begin
|
||||||
|
repeat
|
||||||
|
if (TempSearchRec.Attr <> faDirectory) and
|
||||||
|
GetStringFileInfo(TempPath + TempSearchRec.Name, 'ProductName', TempProductName) and
|
||||||
|
(CompareText(TempProductName, 'Shockwave Flash') = 0) then
|
||||||
|
begin
|
||||||
|
aFileName := TempPath + TempSearchRec.Name;
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
until Result or (FindNext(TempSearchRec) <> 0);
|
||||||
|
|
||||||
|
FindClose(TempSearchRec);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
on e : exception do
|
||||||
|
if CustomExceptionHandler('TCefApplication.FindFlashDLL', e) then raise;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCefApplication.ShowErrorMessageDlg(const aError : string);
|
procedure TCefApplication.ShowErrorMessageDlg(const aError : string);
|
||||||
begin
|
begin
|
||||||
OutputDebugMessage(aError);
|
OutputDebugMessage(aError);
|
||||||
@ -784,16 +819,28 @@ procedure TCefApplication.Internal_OnBeforeCommandLineProcessing(const processTy
|
|||||||
const commandLine : ICefCommandLine);
|
const commandLine : ICefCommandLine);
|
||||||
var
|
var
|
||||||
i : integer;
|
i : integer;
|
||||||
|
TempVersionInfo : TFileVersionInfo;
|
||||||
|
TempFileName : string;
|
||||||
begin
|
begin
|
||||||
if (commandLine <> nil) then
|
if (commandLine <> nil) then
|
||||||
begin
|
begin
|
||||||
if FFlashEnabled then
|
if FindFlashDLL(TempFileName) and
|
||||||
|
GetDLLVersion(TempFileName, TempVersionInfo) then
|
||||||
begin
|
begin
|
||||||
if FEnableGPU then commandLine.AppendSwitch('--enable-gpu-plugin');
|
if FEnableGPU then commandLine.AppendSwitch('--enable-gpu-plugin');
|
||||||
|
|
||||||
commandLine.AppendSwitch('--enable-accelerated-plugins');
|
commandLine.AppendSwitch('--enable-accelerated-plugins');
|
||||||
commandLine.AppendSwitch('--enable-system-flash');
|
commandLine.AppendSwitchWithValue('--ppapi-flash-path', TempFileName);
|
||||||
end;
|
commandLine.AppendSwitchWithValue('--ppapi-flash-version', FileVersionInfoToString(TempVersionInfo));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if FFlashEnabled then
|
||||||
|
begin
|
||||||
|
if FEnableGPU then commandLine.AppendSwitch('--enable-gpu-plugin');
|
||||||
|
|
||||||
|
commandLine.AppendSwitch('--enable-accelerated-plugins');
|
||||||
|
commandLine.AppendSwitch('--enable-system-flash');
|
||||||
|
end;
|
||||||
|
|
||||||
commandLine.AppendSwitchWithValue('--enable-spelling-service', IntToStr(Ord(FEnableSpellingService)));
|
commandLine.AppendSwitchWithValue('--enable-spelling-service', IntToStr(Ord(FEnableSpellingService)));
|
||||||
commandLine.AppendSwitchWithValue('--enable-media-stream', IntToStr(Ord(FEnableMediaStream)));
|
commandLine.AppendSwitchWithValue('--enable-media-stream', IntToStr(Ord(FEnableMediaStream)));
|
||||||
|
@ -133,14 +133,16 @@ function CefClearCrossOriginWhitelist: Boolean;
|
|||||||
|
|
||||||
procedure UInt64ToFileVersionInfo(const aVersion : uint64; var aVersionInfo : TFileVersionInfo);
|
procedure UInt64ToFileVersionInfo(const aVersion : uint64; var aVersionInfo : TFileVersionInfo);
|
||||||
function GetExtendedFileVersion(const aFileName : string) : uint64;
|
function GetExtendedFileVersion(const aFileName : string) : uint64;
|
||||||
|
function GetStringFileInfo(const aFileName, aField : string; var aValue : string) : boolean;
|
||||||
function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersionInfo) : boolean;
|
function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersionInfo) : boolean;
|
||||||
|
|
||||||
function SplitLongString(aSrcString : string) : string;
|
function SplitLongString(aSrcString : string) : string;
|
||||||
function GetAbsoluteDirPath(const aSrcPath : string; var aRsltPath : string) : boolean;
|
function GetAbsoluteDirPath(const aSrcPath : string; var aRsltPath : string) : boolean;
|
||||||
function CheckLocales(const aLocalesDirPath, aLocalesRequired : string) : boolean;
|
function CheckLocales(const aLocalesDirPath : string; const aLocalesRequired : string = '') : boolean;
|
||||||
function CheckResources(const aResourcesDirPath : string; aCheckDevResources: boolean) : boolean;
|
function CheckResources(const aResourcesDirPath : string; aCheckDevResources: boolean = True) : boolean;
|
||||||
function CheckDLLs(const aFrameworkDirPath : string) : boolean;
|
function CheckDLLs(const aFrameworkDirPath : string) : boolean;
|
||||||
function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean;
|
function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean;
|
||||||
|
function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string;
|
||||||
|
|
||||||
function CefParseUrl(const url: ustring; var parts: TUrlParts): Boolean;
|
function CefParseUrl(const url: ustring; var parts: TUrlParts): Boolean;
|
||||||
function CefCreateUrl(var parts: TUrlParts): ustring;
|
function CefCreateUrl(var parts: TUrlParts): ustring;
|
||||||
@ -820,6 +822,96 @@ begin
|
|||||||
if (TempBuffer <> nil) then FreeMem(TempBuffer);
|
if (TempBuffer <> nil) then FreeMem(TempBuffer);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetStringFileInfo(const aFileName, aField : string; var aValue : string) : boolean;
|
||||||
|
type
|
||||||
|
PLangAndCodepage = ^TLangAndCodepage;
|
||||||
|
TLangAndCodepage = record
|
||||||
|
wLanguage : word;
|
||||||
|
wCodePage : word;
|
||||||
|
end;
|
||||||
|
var
|
||||||
|
TempSize : DWORD;
|
||||||
|
TempBuffer : pointer;
|
||||||
|
TempHandle : cardinal;
|
||||||
|
TempPointer : pointer;
|
||||||
|
TempSubBlock : string;
|
||||||
|
TempLang : PLangAndCodepage;
|
||||||
|
TempArray : array of TLangAndCodepage;
|
||||||
|
i, j : DWORD;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
TempBuffer := nil;
|
||||||
|
TempArray := nil;
|
||||||
|
aValue := '';
|
||||||
|
|
||||||
|
try
|
||||||
|
try
|
||||||
|
TempSize := GetFileVersionInfoSize(PChar(aFileName), TempHandle);
|
||||||
|
|
||||||
|
if (TempSize > 0) then
|
||||||
|
begin
|
||||||
|
GetMem(TempBuffer, TempSize);
|
||||||
|
|
||||||
|
if GetFileVersionInfo(PChar(aFileName), 0, TempSize, TempBuffer) then
|
||||||
|
begin
|
||||||
|
if VerQueryValue(TempBuffer, '\VarFileInfo\Translation\', Pointer(TempLang), TempSize) then
|
||||||
|
begin
|
||||||
|
i := 0;
|
||||||
|
j := TempSize div SizeOf(TLangAndCodepage);
|
||||||
|
|
||||||
|
SetLength(TempArray, j);
|
||||||
|
|
||||||
|
while (i < j) do
|
||||||
|
begin
|
||||||
|
TempArray[i].wLanguage := TempLang.wLanguage;
|
||||||
|
TempArray[i].wCodePage := TempLang.wCodePage;
|
||||||
|
inc(TempLang);
|
||||||
|
inc(i);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
i := 0;
|
||||||
|
j := Length(TempArray);
|
||||||
|
|
||||||
|
while (i < j) and not(Result) do
|
||||||
|
begin
|
||||||
|
TempSubBlock := '\StringFileInfo\' +
|
||||||
|
IntToHex(TempArray[i].wLanguage, 4) + IntToHex(TempArray[i].wCodePage, 4) +
|
||||||
|
'\' + aField;
|
||||||
|
|
||||||
|
if VerQueryValue(TempBuffer, PChar(TempSubBlock), TempPointer, TempSize) then
|
||||||
|
begin
|
||||||
|
aValue := trim(PChar(TempPointer));
|
||||||
|
Result := (length(aValue) > 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
inc(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Adobe's flash player DLL uses a different codepage to store the StringFileInfo fields
|
||||||
|
if not(Result) and (j > 0) and (TempArray[0].wCodePage <> 1252) then
|
||||||
|
begin
|
||||||
|
TempSubBlock := '\StringFileInfo\' +
|
||||||
|
IntToHex(TempArray[0].wLanguage, 4) + IntToHex(1252, 4) +
|
||||||
|
'\' + aField;
|
||||||
|
|
||||||
|
if VerQueryValue(TempBuffer, PChar(TempSubBlock), TempPointer, TempSize) then
|
||||||
|
begin
|
||||||
|
aValue := trim(PChar(TempPointer));
|
||||||
|
Result := (length(aValue) > 0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
on e : exception do
|
||||||
|
if CustomExceptionHandler('GetStringFileInfo', e) then raise;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
if (TempBuffer <> nil) then FreeMem(TempBuffer);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersionInfo) : boolean;
|
function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersionInfo) : boolean;
|
||||||
var
|
var
|
||||||
@ -839,6 +931,14 @@ begin
|
|||||||
if CustomExceptionHandler('GetDLLVersion', e) then raise;
|
if CustomExceptionHandler('GetDLLVersion', e) then raise;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string;
|
||||||
|
begin
|
||||||
|
Result := IntToStr(aVersionInfo.MajorVer) + '.' +
|
||||||
|
IntToStr(aVersionInfo.MinorVer) + '.' +
|
||||||
|
IntToStr(aVersionInfo.Release) + '.' +
|
||||||
|
IntToStr(aVersionInfo.Build);
|
||||||
|
end;
|
||||||
|
|
||||||
function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean;
|
function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean;
|
||||||
var
|
var
|
||||||
|
Reference in New Issue
Block a user