Bug 737600 - When telemetry is disabled in the pref pane, we should update toolkit.telemetry.rejected, r=mak77
authorTheo Chevalier <theo.chevalier11@gmail.com>
Sat, 08 Dec 2012 18:39:24 +0100
changeset 115418 b19ebbfd9ce4703cbbdd127290b020314a813020
parent 115417 46b7a3a221adca85ce40fcaf6a7fa26bdc85d487
child 115419 a14a9d4f5d164fb0403fafff20eaa26c560263e8
push id24003
push usereakhgari@mozilla.com
push dateSun, 09 Dec 2012 18:17:18 +0000
treeherdermozilla-central@725eb8792d27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak77
bugs737600
milestone20.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 737600 - When telemetry is disabled in the pref pane, we should update toolkit.telemetry.rejected, r=mak77
browser/components/preferences/advanced.js
browser/components/preferences/advanced.xul
browser/components/preferences/in-content/advanced.js
browser/components/preferences/in-content/advanced.xul
configure.in
toolkit/content/aboutTelemetry.js
toolkit/content/jar.mn
--- a/browser/components/preferences/advanced.js
+++ b/browser/components/preferences/advanced.js
@@ -1,8 +1,9 @@
+#filter substitution
 # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 // Load DownloadUtils module for convertByteUnits
 Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
 Components.utils.import("resource://gre/modules/ctypes.jsm");
@@ -149,16 +150,28 @@ var gAdvancedPane = {
     try {
       var cr = Components.classes["@mozilla.org/toolkit/crash-reporter;1"].
                getService(Components.interfaces.nsICrashReporter);
       cr.submitReports = checkbox.checked;
     } catch (e) { }
   },
 
   /**
+   * When the user toggles telemetry, update the rejected value as well, so we
+   * know he expressed a choice, and don't re-prompt inadvertently.
+   */
+  telemetryEnabledChanged: function (event)
+  {
+    let rejected = document.getElementById("toolkit.telemetry.rejected");
+    rejected.value = !event.target.value;
+    let displayed = document.getElementById("toolkit.telemetry.prompted");
+    displayed.value = @MOZ_TELEMETRY_DISPLAY_REV@;
+  },
+
+  /**
    * When the user toggles the layers.acceleration.disabled pref,
    * sync its new value to the gfx.direct2d.disabled pref too.
    */
   updateHardwareAcceleration: function()
   {
 #ifdef XP_WIN
     var fromPref = document.getElementById("layers.acceleration.disabled");
     var toPref = document.getElementById("gfx.direct2d.disabled");
--- a/browser/components/preferences/advanced.xul
+++ b/browser/components/preferences/advanced.xul
@@ -45,19 +45,28 @@
                   name="browser.shell.checkDefaultBrowser"
                   type="bool"/>
 
       <preference id="pref.general.disable_button.default_browser"
                   name="pref.general.disable_button.default_browser"
                   type="bool"/>
 #endif
 
+#ifdef MOZ_TELEMETRY_REPORTING
       <preference id="toolkit.telemetry.enabled"
                   name="toolkit.telemetry.enabled"
+                  onchange="gAdvancedPane.telemetryEnabledChanged(event);"
                   type="bool"/>
+      <preference id="toolkit.telemetry.prompted"
+                  name="toolkit.telemetry.prompted"
+                  type="int"/>
+      <preference id="toolkit.telemetry.rejected"
+                  name="toolkit.telemetry.rejected"
+                  type="bool"/>
+#endif
 
       <!-- Network tab -->
       <preference id="browser.cache.disk.capacity"     name="browser.cache.disk.capacity"     type="int"/>
       <preference id="browser.offline-apps.notify"     name="browser.offline-apps.notify"     type="bool"/>
  
       <preference id="browser.cache.disk.smart_size.enabled"
                   name="browser.cache.disk.smart_size.enabled"
                   inverted="true"
@@ -181,19 +190,21 @@
               </deck>
             </hbox>
 #ifdef MOZ_CRASHREPORTER
             <checkbox id="submitCrashesBox" flex="1"
                       oncommand="gAdvancedPane.updateSubmitCrashes();"
                       label="&submitCrashes.label;" accesskey="&submitCrashes.accesskey;"/>
 #endif
 #endif
+#ifdef MOZ_TELEMETRY_REPORTING
             <checkbox id="submitTelemetryBox" flex="1"
                       preference="toolkit.telemetry.enabled"
                       label="&submitTelemetry.label;" accesskey="&submitTelemetry.accesskey;"/>
+#endif
           </groupbox>
         </tabpanel>
 
         <!-- Network -->
         <tabpanel id="networkPanel" orient="vertical">
 
           <!-- Connection -->
           <groupbox id="connectionGroup">
--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -1,8 +1,9 @@
+#filter substitution
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Load DownloadUtils module for convertByteUnits
 Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
 
 var gAdvancedPane = {
@@ -137,16 +138,28 @@ var gAdvancedPane = {
     try {
       var cr = Components.classes["@mozilla.org/toolkit/crash-reporter;1"].
                getService(Components.interfaces.nsICrashReporter);
       cr.submitReports = checkbox.checked;
     } catch (e) { }
   },
 
   /**
+   * When the user toggles telemetry, update the rejected value as well, so we
+   * know he expressed a choice, and don't re-prompt inadvertently.
+   */
+  telemetryEnabledChanged: function (event)
+  {
+    let rejected = document.getElementById("toolkit.telemetry.rejected");
+    rejected.value = !event.target.value;
+    let displayed = document.getElementById("toolkit.telemetry.prompted");
+    displayed.value = @MOZ_TELEMETRY_DISPLAY_REV@;
+  },
+
+  /**
    * When the user toggles the layers.acceleration.disabled pref,
    * sync its new value to the gfx.direct2d.disabled pref too.
    */
   updateHardwareAcceleration: function()
   {
 #ifdef XP_WIN
     var fromPref = document.getElementById("layers.acceleration.disabled");
     var toPref = document.getElementById("gfx.direct2d.disabled");
--- a/browser/components/preferences/in-content/advanced.xul
+++ b/browser/components/preferences/in-content/advanced.xul
@@ -47,19 +47,28 @@
               name="browser.shell.checkDefaultBrowser"
               type="bool"/>
 
   <preference id="pref.general.disable_button.default_browser"
               name="pref.general.disable_button.default_browser"
               type="bool"/>
 #endif
 
+#ifdef MOZ_TELEMETRY_REPORTING
   <preference id="toolkit.telemetry.enabled"
               name="toolkit.telemetry.enabled"
+              onchange="gAdvancedPane.telemetryEnabledChanged(event);"
               type="bool"/>
+  <preference id="toolkit.telemetry.prompted"
+              name="toolkit.telemetry.prompted"
+              type="int"/>
+  <preference id="toolkit.telemetry.rejected"
+              name="toolkit.telemetry.rejected"
+              type="bool"/>
+#endif
 
   <!-- Network tab -->
   <preference id="browser.cache.disk.capacity"
               name="browser.cache.disk.capacity"
               type="int"/>
   <preference id="browser.offline-apps.notify"
               name="browser.offline-apps.notify"
               type="bool"/>
@@ -202,19 +211,21 @@
           </deck>
         </hbox>
 #ifdef MOZ_CRASHREPORTER
         <checkbox id="submitCrashesBox" flex="1"
                   oncommand="gAdvancedPane.updateSubmitCrashes();"
                   label="&submitCrashes.label;" accesskey="&submitCrashes.accesskey;"/>
 #endif
 #endif
+#ifdef MOZ_TELEMETRY_REPORTING
         <checkbox id="submitTelemetryBox" flex="1"
                   preference="toolkit.telemetry.enabled"
                   label="&submitTelemetry.label;" accesskey="&submitTelemetry.accesskey;"/>
+#endif
       </groupbox>
     </tabpanel>
 
     <!-- Network -->
     <tabpanel id="networkPanel" orient="vertical">
 
       <!-- Connection -->
       <groupbox id="connectionGroup">
--- a/configure.in
+++ b/configure.in
@@ -8634,16 +8634,19 @@ if test -n "$LIBXUL_SDK"; then
     MOZ_APP_STATIC_INI=
 fi
 AC_SUBST(MOZ_APP_STATIC_INI)
 
 AC_SUBST(MOZ_PKG_SPECIAL)
 
 AC_SUBST(MOZILLA_OFFICIAL)
 
+AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
+AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
+
 if test "$MOZ_TELEMETRY_REPORTING"; then
     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
 fi
 
 dnl win32 options
 AC_SUBST(MOZ_MAPINFO)
 AC_SUBST(MOZ_BROWSE_INFO)
 AC_SUBST(MOZ_TOOLS_DIR)
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1,8 +1,9 @@
+#filter substitution
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 'use strict';
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
@@ -17,16 +18,19 @@ const brandBundle = Services.strings.cre
   "chrome://branding/locale/brand.properties");
 const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].
   getService(Ci.nsITelemetryPing);
 
 // Maximum height of a histogram bar (in em)
 const MAX_BAR_HEIGHT = 18;
 const PREF_TELEMETRY_SERVER_OWNER = "toolkit.telemetry.server_owner";
 const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
+const PREF_TELEMETRY_DISPLAYED = "toolkit.telemetry.prompted";
+const PREF_TELEMETRY_REJECTED  = "toolkit.telemetry.rejected";
+const TELEMETRY_DISPLAY_REV = @MOZ_TELEMETRY_DISPLAY_REV@;
 const PREF_DEBUG_SLOW_SQL = "toolkit.telemetry.debugSlowSql";
 const PREF_SYMBOL_SERVER_URI = "profiler.symbolicationUrl";
 const DEFAULT_SYMBOL_SERVER_URI = "http://symbolapi.mozilla.org";
 
 // Cached value of document's RTL mode
 let documentRTLMode = "";
 
 /**
@@ -70,16 +74,20 @@ let observer = {
   disableTelemetry: bundle.GetStringFromName("disableTelemetry"),
 
   /**
    * Observer is called whenever Telemetry is enabled or disabled
    */
   observe: function observe(aSubject, aTopic, aData) {
     if (aData == PREF_TELEMETRY_ENABLED) {
       this.updatePrefStatus();
+      Services.prefs.setBoolPref(PREF_TELEMETRY_REJECTED,
+                                 !getPref(PREF_TELEMETRY_ENABLED, false));
+      Services.prefs.setIntPref(PREF_TELEMETRY_DISPLAYED,
+                                TELEMETRY_DISPLAY_REV);
     }
   },
 
   /**
    * Updates the button & text at the top of the page to reflect Telemetry state.
    */
   updatePrefStatus: function updatePrefStatus() {
     // Notify user whether Telemetry is enabled
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -11,17 +11,17 @@ toolkit.jar:
    content/global/textbox.css                 (textbox.css)
    content/global/menulist.css                (menulist.css)
    content/global/about.xhtml                 (about.xhtml)
    content/global/aboutAbout.xhtml            (aboutAbout.xhtml)
    content/global/aboutRights.xhtml           (aboutRights.xhtml)
    content/global/aboutRights-unbranded.xhtml (aboutRights-unbranded.xhtml)
 *  content/global/aboutSupport.js
 *  content/global/aboutSupport.xhtml
-   content/global/aboutTelemetry.js
+*  content/global/aboutTelemetry.js
 *  content/global/aboutTelemetry.xhtml
    content/global/aboutTelemetry.css          (aboutTelemetry.css)
    content/global/directionDetector.html
    content/global/plugins.html
    content/global/plugins.css
 *+  content/global/buildconfig.html            (buildconfig.html)
 +  content/global/charsetOverlay.js           (charsetOverlay.js)
 +  content/global/charsetOverlay.xul          (charsetOverlay.xul)