Skip to content
Snippets Groups Projects
Verified Commit d41058d1 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

Revert "Bug 9173: Change the default Firefox profile directory to be relative."

This reverts commit 0ef71611.
parent 2bbd2240
Branches
No related tags found
1 merge request!534Bug 20497: Check if the browser should run in portable mode at runtime (Base Browser)
......@@ -44,5 +44,3 @@ ac_add_options MOZ_TELEMETRY_REPORTING=
if test -z "$WASI_SYSROOT"; then
ac_add_options --without-wasm-sandboxed-libraries
fi
ac_add_options --with-relative-data-dir=BaseBrowser/Data/Browser
......@@ -1025,25 +1025,6 @@ set_config("BASE_BROWSER", True, when="--enable-base-browser")
set_define("BASE_BROWSER", True, when="--enable-base-browser")
option(
"--with-relative-data-dir",
nargs=1,
help="Sets the data directories to be relative to the application directory"
)
@depends("--with-relative-data-dir", target)
@imports("json")
def relative_data_dir(value, target):
if value and target.os == "Android":
die("--with-relative-data-dir is not supported on Android")
if value:
return json.dumps(value[0])
set_define("RELATIVE_DATA_DIR", relative_data_dir)
# Please do not add configure checks from here on.
# Fallthrough to autoconf-based configure
......
......@@ -4,6 +4,3 @@ ac_add_options --enable-strip
# See bug #41131
ac_add_options --disable-update-agent
# For base-browser we do not enable portable mode on macOS.
ac_add_options --without-relative-data-dir
......@@ -2779,8 +2779,6 @@ static nsresult ProfileMissingDialog(nsINativeAppSupport* aNative) {
#endif // MOZ_WIDGET_ANDROID
}
// If aUnlocker is NULL, it is also OK for the following arguments to be NULL:
// aProfileDir, aProfileLocalDir, aResult.
static ReturnAbortOnError ProfileLockedDialog(nsIFile* aProfileDir,
nsIFile* aProfileLocalDir,
nsIProfileUnlocker* aUnlocker,
......@@ -2788,20 +2786,18 @@ static ReturnAbortOnError ProfileLockedDialog(nsIFile* aProfileDir,
nsIProfileLock** aResult) {
nsresult rv;
if (aProfileDir) {
bool exists;
aProfileDir->Exists(&exists);
if (!exists) {
return ProfileMissingDialog(aNative);
}
}
ScopedXPCOMStartup xpcom;
rv = xpcom.Initialize();
NS_ENSURE_SUCCESS(rv, rv);
#if defined(MOZ_TELEMETRY_REPORTING)
if (aProfileDir) mozilla::Telemetry::WriteFailedProfileLock(aProfileDir);
mozilla::Telemetry::WriteFailedProfileLock(aProfileDir);
#endif
rv = xpcom.SetWindowCreator(aNative);
......
......@@ -1328,7 +1328,6 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
bool aLocal) {
// Copied from nsAppFileLocationProvider (more or less)
nsresult rv;
NS_ENSURE_ARG_POINTER(aFile);
nsCOMPtr<nsIFile> localDir;
if (aLocal && gDataDirHomeLocal) {
......@@ -1338,21 +1337,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
return gDataDirHome->Clone(aFile);
}
#if defined(RELATIVE_DATA_DIR)
RefPtr<nsXREDirProvider> singleton = GetSingleton();
if (!singleton) {
return NS_ERROR_OUT_OF_MEMORY;
}
rv = singleton->GetAppRootDir(getter_AddRefs(localDir));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString profileDir(RELATIVE_DATA_DIR);
rv = localDir->SetRelativePath(localDir.get(), profileDir);
NS_ENSURE_SUCCESS(rv, rv);
if (aLocal) {
rv = localDir->AppendNative("Caches"_ns);
NS_ENSURE_SUCCESS(rv, rv);
}
#elif defined(XP_MACOSX)
#if defined(XP_MACOSX)
FSRef fsRef;
OSType folderType;
if (aLocal) {
......@@ -1495,25 +1480,6 @@ nsresult nsXREDirProvider::GetUserDataDirectory(nsIFile** aFile, bool aLocal) {
return NS_OK;
}
nsresult nsXREDirProvider::GetAppRootDir(nsIFile** aFile) {
bool persistent = false;
nsCOMPtr<nsIFile> file, appRootDir;
nsresult rv = GetFile(XRE_EXECUTABLE_FILE, &persistent, getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, rv);
rv = file->Normalize();
NS_ENSURE_SUCCESS(rv, rv);
int levelsToRemove = 1;
#if defined(XP_MACOSX)
levelsToRemove += 2;
#endif
while (levelsToRemove-- > 0) {
rv = file->GetParent(getter_AddRefs(appRootDir));
NS_ENSURE_SUCCESS(rv, rv);
file = appRootDir;
}
return appRootDir->Clone(aFile);
}
nsresult nsXREDirProvider::EnsureDirectoryExists(nsIFile* aDirectory) {
nsresult rv = aDirectory->Create(nsIFile::DIRECTORY_TYPE, 0700);
......@@ -1579,27 +1545,23 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
#if defined(XP_MACOSX)
if (!profile.IsEmpty()) {
rv = AppendProfileString(aFile, profile.get());
# ifndef RELATIVE_DATA_DIR
} else {
// Note that MacOS ignores the vendor when creating the profile hierarchy -
// all application preferences directories live alongside one another in
// ~/Library/Application Support/
rv = aFile->AppendNative(appName);
# endif
}
NS_ENSURE_SUCCESS(rv, rv);
#elif defined(XP_WIN)
if (!profile.IsEmpty()) {
rv = AppendProfileString(aFile, profile.get());
# ifndef RELATIVE_DATA_DIR
} else {
if (!vendor.IsEmpty()) {
rv = aFile->AppendNative(vendor);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = aFile->AppendNative(appName);
# endif
}
NS_ENSURE_SUCCESS(rv, rv);
......@@ -1614,26 +1576,21 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
nsAutoCString folder;
// Make it hidden (by starting with "."), except when local (the
// profile is already under ~/.cache or XDG_CACHE_HOME).
# ifndef RELATIVE_DATA_DIR
if (!aLocal) folder.Assign('.');
# endif
if (!profile.IsEmpty()) {
// Skip any leading path characters
const char* profileStart = profile.get();
while (*profileStart == '/' || *profileStart == '\\') profileStart++;
# ifndef RELATIVE_DATA_DIR
// On the off chance that someone wanted their folder to be hidden don't
// let it become ".."
if (*profileStart == '.' && !aLocal) profileStart++;
# endif
folder.Append(profileStart);
ToLowerCase(folder);
rv = AppendProfileString(aFile, folder.BeginReading());
# ifndef RELATIVE_DATA_DIR
} else {
if (!vendor.IsEmpty()) {
folder.Append(vendor);
......@@ -1652,7 +1609,6 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
rv = aFile->AppendNative(folder);
}
# endif
}
NS_ENSURE_SUCCESS(rv, rv);
......
......@@ -109,14 +109,6 @@ class nsXREDirProvider final : public nsIDirectoryServiceProvider2,
*/
nsresult GetProfileDir(nsIFile** aResult);
/**
* Get the path to the base application directory.
*
* In almost all platforms it is the directory that contains the Firefox
* executable; on macOS we remove also Contents/MacOS from it.
*/
nsresult GetAppRootDir(nsIFile** aFile);
protected:
nsresult GetFilesInternal(const char* aProperty,
nsISimpleEnumerator** aResult);
......
......@@ -243,43 +243,11 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
return NS_ERROR_INVALID_ARG;
}
nsresult rv = NS_ERROR_UNEXPECTED;
nsresult rv;
bool exists;
nsCOMPtr<nsIFile> localDir;
#if defined(RELATIVE_DATA_DIR)
nsCOMPtr<nsIProperties> directoryService(
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
bool persistent = false;
nsCOMPtr<nsIFile> file, appRootDir;
rv = directoryService->Get(XRE_EXECUTABLE_FILE, NS_GET_IID(nsIFile),
getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, rv);
rv = file->Normalize();
NS_ENSURE_SUCCESS(rv, rv);
int levelsToRemove = 1;
# if defined(XP_MACOSX)
levelsToRemove += 2;
# endif
while (levelsToRemove-- > 0) {
rv = file->GetParent(getter_AddRefs(appRootDir));
NS_ENSURE_SUCCESS(rv, rv);
file = appRootDir;
}
localDir = appRootDir;
nsAutoCString profileDir(RELATIVE_DATA_DIR);
rv = localDir->SetRelativePath(localDir.get(), profileDir);
NS_ENSURE_SUCCESS(rv, rv);
if (aLocal) {
rv = localDir->AppendNative("Caches"_ns);
NS_ENSURE_SUCCESS(rv, rv);
}
#elif defined(MOZ_WIDGET_COCOA)
#if defined(MOZ_WIDGET_COCOA)
FSRef fsRef;
OSType folderType =
aLocal ? (OSType)kCachedDataFolderType : (OSType)kDomainLibraryFolderType;
......@@ -318,12 +286,10 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
# error dont_know_how_to_get_product_dir_on_your_platform
#endif
#if !defined(RELATIVE_DATA_DIR)
rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
if (NS_FAILED(rv)) {
return rv;
}
#endif
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists) {
......@@ -342,6 +308,10 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
//----------------------------------------------------------------------------------------
// GetDefaultUserProfileRoot - Gets the directory which contains each user
// profile dir
//
// UNIX : ~/.mozilla/
// WIN : <Application Data folder on user's machine>\Mozilla\Profiles
// Mac : :Documents:Mozilla:Profiles:
//----------------------------------------------------------------------------------------
nsresult nsAppFileLocationProvider::GetDefaultUserProfileRoot(
nsIFile** aLocalFile, bool aLocal) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment