Bug 1514724 - set default prefs in firefox.js instead of dynamically, r=mconley
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 28 Dec 2018 11:27:09 +0000
changeset 509149 0fdb96690a40599c0f42fd47000ad0b2110ff148
parent 509148 3ad55634aa8a18c4362c5186a509191e18d97151
child 509150 c17712b31f9ae3b38a7f2c3de16b4cab5dcc0275
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1514724
milestone66.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 1514724 - set default prefs in firefox.js instead of dynamically, r=mconley Differential Revision: https://phabricator.services.mozilla.com/D14804
browser/app/profile/firefox.js
browser/components/pocket/content/SaveToPocket.jsm
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1646,18 +1646,20 @@ pref("dom.ipc.processPrelaunch.enabled",
 
 // See comments in bug 1340115 on how we got to these numbers.
 pref("browser.migrate.chrome.history.limit", 2000);
 pref("browser.migrate.chrome.history.maxAgeInDays", 180);
 
 // Enable browser frames for use on desktop.  Only exposed to chrome callers.
 pref("dom.mozBrowserFramesEnabled", true);
 
+pref("extensions.pocket.api", "api.getpocket.com");
 pref("extensions.pocket.enabled", true);
 pref("extensions.pocket.oAuthConsumerKey", "40249-e88c401e1b1f2242d9e441c4");
+pref("extensions.pocket.site", "getpocket.com");
 
 pref("signon.schemeUpgrades", true);
 
 // Enable the "Simplify Page" feature in Print Preview. This feature
 // is disabled by default in toolkit.
 pref("print.use_simplify_page", true);
 
 // Space separated list of URLS that are allowed to send objects (instead of
--- a/browser/components/pocket/content/SaveToPocket.jsm
+++ b/browser/components/pocket/content/SaveToPocket.jsm
@@ -16,44 +16,16 @@ ChromeUtils.defineModuleGetter(this, "Po
 ChromeUtils.defineModuleGetter(this, "ReaderMode",
                                "resource://gre/modules/ReaderMode.jsm");
 XPCOMUtils.defineLazyGetter(this, "gPocketBundle", function() {
   return Services.strings.createBundle("chrome://pocket/locale/pocket.properties");
 });
 
 var EXPORTED_SYMBOLS = ["SaveToPocket"];
 
-const PREF_BRANCH = "extensions.pocket.";
-const PREFS = {
-  enabled: true, // bug 1229937, figure out ui tour support
-  api: "api.getpocket.com",
-  site: "getpocket.com",
-};
-
-function setDefaultPrefs() {
-  let branch = Services.prefs.getDefaultBranch(PREF_BRANCH);
-  for (let [key, val] of Object.entries(PREFS)) {
-    // If someone beat us to setting a default, don't overwrite it.  This can
-    // happen if distribution.ini sets the default first.
-    if (branch.getPrefType(key) != branch.PREF_INVALID)
-      continue;
-    switch (typeof val) {
-      case "boolean":
-        branch.setBoolPref(key, val);
-        break;
-      case "number":
-        branch.setIntPref(key, val);
-        break;
-      case "string":
-        branch.setCharPref(key, val);
-        break;
-    }
-  }
-}
-
 function createElementWithAttrs(document, type, attrs) {
   let element = document.createXULElement(type);
   Object.keys(attrs).forEach(function(attr) {
     element.setAttribute(attr, attrs[attr]);
   });
   return element;
 }
 
@@ -437,17 +409,16 @@ function prefObserver(aSubject, aTopic, 
 }
 
 function browserWindows() {
   return Services.wm.getEnumerator("navigator:browser");
 }
 
 var SaveToPocket = {
   init() {
-    setDefaultPrefs();
     // migrate enabled pref
     if (Services.prefs.prefHasUserValue("browser.pocket.enabled")) {
       Services.prefs.setBoolPref("extensions.pocket.enabled", Services.prefs.getBoolPref("browser.pocket.enabled"));
       Services.prefs.clearUserPref("browser.pocket.enabled");
     }
     // watch pref change and enable/disable if necessary
     Services.prefs.addObserver("extensions.pocket.enabled", prefObserver);
     if (!Services.prefs.getBoolPref("extensions.pocket.enabled"))