зеркало из https://github.com/mozilla/gecko-dev.git
Bug 640630 - about:home advertises add-ons that are installed already [r=mfinkle]
This commit is contained in:
Родитель
4f0d491bdd
Коммит
3ea309cc44
|
@ -98,6 +98,7 @@
|
|||
<script type="application/javascript;version=1.8"><![CDATA[
|
||||
let Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
|
||||
let gChromeWin = null;
|
||||
Cu.import("resource://gre/modules/AddonManager.jsm");
|
||||
|
||||
function openLink(aElement) {
|
||||
try {
|
||||
|
@ -308,9 +309,10 @@
|
|||
list.removeChild(header.nextSibling);
|
||||
|
||||
for (let i=0; i<aAddons.length; i++) {
|
||||
let addon = aAddons[i];
|
||||
let outer = document.createElement("div");
|
||||
outer.setAttribute("role", "button");
|
||||
outer.setAttribute("addonID", aAddons[i].id);
|
||||
outer.setAttribute("addonID", addon.id);
|
||||
|
||||
let addonName = aAddons[i].name;
|
||||
outer.addEventListener("click", function() {
|
||||
|
@ -319,19 +321,19 @@
|
|||
|
||||
let img = document.createElement("img");
|
||||
img.className = "favicon";
|
||||
img.setAttribute("src", aAddons[i].iconURL);
|
||||
img.setAttribute("src", addon.iconURL);
|
||||
outer.appendChild(img);
|
||||
|
||||
let inner = document.createElement("div");
|
||||
inner.className = "inner";
|
||||
|
||||
let titlePart = document.createElement("span");
|
||||
titlePart.textContent = aAddons[i].name;
|
||||
titlePart.textContent = addon.name;
|
||||
titlePart.className = "title";
|
||||
inner.appendChild(titlePart);
|
||||
|
||||
let versionPart = document.createElement("span");
|
||||
versionPart.textContent = aAddons[i].version;
|
||||
versionPart.textContent = addon.version;
|
||||
versionPart.className = "version";
|
||||
inner.appendChild(versionPart);
|
||||
|
||||
|
@ -344,7 +346,21 @@
|
|||
let file = this._getFile();
|
||||
if (file.exists()) {
|
||||
let json = JSON.parse(this._readFile(file));
|
||||
this._loadAddons(json.addons, json.addonCount, json.totalResults);
|
||||
|
||||
// Ignore addons already installed
|
||||
let self = this;
|
||||
let addonsCache = json.addons;
|
||||
AddonManager.getAllAddons(function(aAddons) {
|
||||
let addons = addonsCache.filter(function(addon) {
|
||||
for (let i =0; i < aAddons.length; i++)
|
||||
if (addon.id == aAddons[i].id)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
self._loadAddons(addons, addons.length, json.totalResults);
|
||||
});
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
let aus = Cc["@mozilla.org/browser/addon-update-service;1"].getService(Ci.nsITimerCallback);
|
||||
|
|
Загрузка…
Ссылка в новой задаче