diff --git a/browser/components/search/jar.mn b/browser/components/search/jar.mn index 8fb17f801455..91ee00801034 100644 --- a/browser/components/search/jar.mn +++ b/browser/components/search/jar.mn @@ -11,6 +11,6 @@ browser.jar: content/browser/contentSearchUI.js (content/contentSearchUI.js) content/browser/contentSearchHandoffUI.js (content/contentSearchHandoffUI.js) content/browser/contentSearchUI.css (content/contentSearchUI.css) - search-extensions/ (extensions/**) +# search-extensions/ (extensions/**) % resource search-extensions %search-extensions/ contentaccessible=yes diff --git a/toolkit/components/search/AppProvidedSearchEngine.sys.mjs b/toolkit/components/search/AppProvidedSearchEngine.sys.mjs index 32e2e54244cc..933f3f6137a2 100644 --- a/toolkit/components/search/AppProvidedSearchEngine.sys.mjs +++ b/toolkit/components/search/AppProvidedSearchEngine.sys.mjs @@ -115,11 +115,13 @@ class IconHandler { if (!this.#iconMap) { await this.#buildIconMap(); } - - let iconList = this.#iconMap.get(this.getKey(engineIdentifier)) || []; - return iconList.filter(r => - this.#identifierMatches(engineIdentifier, r.engineIdentifiers) - ); + // If #buildIconMap could have resulted in #iconMap being null + if (!this.#iconMap) { + console.warn("Icon map is not available."); + return []; + } + // Get the array of icon objects for the engine, or an empty array if not found. + return this.#iconMap.get(engineIdentifier) || []; } /** @@ -240,25 +242,20 @@ class IconHandler { async #buildIconMap() { let iconList = []; try { - iconList = await this.#iconCollection.get(); + this.#iconMap = new Map( + await ( + await fetch( + "chrome://browser/content/search/BrowserSearchEngineIcons.json" + ) + ).json() + ); } catch (ex) { console.error(ex); + this.#iconMap = null; } - if (!iconList.length) { + if (!this.#iconMap) { console.error("Failed to obtain search engine icon list records"); } - - this.#iconMap = new Map(); - for (let record of iconList) { - let keys = new Set(record.engineIdentifiers.map(this.getKey)); - for (let key of keys) { - if (this.#iconMap.has(key)) { - this.#iconMap.get(key).push(record); - } else { - this.#iconMap.set(key, [record]); - } - } - } } /** @@ -561,27 +558,29 @@ export class AppProvidedSearchEngine extends SearchEngine { * A promise that resolves to the URL of the icon. */ async getIconURL(preferredWidth) { - // XPCOM interfaces pass optional number parameters as 0. preferredWidth ||= 16; - let availableRecords = + // This call should return a string (the icon URL) if the engineId is in your JSON, + // or undefined if not found or if #iconMap failed to build. + const iconURLString = await AppProvidedSearchEngine.iconHandler.getAvailableRecords(this.id); - if (!availableRecords.length) { - console.warn("No icon found for", this.id); + + if (typeof iconURLString === "string") { + // We have a direct URL string. + // The #blobURLPromises cache was keyed by actual image width. + // Since we only get one URL directly, we can use preferredWidth as the cache key. + if (this.#blobURLPromises.has(preferredWidth)) { + return this.#blobURLPromises.get(preferredWidth); + } + // Store and return the promise for this direct URL. + const promise = Promise.resolve(iconURLString); + this.#blobURLPromises.set(preferredWidth, promise); + return promise; + } else { + // No specific icon URL found from the JSON-backed map for this engine. + console.warn(`No icon URL string found for engine ${this.id} via IconHandler.getAvailableRecords.`); return null; } - - let availableSizes = availableRecords.map(r => r.imageSize); - let width = lazy.SearchUtils.chooseIconSize(preferredWidth, availableSizes); - - if (this.#blobURLPromises.has(width)) { - return this.#blobURLPromises.get(width); - } - - let record = availableRecords.find(r => r.imageSize == width); - let promise = AppProvidedSearchEngine.iconHandler.createIconURL(record); - this.#blobURLPromises.set(width, promise); - return promise; } /** diff --git a/toolkit/components/search/SearchService.sys.mjs b/toolkit/components/search/SearchService.sys.mjs index aca95f0acb02..9a6dafbfbe62 100644 --- a/toolkit/components/search/SearchService.sys.mjs +++ b/toolkit/components/search/SearchService.sys.mjs @@ -2631,21 +2631,11 @@ export class SearchService { // This is prefixed with _ rather than # because it is // called in test_remove_engine_notification_box.js async _fetchEngineSelectorEngines() { - 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 - ); + const engines = await ( + await fetch("chrome://browser/content/search/BrowserSearchEngines.json") + ).json(); + // MODIFICATION: Use the correct property names appDefaultEngineId and appPrivateDefaultEngineId. + return { engines, appDefaultEngineId: "ecosia", appPrivateDefaultEngineId: "ecosia" }; } #setDefaultFromSelector(refinedConfig) { diff --git a/waterfox/browser/components/moz.build b/waterfox/browser/components/moz.build index d01274a021a3..8d081221a2dd 100644 --- a/waterfox/browser/components/moz.build +++ b/waterfox/browser/components/moz.build @@ -11,6 +11,7 @@ DIRS += [ "addonstores", "preferences", "privatetab", + "search", "statusbar", "tabfeatures", "uicustomizations", diff --git a/waterfox/browser/components/search/content/BrowserSearchEngineIcons.json b/waterfox/browser/components/search/content/BrowserSearchEngineIcons.json new file mode 100644 index 000000000000..d0c17c5514df --- /dev/null +++ b/waterfox/browser/components/search/content/BrowserSearchEngineIcons.json @@ -0,0 +1,10 @@ +[ + ["bing", "chrome://browser/content/search/bing/favicon.ico"], + ["ddg", "chrome://browser/content/search/ddg/favicon.ico"], + ["ecosia", "chrome://browser/content/search/ecosia/favicon.ico"], + ["google", "chrome://browser/content/search/google/favicon.ico"], + ["mojeek", "chrome://browser/content/search/mojeek/favicon.ico"], + ["qwant", "chrome://browser/content/search/qwant/favicon.ico"], + ["startpage", "chrome://browser/content/search/startpage/favicon.ico"], + ["wps", "chrome://browser/content/search/wps/favicon.svg"] +] diff --git a/waterfox/browser/components/search/content/BrowserSearchEngines.json b/waterfox/browser/components/search/content/BrowserSearchEngines.json new file mode 100644 index 000000000000..6336362f88ea --- /dev/null +++ b/waterfox/browser/components/search/content/BrowserSearchEngines.json @@ -0,0 +1,402 @@ +[ + { + "aliases": [ + "bing", + "b" + ], + "name": "Bing", + "urls": { + "search": { + "base": "https://www.bing.com/search", + "params": [ + { + "name": "PC", + "value": "IS45" + }, + { + "name": "PTAG", + "value": "SYS1000000" + } + ], + "searchTermParamName": "q" + }, + "suggestions": { + "base": "https://www.google.com/complete/search", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "experimentConfig": "search_rich_suggestions", + "name": "channel" + } + ], + "searchTermParamName": "q" + }, + "trending": { + "base": "https://www.google.com/complete/search", + "method": "GET", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "name": "channel", + "value": "ftr" + } + ], + "searchTermParamName": "q" + } + }, + "id": "2b86db12-a65d-4cdc-84f8-cdcf705ad5ca", + "identifier": "bing", + "recordType": "engine", + "variants": [] + }, + { + "aliases": [ + "duckduckgo", + "ddg" + ], + "name": "DuckDuckGo", + "urls": { + "search": { + "base": "https://duckduckgo.com/", + "params": [ + { + "name": "t", + "value": "waterfox" + } + ], + "searchTermParamName": "q" + }, + "suggestions": { + "base": "https://www.google.com/complete/search", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "experimentConfig": "search_rich_suggestions", + "name": "channel" + } + ], + "searchTermParamName": "q" + }, + "trending": { + "base": "https://www.google.com/complete/search", + "method": "GET", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "name": "channel", + "value": "ftr" + } + ], + "searchTermParamName": "q" + } + }, + "id": "c8ef2865-c592-4eea-8e13-abdefc4e586d", + "identifier": "ddg", + "recordType": "engine", + "variants": [] + }, + { + "aliases": [ + "ecosia", + "e" + ], + "name": "Ecosia", + "urls": { + "search": { + "base": "https://www.ecosia.org/search", + "params": [ + { + "name": "tt", + "value": "57226k1p" + } + ], + "searchTermParamName": "q" + }, + "suggestions": { + "base": "https://www.google.com/complete/search", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "experimentConfig": "search_rich_suggestions", + "name": "channel" + } + ], + "searchTermParamName": "q" + }, + "trending": { + "base": "https://www.google.com/complete/search", + "method": "GET", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "name": "channel", + "value": "ftr" + } + ], + "searchTermParamName": "q" + } + }, + "id": "6e24cbe0-e421-4462-ad7d-197db4cde98f", + "identifier": "ecosia", + "recordType": "engine", + "variants": [] + }, + { + "aliases": [ + "google", + "g" + ], + "name": "Google", + "urls": { + "search": { + "base": "https://www.google.com/search", + "params": [], + "searchTermParamName": "q" + }, + "suggestions": { + "base": "https://www.google.com/complete/search", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "experimentConfig": "search_rich_suggestions", + "name": "channel" + } + ], + "searchTermParamName": "q" + }, + "trending": { + "base": "https://www.google.com/complete/search", + "method": "GET", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "name": "channel", + "value": "ftr" + } + ], + "searchTermParamName": "q" + } + }, + "id": "cc42ee69-382f-44b9-9222-980755a6849f", + "identifier": "google", + "recordType": "engine", + "variants": [] + }, + { + "aliases": [ + "mojeek", + "m" + ], + "name": "Mojeek", + "urls": { + "search": { + "base": "https://www.mojeek.com/search", + "searchTermParamName": "q" + }, + "suggestions": { + "base": "https://www.google.com/complete/search", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "experimentConfig": "search_rich_suggestions", + "name": "channel" + } + ], + "searchTermParamName": "q" + }, + "trending": { + "base": "https://www.google.com/complete/search", + "method": "GET", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "name": "channel", + "value": "ftr" + } + ], + "searchTermParamName": "q" + } + }, + "id": "db59d254-ecf4-42a1-b15c-63563debb60a", + "identifier": "mojeek", + "recordType": "engine", + "variants": [] + }, + { + "aliases": [ + "qwant", + "q" + ], + "name": "Qwant", + "urls": { + "search": { + "base": "https://www.qwant.com/", + "params": [], + "searchTermParamName": "q" + }, + "suggestions": { + "base": "https://www.google.com/complete/search", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "experimentConfig": "search_rich_suggestions", + "name": "channel" + } + ], + "searchTermParamName": "q" + }, + "trending": { + "base": "https://www.google.com/complete/search", + "method": "GET", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "name": "channel", + "value": "ftr" + } + ], + "searchTermParamName": "q" + } + }, + "id": "d7e41317-0461-4801-9ebc-fa4de57dcd57", + "identifier": "qwant", + "recordType": "engine", + "variants": [] + }, + { + "aliases": [ + "startpage", + "sp" + ], + "name": "Startpage", + "urls": { + "search": { + "base": "https://www.startpage.com/sp/search", + "method": "POST", + "params": [ + { + "name": "segment", + "value": "startpage.waterfox.1" + } + ], + "searchTermParamName": "query" + }, + "suggestions": { + "base": "https://www.google.com/complete/search", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "experimentConfig": "search_rich_suggestions", + "name": "channel" + } + ], + "searchTermParamName": "q" + }, + "trending": { + "base": "https://www.google.com/complete/search", + "method": "GET", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "name": "channel", + "value": "ftr" + } + ], + "searchTermParamName": "q" + } + }, + "id": "7debf7f1-bac9-4585-b94e-cce2a4eecacc", + "identifier": "startpage", + "recordType": "engine", + "variants": [] + }, + { + "aliases": [ + "wps", + "w" + ], + "name": "Waterfox Private Search", + "urls": { + "search": { + "base": "https://search.waterfox.net/search", + "params": [], + "searchTermParamName": "q" + }, + "suggestions": { + "base": "https://www.google.com/complete/search", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "experimentConfig": "search_rich_suggestions", + "name": "channel" + } + ], + "searchTermParamName": "q" + }, + "trending": { + "base": "https://www.google.com/complete/search", + "method": "GET", + "params": [ + { + "name": "client", + "value": "firefox" + }, + { + "name": "channel", + "value": "ftr" + } + ], + "searchTermParamName": "q" + } + }, + "id": "9b2df7d1-77d2-43e8-b20c-6b6ae4b6844b", + "identifier": "wps", + "recordType": "engine", + "variants": [] + } +] diff --git a/waterfox/browser/components/search/extensions/bing/favicon.ico b/waterfox/browser/components/search/extensions/bing/favicon.ico new file mode 100644 index 000000000000..fdc021cfebd1 Binary files /dev/null and b/waterfox/browser/components/search/extensions/bing/favicon.ico differ diff --git a/waterfox/browser/components/search/extensions/ddg/favicon.ico b/waterfox/browser/components/search/extensions/ddg/favicon.ico new file mode 100644 index 000000000000..560000b03e2c Binary files /dev/null and b/waterfox/browser/components/search/extensions/ddg/favicon.ico differ diff --git a/waterfox/browser/components/search/extensions/ecosia/favicon.ico b/waterfox/browser/components/search/extensions/ecosia/favicon.ico new file mode 100644 index 000000000000..07ace433025d Binary files /dev/null and b/waterfox/browser/components/search/extensions/ecosia/favicon.ico differ diff --git a/waterfox/browser/components/search/extensions/google/favicon.ico b/waterfox/browser/components/search/extensions/google/favicon.ico new file mode 100644 index 000000000000..82339b3b1dbb Binary files /dev/null and b/waterfox/browser/components/search/extensions/google/favicon.ico differ diff --git a/waterfox/browser/components/search/extensions/mojeek/favicon.ico b/waterfox/browser/components/search/extensions/mojeek/favicon.ico new file mode 100644 index 000000000000..a89d560d839f Binary files /dev/null and b/waterfox/browser/components/search/extensions/mojeek/favicon.ico differ diff --git a/waterfox/browser/components/search/extensions/qwant/favicon.ico b/waterfox/browser/components/search/extensions/qwant/favicon.ico new file mode 100644 index 000000000000..1767c9ab6f7a Binary files /dev/null and b/waterfox/browser/components/search/extensions/qwant/favicon.ico differ diff --git a/waterfox/browser/components/search/extensions/startpage/favicon.ico b/waterfox/browser/components/search/extensions/startpage/favicon.ico new file mode 100644 index 000000000000..f0726fbba18c Binary files /dev/null and b/waterfox/browser/components/search/extensions/startpage/favicon.ico differ diff --git a/waterfox/browser/components/search/extensions/wps/favicon.svg b/waterfox/browser/components/search/extensions/wps/favicon.svg new file mode 100644 index 000000000000..719adf511e6d --- /dev/null +++ b/waterfox/browser/components/search/extensions/wps/favicon.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/waterfox/browser/components/search/jar.mn b/waterfox/browser/components/search/jar.mn new file mode 100644 index 000000000000..bdeb5014a7ee --- /dev/null +++ b/waterfox/browser/components/search/jar.mn @@ -0,0 +1,8 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +browser.jar: + content/browser/search/BrowserSearchEngineIcons.json (content/BrowserSearchEngineIcons.json) + content/browser/search/BrowserSearchEngines.json (content/BrowserSearchEngines.json) + content/browser/search/ (extensions/**) diff --git a/waterfox/browser/components/search/moz.build b/waterfox/browser/components/search/moz.build new file mode 100644 index 000000000000..d988c0ff9b16 --- /dev/null +++ b/waterfox/browser/components/search/moz.build @@ -0,0 +1,7 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +JAR_MANIFESTS += ["jar.mn"]