mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 364297: add a new per-profile default-pref directory and associated directory service keys, and a way to trigger pref service default pref reloading to facilitate the change of default prefs without affecting exisiting users, r=mconnor, sr=bsmedberg
This commit is contained in:
parent
f4a318af67
commit
3b23c3bc14
@ -62,10 +62,12 @@ endif
|
||||
|
||||
ifndef MOZ_BRANDING_DIRECTORY
|
||||
libs locale::
|
||||
$(INSTALL) $(srcdir)/content/browserconfig.properties $(DIST)/bin
|
||||
$(SYSINSTALL) $(IFLAGS1) $(srcdir)/content/browserconfig.properties $(DIST)/bin
|
||||
$(SYSINSTALL) $(IFLAGS1) $(srcdir)/content/old-homepage-default.properties $(DIST)/bin
|
||||
|
||||
install::
|
||||
$(SYSINSTALL) $(srcdir)/content/browserconfig.properties $(DESTDIR)$(mozappdir)
|
||||
$(SYSINSTALL) $(IFLAGS1) $(srcdir)/content/browserconfig.properties $(DESTDIR)$(mozappdir)
|
||||
$(SYSINSTALL) $(IFLAGS1) $(srcdir)/content/old-homepage-default.properties $(DESTDIR)$(mozappdir)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter windows mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
|
||||
|
2
browser/base/content/old-homepage-default.properties
Normal file
2
browser/base/content/old-homepage-default.properties
Normal file
@ -0,0 +1,2 @@
|
||||
# Do NOT localize or otherwise change these values
|
||||
browser.startup.homepage=http://www.mozilla.org/projects/bonecho/
|
@ -47,6 +47,18 @@ function clearAllPrefs() {
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
prefService.resetUserPrefs();
|
||||
|
||||
// Remove the pref-overrides dir, if it exists
|
||||
try {
|
||||
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
const NS_APP_PREFS_OVERRIDE_DIR = "PrefDOverride";
|
||||
var prefOverridesDir = fileLocator.get(NS_APP_PREFS_OVERRIDE_DIR,
|
||||
Components.interfaces.nsIFile);
|
||||
prefOverridesDir.remove(true);
|
||||
} catch (ex) {
|
||||
Components.utils.reportError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function restoreDefaultBookmarks() {
|
||||
|
@ -126,10 +126,19 @@ nsBrowserDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist,
|
||||
nsCString path;
|
||||
rv = prefs->GetCharPref("browser.bookmarks.file", getter_Copies(path));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
NS_NewNativeLocalFile(path, PR_TRUE, (nsILocalFile**)(nsIFile**) getter_AddRefs(file));
|
||||
NS_NewNativeLocalFile(path, PR_TRUE, (nsILocalFile**)(nsIFile**) getter_AddRefs(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp(aKey, NS_APP_EXISTING_PREF_OVERRIDE)) {
|
||||
rv = NS_GetSpecialDirectory(NS_APP_DEFAULTS_50_DIR,
|
||||
getter_AddRefs(file));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
file->AppendNative(NS_LITERAL_CSTRING("existing-profile-defaults.js"));
|
||||
file.swap(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (!strcmp(aKey, NS_APP_MICROSUMMARY_DIR)) {
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(file));
|
||||
|
@ -53,6 +53,7 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define NS_APP_MICROSUMMARY_DIR "MicsumGens"
|
||||
#define NS_APP_EXISTING_PREF_OVERRIDE "ExistingPrefOverride"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Files and directories that exist on a per-profile basis.
|
||||
|
@ -137,6 +137,40 @@ function needHomepageOverride(prefb) {
|
||||
return OVERRIDE_NONE;
|
||||
}
|
||||
|
||||
// Copies a pref override file into the user's profile pref-override folder,
|
||||
// and then tells the pref service to reload it's default prefs.
|
||||
function copyPrefOverride() {
|
||||
try {
|
||||
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
const NS_APP_EXISTING_PREF_OVERRIDE = "ExistingPrefOverride";
|
||||
var prefOverride = fileLocator.get(NS_APP_EXISTING_PREF_OVERRIDE,
|
||||
Components.interfaces.nsIFile);
|
||||
if (!prefOverride.exists())
|
||||
return; // nothing to do
|
||||
|
||||
const NS_APP_PREFS_OVERRIDE_DIR = "PrefDOverride";
|
||||
var prefOverridesDir = fileLocator.get(NS_APP_PREFS_OVERRIDE_DIR,
|
||||
Components.interfaces.nsIFile);
|
||||
|
||||
// Check for any existing pref overrides, and remove them if present
|
||||
var existingPrefOverridesFile = prefOverridesDir.clone();
|
||||
existingPrefOverridesFile.append(prefOverride.leafName);
|
||||
if (existingPrefOverridesFile.exists())
|
||||
existingPrefOverridesFile.remove(false);
|
||||
|
||||
prefOverride.copyTo(prefOverridesDir, null);
|
||||
|
||||
// Now that we've installed the new-profile pref override file,
|
||||
// re-read the default prefs.
|
||||
var prefSvcObs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIObserver);
|
||||
prefSvcObs.observe(null, "reload-default-prefs", null);
|
||||
} catch (ex) {
|
||||
Components.utils.reportError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function openWindow(parent, url, target, features, args) {
|
||||
var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService(nsIWindowWatcher);
|
||||
@ -444,9 +478,13 @@ var nsBrowserContentHandler = {
|
||||
try {
|
||||
switch (needHomepageOverride(prefb)) {
|
||||
case OVERRIDE_NEW_PROFILE:
|
||||
// New profile
|
||||
overridePage = formatter.formatURLPref("startup.homepage_welcome_url");
|
||||
break;
|
||||
case OVERRIDE_NEW_MSTONE:
|
||||
// Existing profile, new build
|
||||
copyPrefOverride();
|
||||
|
||||
// Check whether we have a session to restore. If we do, we assume
|
||||
// that this is an "update" session.
|
||||
var ss = Components.classes["@mozilla.org/browser/sessionstartup;1"]
|
||||
|
@ -16,8 +16,10 @@ bin/.autoreg
|
||||
bin/chrome/@AB_CD@.jar
|
||||
bin/chrome/@AB_CD@.manifest
|
||||
bin/defaults/pref/firefox-l10n.js
|
||||
bin/defaults/existing-profile-defaults.js
|
||||
; If you add a new directory you must explicitly call addDirectory in ab-CD.jst
|
||||
bin/browserconfig.properties
|
||||
bin/old-homepage-default.properties
|
||||
bin/searchplugins/*
|
||||
bin/defaults/profile/bookmarks.html
|
||||
bin/defaults/profile/localstore.rdf
|
||||
|
@ -16,7 +16,9 @@ bin/.autoreg
|
||||
bin\chrome\@AB_CD@.jar
|
||||
bin\chrome\@AB_CD@.manifest
|
||||
bin\defaults\pref\firefox-l10n.js
|
||||
bin\defaults\existing-profile-defaults.js
|
||||
bin\browserconfig.properties
|
||||
bin\old-homepage-default.properties
|
||||
bin\searchplugins\*
|
||||
bin\defaults\profile\bookmarks.html
|
||||
bin\defaults\profile\localstore.rdf
|
||||
|
@ -88,6 +88,17 @@ PREF_JS_EXPORTS = $(LOCALE_SRCDIR)/firefox-l10n.js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
libs::
|
||||
@if test -f "$(LOCALE_SRCDIR)/existing-profile-defaults.js"; then \
|
||||
$(PERL) $(topsrcdir)/config/preprocessor.pl $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
|
||||
$(LOCALE_SRCDIR)/existing-profile-defaults.js > $(FINAL_TARGET)/defaults/existing-profile-defaults.js; \
|
||||
fi
|
||||
install::
|
||||
@if test -f "$(LOCALE_SRCDIR)/existing-profile-defaults.js"; then \
|
||||
$(PERL) $(topsrcdir)/config/preprocessor.pl $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
|
||||
$(LOCALE_SRCDIR)/existing-profile-defaults.js > $(DESTDIR)$(mozappdir)/defaults/existing-profile-defaults.js; \
|
||||
fi
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
README_FILES = \
|
||||
os2/README.txt \
|
||||
|
@ -199,6 +199,9 @@ NS_IMETHODIMP nsPrefService::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
ResetUserPrefs();
|
||||
rv = ReadUserPrefs(nsnull);
|
||||
}
|
||||
} else if (!nsCRT::strcmp(aTopic, "reload-default-prefs")) {
|
||||
// Reload the default prefs from file.
|
||||
pref_InitInitialObjects();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -49,7 +49,11 @@ include $(topsrcdir)/config/rules.mk
|
||||
libs::
|
||||
@$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
|
||||
$(srcdir)/browserconfig.properties > $(FINAL_TARGET)/browserconfig.properties
|
||||
@$(PERL) $(topsrcdir)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) \
|
||||
$(srcdir)/old-homepage-default.properties > $(FINAL_TARGET)/old-homepage-default.properties
|
||||
|
||||
install::
|
||||
@$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
|
||||
$(srcdir)/browserconfig.properties > $(DESTDIR)$(mozappdir)/browserconfig.properties
|
||||
@$(PERL) $(topsrcdir)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) \
|
||||
$(srcdir)/old-homepage-default.properties > $(DESTDIR)$(mozappdir)/old-homepage-default.properties
|
||||
|
@ -1,3 +1,3 @@
|
||||
# Do NOT localize or otherwise change these values
|
||||
#expand browser.startup.homepage=http://__AB_CD__.start.mozilla.com/firefox?client=firefox-a&rls=__MOZ_DISTRIBUTION_ID_UNQUOTED__:__AB_CD__:official
|
||||
#expand browser.startup.homepage_reset=http://__AB_CD__.start.mozilla.com/firefox?client=firefox-a&rls=__MOZ_DISTRIBUTION_ID_UNQUOTED__:__AB_CD__:official
|
||||
#expand browser.startup.homepage=http://__AB_CD__.start2.mozilla.com/firefox?client=firefox-a&rls=__MOZ_DISTRIBUTION_ID_UNQUOTED__:__AB_CD__:official
|
||||
#expand browser.startup.homepage_reset=http://__AB_CD__.start2.mozilla.com/firefox?client=firefox-a&rls=__MOZ_DISTRIBUTION_ID_UNQUOTED__:__AB_CD__:official
|
||||
|
@ -0,0 +1,2 @@
|
||||
# Do NOT localize or otherwise change these values
|
||||
#expand browser.startup.homepage=http://__AB_CD__.start.mozilla.com/firefox?client=firefox-a&rls=__MOZ_DISTRIBUTION_ID_UNQUOTED__:__AB_CD__:official
|
@ -95,6 +95,8 @@
|
||||
#define APP_REGISTRY_NAME "appreg"
|
||||
#endif
|
||||
|
||||
#define PREF_OVERRIDE_DIRNAME "preferences"
|
||||
|
||||
nsXREDirProvider* gDirServiceProvider = nsnull;
|
||||
|
||||
nsXREDirProvider::nsXREDirProvider() :
|
||||
@ -349,6 +351,11 @@ nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
|
||||
else if (!strcmp(aProperty, NS_APP_DOWNLOADS_50_FILE)) {
|
||||
rv = file->AppendNative(NS_LITERAL_CSTRING("downloads.rdf"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PREFS_OVERRIDE_DIR)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(NS_LITERAL_CSTRING(PREF_OVERRIDE_DIRNAME));
|
||||
rv |= EnsureDirectoryExists(file);
|
||||
}
|
||||
// XXXbsmedberg move these defines into application-specific providers.
|
||||
else if (!strcmp(aProperty, NS_APP_MAIL_50_DIR)) {
|
||||
rv = file->AppendNative(NS_LITERAL_CSTRING("Mail"));
|
||||
@ -555,22 +562,30 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PREFS_DEFAULTS_DIR_LIST)) {
|
||||
nsCOMArray<nsIFile> directories;
|
||||
PRBool exists;
|
||||
|
||||
if (mXULAppDir) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
mXULAppDir->Clone(getter_AddRefs(file));
|
||||
file->AppendNative(NS_LITERAL_CSTRING("defaults"));
|
||||
file->AppendNative(NS_LITERAL_CSTRING("preferences"));
|
||||
PRBool exists;
|
||||
if (NS_SUCCEEDED(file->Exists(&exists)) && exists)
|
||||
directories.AppendObject(file);
|
||||
}
|
||||
|
||||
if (mProfileDir && !gSafeMode) {
|
||||
static const char *const kAppendPrefDir[] = { "defaults", "preferences", nsnull };
|
||||
if (mProfileDir) {
|
||||
nsCOMPtr<nsIFile> overrideFile;
|
||||
mProfileDir->Clone(getter_AddRefs(overrideFile));
|
||||
overrideFile->AppendNative(NS_LITERAL_CSTRING(PREF_OVERRIDE_DIRNAME));
|
||||
if (NS_SUCCEEDED(overrideFile->Exists(&exists)) && exists)
|
||||
directories.AppendObject(overrideFile);
|
||||
|
||||
LoadDirsIntoArray(profileFile, "ExtensionDirs",
|
||||
kAppendPrefDir, directories);
|
||||
if (!gSafeMode) {
|
||||
static const char *const kAppendPrefDir[] = { "defaults", "preferences", nsnull };
|
||||
|
||||
LoadDirsIntoArray(profileFile, "ExtensionDirs",
|
||||
kAppendPrefDir, directories);
|
||||
}
|
||||
}
|
||||
|
||||
rv = NS_NewArrayEnumerator(aResult, directories);
|
||||
|
@ -96,6 +96,7 @@
|
||||
#define NS_APP_PREFS_50_DIR "PrefD" // Directory which contains user prefs
|
||||
#define NS_APP_PREFS_50_FILE "PrefF"
|
||||
#define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
|
||||
#define NS_APP_PREFS_OVERRIDE_DIR "PrefDOverride" // Directory for per-profile defaults
|
||||
|
||||
#define NS_APP_USER_PROFILE_50_DIR "ProfD"
|
||||
#define NS_APP_USER_PROFILE_LOCAL_50_DIR "ProfLD"
|
||||
|
Loading…
Reference in New Issue
Block a user