Pier Angelo Vendrame pushed to branch base-browser-140.2.0esr-15.0-1 at The Tor Project / Applications / Tor Browser
Commits:
-
a1886d8c
by Pier Angelo Vendrame at 2025-09-08T11:57:50+02:00
9 changed files:
- toolkit/components/search/AppProvidedSearchEngine.sys.mjs
- toolkit/components/search/SearchEngineSelector.sys.mjs
- + toolkit/components/search/content/base-browser-search-engine-icons.json
- + toolkit/components/search/content/base-browser-search-engines.json
- + toolkit/components/search/content/duckduckgo.ico
- + toolkit/components/search/content/startpage-16.png
- + toolkit/components/search/content/startpage-32.png
- + toolkit/components/search/jar.mn
- toolkit/components/search/moz.build
Changes:
... | ... | @@ -116,6 +116,10 @@ class IconHandler { |
116 | 116 | await this.#buildIconMap();
|
117 | 117 | }
|
118 | 118 | |
119 | + if (AppConstants.BASE_BROWSER_VERSION) {
|
|
120 | + return this.#iconMap.get(engineIdentifier);
|
|
121 | + }
|
|
122 | + |
|
119 | 123 | let iconList = this.#iconMap.get(this.getKey(engineIdentifier)) || [];
|
120 | 124 | return iconList.filter(r =>
|
121 | 125 | this.#identifierMatches(engineIdentifier, r.engineIdentifiers)
|
... | ... | @@ -132,29 +136,7 @@ class IconHandler { |
132 | 136 | * source object or null of there is no icon with the supplied width.
|
133 | 137 | */
|
134 | 138 | async createIconURL(iconRecord) {
|
135 | - let iconData;
|
|
136 | - try {
|
|
137 | - iconData = await this.#iconCollection.attachments.get(iconRecord);
|
|
138 | - } catch (ex) {
|
|
139 | - console.error(ex);
|
|
140 | - }
|
|
141 | - if (!iconData) {
|
|
142 | - console.warn("Unable to find the attachment for", iconRecord.id);
|
|
143 | - // Queue an update in case we haven't downloaded it yet.
|
|
144 | - this.#pendingUpdatesMap.set(iconRecord.id, iconRecord);
|
|
145 | - this.#maybeQueueIdle();
|
|
146 | - return null;
|
|
147 | - }
|
|
148 | - |
|
149 | - if (iconData.record.last_modified != iconRecord.last_modified) {
|
|
150 | - // The icon we have stored is out of date, queue an update so that we'll
|
|
151 | - // download the new icon.
|
|
152 | - this.#pendingUpdatesMap.set(iconRecord.id, iconRecord);
|
|
153 | - this.#maybeQueueIdle();
|
|
154 | - }
|
|
155 | - return URL.createObjectURL(
|
|
156 | - new Blob([iconData.buffer], { type: iconRecord.attachment.mimetype })
|
|
157 | - );
|
|
139 | + return iconRecord.url;
|
|
158 | 140 | }
|
159 | 141 | |
160 | 142 | QueryInterface = ChromeUtils.generateQI(["nsIObserver"]);
|
... | ... | @@ -238,27 +220,23 @@ class IconHandler { |
238 | 220 | * Obtains the icon list from the remote settings collection.
|
239 | 221 | */
|
240 | 222 | async #buildIconMap() {
|
241 | - let iconList = [];
|
|
242 | 223 | try {
|
243 | - iconList = await this.#iconCollection.get();
|
|
224 | + this.#iconMap = new Map(
|
|
225 | + Object.entries(
|
|
226 | + await (
|
|
227 | + await fetch(
|
|
228 | + "chrome://global/content/search/base-browser-search-engine-icons.json"
|
|
229 | + )
|
|
230 | + ).json()
|
|
231 | + )
|
|
232 | + );
|
|
244 | 233 | } catch (ex) {
|
245 | 234 | console.error(ex);
|
235 | + this.#iconMap = null;
|
|
246 | 236 | }
|
247 | - if (!iconList.length) {
|
|
237 | + if (!this.#iconMap) {
|
|
248 | 238 | console.error("Failed to obtain search engine icon list records");
|
249 | 239 | }
|
250 | - |
|
251 | - this.#iconMap = new Map();
|
|
252 | - for (let record of iconList) {
|
|
253 | - let keys = new Set(record.engineIdentifiers.map(this.getKey));
|
|
254 | - for (let key of keys) {
|
|
255 | - if (this.#iconMap.has(key)) {
|
|
256 | - this.#iconMap.get(key).push(record);
|
|
257 | - } else {
|
|
258 | - this.#iconMap.set(key, [record]);
|
|
259 | - }
|
|
260 | - }
|
|
261 | - }
|
|
262 | 240 | }
|
263 | 241 | |
264 | 242 | /**
|
... | ... | @@ -2,6 +2,8 @@ |
2 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
|
3 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
4 | 4 | |
5 | +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
|
6 | + |
|
5 | 7 | /**
|
6 | 8 | * @typedef {import("../uniffi-bindgen-gecko-js/components/generated/RustSearch.sys.mjs").SearchEngineSelector} RustSearchEngineSelector
|
7 | 9 | * We use "Rust" above to avoid conflict with the class name for the JavaScript wrapper.
|
... | ... | @@ -92,30 +94,15 @@ export class SearchEngineSelector { |
92 | 94 | return this._getConfigurationPromise;
|
93 | 95 | }
|
94 | 96 | |
95 | - this._getConfigurationPromise = Promise.all([
|
|
96 | - this._getConfiguration(),
|
|
97 | - this._getConfigurationOverrides(),
|
|
98 | - ]);
|
|
99 | - let remoteSettingsData = await this._getConfigurationPromise;
|
|
100 | - this._configuration = remoteSettingsData[0];
|
|
101 | - this._configurationOverrides = remoteSettingsData[1];
|
|
102 | - delete this._getConfigurationPromise;
|
|
103 | - |
|
104 | - if (!this._configuration?.length) {
|
|
105 | - throw Components.Exception(
|
|
106 | - "Failed to get engine data from Remote Settings",
|
|
107 | - Cr.NS_ERROR_UNEXPECTED
|
|
108 | - );
|
|
109 | - }
|
|
110 | - |
|
111 | - if (!this._listenerAdded) {
|
|
112 | - this._remoteConfig.on("sync", this._onConfigurationUpdated);
|
|
113 | - this._remoteConfigOverrides.on(
|
|
114 | - "sync",
|
|
115 | - this._onConfigurationOverridesUpdated
|
|
116 | - );
|
|
117 | - this._listenerAdded = true;
|
|
118 | - }
|
|
97 | + let { promise, resolve } = Promise.withResolvers();
|
|
98 | + this._getConfigurationPromise = promise;
|
|
99 | + this._configuration = await (
|
|
100 | + await fetch(
|
|
101 | + "chrome://global/content/search/base-browser-search-engines.json"
|
|
102 | + )
|
|
103 | + ).json();
|
|
104 | + this._configurationOverrides = [];
|
|
105 | + resolve(this._configuration);
|
|
119 | 106 | |
120 | 107 | if (lazy.SearchUtils.rustSelectorFeatureGate) {
|
121 | 108 | this.#selector.setSearchConfig(
|
... | ... | @@ -242,6 +229,12 @@ export class SearchEngineSelector { |
242 | 229 | * The new configuration object
|
243 | 230 | */
|
244 | 231 | _onConfigurationUpdated({ data: { current } }) {
|
232 | + // tor-browser#43525: Even though RemoteSettings are a no-op for us, we do
|
|
233 | + // not want them to interfere in any way.
|
|
234 | + if (AppConstants.BASE_BROWSER_VERSION) {
|
|
235 | + return;
|
|
236 | + }
|
|
237 | + |
|
245 | 238 | this._configuration = current;
|
246 | 239 | |
247 | 240 | if (lazy.SearchUtils.rustSelectorFeatureGate) {
|
... | ... | @@ -268,6 +261,12 @@ export class SearchEngineSelector { |
268 | 261 | * The new configuration object
|
269 | 262 | */
|
270 | 263 | _onConfigurationOverridesUpdated({ data: { current } }) {
|
264 | + // tor-browser#43525: Even though RemoteSettings are a no-op for us, we do
|
|
265 | + // not want them to interfere in any way.
|
|
266 | + if (AppConstants.BASE_BROWSER_VERSION) {
|
|
267 | + return;
|
|
268 | + }
|
|
269 | + |
|
271 | 270 | this._configurationOverrides = current;
|
272 | 271 | |
273 | 272 | if (lazy.SearchUtils.rustSelectorFeatureGate) {
|
1 | +{
|
|
2 | + "ddg": [
|
|
3 | + { "url": "chrome://global/content/search/duckduckgo.ico", "imageSize": 32 }
|
|
4 | + ],
|
|
5 | + "startpage": [
|
|
6 | + {
|
|
7 | + "url": "chrome://global/content/search/startpage-16.png",
|
|
8 | + "imageSize": 16
|
|
9 | + },
|
|
10 | + {
|
|
11 | + "url": "chrome://global/content/search/startpage-32.png",
|
|
12 | + "imageSize": 32
|
|
13 | + }
|
|
14 | + ]
|
|
15 | +} |
1 | +[
|
|
2 | + {
|
|
3 | + "base": {
|
|
4 | + "aliases": ["duckduckgo", "ddg"],
|
|
5 | + "classification": "general",
|
|
6 | + "name": "DuckDuckGo",
|
|
7 | + "urls": {
|
|
8 | + "search": {
|
|
9 | + "base": "https://duckduckgo.com/",
|
|
10 | + "params": [],
|
|
11 | + "searchTermParamName": "q"
|
|
12 | + }
|
|
13 | + }
|
|
14 | + },
|
|
15 | + "id": "04e99a38-13ee-47d8-8aa4-64482b3dea99",
|
|
16 | + "identifier": "ddg",
|
|
17 | + "recordType": "engine",
|
|
18 | + "variants": [{ "environment": { "allRegionsAndLocales": true } }]
|
|
19 | + },
|
|
20 | + {
|
|
21 | + "base": {
|
|
22 | + "aliases": ["startpage", "sp"],
|
|
23 | + "classification": "general",
|
|
24 | + "name": "Startpage",
|
|
25 | + "urls": {
|
|
26 | + "search": {
|
|
27 | + "base": "https://www.startpage.com/sp/search",
|
|
28 | + "params": [],
|
|
29 | + "searchTermParamName": "q"
|
|
30 | + }
|
|
31 | + }
|
|
32 | + },
|
|
33 | + "id": "927bbd9f-b2f3-48b4-8974-1c1148028f4d",
|
|
34 | + "identifier": "startpage",
|
|
35 | + "recordType": "engine",
|
|
36 | + "variants": [{ "environment": { "allRegionsAndLocales": true } }]
|
|
37 | + },
|
|
38 | + {
|
|
39 | + "recordType": "defaultEngines",
|
|
40 | + "globalDefault": "ddg",
|
|
41 | + "globalDefaultPrivate": "ddg"
|
|
42 | + }
|
|
43 | +] |
1 | +# This Source Code Form is subject to the terms of the Mozilla Public
|
|
2 | +# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3 | +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
4 | + |
|
5 | +toolkit.jar:
|
|
6 | + content/global/search/ (content/*) |
... | ... | @@ -46,5 +46,7 @@ TESTING_JS_MODULES += [ |
46 | 46 | "tests/SearchTestUtils.sys.mjs",
|
47 | 47 | ]
|
48 | 48 | |
49 | +JAR_MANIFESTS += ["jar.mn"]
|
|
50 | + |
|
49 | 51 | with Files("**"):
|
50 | 52 | BUG_COMPONENT = ("Firefox", "Search") |