зеркало из https://github.com/mozilla/gecko-dev.git
Bug 595639 - Prevent badges handlers to access the awesome row directly [r=mfinkle]
This commit is contained in:
Родитель
111389da29
Коммит
09d917d15c
|
@ -391,11 +391,25 @@
|
|||
if (!item.hasAttribute("url"))
|
||||
continue;
|
||||
|
||||
let itemHost = self._getEffectiveHost(Services.io.newURI(item.getAttribute("url"), null, null));
|
||||
let currentURL = item.getAttribute("url");
|
||||
let itemHost = self._getEffectiveHost(Services.io.newURI(currentURL, null, null));
|
||||
for (let badgeHost in self._badges) {
|
||||
if (itemHost == badgeHost) {
|
||||
// wrap the item to prevent setting a badge on a wrong item
|
||||
let wrapper = {
|
||||
set: function(aBadge) {
|
||||
if (item.getAttribute("url") != currentURL)
|
||||
return;
|
||||
|
||||
if (!aBadge || aBadge == "")
|
||||
item.removeAttribute("badge");
|
||||
else
|
||||
item.setAttribute("badge", aBadge);
|
||||
}
|
||||
};
|
||||
|
||||
let handler = self._badges[badgeHost];
|
||||
handler.updateBadge ? handler.updateBadge(item) : handler(item);
|
||||
handler.updateBadge ? handler.updateBadge(wrapper) : handler(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1216,15 +1230,15 @@
|
|||
tabs.push({ name: client.clientName });
|
||||
|
||||
client.tabs.forEach(function({title, urlHistory, icon}) {
|
||||
let pageUrl = urlHistory[0];
|
||||
let pageURL = urlHistory[0];
|
||||
|
||||
// Skip tabs that are already open
|
||||
if (engine.locallyOpenTabMatchesURL(pageUrl))
|
||||
if (engine.locallyOpenTabMatchesURL(pageURL))
|
||||
return;
|
||||
|
||||
tabs.push({
|
||||
title: title || pageUrl,
|
||||
uri: pageUrl,
|
||||
title: title || pageURL,
|
||||
uri: pageURL,
|
||||
icon: Weave.Utils.getIcon(icon, "chrome://browser/skin/images/tab.png")
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2512,11 +2512,11 @@ var BadgeHandlers = {
|
|||
_lastUpdate: 0,
|
||||
_lastCount: 0,
|
||||
url: "http://mail.google.com",
|
||||
updateBadge: function(aItem) {
|
||||
updateBadge: function(aBadge) {
|
||||
// Use the cache if possible
|
||||
let now = Date.now();
|
||||
if (this._lastCount && this._lastUpdate > now - 1000) {
|
||||
aItem.setAttribute("badge", this._lastCount);
|
||||
aBadge.set(this._lastCount);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2538,7 +2538,7 @@ var BadgeHandlers = {
|
|||
} else {
|
||||
this._lastCount = 0;
|
||||
}
|
||||
this._lastCount = BadgeHandlers.setNumberBadge(aItem, this._lastCount);
|
||||
this._lastCount = BadgeHandlers.setNumberBadge(aBadge, this._lastCount);
|
||||
}
|
||||
};
|
||||
req.send(null);
|
||||
|
@ -2566,12 +2566,12 @@ var BadgeHandlers = {
|
|||
return aValue;
|
||||
},
|
||||
|
||||
setNumberBadge: function(aItem, aValue) {
|
||||
setNumberBadge: function(aBadge, aValue) {
|
||||
if (parseInt(aValue) != 0) {
|
||||
aValue = this.clampBadge(aValue);
|
||||
aItem.setAttribute("badge", aValue);
|
||||
aBadge.set(aValue);
|
||||
} else {
|
||||
aItem.removeAttribute("badge");
|
||||
aBadge.set("");
|
||||
}
|
||||
return aValue;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче