Bug 1502053 - Parse default prefs from MOZ_DEFAULT_PREFS env var r=njn
This will be used by GeckoView to set initial pref values that would normally come from prefs.js or similar on desktop and Fennec. Differential Revision: https://phabricator.services.mozilla.com/D9820
This commit is contained in:
@@ -3231,6 +3231,9 @@ Preferences::HandleDirty()
|
||||
static nsresult
|
||||
openPrefFile(nsIFile* aFile, PrefValueKind aKind);
|
||||
|
||||
static nsresult
|
||||
parsePrefData(const nsCString& aData, PrefValueKind aKind);
|
||||
|
||||
// clang-format off
|
||||
static const char kPrefFileHeader[] =
|
||||
"// Mozilla User Preferences"
|
||||
@@ -3890,6 +3893,11 @@ Preferences::GetInstanceForService()
|
||||
}
|
||||
}
|
||||
|
||||
const char* defaultPrefs = getenv("MOZ_DEFAULT_PREFS");
|
||||
if (defaultPrefs) {
|
||||
parsePrefData(nsCString(defaultPrefs), PrefValueKind::Default);
|
||||
}
|
||||
|
||||
gCacheDataDesc = "set by GetInstanceForService() (2)";
|
||||
|
||||
// Preferences::GetInstanceForService() can be called from GetService(), and
|
||||
@@ -4619,6 +4627,20 @@ openPrefFile(nsIFile* aFile, PrefValueKind aKind)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
parsePrefData(const nsCString& aData, PrefValueKind aKind)
|
||||
{
|
||||
TimeStamp startTime = TimeStamp::Now();
|
||||
const nsCString path = NS_LITERAL_CSTRING("$MOZ_DEFAULT_PREFS");
|
||||
|
||||
Parser parser;
|
||||
if (!parser.Parse(path, aKind, path.get(), startTime, aData)) {
|
||||
return NS_ERROR_FILE_CORRUPTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
pref_CompareFileNames(nsIFile* aFile1, nsIFile* aFile2, void* /* unused */)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user