Bug 741738 - Count impressions for each doorhanger notification type, r=mak
authorTheo Chevalier <theo.chevalier11@gmail.com>
Sat, 15 Sep 2012 22:59:28 +0200
changeset 107164 ee6470d54349fd489739703d072939cc1d88e550
parent 107163 a453b9d8f4e35411b2ab4d070c8ac233b06431d0
child 107165 7bb5f1ebb8339aad35d002688d3dd6f9fe23814a
push id14884
push usertheo.chevalier11@gmail.com
push dateSat, 15 Sep 2012 20:59:51 +0000
treeherdermozilla-inbound@7bb5f1ebb833 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs741738
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 741738 - Count impressions for each doorhanger notification type, r=mak
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -1588,25 +1588,52 @@
         document.getAnonymousElementByAttribute(this, "anonid", "promo-message");
       </field>
       <field name="_promolink" readonly="true">
         document.getAnonymousElementByAttribute(this, "anonid", "promo-link");
       </field>
       <field name="_brandBundle" readonly="true">
         Services.strings.createBundle("chrome://branding/locale/brand.properties");
       </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">
         <getter><![CDATA[
-          try {
-            return Services.prefs.getIntPref("browser.syncPromoViewsLeft");
-          } catch(ex) {}
-          return 5;
+          let views = 5;
+          if (this._viewsLeftMap[this._notificationType] !== undefined) {
+            views = this._viewsLeftMap[this._notificationType];
+          }
+          return views;
         ]]></getter>
         <setter><![CDATA[
-          Services.prefs.setIntPref("browser.syncPromoViewsLeft", val);
+          if (this._viewsLeftMap !== undefined) {
+            let map = this._viewsLeftMap;
+          } else {
+            let map = {};
+          }
+          map[this._notificationType] = val;
+          Services.prefs.setCharPref("browser.syncPromoViewsLeftMap",
+                                     JSON.stringify(map));
           return val;
         ]]></setter>
       </property>
       <property name="_notificationType">
         <getter><![CDATA[
           // Use the popupid attribute to identify the notification type,
           // otherwise just rely on the panel id for common arrowpanels.
           let type = this._panel.firstChild.getAttribute("popupid") ||