Bug 1446445 - app.normandy.first_run should default to true draft
authorMike Cooper <mcooper@mozilla.com>
Mon, 19 Mar 2018 13:55:18 -0700
changeset 775088 5414de03f0e829f80678eee9c0090059e7945282
parent 769492 34a7d2c7e73e01dd81323c90348a98bd37e259f7
push id104593
push userbmo:mcooper@mozilla.com
push dateThu, 29 Mar 2018 23:55:56 +0000
bugs1446445
milestone61.0a1
Bug 1446445 - app.normandy.first_run should default to true 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
@@ -1733,16 +1733,17 @@ pref("browser.chrome.errorReporter.infoU
 #ifdef EARLY_BETA_OR_EARLIER
 pref("browser.policies.enabled", true);
 #endif
 
 // 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");
@@ -72,37 +71,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) {
@@ -139,25 +138,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"]);
@@ -175,17 +174,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) {
@@ -199,14 +198,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;
   },
 };