Commit 9b6474d5 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
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 e74c3571
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -2628,21 +2628,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
    );
    // 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) {
+569 B
Loading image diff...
+32 −0
Original line number Diff line number Diff line
{
  "ddg": [
    {
      "url": "chrome://global/content/search/duckduckgo.ico",
      "imageSize": 16
    }
  ],
  "ddg-onion": [
    {
      "url": "chrome://global/content/search/duckduckgo.ico",
      "imageSize": 16
    }
  ],
  "startpage": [
    {
      "url": "chrome://global/content/search/startpage.png",
      "imageSize": 16
    }
  ],
  "startpage-onion": [
    {
      "url": "chrome://global/content/search/startpage.png",
      "imageSize": 16
    }
  ],
  "wikipedia": [
    {
      "url": "chrome://global/content/search/wikipedia.ico",
      "imageSize": 16
    }
  ]
}
+78 −0
Original line number Diff line number Diff line
[
  {
    "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": []
  }
]
+884 B
Loading image diff...