Bug 1446445 - app.normandy.first_run should default to true r=Gijs
authorMike Cooper <mcooper@mozilla.com>
Mon, 19 Mar 2018 13:55:18 -0700
changeset 410724 aeeb277faf1d195000912931b24f2eca9656afe2
parent 410723 9dcd9f186bbfb5a13d59eaa1b04cecc181ac631a
child 410725 c1ee3abb5d406cdc9f3726176b2f84ee1b48e3bb
push id33735
push usershindli@mozilla.com
push dateFri, 30 Mar 2018 09:55:46 +0000
treeherdermozilla-central@3f37287132bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1446445
milestone61.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 1446445 - app.normandy.first_run should default to true r=Gijs MozReview-Commit-ID: 8j3qQvF3BSJ
browser/app/profile/firefox.js
toolkit/components/normandy/lib/ClientEnvironment.jsm
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1742,16 +1742,17 @@ pref("browser.chrome.errorReporter.logLe
 // URL for Learn More link for browser error logging in preferences
 pref("browser.chrome.errorReporter.infoURL",
      "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/nightly-error-collection");
 
 // Normandy client preferences
 pref("app.normandy.api_url", "https://normandy.cdn.mozilla.net/api/v1");
 pref("app.normandy.dev_mode", false);
 pref("app.normandy.enabled", true);
+pref("app.normandy.first_run", true);
 pref("app.normandy.logging.level", 50); // Warn
 pref("app.normandy.run_interval_seconds", 86400); // 24 hours
 pref("app.normandy.shieldLearnMoreUrl", "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/shield");
 #ifdef MOZ_DATA_REPORTING
 pref("app.shield.optoutstudies.enabled", true);
 #else
 pref("app.shield.optoutstudies.enabled", false);
 #endif
--- a/toolkit/components/normandy/lib/ClientEnvironment.jsm
+++ b/toolkit/components/normandy/lib/ClientEnvironment.jsm
@@ -1,15 +1,14 @@
 /* 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";
 
-ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "ShellService", "resource:///modules/ShellService.jsm");
 ChromeUtils.defineModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
 ChromeUtils.defineModuleGetter(this, "TelemetryArchive", "resource://gre/modules/TelemetryArchive.jsm");
 ChromeUtils.defineModuleGetter(this, "UpdateUtils", "resource://gre/modules/UpdateUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "NormandyApi", "resource://normandy/lib/NormandyApi.jsm");
@@ -73,37 +72,37 @@ var ClientEnvironment = {
    * Also note that, because filter expressions implicitly resolve promises, you
    * can add getter functions that return promises for async data.
    * @return {Object}
    */
   getEnvironment() {
     const environment = {};
 
     XPCOMUtils.defineLazyGetter(environment, "userId", () => {
-      let id = Preferences.get("app.normandy.user_id", "");
+      let id = Services.prefs.getCharPref("app.normandy.user_id", "");
       if (!id) {
         // generateUUID adds leading and trailing "{" and "}". strip them off.
         id = generateUUID().toString().slice(1, -1);
-        Preferences.set("app.normandy.user_id", id);
+        Services.prefs.setCharPref("app.normandy.user_id", id);
       }
       return id;
     });
 
     XPCOMUtils.defineLazyGetter(environment, "country", () => {
       return ClientEnvironment.getClientClassification()
         .then(classification => classification.country);
     });
 
     XPCOMUtils.defineLazyGetter(environment, "request_time", () => {
       return ClientEnvironment.getClientClassification()
         .then(classification => classification.request_time);
     });
 
     XPCOMUtils.defineLazyGetter(environment, "distribution", () => {
-      return Preferences.get("distribution.id", "default");
+      return Services.prefs.getCharPref("distribution.id", "default");
     });
 
     XPCOMUtils.defineLazyGetter(environment, "telemetry", async function() {
       const pings = await TelemetryArchive.promiseArchivedPingList();
 
       // get most recent ping per type
       const mostRecentPings = {};
       for (const ping of pings) {
@@ -140,25 +139,25 @@ var ClientEnvironment = {
       const searchInitialized = await new Promise(resolve => Services.search.init(resolve));
       if (Components.isSuccessCode(searchInitialized)) {
         return Services.search.defaultEngine.identifier;
       }
       return null;
     });
 
     XPCOMUtils.defineLazyGetter(environment, "syncSetup", () => {
-      return Preferences.isSet("services.sync.username");
+      return Services.prefs.prefHasUserValue("services.sync.username");
     });
 
     XPCOMUtils.defineLazyGetter(environment, "syncDesktopDevices", () => {
-      return Preferences.get("services.sync.clients.devices.desktop", 0);
+      return Services.prefs.getIntPref("services.sync.clients.devices.desktop", 0);
     });
 
     XPCOMUtils.defineLazyGetter(environment, "syncMobileDevices", () => {
-      return Preferences.get("services.sync.clients.devices.mobile", 0);
+      return Services.prefs.getIntPref("services.sync.clients.devices.mobile", 0);
     });
 
     XPCOMUtils.defineLazyGetter(environment, "syncTotalDevices", () => {
       return environment.syncDesktopDevices + environment.syncMobileDevices;
     });
 
     XPCOMUtils.defineLazyGetter(environment, "plugins", async function() {
       let plugins = await AddonManager.getAddonsByTypes(["plugin"]);
@@ -176,17 +175,17 @@ var ClientEnvironment = {
       }
 
       return Cc["@mozilla.org/chrome/chrome-registry;1"]
         .getService(Ci.nsIXULChromeRegistry)
         .getSelectedLocale("global");
     });
 
     XPCOMUtils.defineLazyGetter(environment, "doNotTrack", () => {
-      return Preferences.get("privacy.donottrackheader.enabled", false);
+      return Services.prefs.getBoolPref("privacy.donottrackheader.enabled", false);
     });
 
     XPCOMUtils.defineLazyGetter(environment, "experiments", async () => {
       const names = {all: [], active: [], expired: []};
 
       for (const experiment of await PreferenceExperiments.getAll()) {
         names.all.push(experiment.name);
         if (experiment.expired) {
@@ -200,14 +199,14 @@ var ClientEnvironment = {
     });
 
     XPCOMUtils.defineLazyGetter(environment, "addons", async () => {
       const addons = await Addons.getAll();
       return Utils.keyBy(addons, "id");
     });
 
     XPCOMUtils.defineLazyGetter(environment, "isFirstRun", () => {
-      return Preferences.get("app.normandy.first_run");
+      return Services.prefs.getBoolPref("app.normandy.first_run", true);
     });
 
     return environment;
   },
 };