Bug 1570492 - Make browser.topSites.get({ newtab: true }) prefer sites' labels to titles. r=mixedpuppy

Differential Revision: https://phabricator.services.mozilla.com/D40112

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Drew Willcoxon 2019-08-06 23:35:33 +00:00
Родитель 82aae30d17
Коммит 2137a9f3ed
1 изменённых файлов: 10 добавлений и 19 удалений

Просмотреть файл

@ -82,31 +82,22 @@ this.topSites = class extends ExtensionAPI {
links = links.slice(0, options.limit);
}
return links.map(link => {
let newLink;
if (link.searchTopSite) {
newLink = {
type: "search",
url: link.url,
title: link.label,
};
} else {
newLink = {
type: "url",
url: link.url,
title: link.title || link.hostname,
};
}
return links.map(link => ({
type: link.searchTopSite ? "search" : "url",
url: link.url,
// The newtab page allows the user to set custom site titles, which
// are stored in `label`, so prefer it. Search top sites currently
// don't have titles but `hostname` instead.
title: link.label || link.title || link.hostname || "",
// Default top sites don't have a favicon property. Instead they
// have tippyTopIcon, a 96x96pt image used on the newtab page.
// We'll use it as the favicon for now, but ideally default top
// sites would have real favicons. Non-default top sites (i.e.,
// those from the user's history) will have favicons.
newLink.favicon = options.includeFavicon
favicon: options.includeFavicon
? link.favicon || link.tippyTopIcon || null
: null;
return newLink;
});
: null,
}));
},
},
};