зеркало из https://github.com/mozilla/pjs.git
Bug 321237 - Make NS_OS_CURRENT_PROCESS_DIR point to the application directory for XULRunner apps, r=robstrong
This commit is contained in:
Родитель
d997e02d87
Коммит
15893099be
|
@ -2097,7 +2097,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
// profile was started with. The format of the version stamp is defined
|
||||
// by the BuildVersion function.
|
||||
PRBool versionOK = CheckCompatibility(profD, version,
|
||||
dirProvider.GetAppDir(),
|
||||
dirProvider.GetGREDir(),
|
||||
gAppData->directory);
|
||||
|
||||
// Every time a profile is loaded by a build with a different version,
|
||||
|
@ -2110,7 +2110,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
if (gSafeMode) {
|
||||
RemoveComponentRegistries(profD, profLD, PR_FALSE);
|
||||
WriteVersion(profD, NS_LITERAL_CSTRING("Safe Mode"),
|
||||
dirProvider.GetAppDir(), gAppData->directory);
|
||||
dirProvider.GetGREDir(), gAppData->directory);
|
||||
}
|
||||
else if (versionOK) {
|
||||
if (ComponentsListChanged(profD)) {
|
||||
|
@ -2135,7 +2135,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
|
||||
// Write out version
|
||||
WriteVersion(profD, version,
|
||||
dirProvider.GetAppDir(), gAppData->directory);
|
||||
dirProvider.GetGREDir(), gAppData->directory);
|
||||
}
|
||||
|
||||
PRBool needsRestart = PR_FALSE;
|
||||
|
|
|
@ -193,7 +193,9 @@ XRE_InitEmbedding(nsILocalFile *aLibXULDirectory,
|
|||
return NS_OK;
|
||||
|
||||
NS_ENSURE_ARG(aLibXULDirectory);
|
||||
NS_ENSURE_ARG(aAppDirectory);
|
||||
|
||||
if (!aAppDirectory)
|
||||
aAppDirectory = aLibXULDirectory;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
|
|
|
@ -115,13 +115,13 @@ nsXREDirProvider::Initialize(nsIFile *aXULAppDir)
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIFile> appDir;
|
||||
rv = lf->GetParent(getter_AddRefs(appDir));
|
||||
nsCOMPtr<nsIFile> greDir;
|
||||
rv = lf->GetParent(getter_AddRefs(greDir));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mAppDir = do_QueryInterface(appDir);
|
||||
if (!mAppDir)
|
||||
mGREDir = do_QueryInterface(greDir);
|
||||
if (!mGREDir)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -177,12 +177,13 @@ nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
|
|||
{
|
||||
*aPersistent = PR_TRUE;
|
||||
|
||||
if (!strcmp(aProperty, NS_GRE_DIR)) {
|
||||
return mGREDir->Clone(aFile);
|
||||
}
|
||||
|
||||
if (!strcmp(aProperty, NS_OS_CURRENT_PROCESS_DIR) ||
|
||||
!strcmp(aProperty, NS_APP_INSTALL_CLEANUP_DIR)) {
|
||||
// NOTE: this should be *different* than NS_XPCOM_CURRENT_PROCESS_DIR.
|
||||
// This should point to the application dir.
|
||||
// NS_XPCOM_CURRENT_PROCESS_DIR points to the toolkit. But we suck.
|
||||
return mAppDir->Clone(aFile);
|
||||
return GetAppDir()->Clone(aFile);
|
||||
}
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
@ -194,7 +195,9 @@ nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
|
|||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PREF_DEFAULTS_50_DIR))
|
||||
{
|
||||
rv = mAppDir->Clone(getter_AddRefs(file));
|
||||
// return the GRE default prefs directory here, and the app default prefs
|
||||
// directory (if applicable) in NS_APP_PREFS_DEFAULTS_DIR_LIST.
|
||||
rv = mGREDir->Clone(getter_AddRefs(file));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = file->AppendNative(NS_LITERAL_CSTRING("defaults"));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -235,8 +238,8 @@ nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
|
|||
if (NS_SUCCEEDED(rv))
|
||||
file = lf;
|
||||
}
|
||||
else if (mXULAppDir && !strcmp(aProperty, "resource:app")) {
|
||||
rv = mXULAppDir->Clone(getter_AddRefs(file));
|
||||
else if (!strcmp(aProperty, "resource:app")) {
|
||||
rv = GetAppDir()->Clone(getter_AddRefs(file));
|
||||
}
|
||||
else if (mProfileDir) {
|
||||
// We need to allow component, xpt, and chrome registration to
|
||||
|
@ -488,7 +491,7 @@ nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
|
|||
nsCOMArray<nsIFile> manifests;
|
||||
|
||||
nsCOMPtr<nsIFile> manifest;
|
||||
mAppDir->Clone(getter_AddRefs(manifest));
|
||||
mGREDir->Clone(getter_AddRefs(manifest));
|
||||
manifest->AppendNative(NS_LITERAL_CSTRING("chrome"));
|
||||
manifests.AppendObject(manifest);
|
||||
|
||||
|
@ -891,13 +894,13 @@ nsXREDirProvider::EnsureProfileFileExists(nsIFile *aFile)
|
|||
nsresult
|
||||
nsXREDirProvider::GetProfileDefaultsDir(nsIFile* *aResult)
|
||||
{
|
||||
NS_ASSERTION(mAppDir, "nsXREDirProvider not initialized.");
|
||||
NS_ASSERTION(mGREDir, "nsXREDirProvider not initialized.");
|
||||
NS_PRECONDITION(aResult, "Null out-param");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFile> defaultsDir;
|
||||
|
||||
rv = mAppDir->Clone(getter_AddRefs(defaultsDir));
|
||||
rv = GetAppDir()->Clone(getter_AddRefs(defaultsDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = defaultsDir->AppendNative(NS_LITERAL_CSTRING("defaults"));
|
||||
|
|
|
@ -78,14 +78,19 @@ public:
|
|||
}
|
||||
|
||||
/* make sure you clone it, if you need to do stuff to it */
|
||||
nsIFile* GetAppDir() { return mAppDir; }
|
||||
nsIFile* GetGREDir() { return mGREDir; }
|
||||
nsIFile* GetAppDir() {
|
||||
if (mXULAppDir)
|
||||
return mXULAppDir;
|
||||
return mGREDir;
|
||||
}
|
||||
|
||||
protected:
|
||||
static nsresult GetUserDataDirectory(nsILocalFile* *aFile, PRBool aLocal);
|
||||
static nsresult EnsureDirectoryExists(nsIFile* aDirectory);
|
||||
void EnsureProfileFileExists(nsIFile* aFile);
|
||||
|
||||
nsCOMPtr<nsILocalFile> mAppDir;
|
||||
nsCOMPtr<nsILocalFile> mGREDir;
|
||||
nsCOMPtr<nsIFile> mXULAppDir;
|
||||
nsCOMPtr<nsIFile> mProfileDir;
|
||||
nsCOMPtr<nsIFile> mProfileLocalDir;
|
||||
|
|
Загрузка…
Ссылка в новой задаче