1
0
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:
Salvador Díaz Fau
2017-10-24 20:44:51 +02:00
parent d5d5bfed26
commit 87d11774bd
3 changed files with 159 additions and 11 deletions

View File

@ -8,3 +8,4 @@ rmdir Win32\Debug
rmdir Win32\Release
rmdir Win32
rmdir __history
rmdir __recovery

View File

@ -83,6 +83,7 @@ type
FLocalesRequired : ustring;
FLogFile : ustring;
FBrowserSubprocessPath : ustring;
FCustomFlashPath : ustring;
FFrameworkDirPath : ustring;
FLogSeverity : TCefLogSeverity;
FJavaScriptFlags : ustring;
@ -193,6 +194,7 @@ type
function SingleExeProcessing : boolean;
function CheckCEFLibrary : boolean;
procedure DeleteDirContents(const aDirectory : string);
function FindFlashDLL(var aFileName : string) : boolean;
procedure ShowErrorMessageDlg(const aError : string); virtual;
public
@ -271,6 +273,7 @@ type
property DeviceScaleFactor : single read FDeviceScaleFactor;
property CheckDevToolsResources : boolean read FCheckDevToolsResources write FCheckDevToolsResources;
property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired;
property CustomFlashPath : ustring read FCustomFlashPath write FCustomFlashPath;
end;
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
@ -328,6 +331,7 @@ begin
FLocale := '';
FLogFile := '';
FBrowserSubprocessPath := '';
FCustomFlashPath := '';
FFrameworkDirPath := '';
FLogSeverity := LOGSEVERITY_DISABLE;
FJavaScriptFlags := '';
@ -465,10 +469,7 @@ end;
function TCefApplication.GetChromeVersion : string;
begin
Result := inttostr(FChromeVersionInfo.MajorVer) + '.' +
inttostr(FChromeVersionInfo.MinorVer) + '.' +
inttostr(FChromeVersionInfo.Release) + '.' +
inttostr(FChromeVersionInfo.Build);
Result := FileVersionInfoToString(FChromeVersionInfo);
end;
function TCefApplication.GetLibCefPath : string;
@ -773,6 +774,40 @@ begin
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);
begin
OutputDebugMessage(aError);
@ -784,9 +819,21 @@ procedure TCefApplication.Internal_OnBeforeCommandLineProcessing(const processTy
const commandLine : ICefCommandLine);
var
i : integer;
TempVersionInfo : TFileVersionInfo;
TempFileName : string;
begin
if (commandLine <> nil) then
begin
if FindFlashDLL(TempFileName) and
GetDLLVersion(TempFileName, TempVersionInfo) then
begin
if FEnableGPU then commandLine.AppendSwitch('--enable-gpu-plugin');
commandLine.AppendSwitch('--enable-accelerated-plugins');
commandLine.AppendSwitchWithValue('--ppapi-flash-path', TempFileName);
commandLine.AppendSwitchWithValue('--ppapi-flash-version', FileVersionInfoToString(TempVersionInfo));
end
else
if FFlashEnabled then
begin
if FEnableGPU then commandLine.AppendSwitch('--enable-gpu-plugin');

View File

@ -133,14 +133,16 @@ function CefClearCrossOriginWhitelist: Boolean;
procedure UInt64ToFileVersionInfo(const aVersion : uint64; var aVersionInfo : TFileVersionInfo);
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 SplitLongString(aSrcString : string) : string;
function GetAbsoluteDirPath(const aSrcPath : string; var aRsltPath : string) : boolean;
function CheckLocales(const aLocalesDirPath, aLocalesRequired : string) : boolean;
function CheckResources(const aResourcesDirPath : string; aCheckDevResources: boolean) : boolean;
function CheckLocales(const aLocalesDirPath : string; const aLocalesRequired : string = '') : boolean;
function CheckResources(const aResourcesDirPath : string; aCheckDevResources: boolean = True) : boolean;
function CheckDLLs(const aFrameworkDirPath : string) : 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 CefCreateUrl(var parts: TUrlParts): ustring;
@ -821,6 +823,96 @@ begin
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;
var
TempVersion : uint64;
@ -840,6 +932,14 @@ begin
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;
var
TempVersionInfo : TFileVersionInfo;