Bug 1390433 - (From 1385179)Enable addresses sync engine as formautofill initializes. r?MattN draft
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 08 Aug 2017 15:07:10 +1000
changeset 649806 8180c096add88b50e4973e2fe1b66008b6e2f132
parent 649805 edba5dff484787fb6a2f53cfa7730ccd9bd1dd3f
child 649807 ef55362dc916b05aa3ed83418577668a3d091e23
push id75162
push userschung@mozilla.com
push dateMon, 21 Aug 2017 10:29:17 +0000
reviewersMattN
bugs1390433, 1385179
milestone56.0
Bug 1390433 - (From 1385179)Enable addresses sync engine as formautofill initializes. r?MattN MozReview-Commit-ID: BPikY3wM8Df
browser/extensions/formautofill/bootstrap.js
--- a/browser/extensions/formautofill/bootstrap.js
+++ b/browser/extensions/formautofill/bootstrap.js
@@ -60,16 +60,19 @@ function isAvailable() {
     return locale == "en-US" && region == "US";
   }
   return false;
 }
 
 function startup(data) {
   if (!isAvailable()) {
     Services.prefs.clearUserPref("dom.forms.autocomplete.formautofill");
+    // reset the sync related prefs incase the feature was previously available
+    // but isn't now.
+    Services.prefs.clearUserPref("services.sync.engine.addresses.available");
     return;
   }
 
   if (data.hasOwnProperty("instanceID") && data.instanceID) {
     if (AddonManagerPrivate.isDBLoaded()) {
       addUpgradeListener(data.instanceID);
     } else {
       // Wait for the extension database to be loaded so we don't cause its init.
@@ -82,16 +85,21 @@ function startup(data) {
     throw Error("no instanceID passed to bootstrap startup");
   }
 
   // This pref is used for web contents to detect the autocomplete feature.
   // When it's true, "element.autocomplete" will return tokens we currently
   // support -- otherwise it'll return an empty string.
   Services.prefs.setBoolPref("dom.forms.autocomplete.formautofill", true);
 
+  // This pref determines whether the "addresses" sync engine is available
+  // (ie, whether it is shown in any UI etc) - it *does not* determine whether
+  // the engine is actually enabled or not.
+  Services.prefs.setBoolPref("services.sync.engine.addresses.available", true);
+
   // Listen for the autocomplete popup message to lazily append our stylesheet related to the popup.
   Services.mm.addMessageListener("FormAutoComplete:MaybeOpenPopup", onMaybeOpenPopup);
 
   let parent = new FormAutofillParent();
   parent.init().catch(Cu.reportError);
   Services.ppmm.loadProcessScript("data:,new " + function() {
     Components.utils.import("resource://formautofill/FormAutofillContent.jsm");
   }, true);