mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1170092 Load preferences from /etc/firefox/defaults/pref on Linux; r=mkaply
Preferences from /etc/firefox/defaults/pref overwrites preferences set in omni.jar and firefox/defaults/pref. The code was used for flatpak and snap only, but it could be used also for regular Linux builds. Differential Revision: https://phabricator.services.mozilla.com/D168799
This commit is contained in:
parent
7bc36fb361
commit
bddcbe8678
@ -11,6 +11,9 @@ function run_test() {
|
||||
|
||||
updateAppInfo();
|
||||
|
||||
try {
|
||||
Services.dirsvc.undefine("SysConfD");
|
||||
} catch (e) {}
|
||||
let customSysConfD = Services.dirsvc.get("SysConfD", Ci.nsIFile);
|
||||
let parent = customSysConfD.parent;
|
||||
let child = customSysConfD.leafName;
|
||||
|
@ -8,6 +8,9 @@ const { updateAppInfo } = ChromeUtils.importESModule(
|
||||
function run_test() {
|
||||
updateAppInfo();
|
||||
|
||||
try {
|
||||
Services.dirsvc.undefine("SysConfD");
|
||||
} catch (e) {}
|
||||
let defaultSysConfD = Services.dirsvc.get("SysConfD", Ci.nsIFile);
|
||||
equal("/etc/xpcshell", defaultSysConfD.path, "SysConfD is in /etc");
|
||||
}
|
||||
|
@ -4919,23 +4919,6 @@ nsresult Preferences::InitInitialObjects(bool aIsStartup) {
|
||||
NS_WARNING("Error parsing application default preferences.");
|
||||
}
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
// Under Flatpak/Snap package, load /etc/firefox/defaults/pref/*.js.
|
||||
if (mozilla::widget::IsRunningUnderFlatpakOrSnap()) {
|
||||
nsCOMPtr<nsIFile> defaultSnapPrefDir;
|
||||
rv = NS_GetSpecialDirectory(NS_OS_SYSTEM_CONFIG_DIR,
|
||||
getter_AddRefs(defaultSnapPrefDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
defaultSnapPrefDir->AppendNative("defaults"_ns);
|
||||
defaultSnapPrefDir->AppendNative("pref"_ns);
|
||||
|
||||
rv = pref_LoadPrefsInDir(defaultSnapPrefDir, nullptr, 0);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Error parsing application default preferences under Snap.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Load jar:$app/omni.jar!/defaults/preferences/*.js
|
||||
// or jar:$gre/omni.jar!/defaults/preferences/*.js.
|
||||
RefPtr<nsZipArchive> appJarReader = Omnijar::GetReader(Omnijar::APP);
|
||||
@ -5008,6 +4991,24 @@ nsresult Preferences::InitInitialObjects(bool aIsStartup) {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
// To ensure the system-wide preferences are not overwritten by
|
||||
// firefox/browser/defauts/preferences/*.js we need to load
|
||||
// the /etc/firefox/defaults/pref/*.js settings as last.
|
||||
// Under Flatpak, the NS_OS_SYSTEM_CONFIG_DIR points to /app/etc/firefox
|
||||
nsCOMPtr<nsIFile> defaultSystemPrefDir;
|
||||
rv = NS_GetSpecialDirectory(NS_OS_SYSTEM_CONFIG_DIR,
|
||||
getter_AddRefs(defaultSystemPrefDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
defaultSystemPrefDir->AppendNative("defaults"_ns);
|
||||
defaultSystemPrefDir->AppendNative("pref"_ns);
|
||||
|
||||
rv = pref_LoadPrefsInDir(defaultSystemPrefDir, nullptr, 0);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Error parsing application default preferences.");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
SetupTelemetryPref();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user