Bug 1598903 - Port bug 1575905 Part 1: Show theme previews for built-in themes. r=darktrojan
authorRichard Marti <richard.marti@gmail.com>
Tue, 26 Nov 2019 18:05:55 +0100
changeset 28269 83336f180281f202107a7c506323a4f60253888e
parent 28268 06fd730429c0a1ad4992f5377fbf56f7b8ac1643
child 28270 0f56d3bf93002d512dc067d3e74ff15b97bcc76a
push id16730
push usergeoff@darktrojan.net
push dateWed, 27 Nov 2019 07:07:11 +0000
treeherdercomm-central@83336f180281 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1598903, 1575905
Bug 1598903 - Port bug 1575905 Part 1: Show theme previews for built-in themes. r=darktrojan
mail/base/content/aboutAddonsExtra.js
--- a/mail/base/content/aboutAddonsExtra.js
+++ b/mail/base/content/aboutAddonsExtra.js
@@ -11,16 +11,27 @@ var { BrowserUtils } = ChromeUtils.impor
   "resource://gre/modules/BrowserUtils.jsm"
 );
 
 var mailExtBundle = Services.strings.createBundle(
   "chrome://messenger/locale/extensionsOverlay.properties"
 );
 var extensionsNeedingRestart = new Set();
 
+const THUNDERBIRD_THEME_PREVIEWS = new Map([
+  [
+    "thunderbird-compact-light@mozilla.org",
+    "chrome://mozapps/content/extensions/firefox-compact-light.svg",
+  ],
+  [
+    "thunderbird-compact-dark@mozilla.org",
+    "chrome://mozapps/content/extensions/firefox-compact-dark.svg",
+  ],
+]);
+
 /* This file runs in both the outer window, which controls the categories list, search bar, etc.,
  * and the inner window which is the list of add-ons or the detail view. */
 (async function() {
   if (window.location.href == "about:addons") {
     let contentStylesheet = document.createProcessingInstruction(
       "xml-stylesheet",
       'href="chrome://messenger/content/aboutAddonsExtra.css" type="text/css"'
     );
@@ -42,16 +53,24 @@ var extensionsNeedingRestart = new Set()
     return true;
   };
 
   delete window.browserBundle;
   window.browserBundle = Services.strings.createBundle(
     "chrome://messenger/locale/addons.properties"
   );
 
+  let _getScreenshotUrlForAddon = getScreenshotUrlForAddon;
+  getScreenshotUrlForAddon = function(addon) {
+    if (THUNDERBIRD_THEME_PREVIEWS.has(addon.id)) {
+      return THUNDERBIRD_THEME_PREVIEWS.get(addon.id);
+    }
+    return _getScreenshotUrlForAddon(addon);
+  }
+
   let _getAddonMessageInfo = getAddonMessageInfo;
   getAddonMessageInfo = async function(addon) {
     let result = await _getAddonMessageInfo(addon);
     if (!result.message) {
       let { stringName } = getTrueState(addon, "gDetailView._addon");
       if (stringName) {
         result.message = mailExtBundle.formatStringFromName(stringName, [
           addon.name,