Skip to content
Snippets Groups Projects
Commit b52c9ab5 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

TB 42891: Set the bundled search engine for Tor Browser.

After upstream changes between Firefox 115 and 128, we had to
completely rework the way in which we define our search engines.

This commit replaces the old "Omnibox: Add DDG, Startpage, Disconnect,
Youtube, Twitter; remove Amazon, eBay, bing".

With that commit, we customized a list of addons IDs to ship as
built-in search engines, but then upsteam moved to using only
RemoteSettings.
The configuration has many more fields, and it would be quite long to
include it in the source code. Therefore, we use some local JSON files
and load the settings from them.
parent 46f1bfe1
No related branches found
No related tags found
1 merge request!1500TB 43415: Rebased onto 134.0a1
Showing
with 184 additions and 20 deletions
browser/components/search/extensions/ddg-onion/favicon.ico

973 B

{
"name": "DuckDuckGo (.onion)",
"description": "Duck Duck Go Onion",
"manifest_version": 2,
"version": "1.0",
"applications": {
"gecko": {
"id": "ddg-onion@search.mozilla.org"
}
},
"hidden": true,
"icons": {
"16": "favicon.ico"
},
"web_accessible_resources": ["favicon.ico"],
"chrome_settings_overrides": {
"search_provider": {
"name": "DuckDuckGo (.onion)",
"search_url": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion",
"search_form": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/?q={searchTerms}",
"search_url_get_params": "q={searchTerms}",
"suggest_url": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/ac/",
"suggest_url_get_params": "q={searchTerms}&type=list"
}
}
}
......@@ -14,7 +14,7 @@
"keyword": ["@duckduckgo", "@ddg"],
"name": "DuckDuckGo",
"search_url": "https://duckduckgo.com/",
"search_url_get_params": "t=ffab&q={searchTerms}",
"search_url_get_params": "q={searchTerms}",
"suggest_url": "https://ac.duckduckgo.com/ac/",
"suggest_url_get_params": "q={searchTerms}&type=list"
}
......
browser/components/search/extensions/startpage-onion/favicon.png

569 B

{
"name": "Startpage (.onion)",
"description": "Startpage Onion",
"manifest_version": 2,
"version": "1.0",
"applications": {
"gecko": {
"id": "startpage-onion@search.mozilla.org"
}
},
"hidden": true,
"icons": {
"16": "favicon.png"
},
"web_accessible_resources": ["favicon.png"],
"chrome_settings_overrides": {
"search_provider": {
"name": "Startpage (.onion)",
"search_url": "http://startpagel6srwcjlue4zgq3zevrujfaow726kjytqbbjyrswwmjzcqd.onion/sp/search",
"search_form": "http://startpagel6srwcjlue4zgq3zevrujfaow726kjytqbbjyrswwmjzcqd.onion/sp/search/",
"search_url_post_params": "q={searchTerms}"
}
}
}
browser/components/search/extensions/startpage/favicon.png

569 B

{
"name": "Startpage",
"description": "Startpage",
"manifest_version": 2,
"version": "1.0",
"applications": {
"gecko": {
"id": "startpage@search.mozilla.org"
}
},
"hidden": true,
"icons": {
"16": "favicon.png"
},
"web_accessible_resources": ["favicon.png"],
"chrome_settings_overrides": {
"search_provider": {
"name": "Startpage",
"search_url": "https://www.startpage.com/sp/search",
"search_form": "https://www.startpage.com/sp/search/",
"search_url_post_params": "q={searchTerms}"
}
}
}
......@@ -95,6 +95,8 @@ class IconHandler {
await this.#getIconList();
}
return this.#iconList.get(engineIdentifier);
// eslint-disable-next-line no-unreachable
let iconRecords = this.#iconList.filter(r =>
this._identifierMatches(engineIdentifier, r.engineIdentifiers)
);
......@@ -221,12 +223,18 @@ class IconHandler {
*/
async #getIconList() {
try {
this.#iconList = await this.#iconCollection.get();
this.#iconList = new Map(
await (
await fetch(
"chrome://global/content/search/torBrowserSearchEngineIcons.json"
)
).json()
);
} catch (ex) {
console.error(ex);
this.#iconList = [];
this.#iconList = null;
}
if (!this.#iconList.length) {
if (!this.#iconList) {
console.error("Failed to obtain search engine icon list records");
}
}
......
......@@ -2451,22 +2451,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:
lazy.NimbusFeatures.searchConfiguration.getVariable("experiment") ?? "",
distroID: lazy.SearchUtils.distroID ?? "",
};
for (let [key, value] of Object.entries(searchEngineSelectorProperties)) {
this._settings.setMetaDataAttribute(key, value);
}
return this.#engineSelector.fetchEngineConfiguration(
searchEngineSelectorProperties
);
// tor-browser#43525: Check this still works.
const engines = await (
await fetch("chrome://global/content/search/torBrowserSearchEngines.json")
).json();
return { engines, privateDefault: undefined };
}
#setDefaultFromSelector(refinedConfig) {
......
toolkit/components/search/content/duckduckgo.ico

2.73 KiB

toolkit/components/search/content/startpage.png

569 B

[
["ddg", "chrome://global/content/search/duckduckgo.ico"],
["ddg-onion", "chrome://global/content/search/duckduckgo.ico"],
["startpage", "chrome://global/content/search/startpage.png"],
["startpage-onion", "chrome://global/content/search/startpage.png"],
["wikipedia", "chrome://global/content/search/wikipedia.ico"]
]
[
{
"aliases": ["duckduckgo", "ddg"],
"name": "DuckDuckGo",
"urls": {
"search": {
"base": "https://duckduckgo.com/",
"params": [],
"searchTermParamName": "q"
}
},
"id": "04e99a38-13ee-47d8-8aa4-64482b3dea99",
"identifier": "ddg",
"recordType": "engine",
"variants": []
},
{
"aliases": ["ddgonion"],
"name": "DuckDuckGo (.onion)",
"urls": {
"search": {
"base": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/",
"params": [],
"searchTermParamName": "q"
}
},
"id": "1e431da4-a60c-4411-9251-a95a841d451f",
"identifier": "ddg-onion",
"recordType": "engine",
"variants": []
},
{
"aliases": ["startpage"],
"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": []
},
{
"aliases": ["startpage-onion"],
"name": "Startpage (.onion)",
"urls": {
"search": {
"base": "http://startpagel6srwcjlue4zgq3zevrujfaow726kjytqbbjyrswwmjzcqd.onion/sp/search",
"params": [],
"searchTermParamName": "q"
}
},
"id": "e7eaba8d-6b9e-43fb-a799-b01b096c03ff",
"identifier": "startpage-onion",
"recordType": "engine",
"variants": []
},
{
"aliases": ["wikipedia"],
"classification": "unknown",
"name": "Wikipedia (en)",
"urls": {
"search": {
"base": "https://en.wikipedia.org/wiki/Special:Search",
"params": [],
"searchTermParamName": "search"
}
},
"id": "7f6d23c2-191e-483e-af3a-ce6451e3a8dd",
"identifier": "wikipedia",
"recordType": "engine",
"variants": []
}
]
toolkit/components/search/content/wikipedia.ico

884 B

# 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/.
toolkit.jar:
content/global/search/ (content/*)
......@@ -42,5 +42,7 @@ TESTING_JS_MODULES += [
"tests/SearchTestUtils.sys.mjs",
]
JAR_MANIFESTS += ["jar.mn"]
with Files("**"):
BUG_COMPONENT = ("Firefox", "Search")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment