зеркало из https://github.com/mozilla/pjs.git
Bug 392967: Load app and extension prefs separately. r=bsmedberg
This commit is contained in:
Родитель
ab8608367c
Коммит
bc24092d2c
|
@ -179,4 +179,11 @@ interface nsIPrefService : nsISupports
|
|||
*/
|
||||
#define NS_PREFSERVICE_RESET_TOPIC_ID "prefservice:before-reset"
|
||||
|
||||
/**
|
||||
* Notification sent when after reading app-provided default
|
||||
* preferences, but before user profile override defaults or extension
|
||||
* defaults are loaded.
|
||||
*/
|
||||
#define NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID "prefservice:after-app-defaults"
|
||||
|
||||
%}
|
||||
|
|
|
@ -717,6 +717,32 @@ pref_LoadPrefsInDir(nsIFile* aDir, char const *const *aSpecialFiles, PRUint32 aS
|
|||
return rv;
|
||||
}
|
||||
|
||||
static nsresult pref_LoadPrefsInDirList(const char *listId)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIProperties> dirSvc(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> dirList;
|
||||
dirSvc->Get(listId,
|
||||
NS_GET_IID(nsISimpleEnumerator),
|
||||
getter_AddRefs(dirList));
|
||||
if (dirList) {
|
||||
PRBool hasMore;
|
||||
while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> elem;
|
||||
dirList->GetNext(getter_AddRefs(elem));
|
||||
if (elem) {
|
||||
nsCOMPtr<nsIFile> dir = do_QueryInterface(elem);
|
||||
if (dir) {
|
||||
// Do we care if a file provided by this process fails to load?
|
||||
pref_LoadPrefsInDir(dir, nsnull, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Initialize default preference JavaScript buffers from
|
||||
|
@ -773,30 +799,19 @@ static nsresult pref_InitInitialObjects()
|
|||
NS_WARNING("Error parsing application default preferences.");
|
||||
}
|
||||
|
||||
// xxxbsmedberg: TODO load default prefs from a category
|
||||
// but the architecture is not quite there yet
|
||||
rv = pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIProperties> dirSvc(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
|
||||
nsnull, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> dirList;
|
||||
dirSvc->Get(NS_APP_PREFS_DEFAULTS_DIR_LIST,
|
||||
NS_GET_IID(nsISimpleEnumerator),
|
||||
getter_AddRefs(dirList));
|
||||
if (dirList) {
|
||||
PRBool hasMore;
|
||||
while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> elem;
|
||||
dirList->GetNext(getter_AddRefs(elem));
|
||||
if (elem) {
|
||||
nsCOMPtr<nsIFile> dir = do_QueryInterface(elem);
|
||||
if (dir) {
|
||||
// Do we care if a file provided by this process fails to load?
|
||||
pref_LoadPrefsInDir(dir, nsnull, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
|
||||
return NS_OK;
|
||||
if (NS_FAILED(rv) || !observerService)
|
||||
return rv;
|
||||
|
||||
observerService->NotifyObservers(nsnull, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID, nsnull);
|
||||
|
||||
return pref_LoadPrefsInDirList(NS_EXT_PREFS_DEFAULTS_DIR_LIST);
|
||||
}
|
||||
|
|
|
@ -641,6 +641,13 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
|
|||
LoadAppPlatformDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
|
||||
}
|
||||
|
||||
rv = NS_NewArrayEnumerator(aResult, directories);
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_EXT_PREFS_DEFAULTS_DIR_LIST)) {
|
||||
static const char *const kAppendPrefDir[] = { "defaults", "preferences", nsnull };
|
||||
nsCOMArray<nsIFile> directories;
|
||||
PRBool exists;
|
||||
|
||||
if (mProfileDir) {
|
||||
nsCOMPtr<nsIFile> overrideFile;
|
||||
mProfileDir->Clone(getter_AddRefs(overrideFile));
|
||||
|
|
|
@ -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_EXT_PREFS_DEFAULTS_DIR_LIST "ExtPrefDL"
|
||||
#define NS_APP_PREFS_OVERRIDE_DIR "PrefDOverride" // Directory for per-profile defaults
|
||||
|
||||
#define NS_APP_USER_PROFILE_50_DIR "ProfD"
|
||||
|
|
Загрузка…
Ссылка в новой задаче