
Pier Angelo Vendrame pushed to branch mullvad-browser-140.2.0esr-15.0-1 at The Tor Project / Applications / Mullvad Browser Commits: fd210716 by Pier Angelo Vendrame at 2025-09-08T11:52:36+02:00 fixup! MB 213: Customize the search engines list BB 43525: Skip Remote Settings for search engine customization. Drop some changes that we are not going to keep with the shared approach. - - - - - 0c345e48 by Pier Angelo Vendrame at 2025-09-08T11:53:16+02:00 dropme! MB 213: Customize the search engines list BB 43525: Skip Remote Settings for search engine customization. Prepare the tree for the new approach. - - - - - e95419fa by Pier Angelo Vendrame at 2025-09-08T11:53:17+02:00 BB 43525: Skip Remote Settings for search engine customization. Also, add some bundled search engines. - - - - - b80c84c1 by Pier Angelo Vendrame at 2025-09-08T11:53:17+02:00 amend! MB 213: Customize the search engines list MB 213: Customize the search engines list. - - - - - 6 changed files: - toolkit/components/search/AppProvidedSearchEngine.sys.mjs - toolkit/components/search/SearchEngineSelector.sys.mjs - toolkit/components/search/SearchService.sys.mjs - toolkit/components/search/content/mullvadBrowserSearchEngineIcons.json → toolkit/components/search/content/base-browser-search-engine-icons.json - + toolkit/components/search/content/base-browser-search-engines.json - − toolkit/components/search/content/mullvadBrowserSearchEngines.json Changes: ===================================== toolkit/components/search/AppProvidedSearchEngine.sys.mjs ===================================== @@ -116,7 +116,14 @@ class IconHandler { await this.#buildIconMap(); } - return this.#iconMap.get(engineIdentifier); + if (AppConstants.BASE_BROWSER_VERSION) { + return this.#iconMap.get(engineIdentifier); + } + + let iconList = this.#iconMap.get(this.getKey(engineIdentifier)) || []; + return iconList.filter(r => + this.#identifierMatches(engineIdentifier, r.engineIdentifiers) + ); } /** @@ -218,7 +225,7 @@ class IconHandler { Object.entries( await ( await fetch( - "chrome://global/content/search/mullvadBrowserSearchEngineIcons.json" + "chrome://global/content/search/base-browser-search-engine-icons.json" ) ).json() ) ===================================== toolkit/components/search/SearchEngineSelector.sys.mjs ===================================== @@ -2,6 +2,8 @@ * 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/. */ +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; + /** * @typedef {import("../uniffi-bindgen-gecko-js/components/generated/RustSearch.sys.mjs").SearchEngineSelector} RustSearchEngineSelector * We use "Rust" above to avoid conflict with the class name for the JavaScript wrapper. @@ -92,30 +94,15 @@ export class SearchEngineSelector { return this._getConfigurationPromise; } - this._getConfigurationPromise = Promise.all([ - this._getConfiguration(), - this._getConfigurationOverrides(), - ]); - let remoteSettingsData = await this._getConfigurationPromise; - this._configuration = remoteSettingsData[0]; - this._configurationOverrides = remoteSettingsData[1]; - delete this._getConfigurationPromise; - - if (!this._configuration?.length) { - throw Components.Exception( - "Failed to get engine data from Remote Settings", - Cr.NS_ERROR_UNEXPECTED - ); - } - - if (!this._listenerAdded) { - this._remoteConfig.on("sync", this._onConfigurationUpdated); - this._remoteConfigOverrides.on( - "sync", - this._onConfigurationOverridesUpdated - ); - this._listenerAdded = true; - } + let { promise, resolve } = Promise.withResolvers(); + this._getConfigurationPromise = promise; + this._configuration = await ( + await fetch( + "chrome://global/content/search/base-browser-search-engines.json" + ) + ).json(); + this._configurationOverrides = []; + resolve(this._configuration); if (lazy.SearchUtils.rustSelectorFeatureGate) { this.#selector.setSearchConfig( @@ -242,6 +229,12 @@ export class SearchEngineSelector { * The new configuration object */ _onConfigurationUpdated({ data: { current } }) { + // tor-browser#43525: Even though RemoteSettings are a no-op for us, we do + // not want them to interfere in any way. + if (AppConstants.BASE_BROWSER_VERSION) { + return; + } + this._configuration = current; if (lazy.SearchUtils.rustSelectorFeatureGate) { @@ -268,6 +261,12 @@ export class SearchEngineSelector { * The new configuration object */ _onConfigurationOverridesUpdated({ data: { current } }) { + // tor-browser#43525: Even though RemoteSettings are a no-op for us, we do + // not want them to interfere in any way. + if (AppConstants.BASE_BROWSER_VERSION) { + return; + } + this._configurationOverrides = current; if (lazy.SearchUtils.rustSelectorFeatureGate) { ===================================== toolkit/components/search/SearchService.sys.mjs ===================================== @@ -25,7 +25,6 @@ ChromeUtils.defineESModuleGetters(lazy, { Region: "resource://gre/modules/Region.sys.mjs", RemoteSettings: "resource://services-settings/remote-settings.sys.mjs", SearchEngine: "moz-src:///toolkit/components/search/SearchEngine.sys.mjs", - // eslint-disable-next-line mozilla/valid-lazy SearchEngineSelector: "moz-src:///toolkit/components/search/SearchEngineSelector.sys.mjs", SearchSettings: "moz-src:///toolkit/components/search/SearchSettings.sys.mjs", @@ -579,7 +578,11 @@ export class SearchService { // Test-only function to reset just the engine selector so that it can // load a different configuration. - resetEngineSelector() {} + resetEngineSelector() { + this.#engineSelector = new lazy.SearchEngineSelector( + this.#handleConfigurationUpdated.bind(this) + ); + } resetToAppDefaultEngine() { let appDefaultEngine = this.appDefaultEngine; @@ -1420,6 +1423,10 @@ export class SearchService { // We need to catch the region being updated during initialization so we // start listening straight away. Services.obs.addObserver(this, lazy.Region.REGION_TOPIC); + + this.#engineSelector = new lazy.SearchEngineSelector( + this.#handleConfigurationUpdated.bind(this) + ); } /** @@ -1652,7 +1659,6 @@ export class SearchService { * Handles the search configuration being - adds a wait on the user * being idle, before the search engine update gets handled. */ - // eslint-disable-next-line no-unused-private-class-members #handleConfigurationUpdated() { if (this.#queuedIdle) { return; @@ -2622,12 +2628,21 @@ export class SearchService { // This is prefixed with _ rather than # because it is // called in test_remove_engine_notification_box.js async _fetchEngineSelectorEngines() { - const engines = await ( - await fetch( - "chrome://global/content/search/mullvadBrowserSearchEngines.json" - ) - ).json(); - return { engines, privateDefault: undefined }; + let searchEngineSelectorProperties = { + locale: Services.locale.appLocaleAsBCP47, + region: lazy.Region.home || "unknown", + channel: lazy.SearchUtils.MODIFIED_APP_CHANNEL, + experiment: this._experimentPrefValue, + distroID: lazy.SearchUtils.distroID ?? "", + }; + + for (let [key, value] of Object.entries(searchEngineSelectorProperties)) { + this._settings.setMetaDataAttribute(key, value); + } + + return this.#engineSelector.fetchEngineConfiguration( + searchEngineSelectorProperties + ); } #setDefaultFromSelector(refinedConfig) { ===================================== toolkit/components/search/content/mullvadBrowserSearchEngineIcons.json → toolkit/components/search/content/base-browser-search-engine-icons.json ===================================== @@ -1,27 +1,33 @@ { "ddg": [ - { "url": "chrome://global/content/search/duckduckgo.ico", "iconSize": 32 } + { "url": "chrome://global/content/search/duckduckgo.ico", "imageSize": 32 } ], "ddg-html": [ - { "url": "chrome://global/content/search/duckduckgo.ico", "iconSize": 32 } + { "url": "chrome://global/content/search/duckduckgo.ico", "imageSize": 32 } ], "mullvad-leta": [ - { "url": "chrome://global/content/search/mullvad-leta.svg", "iconSize": 16 } + { + "url": "chrome://global/content/search/mullvad-leta.svg", + "imageSize": 16 + } ], "mojeek": [ - { "url": "chrome://global/content/search/mojeek.ico", "iconSize": 32 } + { "url": "chrome://global/content/search/mojeek.ico", "imageSize": 32 } ], "brave": [ - { "url": "chrome://global/content/search/brave.svg", "iconSize": 16 } + { "url": "chrome://global/content/search/brave.svg", "imageSize": 16 } ], "startpage": [ { "url": "chrome://global/content/search/startpage-16.png", - "iconSize": 16 + "imageSize": 16 }, - { "url": "chrome://global/content/search/startpage-32.png", "iconSize": 32 } + { + "url": "chrome://global/content/search/startpage-32.png", + "imageSize": 32 + } ], "metager": [ - { "url": "chrome://global/content/search/metager.ico", "iconSize": 196 } + { "url": "chrome://global/content/search/metager.ico", "imageSize": 196 } ] } ===================================== toolkit/components/search/content/base-browser-search-engines.json ===================================== @@ -0,0 +1,133 @@ +[ + { + "base": { + "aliases": ["mullvad-leta", "leta", "mullvad", "ml"], + "classification": "general", + "name": "Mullvad Leta", + "urls": { + "search": { + "base": "https://leta.mullvad.net/", + "params": [], + "searchTermParamName": "q" + } + } + }, + "id": "ee88d691-6d7a-4adb-9fec-5a205565505a", + "identifier": "mullvad-leta", + "recordType": "engine", + "variants": [{ "environment": { "allRegionsAndLocales": true } }] + }, + { + "base": { + "aliases": ["duckduckgo", "ddg"], + "classification": "general", + "name": "DuckDuckGo", + "urls": { + "search": { + "base": "https://duckduckgo.com/", + "params": [], + "searchTermParamName": "q" + } + } + }, + "id": "04e99a38-13ee-47d8-8aa4-64482b3dea99", + "identifier": "ddg", + "recordType": "engine", + "variants": [{ "environment": { "allRegionsAndLocales": true } }] + }, + { + "base": { + "aliases": ["ddg-html", "duckduckgohtml", "ddgh"], + "classification": "general", + "name": "DuckDuckGo (HTML)", + "urls": { + "search": { + "base": "https://html.duckduckgo.com/html/", + "params": [], + "searchTermParamName": "q" + } + } + }, + "id": "98d8c84b-7455-431d-98b9-890e7bcc0041", + "identifier": "ddg-html", + "recordType": "engine", + "variants": [{ "environment": { "allRegionsAndLocales": true } }] + }, + { + "base": { + "aliases": ["mojeek", "mj"], + "classification": "general", + "name": "Mojeek", + "urls": { + "search": { + "base": "https://www.mojeek.com/search", + "params": [], + "searchTermParamName": "q" + } + } + }, + "id": "10df12ac-2b39-4aa9-8845-d5b35d5bb70c", + "identifier": "mojeek", + "recordType": "engine", + "variants": [{ "environment": { "allRegionsAndLocales": true } }] + }, + { + "base": { + "aliases": ["brave", "bv"], + "classification": "general", + "name": "Brave Search", + "urls": { + "search": { + "base": "https://search.brave.com/search", + "params": [], + "searchTermParamName": "q" + } + } + }, + "id": "f479314b-030b-49a8-a2fe-7e1c5d1d9071", + "identifier": "brave", + "recordType": "engine", + "variants": [{ "environment": { "allRegionsAndLocales": true } }] + }, + { + "base": { + "aliases": ["startpage", "sp"], + "classification": "general", + "name": "Startpage", + "urls": { + "search": { + "base": "https://www.startpage.com/sp/search", + "params": [], + "searchTermParamName": "q" + } + } + }, + "id": "927bbd9f-b2f3-48b4-8974-1c1148028f4d", + "identifier": "startpage", + "recordType": "engine", + "variants": [{ "environment": { "allRegionsAndLocales": true } }] + }, + { + "base": { + "aliases": ["metager", "mg"], + "classification": "general", + "name": "MetaGer", + "urls": { + "search": { + "base": "https://metager.org/meta/meta.ger3", + "params": [], + "searchTermParamName": "eingabe" + } + } + }, + "id": "a9d07d93-469c-4bf4-8dd1-fa137f1cc85f", + "identifier": "metager", + "recordType": "engine", + "variants": [{ "environment": { "allRegionsAndLocales": true } }] + }, + { + "recordType": "defaultEngines", + "globalDefault": "mullvad-leta", + "globalDefaultPrivate": "mullvad-leta" + } +] ===================================== toolkit/components/search/content/mullvadBrowserSearchEngines.json deleted ===================================== @@ -1,114 +0,0 @@ -[ - { - "aliases": ["mullvad-leta", "leta", "mullvad", "ml"], - "name": "Mullvad Leta", - "urls": { - "search": { - "base": "https://leta.mullvad.net/", - "params": [], - "searchTermParamName": "q" - } - }, - "id": "ee88d691-6d7a-4adb-9fec-5a205565505a", - "identifier": "mullvad-leta", - "recordType": "engine", - "orderHint": 100, - "variants": [] - }, - { - "aliases": ["duckduckgo", "ddg"], - "name": "DuckDuckGo", - "urls": { - "search": { - "base": "https://duckduckgo.com/", - "params": [], - "searchTermParamName": "q" - } - }, - "id": "04e99a38-13ee-47d8-8aa4-64482b3dea99", - "identifier": "ddg", - "recordType": "engine", - "orderHint": 90, - "variants": [] - }, - { - "aliases": ["ddg-html", "duckduckgohtml", "ddgh"], - "name": "DuckDuckGo (HTML)", - "urls": { - "search": { - "base": "https://html.duckduckgo.com/html/", - "params": [], - "searchTermParamName": "q" - } - }, - "id": "98d8c84b-7455-431d-98b9-890e7bcc0041", - "identifier": "ddg-html", - "recordType": "engine", - "orderHint": 80, - "variants": [] - }, - { - "aliases": ["mojeek", "mj"], - "name": "Mojeek", - "urls": { - "search": { - "base": "https://www.mojeek.com/search", - "params": [], - "searchTermParamName": "q" - } - }, - "id": "10df12ac-2b39-4aa9-8845-d5b35d5bb70c", - "identifier": "mojeek", - "recordType": "engine", - "orderHint": 70, - "variants": [] - }, - { - "aliases": ["brave", "bv"], - "name": "Brave Search", - "urls": { - "search": { - "base": "https://search.brave.com/search", - "params": [], - "searchTermParamName": "q" - } - }, - "id": "f479314b-030b-49a8-a2fe-7e1c5d1d9071", - "identifier": "brave", - "recordType": "engine", - "orderHint": 60, - "variants": [] - }, - { - "aliases": ["startpage", "sp"], - "name": "Startpage", - "urls": { - "search": { - "base": "https://www.startpage.com/sp/search", - "params": [], - "searchTermParamName": "q" - } - }, - "id": "049f86fd-28fe-4389-910f-aac28f07d745", - "identifier": "startpage", - "recordType": "engine", - "orderHint": 50, - "variants": [] - }, - { - "aliases": ["metager", "mg"], - "name": "MetaGer", - "urls": { - "search": { - "base": "https://metager.org/meta/meta.ger3", - "params": [], - "searchTermParamName": "eingabe" - } - }, - "id": "a9d07d93-469c-4bf4-8dd1-fa137f1cc85f", - "identifier": "metager", - "recordType": "engine", - "orderHint": 40, - "variants": [] - } -] View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/ac6... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/ac6... You're receiving this email because of your account on gitlab.torproject.org.
participants (1)
-
Pier Angelo Vendrame (@pierov)