henry pushed to branch tor-browser-153.0esr-16.0-1 at The Tor Project / Applications / Tor Browser Commits: f767af19 by Henry Wilkes at 2026-08-06T13:32:41+00:00 fixup! TB 40933: Add tor-launcher functionality TB 45161: Drop the restart prompt. - - - - - e97309cd by Henry Wilkes at 2026-08-06T13:32:41+00:00 fixup! Add TorStrings module for localization TB 45161: Drop TorLauncherUtils prompt strings. - - - - - 3 changed files: - toolkit/components/tor-launcher/TorLauncherUtil.sys.mjs - toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs - toolkit/torbutton/chrome/locale/en-US/torlauncher.properties Changes: ===================================== toolkit/components/tor-launcher/TorLauncherUtil.sys.mjs ===================================== @@ -15,8 +15,6 @@ ChromeUtils.defineESModuleGetters(lazy, { "moz-src:///toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs", }); -const kPropBundleURI = "chrome://torbutton/locale/torlauncher.properties"; -const kPropNamePrefix = "torlauncher."; const kIPCDirPrefName = "extensions.torlauncher.tmp_ipc_dir"; /** @@ -374,86 +372,6 @@ export const TorLauncherUtil = { return !re.test(path); }, - // Returns true if user confirms; false if not. - showConfirm(aParentWindow, aMsg, aDefaultButtonLabel, aCancelButtonLabel) { - if (!aParentWindow) { - aParentWindow = Services.wm.getMostRecentWindow("navigator:browser"); - } - - const ps = Services.prompt; - const title = this.getLocalizedString("error_title"); - const btnFlags = - ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING + - ps.BUTTON_POS_0_DEFAULT + - ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING; - - const notUsed = { value: false }; - const btnIndex = ps.confirmEx( - aParentWindow, - title, - aMsg, - btnFlags, - aDefaultButtonLabel, - aCancelButtonLabel, - null, - null, - notUsed - ); - return btnIndex === 0; - }, - - /** - * Ask the user whether they desire to restart tor. - * - * @param {boolean} initError If we could connect to the control port at - * least once and we are showing this prompt because the tor process exited - * suddenly, we will display a different message - * @returns {boolean} true if the user asked to restart tor - */ - showRestartPrompt(initError) { - let s; - if (initError) { - const key = "tor_exited_during_startup"; - s = this.getLocalizedString(key); - } else { - // tor exited suddenly, so configuration should be okay - s = - this.getLocalizedString("tor_exited") + - "\n\n" + - this.getLocalizedString("tor_exited2"); - } - const defaultBtnLabel = this.getLocalizedString("restart_tor"); - let cancelBtnLabel = "OK"; - try { - const kSysBundleURI = "chrome://global/locale/commonDialogs.properties"; - const sysBundle = Services.strings.createBundle(kSysBundleURI); - cancelBtnLabel = sysBundle.GetStringFromName(cancelBtnLabel); - } catch (e) { - console.warn("Could not localize the cancel button", e); - } - return this.showConfirm(null, s, defaultBtnLabel, cancelBtnLabel); - }, - - _stringBundle: null, - - // Localized Strings - // TODO: Switch to fluent also these ones. - - // "torlauncher." is prepended to aStringName. - getLocalizedString(aStringName) { - if (!aStringName) { - return aStringName; - } - if (!this._stringBundle) { - this._stringBundle = Services.strings.createBundle(kPropBundleURI); - } - try { - const key = kPropNamePrefix + aStringName; - return this._stringBundle.GetStringFromName(key); - } catch (e) {} - return aStringName; - }, - /** * Determine what kind of SOCKS port has been requested for this session or * the browser has been configured for. ===================================== toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs ===================================== @@ -4,8 +4,6 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { - TorLauncherUtil: - "moz-src:///toolkit/components/tor-launcher/TorLauncherUtil.sys.mjs", TorProvider: "moz-src:///toolkit/components/tor-launcher/TorProvider.sys.mjs", TorProviderMock: "moz-src:///toolkit/components/tor-launcher/TorProviderMock.sys.mjs", @@ -279,8 +277,6 @@ export class TorProviderBuilder { TorProviderTopics.ProviderStateChanged, provider.state ); - - this.#promptProviderState(false); } /** @@ -400,85 +396,6 @@ export class TorProviderBuilder { this.#replaceProvider(); } - // TODO: Remove firstWindowLoaded, #uiReady, #prompting, #promptProviderState - // and use TorConnect instead. tor-browser#43570. - /** - * Check if the provider has been succesfully initialized when the first - * browser window is shown. - * This is a workaround we need because ideally we would like the tor process - * to start as soon as possible, to avoid delays in the about:torconnect page, - * but we should modify TorConnect and about:torconnect to handle this case - * there with a better UX. - */ - static firstWindowLoaded() { - this.#promptProviderState(true); - } - - /** - * Tell whether the browser UI is ready. - * We ignore any errors until it is because we cannot show them. - * - * @type {boolean} - */ - static #uiReady = false; - - /** - * Whether we are prompting the user for a restart of the provider. - * - * @type {boolean} - */ - static #prompting = false; - - /** - * Prompt the user to restart the provider, if this is necessary. - * - * @param {boolean} uiReady - Whether this is being called for the first time - * when the UI is ready. - */ - static async #promptProviderState(uiReady) { - if (uiReady) { - this.#uiReady = true; - } - if (this.#providerData.provider.state === TorProviderState.Running) { - // Nothing to wait for. - return; - } - if (!this.#uiReady) { - lazy.logger.warn( - "Seen exit, but not doing anything because the UI is not ready yet." - ); - return; - } - if (this.#prompting) { - // Already prompting, so don't duplicate. - return; - } - - this.#prompting = true; - let waitForInit = uiReady; - let retry = true; - try { - while (retry) { - if (waitForInit) { - try { - await this.#providerData.initPromise; - } catch {} - } - if ( - this.#providerData.provider.state === TorProviderState.Stopped && - lazy.TorLauncherUtil.showRestartPrompt(uiReady) - ) { - waitForInit = true; - this.replace(); - } else { - retry = false; - } - } - } finally { - this.#prompting = false; - } - } - /** * Return the provider chosen by the user. * This function checks the TOR_PROVIDER environment variable and if it is a ===================================== toolkit/torbutton/chrome/locale/en-US/torlauncher.properties ===================================== @@ -3,13 +3,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -torlauncher.error_title=Tor Launcher -torlauncher.tor_exited_during_startup=Tor exited during startup. This might be due to an error in your torrc file, a bug in Tor or another program on your system, or faulty hardware. Until you fix the underlying problem and restart Tor, Tor Browser will not start. -torlauncher.tor_exited=Tor unexpectedly exited. This might be due to a bug in Tor itself, another program on your system, or faulty hardware. Until you restart Tor, Tor Browser will not be able to reach any websites. If the problem persists, please send a copy of your Tor Log to the support team. -torlauncher.tor_exited2=Restarting Tor will not close your browser tabs. -torlauncher.restart_tor=Restart Tor - - # Translation note: %1$S is a bootstrap phase from torlauncher.bootstrapStatus, # %2$S is the error from torlauncher.bootstrapWarning torlauncher.tor_bootstrap_failed_details=%1$S failed (%2$S). View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/5b194fa... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/5b194fa... 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)