Commit 771381c5 authored by henry's avatar henry Committed by Pier Angelo Vendrame
Browse files

fixup! Bug 40597: Implement TorSettings module

Bug 41710: Switch TorConnect.openTorConnect to use new methods.
parent cc17defe
Loading
Loading
Loading
Loading
+20 −16
Changes for toolkit/modules/TorConnect.sys.mjs: 20 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -1742,10 +1742,11 @@ export const TorConnect = {
   * potentially blocked.
   *
   * @param {object} [options] - extra options.
   * @property {boolean} [options.beginBootstrap=false] - Whether to try and
   *   begin Bootstrapping.
   * @property {string} [options.beginAutoBootstrap] - The location to use to
   *   begin AutoBootstrapping, if possible.
   * @property {"soft"|"hard"} [options.beginBootstrapping] - Whether to try and
   *   begin bootstrapping. "soft" will only trigger the bootstrap if we are not
   *   `potentiallyBlocked`. "hard" will try begin the bootstrap regardless.
   * @property {string} [options.regionCode] - A region to pass in for
   *   auto-bootstrapping.
   */
  openTorConnect(options) {
    // FIXME: Should we move this to the about:torconnect actor?
@@ -1753,20 +1754,23 @@ export const TorConnect = {
    win.switchToTabHavingURI("about:torconnect", true, {
      ignoreQueryString: true,
    });
    if (
      options?.beginBootstrap &&
      this.canBeginBootstrap &&
      !this.potentiallyBlocked
    ) {
      this.beginBootstrap();

    if (!options?.beginBootstrapping || !this.canBeginBootstrap) {
      return;
    }
    // options.beginAutoBootstrap can be an empty string.
    if (
      options?.beginAutoBootstrap !== undefined &&
      this.canBeginAutoBootstrap
    ) {
      this.beginAutoBootstrap(options.beginAutoBootstrap);

    if (options.beginBootstrapping === "hard") {
      if (this.canBeginAutoBootstrap && !options.regionCode) {
        // Treat as an addition startAgain request to first move back to the
        // "Start" stage before bootstrapping.
        this.startAgain();
      }
    } else if (this.potentiallyBlocked) {
      // Do not trigger the bootstrap if we have ever had an error.
      return;
    }

    this.beginBootstrapping(options.regionCode);
  },

  // TODO: Move to TorConnectParent.