Bug 807848 - Use 'toolkit.telemetry.prompted' pref as Int. r=mbanner
authoraceman <acelists@atlas.sk>
Thu, 07 Feb 2013 21:04:23 -0500
changeset 14835 d0116578620988c8a663907aaffba3a863ef85b5
parent 14834 e58ec29c87f93b80f15a7591420f2c9a2212a5e2
child 14836 a9077e1863b56c50fec8bd60b71fab33d54e7e9b
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbanner
bugs807848
Bug 807848 - Use 'toolkit.telemetry.prompted' pref as Int. r=mbanner
mail/base/content/specialTabs.js
mail/test/mozmill/runtest.py
mailnews/test/performance/bloat/mailnewsTestPrefs.js
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -236,17 +236,21 @@ const DOMLinkHandler = {
       // when we finish loading the page.
       specialTabs.setTabIcon(tab, link.href);
     }
   }
 };
 
 const kTelemetryPrompted    = "toolkit.telemetry.prompted";
 const kTelemetryEnabled     = "toolkit.telemetry.enabled";
+const kTelemetryRejected    = "toolkit.telemetry.rejected";
 const kTelemetryServerOwner = "toolkit.telemetry.server_owner";
+// This value should be kept synchronized to the value of TELEMETRY_PROMPT_REV
+// in mozilla-central/source/browser/components/nsBrowserGlue.js .
+const kTelemetryPromptRev   = 2;
 
 var contentTabBaseType = {
   inContentWhitelist: ['about:addons'],
   shouldSwitchTo: function onSwitchTo({contentPage: aContentPage}) {
     let tabmail = document.getElementById("tabmail");
     let tabInfo = tabmail.tabInfo;
 
     // Remove any anchors - especially for the about: pages, we just want
@@ -734,18 +738,17 @@ var specialTabs = {
    * Looks at the existing prefs and determines if we should suggest the user
    * enables telemetry or not.
    *
    * This is controlled by the pref toolkit.telemetry.prompted
    */
   shouldShowTelemetryNotification: function() {
     // toolkit has decided that the pref should have no default value
     try {
-      if (Services.prefs.getBoolPref(kTelemetryPrompted) ||
-          Services.prefs.getBoolPref(kTelemetryEnabled))
+      if (Services.prefs.getIntPref(kTelemetryPrompted) >= kTelemetryPromptRev)
         return false;
     } catch (e) { }
     return true;
   },
 
   showTelemetryNotification: function() {
     var notifyBox = document.getElementById("mail-notification-box");
 
@@ -753,35 +756,41 @@ var specialTabs = {
       new StringBundle("chrome://branding/locale/brand.properties");
     var telemetryBundle =
       new StringBundle("chrome://messenger/locale/telemetry.properties");
 
     var productName = brandBundle.get("brandFullName");
     var serverOwner = Services.prefs.getCharPref(kTelemetryServerOwner);
     var telemetryText = telemetryBundle.get("telemetryText", [productName, serverOwner]);
 
+    Services.prefs.clearUserPref(kTelemetryPrompted);
+    Services.prefs.clearUserPref(kTelemetryEnabled);
+    Services.prefs.clearUserPref(kTelemetryRejected);
+
     var buttons = [
       {
         label:     telemetryBundle.get("telemetryYesButtonLabel"),
         accessKey: telemetryBundle.get("telemetryYesButtonAccessKey"),
         popup:     null,
         callback:  function(aNotificationBar, aButton) {
           Services.prefs.setBoolPref(kTelemetryEnabled, true);
         }
       },
       {
         label:     telemetryBundle.get("telemetryNoButtonLabel"),
         accessKey: telemetryBundle.get("telemetryNoButtonAccessKey"),
         popup:     null,
-        callback:  function(aNotificationBar, aButton) {}
+        callback:  function(aNotificationBar, aButton) {
+          Services.prefs.setBoolPref(kTelemetryRejected, true);
+        }
       }
     ];
 
     // Set pref to indicate we've shown the notification.
-    Services.prefs.setBoolPref(kTelemetryPrompted, true);
+    Services.prefs.setIntPref(kTelemetryPrompted, kTelemetryPromptRev);
 
     var notification = notifyBox.appendNotification(telemetryText, "telemetry", null, notifyBox.PRIORITY_INFO_LOW, buttons);
     notification.persistence = 3; // arbitrary number, just so bar sticks around for a bit
 
     let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
     let link = notification.ownerDocument.createElementNS(XULNS, "label");
     link.className = "text-link telemetry-text-link";
     link.setAttribute("value", telemetryBundle.get("telemetryLinkLabel"));
--- a/mail/test/mozmill/runtest.py
+++ b/mail/test/mozmill/runtest.py
@@ -120,17 +120,17 @@ class ThunderTestProfile(mozrunner.Thund
         # Do not enable gloda
         'mailnews.database.global.indexer.enabled': False,
         # But do have gloda log if it does anything.  (When disabled, queries
         # are still serviced; they just should not result in any matches.)
         'mailnews.database.global.logging.upstream': True,
         # Do not allow fonts to be upgraded
         'mail.font.windows.version': 2,
         # No, we don't want to be prompted about Telemetry
-        'toolkit.telemetry.prompted': True,
+        'toolkit.telemetry.prompted': 999,
         }
 
     # Dummied up local accounts to stop the account wizard
     account_preferences = {
         'mail.account.account1.server' :  "server1",
         'mail.account.account2.identities' :  "id1,id2",
         'mail.account.account2.server' :  "server2",
         'mail.account.account3.server' :  "server3",
--- a/mailnews/test/performance/bloat/mailnewsTestPrefs.js
+++ b/mailnews/test/performance/bloat/mailnewsTestPrefs.js
@@ -39,17 +39,17 @@ user_pref("mail.smtpserver.smtp1.usernam
 user_pref("mail.smtpservers", "smtp1");
 user_pref("mail.startup.enabledMailCheckOnce", true);
 user_pref("mailnews.start_page_override.mstone", "ignore");
 user_pref("mailnews.database.global.indexer.enabled", false);
 // Ensure OS X and Outlook/OE books are disabled
 user_pref("ldap_2.servers.osx.position", 0);
 user_pref("ldap_2.servers.oe.position", 0);
 // Suppress Telemetry opt-in prompt
-user_pref("toolkit.telemetry.prompted", true);
+user_pref("toolkit.telemetry.prompted", 999);
 
 //
 // SeaMonkey preferences.
 //
 user_pref("shell.checkDefaultClient", false);
 
 //
 // Thunderbird preferences.