mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-02-12 10:26:05 +02:00
Merge pull request #60 from ashumkin/master
Make able to reduce CEF package size. Thanks Ashumkin!
This commit is contained in:
commit
d5d5bfed26
@ -80,6 +80,7 @@ type
|
|||||||
FUserAgent : ustring;
|
FUserAgent : ustring;
|
||||||
FProductVersion : ustring;
|
FProductVersion : ustring;
|
||||||
FLocale : ustring;
|
FLocale : ustring;
|
||||||
|
FLocalesRequired : ustring;
|
||||||
FLogFile : ustring;
|
FLogFile : ustring;
|
||||||
FBrowserSubprocessPath : ustring;
|
FBrowserSubprocessPath : ustring;
|
||||||
FFrameworkDirPath : ustring;
|
FFrameworkDirPath : ustring;
|
||||||
@ -131,6 +132,7 @@ type
|
|||||||
FRenderProcessHandler : ICefRenderProcessHandler;
|
FRenderProcessHandler : ICefRenderProcessHandler;
|
||||||
FAppSettings : TCefSettings;
|
FAppSettings : TCefSettings;
|
||||||
FDeviceScaleFactor : single;
|
FDeviceScaleFactor : single;
|
||||||
|
FCheckDevToolsResources : boolean;
|
||||||
|
|
||||||
procedure SetFrameworkDirPath(const aValue : ustring);
|
procedure SetFrameworkDirPath(const aValue : ustring);
|
||||||
procedure SetResourcesDirPath(const aValue : ustring);
|
procedure SetResourcesDirPath(const aValue : ustring);
|
||||||
@ -267,6 +269,8 @@ type
|
|||||||
property MuteAudio : boolean read FMuteAudio write FMuteAudio;
|
property MuteAudio : boolean read FMuteAudio write FMuteAudio;
|
||||||
property ReRaiseExceptions : boolean read FReRaiseExceptions write FReRaiseExceptions;
|
property ReRaiseExceptions : boolean read FReRaiseExceptions write FReRaiseExceptions;
|
||||||
property DeviceScaleFactor : single read FDeviceScaleFactor;
|
property DeviceScaleFactor : single read FDeviceScaleFactor;
|
||||||
|
property CheckDevToolsResources : boolean read FCheckDevToolsResources write FCheckDevToolsResources;
|
||||||
|
property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
|
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
|
||||||
@ -369,6 +373,8 @@ begin
|
|||||||
FShowMessageDlg := True;
|
FShowMessageDlg := True;
|
||||||
FSetCurrentDir := False;
|
FSetCurrentDir := False;
|
||||||
FUpdateChromeVer := aUpdateChromeVer;
|
FUpdateChromeVer := aUpdateChromeVer;
|
||||||
|
FCheckDevToolsResources := True;
|
||||||
|
FLocalesRequired := '';
|
||||||
|
|
||||||
UpdateDeviceScaleFactor;
|
UpdateDeviceScaleFactor;
|
||||||
|
|
||||||
@ -549,7 +555,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
if not(CheckResources(FResourcesDirPath)) then
|
if not(CheckResources(FResourcesDirPath, FCheckDevToolsResources)) then
|
||||||
begin
|
begin
|
||||||
TempString := 'CEF resources missing !' + CRLF + CRLF;
|
TempString := 'CEF resources missing !' + CRLF + CRLF;
|
||||||
|
|
||||||
@ -566,7 +572,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
if not(CheckLocales(FLocalesDirPath)) then
|
if not(CheckLocales(FLocalesDirPath, FLocalesRequired)) then
|
||||||
begin
|
begin
|
||||||
TempString := 'CEF locale files missing !' + CRLF + CRLF;
|
TempString := 'CEF locale files missing !' + CRLF + CRLF;
|
||||||
|
|
||||||
|
@ -137,8 +137,8 @@ function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersion
|
|||||||
|
|
||||||
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 : string) : boolean;
|
function CheckLocales(const aLocalesDirPath, aLocalesRequired : string) : boolean;
|
||||||
function CheckResources(const aResourcesDirPath : string) : boolean;
|
function CheckResources(const aResourcesDirPath : string; aCheckDevResources: boolean) : 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;
|
||||||
|
|
||||||
@ -602,9 +602,93 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckLocales(const aLocalesDirPath : string) : boolean;
|
function CheckLocaleFile(const aLocalesDirPath, aLocale : string) : boolean;
|
||||||
|
begin
|
||||||
|
Result := FileExists(aLocalesDirPath + aLocale + '.pak');
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CheckLocaleFiles(const aLocalesDirPath, aLocalesRequired : string) : boolean;
|
||||||
|
var
|
||||||
|
LLocaleList: TStrings;
|
||||||
|
LLocale: string;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
LLocaleList := TStringList.Create;
|
||||||
|
try
|
||||||
|
LLocaleList.CommaText := aLocalesRequired;
|
||||||
|
for LLocale in LLocaleList do
|
||||||
|
begin
|
||||||
|
// avoid typing mistakes
|
||||||
|
if Length(LLocale) = 0 then
|
||||||
|
Continue;
|
||||||
|
Result := Result and CheckLocaleFile(aLocalesDirPath, LLocale);
|
||||||
|
if not Result then
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FreeAndNil(LLocaleList);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CheckLocales(const aLocalesDirPath, aLocalesRequired : string) : boolean;
|
||||||
|
const
|
||||||
|
LOCALES_REQUIRED_DEFAULT =
|
||||||
|
'am,' +
|
||||||
|
'ar,' +
|
||||||
|
'bg,' +
|
||||||
|
'bn,' +
|
||||||
|
'ca,' +
|
||||||
|
'cs,' +
|
||||||
|
'da,' +
|
||||||
|
'de,' +
|
||||||
|
'el,' +
|
||||||
|
'en-GB,' +
|
||||||
|
'en-US,' +
|
||||||
|
'es,' +
|
||||||
|
'es-419,' +
|
||||||
|
'et,' +
|
||||||
|
'fa,' +
|
||||||
|
'fi,' +
|
||||||
|
'fil,' +
|
||||||
|
'fr,' +
|
||||||
|
'gu,' +
|
||||||
|
'he,' +
|
||||||
|
'hi,' +
|
||||||
|
'hr,' +
|
||||||
|
'hu,' +
|
||||||
|
'id,' +
|
||||||
|
'it,' +
|
||||||
|
'ja,' +
|
||||||
|
'kn,' +
|
||||||
|
'ko,' +
|
||||||
|
'lt,' +
|
||||||
|
'lv,' +
|
||||||
|
'ml,' +
|
||||||
|
'mr,' +
|
||||||
|
'ms,' +
|
||||||
|
'nb,' +
|
||||||
|
'nl,' +
|
||||||
|
'pl,' +
|
||||||
|
'pt-BR,' +
|
||||||
|
'pt-PT,' +
|
||||||
|
'ro,' +
|
||||||
|
'ru,' +
|
||||||
|
'sk,' +
|
||||||
|
'sl,' +
|
||||||
|
'sr,' +
|
||||||
|
'sv,' +
|
||||||
|
'sw,' +
|
||||||
|
'ta,' +
|
||||||
|
'te,' +
|
||||||
|
'th,' +
|
||||||
|
'tr,' +
|
||||||
|
'uk,' +
|
||||||
|
'vi,' +
|
||||||
|
'zh-CN,' +
|
||||||
|
'zh-TW';
|
||||||
var
|
var
|
||||||
TempDir : string;
|
TempDir : string;
|
||||||
|
LLocalesRequired: string;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
@ -617,60 +701,12 @@ begin
|
|||||||
if DirectoryExists(TempDir) then
|
if DirectoryExists(TempDir) then
|
||||||
begin
|
begin
|
||||||
TempDir := IncludeTrailingPathDelimiter(TempDir);
|
TempDir := IncludeTrailingPathDelimiter(TempDir);
|
||||||
|
if Length(aLocalesRequired) > 0 then
|
||||||
|
LLocalesRequired := aLocalesRequired
|
||||||
|
else
|
||||||
|
LLocalesRequired := LOCALES_REQUIRED_DEFAULT;
|
||||||
|
|
||||||
Result := FileExists(TempDir + 'am.pak') and
|
Result := CheckLocaleFiles(TempDir, LLocalesRequired);
|
||||||
FileExists(TempDir + 'ar.pak') and
|
|
||||||
FileExists(TempDir + 'bg.pak') and
|
|
||||||
FileExists(TempDir + 'bn.pak') and
|
|
||||||
FileExists(TempDir + 'ca.pak') and
|
|
||||||
FileExists(TempDir + 'cs.pak') and
|
|
||||||
FileExists(TempDir + 'da.pak') and
|
|
||||||
FileExists(TempDir + 'de.pak') and
|
|
||||||
FileExists(TempDir + 'el.pak') and
|
|
||||||
FileExists(TempDir + 'en-GB.pak') and
|
|
||||||
FileExists(TempDir + 'en-US.pak') and
|
|
||||||
FileExists(TempDir + 'es.pak') and
|
|
||||||
FileExists(TempDir + 'es-419.pak') and
|
|
||||||
FileExists(TempDir + 'et.pak') and
|
|
||||||
FileExists(TempDir + 'fa.pak') and
|
|
||||||
FileExists(TempDir + 'fi.pak') and
|
|
||||||
FileExists(TempDir + 'fil.pak') and
|
|
||||||
FileExists(TempDir + 'fr.pak') and
|
|
||||||
FileExists(TempDir + 'gu.pak') and
|
|
||||||
FileExists(TempDir + 'he.pak') and
|
|
||||||
FileExists(TempDir + 'hi.pak') and
|
|
||||||
FileExists(TempDir + 'hr.pak') and
|
|
||||||
FileExists(TempDir + 'hu.pak') and
|
|
||||||
FileExists(TempDir + 'id.pak') and
|
|
||||||
FileExists(TempDir + 'it.pak') and
|
|
||||||
FileExists(TempDir + 'ja.pak') and
|
|
||||||
FileExists(TempDir + 'kn.pak') and
|
|
||||||
FileExists(TempDir + 'ko.pak') and
|
|
||||||
FileExists(TempDir + 'lt.pak') and
|
|
||||||
FileExists(TempDir + 'lv.pak') and
|
|
||||||
FileExists(TempDir + 'ml.pak') and
|
|
||||||
FileExists(TempDir + 'mr.pak') and
|
|
||||||
FileExists(TempDir + 'ms.pak') and
|
|
||||||
FileExists(TempDir + 'nb.pak') and
|
|
||||||
FileExists(TempDir + 'nl.pak') and
|
|
||||||
FileExists(TempDir + 'pl.pak') and
|
|
||||||
FileExists(TempDir + 'pt-BR.pak') and
|
|
||||||
FileExists(TempDir + 'pt-PT.pak') and
|
|
||||||
FileExists(TempDir + 'ro.pak') and
|
|
||||||
FileExists(TempDir + 'ru.pak') and
|
|
||||||
FileExists(TempDir + 'sk.pak') and
|
|
||||||
FileExists(TempDir + 'sl.pak') and
|
|
||||||
FileExists(TempDir + 'sr.pak') and
|
|
||||||
FileExists(TempDir + 'sv.pak') and
|
|
||||||
FileExists(TempDir + 'sw.pak') and
|
|
||||||
FileExists(TempDir + 'ta.pak') and
|
|
||||||
FileExists(TempDir + 'te.pak') and
|
|
||||||
FileExists(TempDir + 'th.pak') and
|
|
||||||
FileExists(TempDir + 'tr.pak') and
|
|
||||||
FileExists(TempDir + 'uk.pak') and
|
|
||||||
FileExists(TempDir + 'vi.pak') and
|
|
||||||
FileExists(TempDir + 'zh-CN.pak') and
|
|
||||||
FileExists(TempDir + 'zh-TW.pak');
|
|
||||||
end;
|
end;
|
||||||
except
|
except
|
||||||
on e : exception do
|
on e : exception do
|
||||||
@ -696,7 +732,7 @@ begin
|
|||||||
aRsltPath := '';
|
aRsltPath := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckResources(const aResourcesDirPath : string) : boolean;
|
function CheckResources(const aResourcesDirPath : string; aCheckDevResources: boolean) : boolean;
|
||||||
var
|
var
|
||||||
TempDir : string;
|
TempDir : string;
|
||||||
begin
|
begin
|
||||||
@ -710,7 +746,7 @@ begin
|
|||||||
FileExists(TempDir + 'cef_100_percent.pak') and
|
FileExists(TempDir + 'cef_100_percent.pak') and
|
||||||
FileExists(TempDir + 'cef_200_percent.pak') and
|
FileExists(TempDir + 'cef_200_percent.pak') and
|
||||||
FileExists(TempDir + 'cef_extensions.pak') and
|
FileExists(TempDir + 'cef_extensions.pak') and
|
||||||
FileExists(TempDir + 'devtools_resources.pak');
|
(not aCheckDevResources or FileExists(TempDir + 'devtools_resources.pak'));
|
||||||
except
|
except
|
||||||
on e : exception do
|
on e : exception do
|
||||||
if CustomExceptionHandler('CheckResources', e) then raise;
|
if CustomExceptionHandler('CheckResources', e) then raise;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user