Bug 1446445 - app.normandy.first_run should default to true r=Gijs a=jcristau
authorMike Cooper <mcooper@mozilla.com>
Mon, 19 Mar 2018 13:55:18 -0700
changeset 460544 7cd7d567a74dc3e4792634289cc7418ad945a8ed
parent 460543 35cabd15daab63e60c54cccc25e10ba5f28cf77f
child 460545 612719d703997f07001e7da9ca5bfcf228a4c280
push id8975
push usershindli@mozilla.com
push dateWed, 04 Apr 2018 14:30:04 +0000
treeherdermozilla-beta@7cd7d567a74d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, jcristau
bugs1446445
milestone60.0
Bug 1446445 - app.normandy.first_run should default to true r=Gijs a=jcristau 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.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");
@@ -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;
   },
 };