henry pushed to branch tor-browser-149.0a1-16.0-2 at The Tor Project / Applications / Tor Browser Commits: c408b593 by Henry Wilkes at 2026-03-23T17:53:56+00:00 fixup! TB 42247: Android helpers for the TorProvider TB 43858: Drop deprecated TorConnect API. - - - - - a9088f07 by Henry Wilkes at 2026-03-23T17:53:56+00:00 fixup! TB 40597: Implement TorSettings module TB 43858: Drop deprecated TorConnect API. - - - - - 3 changed files: - mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorAndroidIntegration.java - toolkit/modules/TorAndroidIntegration.sys.mjs - toolkit/modules/TorConnect.sys.mjs Changes: ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorAndroidIntegration.java ===================================== @@ -56,7 +56,6 @@ public class TorAndroidIntegration implements BundleEventListener { private static final String EVENT_BOOTSTRAP_BEGIN = "GeckoView:Tor:BootstrapBegin"; private static final String EVENT_BOOTSTRAP_BEGIN_AUTO = "GeckoView:Tor:BootstrapBeginAuto"; private static final String EVENT_BOOTSTRAP_CANCEL = "GeckoView:Tor:BootstrapCancel"; - private static final String EVENT_BOOTSTRAP_GET_STATE = "GeckoView:Tor:BootstrapGetState"; private static final String EVENT_START_AGAIN = "GeckoView:Tor:StartAgain"; private static final String EVENT_QUICKSTART_GET = "GeckoView:Tor:QuickstartGet"; private static final String EVENT_QUICKSTART_SET = "GeckoView:Tor:QuickstartSet"; ===================================== toolkit/modules/TorAndroidIntegration.sys.mjs ===================================== @@ -26,8 +26,7 @@ const logger = console.createInstance({ const EmittedEvents = Object.freeze({ settingsReady: "GeckoView:Tor:SettingsReady", settingsChanged: "GeckoView:Tor:SettingsChanged", - connectStateChanged: "GeckoView:Tor:ConnectStateChanged", // deprecation path - connectStageChanged: "GeckoView:Tor:ConnectStageChanged", // new replacement path + connectStageChanged: "GeckoView:Tor:ConnectStageChanged", bootstrapProgress: "GeckoView:Tor:BootstrapProgress", bootstrapComplete: "GeckoView:Tor:BootstrapComplete", torLogs: "GeckoView:Tor:Logs", @@ -43,7 +42,6 @@ const ListenedEvents = Object.freeze({ // Optionally takes a countryCode, as data.countryCode. bootstrapBeginAuto: "GeckoView:Tor:BootstrapBeginAuto", bootstrapCancel: "GeckoView:Tor:BootstrapCancel", - bootstrapGetState: "GeckoView:Tor:BootstrapGetState", startAgain: "GeckoView:Tor:StartAgain", quickstartGet: "GeckoView:Tor:QuickstartGet", quickstartSet: "GeckoView:Tor:QuickstartSet", @@ -108,13 +106,6 @@ class TorAndroidIntegrationImpl { observe(subj, topic) { switch (topic) { - // TODO: Replace with StageChange. - case lazy.TorConnectTopics.StateChange: - lazy.EventDispatcher.instance.sendRequest({ - type: EmittedEvents.connectStateChanged, - state: subj.wrappedJSObject.state ?? "", - }); - break; case lazy.TorConnectTopics.StageChange: lazy.EventDispatcher.instance.sendRequest({ type: EmittedEvents.connectStageChanged, @@ -202,10 +193,6 @@ class TorAndroidIntegrationImpl { case ListenedEvents.bootstrapCancel: lazy.TorConnect.cancelBootstrapping(); break; - // TODO: Replace with TorConnect.stage. - case ListenedEvents.bootstrapGetState: - callback?.onSuccess(lazy.TorConnect.state); - return; case ListenedEvents.startAgain: lazy.TorConnect.startAgain(); break; ===================================== toolkit/modules/TorConnect.sys.mjs ===================================== @@ -35,23 +35,6 @@ const TorConnectPrefs = Object.freeze({ quickstart: "torbrowser.settings.quickstart.enabled", }); -export const TorConnectState = Object.freeze({ - /* Our initial state */ - Initial: "Initial", - /* In-between initial boot and bootstrapping, users can change tor network settings during this state */ - Configuring: "Configuring", - /* Tor is attempting to bootstrap with settings from censorship-circumvention db */ - AutoBootstrapping: "AutoBootstrapping", - /* Tor is bootstrapping */ - Bootstrapping: "Bootstrapping", - /* Passthrough state back to Configuring */ - Error: "Error", - /* Final state, after successful bootstrap */ - Bootstrapped: "Bootstrapped", - /* If we are using System tor or the legacy Tor-Launcher */ - Disabled: "Disabled", -}); - /** * A class for exceptions thrown during the bootstrap process. */ @@ -92,15 +75,11 @@ ChromeUtils.defineLazyGetter(lazy, "logger", () => /* Topics Notified by the TorConnect module */ export const TorConnectTopics = Object.freeze({ StageChange: "torconnect:stage-change", - // TODO: Remove torconnect:state-change when pages have switched to stage. - StateChange: "torconnect:state-change", QuickstartChange: "torconnect:quickstart-change", InternetStatusChange: "torconnect:internet-status-change", RegionNamesChange: "torconnect:region-names-change", BootstrapProgress: "torconnect:bootstrap-progress", BootstrapComplete: "torconnect:bootstrap-complete", - // TODO: Remove torconnect:error when pages have switched to stage. - Error: "torconnect:error", }); /** @@ -1025,7 +1004,6 @@ export const TorConnect = { } lazy.logger.info(`Entering stage ${name}`); - const prevState = this.state; this._stageName = name; this._bootstrappingStatus.hasWarning = false; this._bootstrappingStatus.progress = @@ -1033,15 +1011,6 @@ export const TorConnect = { Services.obs.notifyObservers(this.stage, TorConnectTopics.StageChange); - // TODO: Remove when all pages have switched to stage. - const newState = this.state; - if (prevState !== newState) { - Services.obs.notifyObservers( - { state: newState }, - TorConnectTopics.StateChange - ); - } - // Update the progress after the stage has changed. this._notifyBootstrapProgress(); }, @@ -1117,41 +1086,6 @@ export const TorConnect = { ); }, - // TODO: Remove when all pages have switched to "stage". - get state() { - // There is no "Error" stage, but about:torconnect relies on receiving the - // Error state to update its display. So we temporarily set the stage for a - // StateChange signal. - if (this._isErrorState) { - return TorConnectState.Error; - } - switch (this._stageName) { - case TorConnectStage.Disabled: - return TorConnectState.Disabled; - case TorConnectStage.Loading: - return TorConnectState.Initial; - case TorConnectStage.Start: - case TorConnectStage.Offline: - case TorConnectStage.ChooseRegion: - case TorConnectStage.RegionNotFound: - case TorConnectStage.ConfirmRegion: - case TorConnectStage.FinalError: - return TorConnectState.Configuring; - case TorConnectStage.Bootstrapping: - if ( - this._bootstrapTrigger === TorConnectStage.Start || - this._bootstrapTrigger === TorConnectStage.Offline - ) { - return TorConnectState.Bootstrapping; - } - return TorConnectState.AutoBootstrapping; - case TorConnectStage.Bootstrapped: - return TorConnectState.Bootstrapped; - } - lazy.logger.error(`Unknown state at stage ${this._stageName}`); - return null; - }, - /** * Get a map of all region codes and their localized names. * @@ -1191,38 +1125,6 @@ export const TorConnect = { } }, - /** - * Signal an error to listeners. - * - * @param {Error} error - The error. - */ - _signalError(error) { - // TODO: Replace this method with _setError without any signalling when - // pages have switched to stage. - // Currently it simulates the old behaviour for about:torconnect. - lazy.logger.debug("Signalling error", error); - - if (error instanceof lazy.TorBootstrapError) { - error = new TorConnectError(TorConnectError.BootstrapError, error); - } else if (!(error instanceof TorConnectError)) { - error = new TorConnectError(TorConnectError.ExternalError, error); - } - this._errorDetails = error; - - // Temporarily set an error state for listeners. - // We send the Error signal before the "StateChange" signal. - // Expected on android `onBootstrapError` to set lastKnownError. - // Expected in about:torconnect to set the error codes and internet status - // *before* the StateChange signal. - this._isErrorState = true; - Services.obs.notifyObservers(error, TorConnectTopics.Error); - Services.obs.notifyObservers( - { state: this.state }, - TorConnectTopics.StateChange - ); - this._isErrorState = false; - }, - /** * Add simulation options to the bootstrap request. * @@ -1463,7 +1365,7 @@ export const TorConnect = { // bootstrap being thrown, but we do not want to cancel a bootstrap // attempt prematurely in case the offline state is intermittent or // incorrect. - this._signalError(new TorConnectError(TorConnectError.Offline)); + this._errorDetails = new TorConnectError(TorConnectError.Offline); this._setStage(TorConnectStage.Offline); return; } @@ -1472,7 +1374,19 @@ export const TorConnect = { // Disable quickstart until we have a successful bootstrap. Services.prefs.setBoolPref(TorConnectPrefs.prompt_at_startup, true); - this._signalError(error); + let connectError = error; + if (error instanceof lazy.TorBootstrapError) { + connectError = new TorConnectError( + TorConnectError.BootstrapError, + error + ); + } else if (!(error instanceof TorConnectError)) { + connectError = new TorConnectError( + TorConnectError.ExternalError, + error + ); + } + this._errorDetails = connectError; let errorStage = TorConnectStage.FinalError; @@ -1518,12 +1432,6 @@ export const TorConnect = { lazy.logger.error(`Unexpected bootstrap result`, result); } - // TODO: Remove this Offline hack when pages use "stage". - if (beginStage === TorConnectStage.Offline) { - // Re-send the "Offline" error to push the pages back to "Offline". - this._signalError(new TorConnectError(TorConnectError.Offline)); - } - // Return to the previous stage. this._setStage(beginStage); }, View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/881103b... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/881103b... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help
participants (1)
-
henry (@henry)