Richard Pospesel pushed to branch base-browser-102.6.0esr-12.5-1 at The Tor Project / Applications / Tor Browser
Commits:
-
cc5f2fcd
by Pier Angelo Vendrame at 2023-01-10T19:59:42+00:00
5 changed files:
- browser/config/mozconfigs/base-browser
- moz.configure
- mozconfig-macos-x86_64
- toolkit/xre/nsXREDirProvider.cpp
- xpcom/io/nsAppFileLocationProvider.cpp
Changes:
| ... | ... | @@ -42,4 +42,4 @@ if test -z "$WASI_SYSROOT"; then |
| 42 | 42 | ac_add_options --without-wasm-sandboxed-libraries
|
| 43 | 43 | fi
|
| 44 | 44 | |
| 45 | -ac_add_options --with-relative-profile=BaseBrowser/Data/Browser |
|
| 45 | +ac_add_options --with-relative-data-dir=BaseBrowser/Data/Browser |
| ... | ... | @@ -1026,22 +1026,22 @@ set_define("BASE_BROWSER", True, when="--enable-base-browser") |
| 1026 | 1026 | |
| 1027 | 1027 | |
| 1028 | 1028 | option(
|
| 1029 | - "--with-relative-profile",
|
|
| 1029 | + "--with-relative-data-dir",
|
|
| 1030 | 1030 | nargs=1,
|
| 1031 | - help="Sets the directory of the profile, relative to the application directory"
|
|
| 1031 | + help="Sets the data directories to be relative to the application directory"
|
|
| 1032 | 1032 | )
|
| 1033 | 1033 | |
| 1034 | 1034 | |
| 1035 | -@depends("--with-relative-profile", target)
|
|
| 1035 | +@depends("--with-relative-data-dir", target)
|
|
| 1036 | 1036 | @imports("json")
|
| 1037 | -def relative_profile(value, target):
|
|
| 1037 | +def relative_data_dir(value, target):
|
|
| 1038 | 1038 | if value and target.os == "Android":
|
| 1039 | - die("--with-relative-profile is not supported on Android")
|
|
| 1039 | + die("--with-relative-data-dir is not supported on Android")
|
|
| 1040 | 1040 | if value:
|
| 1041 | 1041 | return json.dumps(value[0])
|
| 1042 | 1042 | |
| 1043 | 1043 | |
| 1044 | -set_define("RELATIVE_PROFILE_DIRECTORY", relative_profile)
|
|
| 1044 | +set_define("RELATIVE_DATA_DIR", relative_data_dir)
|
|
| 1045 | 1045 | |
| 1046 | 1046 | |
| 1047 | 1047 | # Please do not add configure checks from here on.
|
| ... | ... | @@ -4,3 +4,6 @@ ac_add_options --enable-strip |
| 4 | 4 | |
| 5 | 5 | # See bug #41131
|
| 6 | 6 | ac_add_options --disable-update-agent
|
| 7 | + |
|
| 8 | +# For base-browser we do not enable portable mode on macOS.
|
|
| 9 | +ac_add_options --without-relative-data-dir |
| ... | ... | @@ -234,6 +234,9 @@ nsresult nsXREDirProvider::GetUserProfilesRootDir(nsIFile** aResult) { |
| 234 | 234 | nsresult rv = GetUserDataDirectory(getter_AddRefs(file), false);
|
| 235 | 235 | |
| 236 | 236 | if (NS_SUCCEEDED(rv)) {
|
| 237 | +#if !defined(XP_UNIX) || defined(XP_MACOSX)
|
|
| 238 | + rv = file->AppendNative("Profiles"_ns);
|
|
| 239 | +#endif
|
|
| 237 | 240 | // We must create the profile directory here if it does not exist.
|
| 238 | 241 | nsresult tmp = EnsureDirectoryExists(file);
|
| 239 | 242 | if (NS_FAILED(tmp)) {
|
| ... | ... | @@ -249,6 +252,9 @@ nsresult nsXREDirProvider::GetUserProfilesLocalDir(nsIFile** aResult) { |
| 249 | 252 | nsresult rv = GetUserDataDirectory(getter_AddRefs(file), true);
|
| 250 | 253 | |
| 251 | 254 | if (NS_SUCCEEDED(rv)) {
|
| 255 | +#if !defined(XP_UNIX) || defined(XP_MACOSX)
|
|
| 256 | + rv = file->AppendNative("Profiles"_ns);
|
|
| 257 | +#endif
|
|
| 252 | 258 | // We must create the profile directory here if it does not exist.
|
| 253 | 259 | nsresult tmp = EnsureDirectoryExists(file);
|
| 254 | 260 | if (NS_FAILED(tmp)) {
|
| ... | ... | @@ -1332,14 +1338,14 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, |
| 1332 | 1338 | return gDataDirHome->Clone(aFile);
|
| 1333 | 1339 | }
|
| 1334 | 1340 | |
| 1335 | -#if defined(RELATIVE_PROFILE_DIRECTORY)
|
|
| 1341 | +#if defined(RELATIVE_DATA_DIR)
|
|
| 1336 | 1342 | RefPtr<nsXREDirProvider> singleton = GetSingleton();
|
| 1337 | 1343 | if (!singleton) {
|
| 1338 | 1344 | return NS_ERROR_OUT_OF_MEMORY;
|
| 1339 | 1345 | }
|
| 1340 | 1346 | rv = singleton->GetAppRootDir(getter_AddRefs(localDir));
|
| 1341 | 1347 | NS_ENSURE_SUCCESS(rv, rv);
|
| 1342 | - nsAutoCString profileDir(RELATIVE_PROFILE_DIRECTORY);
|
|
| 1348 | + nsAutoCString profileDir(RELATIVE_DATA_DIR);
|
|
| 1343 | 1349 | rv = localDir->SetRelativePath(localDir.get(), profileDir);
|
| 1344 | 1350 | NS_ENSURE_SUCCESS(rv, rv);
|
| 1345 | 1351 | if (aLocal) {
|
| ... | ... | @@ -1502,7 +1508,7 @@ nsresult nsXREDirProvider::GetAppRootDir(nsIFile** aFile) { |
| 1502 | 1508 | #endif
|
| 1503 | 1509 | while (levelsToRemove-- > 0) {
|
| 1504 | 1510 | rv = file->GetParent(getter_AddRefs(appRootDir));
|
| 1505 | - NS_ENSURE_SUCCESS(rv, rv);
|
|
| 1511 | + NS_ENSURE_SUCCESS(rv, rv);
|
|
| 1506 | 1512 | file = appRootDir;
|
| 1507 | 1513 | }
|
| 1508 | 1514 | return appRootDir->Clone(aFile);
|
| ... | ... | @@ -1559,8 +1565,13 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) { |
| 1559 | 1565 | }
|
| 1560 | 1566 | |
| 1561 | 1567 | nsAutoCString profile;
|
| 1568 | + nsAutoCString appName;
|
|
| 1569 | + nsAutoCString vendor;
|
|
| 1562 | 1570 | if (gAppData->profile) {
|
| 1563 | 1571 | profile = gAppData->profile;
|
| 1572 | + } else {
|
|
| 1573 | + appName = gAppData->name;
|
|
| 1574 | + vendor = gAppData->vendor;
|
|
| 1564 | 1575 | }
|
| 1565 | 1576 | |
| 1566 | 1577 | nsresult rv = NS_OK;
|
| ... | ... | @@ -1568,12 +1579,27 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) { |
| 1568 | 1579 | #if defined(XP_MACOSX)
|
| 1569 | 1580 | if (!profile.IsEmpty()) {
|
| 1570 | 1581 | rv = AppendProfileString(aFile, profile.get());
|
| 1582 | +# ifndef RELATIVE_DATA_DIR
|
|
| 1583 | + } else {
|
|
| 1584 | + // Note that MacOS ignores the vendor when creating the profile hierarchy -
|
|
| 1585 | + // all application preferences directories live alongside one another in
|
|
| 1586 | + // ~/Library/Application Support/
|
|
| 1587 | + rv = aFile->AppendNative(appName);
|
|
| 1588 | +# endif
|
|
| 1571 | 1589 | }
|
| 1572 | 1590 | NS_ENSURE_SUCCESS(rv, rv);
|
| 1573 | 1591 | |
| 1574 | 1592 | #elif defined(XP_WIN)
|
| 1575 | 1593 | if (!profile.IsEmpty()) {
|
| 1576 | 1594 | rv = AppendProfileString(aFile, profile.get());
|
| 1595 | +# ifndef RELATIVE_DATA_DIR
|
|
| 1596 | + } else {
|
|
| 1597 | + if (!vendor.IsEmpty()) {
|
|
| 1598 | + rv = aFile->AppendNative(vendor);
|
|
| 1599 | + NS_ENSURE_SUCCESS(rv, rv);
|
|
| 1600 | + }
|
|
| 1601 | + rv = aFile->AppendNative(appName);
|
|
| 1602 | +# endif
|
|
| 1577 | 1603 | }
|
| 1578 | 1604 | NS_ENSURE_SUCCESS(rv, rv);
|
| 1579 | 1605 | |
| ... | ... | @@ -1585,21 +1611,48 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) { |
| 1585 | 1611 | rv = aFile->AppendNative(nsDependentCString("mozilla"));
|
| 1586 | 1612 | NS_ENSURE_SUCCESS(rv, rv);
|
| 1587 | 1613 | #elif defined(XP_UNIX)
|
| 1614 | + nsAutoCString folder;
|
|
| 1615 | + // Make it hidden (by starting with "."), except when local (the
|
|
| 1616 | + // profile is already under ~/.cache or XDG_CACHE_HOME).
|
|
| 1617 | +# ifndef RELATIVE_DATA_DIR
|
|
| 1618 | + if (!aLocal) folder.Assign('.');
|
|
| 1619 | +# endif
|
|
| 1620 | + |
|
| 1588 | 1621 | if (!profile.IsEmpty()) {
|
| 1589 | 1622 | // Skip any leading path characters
|
| 1590 | 1623 | const char* profileStart = profile.get();
|
| 1591 | 1624 | while (*profileStart == '/' || *profileStart == '\\') profileStart++;
|
| 1592 | 1625 | |
| 1626 | +# ifndef RELATIVE_DATA_DIR
|
|
| 1593 | 1627 | // On the off chance that someone wanted their folder to be hidden don't
|
| 1594 | 1628 | // let it become ".."
|
| 1595 | - if (*profileStart == '.') profileStart++;
|
|
| 1629 | + if (*profileStart == '.' && !aLocal) profileStart++;
|
|
| 1630 | +# endif
|
|
| 1596 | 1631 | |
| 1597 | - // Make it hidden (by starting with ".").
|
|
| 1598 | - nsAutoCString folder(".");
|
|
| 1599 | 1632 | folder.Append(profileStart);
|
| 1600 | 1633 | ToLowerCase(folder);
|
| 1601 | 1634 | |
| 1602 | 1635 | rv = AppendProfileString(aFile, folder.BeginReading());
|
| 1636 | +# ifndef RELATIVE_DATA_DIR
|
|
| 1637 | + } else {
|
|
| 1638 | + if (!vendor.IsEmpty()) {
|
|
| 1639 | + folder.Append(vendor);
|
|
| 1640 | + ToLowerCase(folder);
|
|
| 1641 | + |
|
| 1642 | + rv = aFile->AppendNative(folder);
|
|
| 1643 | + NS_ENSURE_SUCCESS(rv, rv);
|
|
| 1644 | + |
|
| 1645 | + folder.Truncate();
|
|
| 1646 | + }
|
|
| 1647 | + |
|
| 1648 | + // This can be the case in tests.
|
|
| 1649 | + if (!appName.IsEmpty()) {
|
|
| 1650 | + folder.Append(appName);
|
|
| 1651 | + ToLowerCase(folder);
|
|
| 1652 | + |
|
| 1653 | + rv = aFile->AppendNative(folder);
|
|
| 1654 | + }
|
|
| 1655 | +# endif
|
|
| 1603 | 1656 | }
|
| 1604 | 1657 | NS_ENSURE_SUCCESS(rv, rv);
|
| 1605 | 1658 |
| ... | ... | @@ -247,7 +247,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile, |
| 247 | 247 | bool exists;
|
| 248 | 248 | nsCOMPtr<nsIFile> localDir;
|
| 249 | 249 | |
| 250 | -#if defined(RELATIVE_PROFILE_DIRECTORY)
|
|
| 250 | +#if defined(RELATIVE_DATA_DIR)
|
|
| 251 | 251 | nsCOMPtr<nsIProperties> directoryService(
|
| 252 | 252 | do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
|
| 253 | 253 | NS_ENSURE_SUCCESS(rv, rv);
|
| ... | ... | @@ -260,9 +260,9 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile, |
| 260 | 260 | rv = file->Normalize();
|
| 261 | 261 | NS_ENSURE_SUCCESS(rv, rv);
|
| 262 | 262 | int levelsToRemove = 1;
|
| 263 | -#if defined(XP_MACOSX)
|
|
| 263 | +# if defined(XP_MACOSX)
|
|
| 264 | 264 | levelsToRemove += 2;
|
| 265 | -#endif
|
|
| 265 | +# endif
|
|
| 266 | 266 | while (levelsToRemove-- > 0) {
|
| 267 | 267 | rv = file->GetParent(getter_AddRefs(appRootDir));
|
| 268 | 268 | NS_ENSURE_SUCCESS(rv, rv);
|
| ... | ... | @@ -270,7 +270,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile, |
| 270 | 270 | }
|
| 271 | 271 | |
| 272 | 272 | localDir = appRootDir;
|
| 273 | - nsAutoCString profileDir(RELATIVE_PROFILE_DIRECTORY);
|
|
| 273 | + nsAutoCString profileDir(RELATIVE_DATA_DIR);
|
|
| 274 | 274 | rv = localDir->SetRelativePath(localDir.get(), profileDir);
|
| 275 | 275 | NS_ENSURE_SUCCESS(rv, rv);
|
| 276 | 276 | |
| ... | ... | @@ -318,6 +318,12 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile, |
| 318 | 318 | # error dont_know_how_to_get_product_dir_on_your_platform
|
| 319 | 319 | #endif
|
| 320 | 320 | |
| 321 | +#if !defined(RELATIVE_DATA_DIR)
|
|
| 322 | + rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
|
|
| 323 | + if (NS_FAILED(rv)) {
|
|
| 324 | + return rv;
|
|
| 325 | + }
|
|
| 326 | +#endif
|
|
| 321 | 327 | rv = localDir->Exists(&exists);
|
| 322 | 328 | |
| 323 | 329 | if (NS_SUCCEEDED(rv) && !exists) {
|
| ... | ... | @@ -351,6 +357,23 @@ nsresult nsAppFileLocationProvider::GetDefaultUserProfileRoot( |
| 351 | 357 | return rv;
|
| 352 | 358 | }
|
| 353 | 359 | |
| 360 | +#if defined(MOZ_WIDGET_COCOA) || defined(XP_WIN)
|
|
| 361 | + // These 3 platforms share this part of the path - do them as one
|
|
| 362 | + rv = localDir->AppendRelativeNativePath("Profiles"_ns);
|
|
| 363 | + if (NS_FAILED(rv)) {
|
|
| 364 | + return rv;
|
|
| 365 | + }
|
|
| 366 | + |
|
| 367 | + bool exists;
|
|
| 368 | + rv = localDir->Exists(&exists);
|
|
| 369 | + if (NS_SUCCEEDED(rv) && !exists) {
|
|
| 370 | + rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
|
|
| 371 | + }
|
|
| 372 | + if (NS_FAILED(rv)) {
|
|
| 373 | + return rv;
|
|
| 374 | + }
|
|
| 375 | +#endif
|
|
| 376 | + |
|
| 354 | 377 | localDir.forget(aLocalFile);
|
| 355 | 378 | |
| 356 | 379 | return rv;
|