Bug 1385179 - Enable addresses sync engine as formautofill initializes. r?MattN
MozReview-Commit-ID: BPikY3wM8Df
--- 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);