Richard Pospesel pushed to branch tor-browser-102.6.0esr-12.5-1 at The Tor Project / Applications / Tor Browser

Commits:

6 changed files:

Changes:

  • browser/config/mozconfigs/tor-browser
    1 1
     . $topsrcdir/browser/config/mozconfigs/base-browser
    
    2 2
     
    
    3
    +export MOZ_APP_BASENAME="TorBrowser"
    
    3 4
     mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
    
    4 5
     
    
    5
    -ac_add_options --with-relative-profile=TorBrowser/Data/Browser
    
    6
    +ac_add_options --with-relative-data-dir=TorBrowser/Data/Browser
    
    7
    +# This is not needed with the relative data directory, but it is when you
    
    8
    +# disable it, otherwise it is "Mozilla" (on Windows and macOS) or ".mozilla" on
    
    9
    +# Unix systems.
    
    10
    +# It is used, for example, for GetProductDirectory.
    
    11
    +# ac_add_options --with-user-appdir=TorProject
    
    12
    +# ac_add_options --with-user-appdir=.torproject
    
    6 13
     
    
    7 14
     ac_add_options --enable-tor-browser-update
    
    8 15
     ac_add_options --enable-verify-mar
    

  • browser/confvars.sh
    ... ... @@ -3,7 +3,7 @@
    3 3
     # License, v. 2.0. If a copy of the MPL was not distributed with this
    
    4 4
     # file, You can obtain one at http://mozilla.org/MPL/2.0/.
    
    5 5
     
    
    6
    -MOZ_APP_VENDOR=Mozilla
    
    6
    +MOZ_APP_VENDOR="Tor Project"
    
    7 7
     
    
    8 8
     BROWSER_CHROME_URL=chrome://browser/content/browser.xhtml
    
    9 9
     
    

  • moz.configure
    ... ... @@ -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
     # Tor additions.
    

  • toolkit/xre/nsAppRunner.cpp
    ... ... @@ -4158,14 +4158,6 @@ int XREMain::XRE_mainInit(bool* aExitFlag) {
    4158 4158
       if (PR_GetEnv("XRE_MAIN_BREAK")) NS_BREAK();
    
    4159 4159
     #endif
    
    4160 4160
     
    
    4161
    -#if defined(XP_MACOSX) && defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
    
    4162
    -  bool hideDockIcon = (CheckArg("invisible") == ARG_FOUND);
    
    4163
    -  if (hideDockIcon) {
    
    4164
    -    ProcessSerialNumber psn = {0, kCurrentProcess};
    
    4165
    -    TransformProcessType(&psn, kProcessTransformToBackgroundApplication);
    
    4166
    -  }
    
    4167
    -#endif
    
    4168
    -
    
    4169 4161
       mozilla::startup::IncreaseDescriptorLimits();
    
    4170 4162
     
    
    4171 4163
     #ifdef USE_GLX_TEST
    
    ... ... @@ -5222,6 +5214,14 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
    5222 5214
         if (CheckArg("test-process-updates")) {
    
    5223 5215
           SaveToEnv("MOZ_TEST_PROCESS_UPDATES=1");
    
    5224 5216
         }
    
    5217
    +#  ifndef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
    
    5218
    +    nsCOMPtr<nsIFile> exeFile, exeDir;
    
    5219
    +    rv = mDirProvider.GetFile(XRE_EXECUTABLE_FILE, &persistent,
    
    5220
    +                              getter_AddRefs(exeFile));
    
    5221
    +    NS_ENSURE_SUCCESS(rv, 1);
    
    5222
    +    rv = exeFile->GetParent(getter_AddRefs(exeDir));
    
    5223
    +#  endif
    
    5224
    +
    
    5225 5225
     #  ifdef TOR_BROWSER_UPDATE
    
    5226 5226
         nsAutoCString compatVersion(TOR_BROWSER_VERSION_QUOTED);
    
    5227 5227
     #  endif
    

  • toolkit/xre/nsXREDirProvider.cpp
    ... ... @@ -236,6 +236,11 @@ nsresult nsXREDirProvider::GetUserProfilesRootDir(nsIFile** aResult) {
    236 236
       nsresult rv = GetUserDataDirectory(getter_AddRefs(file), false);
    
    237 237
     
    
    238 238
       if (NS_SUCCEEDED(rv)) {
    
    239
    +    // For some reason, we have decided not to append "Profiles" in Tor Browser.
    
    240
    +    // So, let's keep removing it, or we should somehow migrate the profile.
    
    241
    +#if !defined(TOR_BROWSER_VERSION) && (!defined(XP_UNIX) || defined(XP_MACOSX))
    
    242
    +    rv = file->AppendNative("Profiles"_ns);
    
    243
    +#endif
    
    239 244
         // We must create the profile directory here if it does not exist.
    
    240 245
         nsresult tmp = EnsureDirectoryExists(file);
    
    241 246
         if (NS_FAILED(tmp)) {
    
    ... ... @@ -251,6 +256,9 @@ nsresult nsXREDirProvider::GetUserProfilesLocalDir(nsIFile** aResult) {
    251 256
       nsresult rv = GetUserDataDirectory(getter_AddRefs(file), true);
    
    252 257
     
    
    253 258
       if (NS_SUCCEEDED(rv)) {
    
    259
    +#if !defined(TOR_BROWSER_VERSION) && (!defined(XP_UNIX) || defined(XP_MACOSX))
    
    260
    +    rv = file->AppendNative("Profiles"_ns);
    
    261
    +#endif
    
    254 262
         // We must create the profile directory here if it does not exist.
    
    255 263
         nsresult tmp = EnsureDirectoryExists(file);
    
    256 264
         if (NS_FAILED(tmp)) {
    
    ... ... @@ -1366,8 +1374,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
    1366 1374
         return gDataDirHome->Clone(aFile);
    
    1367 1375
       }
    
    1368 1376
     
    
    1369
    -#if defined(RELATIVE_PROFILE_DIRECTORY) || \
    
    1370
    -    defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
    
    1377
    +#if defined(RELATIVE_DATA_DIR) || defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
    
    1371 1378
     #  ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
    
    1372 1379
       rv = GetTorBrowserUserDataDir(getter_AddRefs(localDir));
    
    1373 1380
       NS_ENSURE_SUCCESS(rv, rv);
    
    ... ... @@ -1379,10 +1386,10 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
    1379 1386
       }
    
    1380 1387
       rv = singleton->GetAppRootDir(getter_AddRefs(localDir));
    
    1381 1388
       NS_ENSURE_SUCCESS(rv, rv);
    
    1382
    -  nsAutoCString profileDir(RELATIVE_PROFILE_DIRECTORY);
    
    1389
    +  nsAutoCString profileDir(RELATIVE_DATA_DIR);
    
    1383 1390
       rv = localDir->SetRelativePath(localDir.get(), profileDir);
    
    1384 1391
       NS_ENSURE_SUCCESS(rv, rv);
    
    1385
    -#endif
    
    1392
    +#  endif
    
    1386 1393
       if (aLocal) {
    
    1387 1394
         rv = localDir->AppendNative("Caches"_ns);
    
    1388 1395
         NS_ENSURE_SUCCESS(rv, rv);
    
    ... ... @@ -1555,7 +1562,7 @@ nsresult nsXREDirProvider::GetAppRootDir(nsIFile** aFile) {
    1555 1562
     #endif
    
    1556 1563
       while (levelsToRemove-- > 0) {
    
    1557 1564
         rv = file->GetParent(getter_AddRefs(appRootDir));
    
    1558
    -  NS_ENSURE_SUCCESS(rv, rv);
    
    1565
    +    NS_ENSURE_SUCCESS(rv, rv);
    
    1559 1566
         file = appRootDir;
    
    1560 1567
       }
    
    1561 1568
       return appRootDir->Clone(aFile);
    
    ... ... @@ -1612,8 +1619,13 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
    1612 1619
       }
    
    1613 1620
     
    
    1614 1621
       nsAutoCString profile;
    
    1622
    +  nsAutoCString appName;
    
    1623
    +  nsAutoCString vendor;
    
    1615 1624
       if (gAppData->profile) {
    
    1616 1625
         profile = gAppData->profile;
    
    1626
    +  } else {
    
    1627
    +    appName = gAppData->name;
    
    1628
    +    vendor = gAppData->vendor;
    
    1617 1629
       }
    
    1618 1630
     
    
    1619 1631
       nsresult rv = NS_OK;
    
    ... ... @@ -1621,12 +1633,27 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
    1621 1633
     #if defined(XP_MACOSX)
    
    1622 1634
       if (!profile.IsEmpty()) {
    
    1623 1635
         rv = AppendProfileString(aFile, profile.get());
    
    1636
    +#  ifndef RELATIVE_DATA_DIR
    
    1637
    +  } else {
    
    1638
    +    // Note that MacOS ignores the vendor when creating the profile hierarchy -
    
    1639
    +    // all application preferences directories live alongside one another in
    
    1640
    +    // ~/Library/Application Support/
    
    1641
    +    rv = aFile->AppendNative(appName);
    
    1642
    +#  endif
    
    1624 1643
       }
    
    1625 1644
       NS_ENSURE_SUCCESS(rv, rv);
    
    1626 1645
     
    
    1627 1646
     #elif defined(XP_WIN)
    
    1628 1647
       if (!profile.IsEmpty()) {
    
    1629 1648
         rv = AppendProfileString(aFile, profile.get());
    
    1649
    +#  ifndef RELATIVE_DATA_DIR
    
    1650
    +  } else {
    
    1651
    +    if (!vendor.IsEmpty()) {
    
    1652
    +      rv = aFile->AppendNative(vendor);
    
    1653
    +      NS_ENSURE_SUCCESS(rv, rv);
    
    1654
    +    }
    
    1655
    +    rv = aFile->AppendNative(appName);
    
    1656
    +#  endif
    
    1630 1657
       }
    
    1631 1658
       NS_ENSURE_SUCCESS(rv, rv);
    
    1632 1659
     
    
    ... ... @@ -1638,21 +1665,48 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
    1638 1665
       rv = aFile->AppendNative(nsDependentCString("mozilla"));
    
    1639 1666
       NS_ENSURE_SUCCESS(rv, rv);
    
    1640 1667
     #elif defined(XP_UNIX)
    
    1668
    +  nsAutoCString folder;
    
    1669
    +  // Make it hidden (by starting with "."), except when local (the
    
    1670
    +  // profile is already under ~/.cache or XDG_CACHE_HOME).
    
    1671
    +#  ifndef RELATIVE_DATA_DIR
    
    1672
    +  if (!aLocal) folder.Assign('.');
    
    1673
    +#  endif
    
    1674
    +
    
    1641 1675
       if (!profile.IsEmpty()) {
    
    1642 1676
         // Skip any leading path characters
    
    1643 1677
         const char* profileStart = profile.get();
    
    1644 1678
         while (*profileStart == '/' || *profileStart == '\\') profileStart++;
    
    1645 1679
     
    
    1680
    +#  ifndef RELATIVE_DATA_DIR
    
    1646 1681
         // On the off chance that someone wanted their folder to be hidden don't
    
    1647 1682
         // let it become ".."
    
    1648
    -    if (*profileStart == '.') profileStart++;
    
    1683
    +    if (*profileStart == '.' && !aLocal) profileStart++;
    
    1684
    +#  endif
    
    1649 1685
     
    
    1650
    -    // Make it hidden (by starting with ".").
    
    1651
    -    nsAutoCString folder(".");
    
    1652 1686
         folder.Append(profileStart);
    
    1653 1687
         ToLowerCase(folder);
    
    1654 1688
     
    
    1655 1689
         rv = AppendProfileString(aFile, folder.BeginReading());
    
    1690
    +#  ifndef RELATIVE_DATA_DIR
    
    1691
    +  } else {
    
    1692
    +    if (!vendor.IsEmpty()) {
    
    1693
    +      folder.Append(vendor);
    
    1694
    +      ToLowerCase(folder);
    
    1695
    +
    
    1696
    +      rv = aFile->AppendNative(folder);
    
    1697
    +      NS_ENSURE_SUCCESS(rv, rv);
    
    1698
    +
    
    1699
    +      folder.Truncate();
    
    1700
    +    }
    
    1701
    +
    
    1702
    +    // This can be the case in tests.
    
    1703
    +    if (!appName.IsEmpty()) {
    
    1704
    +      folder.Append(appName);
    
    1705
    +      ToLowerCase(folder);
    
    1706
    +
    
    1707
    +      rv = aFile->AppendNative(folder);
    
    1708
    +    }
    
    1709
    +#  endif
    
    1656 1710
       }
    
    1657 1711
       NS_ENSURE_SUCCESS(rv, rv);
    
    1658 1712
     
    

  • xpcom/io/nsAppFileLocationProvider.cpp
    ... ... @@ -249,8 +249,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
    249 249
       bool exists;
    
    250 250
       nsCOMPtr<nsIFile> localDir;
    
    251 251
     
    
    252
    -#if defined(RELATIVE_PROFILE_DIRECTORY) || \
    
    253
    -    defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
    
    252
    +#if defined(RELATIVE_DATA_DIR) || defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
    
    254 253
       nsCOMPtr<nsIProperties> directoryService(
    
    255 254
           do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
    
    256 255
       NS_ENSURE_SUCCESS(rv, rv);
    
    ... ... @@ -263,26 +262,24 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
    263 262
       rv = file->Normalize();
    
    264 263
       NS_ENSURE_SUCCESS(rv, rv);
    
    265 264
       int levelsToRemove = 1;
    
    266
    -#if defined(XP_MACOSX)
    
    265
    +#  if defined(XP_MACOSX)
    
    267 266
       levelsToRemove += 2;
    
    268
    -#endif
    
    267
    +#  endif
    
    269 268
       while (levelsToRemove-- > 0) {
    
    270 269
         rv = file->GetParent(getter_AddRefs(appRootDir));
    
    271 270
         NS_ENSURE_SUCCESS(rv, rv);
    
    272 271
         file = appRootDir;
    
    273 272
       }
    
    274 273
     
    
    275
    -#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
    
    274
    +#  ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
    
    276 275
       rv = TorBrowser_GetUserDataDir(appRootDir, getter_AddRefs(localDir));
    
    277 276
       NS_ENSURE_SUCCESS(rv, rv);
    
    278 277
       rv = localDir->AppendNative("Browser"_ns);
    
    279
    -#else
    
    278
    +#  else
    
    280 279
       localDir = appRootDir;
    
    281
    -  nsAutoCString profileDir(RELATIVE_PROFILE_DIRECTORY);
    
    280
    +  nsAutoCString profileDir(RELATIVE_DATA_DIR);
    
    282 281
       rv = localDir->SetRelativePath(localDir.get(), profileDir);
    
    283
    -  NS_ENSURE_SUCCESS(rv, rv);
    
    284
    -#endif
    
    285
    -
    
    282
    +#  endif
    
    286 283
       NS_ENSURE_SUCCESS(rv, rv);
    
    287 284
     
    
    288 285
       if (aLocal) {
    
    ... ... @@ -329,6 +326,12 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
    329 326
     #  error dont_know_how_to_get_product_dir_on_your_platform
    
    330 327
     #endif
    
    331 328
     
    
    329
    +#if !defined(RELATIVE_DATA_DIR) && !defined(TOR_BROWSER_VERSION)
    
    330
    +  rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
    
    331
    +  if (NS_FAILED(rv)) {
    
    332
    +    return rv;
    
    333
    +  }
    
    334
    +#endif
    
    332 335
       rv = localDir->Exists(&exists);
    
    333 336
     
    
    334 337
       if (NS_SUCCEEDED(rv) && !exists) {
    
    ... ... @@ -362,6 +365,26 @@ nsresult nsAppFileLocationProvider::GetDefaultUserProfileRoot(
    362 365
         return rv;
    
    363 366
       }
    
    364 367
     
    
    368
    +#if defined(MOZ_WIDGET_COCOA) || defined(XP_WIN)
    
    369
    +  // These 3 platforms share this part of the path - do them as one
    
    370
    +#  ifndef TOR_BROWSER_VERSION
    
    371
    +  // Legacy: we do not use "Profiles" on Tor Browser.
    
    372
    +  rv = localDir->AppendRelativeNativePath("Profiles"_ns);
    
    373
    +  if (NS_FAILED(rv)) {
    
    374
    +    return rv;
    
    375
    +  }
    
    376
    +#  endif
    
    377
    +
    
    378
    +  bool exists;
    
    379
    +  rv = localDir->Exists(&exists);
    
    380
    +  if (NS_SUCCEEDED(rv) && !exists) {
    
    381
    +    rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
    
    382
    +  }
    
    383
    +  if (NS_FAILED(rv)) {
    
    384
    +    return rv;
    
    385
    +  }
    
    386
    +#endif
    
    387
    +
    
    365 388
       localDir.forget(aLocalFile);
    
    366 389
     
    
    367 390
       return rv;