Bug 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 646209 b1cb1f83ca5a45fbe20fec743faed7b63d925dce
parent 646207 824d4f269c6323e1ad2bd8ebeb6496d60b8ba3e5
child 726155 4b27b41b622824f79e8901ef7c216a21fc278017
push id74025
push userbmo:markh@mozilla.com
push dateMon, 14 Aug 2017 23:40:02 +0000
reviewersMattN
bugs1385179
milestone57.0a1
Bug 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);