Bug 702281 - Telemetry prompt on mobile should be tri-state r=bnicholson
authorMark Finkle <mfinkle@mozilla.com>
Fri, 10 Feb 2012 09:44:06 -0500
changeset 86733 c09af9f27313980150073c0e1fcb55a807d06089
parent 86732 82612a816cc0f7af875639a9eb023fd040c8c21b
child 86734 7422761d5b90475a08a2e65845507a44a654067d
push id102
push userMs2ger@gmail.com
push dateFri, 10 Feb 2012 20:38:19 +0000
reviewersbnicholson
bugs702281
milestone13.0a1
Bug 702281 - Telemetry prompt on mobile should be tri-state r=bnicholson
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -348,39 +348,53 @@ var BrowserApp = {
       gecko: {
         "type": "Checkerboard:Toggle",
         "value": Services.prefs.getBoolPref("gfx.show_checkerboard_pattern")
       }
     });
   },
 
   _showTelemetryPrompt: function _showTelemetryPrompt() {
-    let telemetryPrompted = false;
+    const PREF_TELEMETRY_PROMPTED = "toolkit.telemetry.prompted";
+    const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
+    const PREF_TELEMETRY_REJECTED = "toolkit.telemetry.rejected";
+
+    // This is used to reprompt users when privacy message changes
+    const TELEMETRY_PROMPT_REV = 2;
+
+    let telemetryPrompted = null;
     try {
-      telemetryPrompted = Services.prefs.getBoolPref("toolkit.telemetry.prompted");
+      telemetryPrompted = Services.prefs.getIntPref(PREF_TELEMETRY_PROMPTED);
     } catch (e) { /* Optional */ }
-    if (telemetryPrompted)
+
+    // If the user has seen the latest telemetry prompt, do not prompt again
+    // else clear old prefs and reprompt
+    if (telemetryPrompted === TELEMETRY_PROMPT_REV)
       return;
 
+    Services.prefs.clearUserPref(PREF_TELEMETRY_PROMPTED);
+    Services.prefs.clearUserPref(PREF_TELEMETRY_ENABLED);
+  
     let buttons = [
       {
         label: Strings.browser.GetStringFromName("telemetry.optin.yes"),
         callback: function () {
-          Services.prefs.setBoolPref("toolkit.telemetry.prompted", true);
-          Services.prefs.setBoolPref("toolkit.telemetry.enabled", true);
+          Services.prefs.setIntPref(PREF_TELEMETRY_PROMPTED, TELEMETRY_PROMPT_REV);
+          Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, true);
         }
       },
       {
         label: Strings.browser.GetStringFromName("telemetry.optin.no"),
         callback: function () {
-          Services.prefs.setBoolPref("toolkit.telemetry.prompted", true);
-          Services.prefs.setBoolPref("toolkit.telemetry.enabled", false);
+          Services.prefs.setIntPref(PREF_TELEMETRY_PROMPTED, TELEMETRY_PROMPT_REV);
+          Services.prefs.setBoolPref(PREF_TELEMETRY_REJECTED, true);
         }
       }
     ];
+
     let brandShortName = Strings.brand.GetStringFromName("brandShortName");
     let message = Strings.browser.formatStringFromName("telemetry.optin.message", [brandShortName], 1);
     NativeWindow.doorhanger.show(message, "telemetry-optin", buttons);
   },
 
   shutdown: function shutdown() {
     NativeWindow.uninit();
     FormAssistant.uninit();
@@ -4160,12 +4174,11 @@ var CharacterEncoding = {
     });
   },
 
   setEncoding: function setEncoding(aEncoding) {
     let browser = BrowserApp.selectedBrowser;
     let docCharset = browser.docShell.QueryInterface(Ci.nsIDocCharset);
     docCharset.charset = aEncoding;
     browser.reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
-  },
-
+  }
 };