henry pushed to branch tor-browser-128.9.0esr-14.5-1 at The Tor Project / Applications / Tor Browser
Commits: 2511a6b2 by Henry Wilkes at 2025-04-15T10:00:03+01:00 fixup! TB 7494: Create local home page for TBB.
This reverts commit 2780d106d85ca2fa6d41ef08106d02293f21af2a.
- - - - - bc19a47c by Henry Wilkes at 2025-04-15T10:00:20+01:00 fixup! TB 7494: Create local home page for TBB.
TB 43647: Use the app locale directly from the parent actor for setting the survey banner's language.
- - - - -
2 changed files:
- browser/components/abouttor/AboutTorParent.sys.mjs - browser/components/abouttor/content/aboutTor.js
Changes:
===================================== browser/components/abouttor/AboutTorParent.sys.mjs ===================================== @@ -26,6 +26,7 @@ export class AboutTorParent extends JSWindowActorParent { surveyDismissVersionPref, 0 ), + appLocale: Services.locale.appLocaleAsBCP47, }); case "AboutTor:SetSearchOnionize": Services.prefs.setBoolPref(onionizePref, message.data);
===================================== browser/components/abouttor/content/aboutTor.js ===================================== @@ -182,21 +182,6 @@ const SurveyArea = { */ _version: 1,
- /** - * The latest version of the survey the user has dismissed. - * If higher or equal than _version, the survey will not be displayed. - * - * @type {integer} - */ - _dismissVersion: 0, - - /** - * The surveys will be shown only in the stable channel of Tor Browser. - * - * @type {boolean} - */ - _isStable: false, - /** * The date to start showing the survey. * @@ -308,13 +293,6 @@ const SurveyArea = { }, ],
- /** - * The observer to update the localized content whenever the language changes. - * - * @type {MutationObserver} - */ - _langObserver: null, - /** * Initialize the survey area. */ @@ -333,17 +311,6 @@ const SurveyArea = { document.getElementById("survey-dismiss").addEventListener("click", () => { this._hide(); }); - this._langObserver = new MutationObserver(mutationList => { - for (const mutation of mutationList) { - if ( - mutation.type === "attributes" && - mutation.attributeName === "lang" - ) { - this.potentiallyShow(); - } - } - }); - this._langObserver.observe(document.documentElement, { attributes: true }); },
/** @@ -366,49 +333,42 @@ const SurveyArea = { },
/** - * Set the data for the survey. + * Decide whether to show the survey. * * @param {integer} dismissVersion - The latest version of survey that the * user has already dismissed. * @param {boolean} isStable - Whether this is the stable release of Tor * Browser. + * @param {string} appLocale - The app locale currently in use. */ - setData(dismissVersion, isStable) { - this._isStable = isStable; - this._dismissVersion = dismissVersion; - this.potentiallyShow(); - }, - - /** - * Decide whether to show or update the survey. - */ - potentiallyShow() { + potentiallyShow(dismissVersion, isStable, appLocale) { const now = Date.now(); if ( now < this._startDate || now >= this._endDate || // The user has already dismissed this version of the survey before: - this._dismissVersion >= this._version || - !this._isStable + dismissVersion >= this._version || + !isStable ) { // Don't show the survey. - document.body.classList.remove("show-survey"); return; }
- // Determine the survey locale based on the about:tor locale. + // Determine the survey locale based on the app locale. // NOTE: We do not user document.l10n to translate the survey banner. // Instead we only translate the banner into a limited set of locales that // match the languages that the survey itself supports. This should match // the language of the survey when it is opened by the user. - this._localeData = this._localeDataSet[0]; - const pageLocale = document.documentElement.getAttribute("lang"); for (const localeData of this._localeDataSet) { - if (localeData.browserLocales.includes(pageLocale)) { + if (localeData.browserLocales.includes(appLocale)) { this._localeData = localeData; break; } } + if (!this._localeData) { + // Show the default en-US banner. + this._localeData = this._localeDataSet[0]; + }
// Make sure the survey's lang and dir attributes match the chosen locale. const surveyEl = document.getElementById("survey"); @@ -440,8 +400,9 @@ window.addEventListener("InitialData", event => { searchOnionize, messageData, surveyDismissVersion, + appLocale, } = event.detail; SearchWidget.setOnionizeState(!!searchOnionize); MessageArea.setMessageData(messageData, !!isStable, !!torConnectEnabled); - SurveyArea.setData(surveyDismissVersion, isStable); + SurveyArea.potentiallyShow(surveyDismissVersion, isStable, appLocale); });
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/d620bd8...
tbb-commits@lists.torproject.org