Bug 741738 - Count impressions for each doorhanger notification type

r=mak
This commit is contained in:
Theo Chevalier 2012-10-11 11:48:33 +02:00
Родитель 41ab5cfdd4
Коммит 585992d190
1 изменённых файлов: 39 добавлений и 12 удалений

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

@ -1714,15 +1714,39 @@
<field name="_brandBundle" readonly="true"> <field name="_brandBundle" readonly="true">
Services.strings.createBundle("chrome://branding/locale/brand.properties"); Services.strings.createBundle("chrome://branding/locale/brand.properties");
</field> </field>
<property name="_viewsLeftMap">
<getter><![CDATA[
let viewsLeftMap = {};
try {
viewsLeftMap = JSON.parse(Services.prefs.getCharPref("browser.syncPromoViewsLeftMap"));
} catch (ex) {
// If the old preference exists, migrate it to the new one.
try {
let oldPref = Services.prefs.getIntPref("browser.syncPromoViewsLeft");
Services.prefs.clearUserPref("browser.syncPromoViewsLeft");
viewsLeftMap.bookmarks = oldPref;
viewsLeftMap.passwords = oldPref;
Services.prefs.setCharPref("browser.syncPromoViewsLeftMap",
JSON.stringify(viewsLeftMap));
} catch (ex2) {}
}
return viewsLeftMap;
]]></getter>
</property>
<property name="_viewsLeft"> <property name="_viewsLeft">
<getter><![CDATA[ <getter><![CDATA[
try { let views = 5;
return Services.prefs.getIntPref("browser.syncPromoViewsLeft"); let map = this._viewsLeftMap;
} catch(ex) {} if (this._notificationType in map) {
return 5; views = map[this._notificationType];
}
return views;
]]></getter> ]]></getter>
<setter><![CDATA[ <setter><![CDATA[
Services.prefs.setIntPref("browser.syncPromoViewsLeft", val); let map = this._viewsLeftMap;
map[this._notificationType] = val;
Services.prefs.setCharPref("browser.syncPromoViewsLeftMap",
JSON.stringify(map));
return val; return val;
]]></setter> ]]></setter>
</property> </property>
@ -1814,13 +1838,16 @@
// thus set a width on it, based on the available space, before // thus set a width on it, based on the available space, before
// setting its textContent. Then set its height as well, to // setting its textContent. Then set its height as well, to
// fix wrong height calculation on Linux (bug 659578). // fix wrong height calculation on Linux (bug 659578).
let self = this; this._panel.addEventListener("popupshown", function panelShown() {
this._panel.addEventListener("popupshown", function (evt) { this._panel.removeEventListener("popupshown", panelShown, true);
self._panel.removeEventListener("popupshown", arguments.callee, true); // Previous popupShown events may close the panel or change
self._promomessage.width = self._promomessage.getBoundingClientRect().width; // its contents, so ensure this is still valid.
self._promomessage.firstChild.textContent = self._notificationMessage; if (this._panel.state != "open" || !this._notificationType)
self._promomessage.height = self._promomessage.getBoundingClientRect().height; return;
}, true); this._promomessage.width = this._promomessage.getBoundingClientRect().width;
this._promomessage.firstChild.textContent = this._notificationMessage;
this._promomessage.height = this._promomessage.getBoundingClientRect().height;
}.bind(this), true);
} }
]]></body> ]]></body>
</method> </method>