Commit f444e266 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

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

TB 43728: Update our custom icon fetching code.

Upstream added the possibility to have search engine icons in various
size, so we needed to update our code for getting search engines.
parent 09da1cb0
Loading
Loading
Loading
Loading
+8 −28
Original line number Diff line number Diff line
@@ -134,29 +134,7 @@ class IconHandler {
   *   source object or null of there is no icon with the supplied width.
   */
  async createIconURL(iconRecord) {
    let iconData;
    try {
      iconData = await this.#iconCollection.attachments.get(iconRecord);
    } catch (ex) {
      console.error(ex);
    }
    if (!iconData) {
      console.warn("Unable to find the attachment for", iconRecord.id);
      // Queue an update in case we haven't downloaded it yet.
      this.#pendingUpdatesMap.set(iconRecord.id, iconRecord);
      this.#maybeQueueIdle();
      return null;
    }

    if (iconData.record.last_modified != iconRecord.last_modified) {
      // The icon we have stored is out of date, queue an update so that we'll
      // download the new icon.
      this.#pendingUpdatesMap.set(iconRecord.id, iconRecord);
      this.#maybeQueueIdle();
    }
    return URL.createObjectURL(
      new Blob([iconData.buffer], { type: iconRecord.attachment.mimetype })
    );
    return iconRecord.url;
  }

  QueryInterface = ChromeUtils.generateQI(["nsIObserver"]);
@@ -242,11 +220,13 @@ class IconHandler {
  async #buildIconMap() {
    try {
      this.#iconMap = new Map(
        Object.entries(
          await (
            await fetch(
              "chrome://global/content/search/torBrowserSearchEngineIcons.json"
            )
          ).json()
        )
      );
    } catch (ex) {
      console.error(ex);
+32 −7
Original line number Diff line number Diff line
[
  ["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"]
{
  "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
    }
  ]
}