Bug 1385196 - [Form Autofill] Enable the feature based on locale and geoip. r=MattN draft
authorLuke Chang <lchang@mozilla.com>
Tue, 01 Aug 2017 14:35:16 +0800
changeset 643741 3fd8196485c1295a89e6f7e80afa3b4760a58587
parent 641444 bb8de16ce00cb57b587a14c210ecc7505f366328
child 725387 b98e815a3b89f2bb374c0b867747fc0e5bdbece7
push id73196
push userbmo:lchang@mozilla.com
push dateThu, 10 Aug 2017 02:45:54 +0000
reviewersMattN
bugs1385196
milestone57.0a1
Bug 1385196 - [Form Autofill] Enable the feature based on locale and geoip. r=MattN MozReview-Commit-ID: 3yvCJvB5zdT
browser/extensions/formautofill/bootstrap.js
--- a/browser/extensions/formautofill/bootstrap.js
+++ b/browser/extensions/formautofill/bootstrap.js
@@ -36,17 +36,28 @@ function onMaybeOpenPopup(evt) {
     // This window already has autofill stylesheets.
     return;
   }
 
   insertStyleSheet(domWindow, STYLESHEET_URI);
 }
 
 function startup() {
-  if (Services.prefs.getStringPref("extensions.formautofill.available") != "on") {
+  let featureAvailable = false;
+  let prefAvailable = Services.prefs.getCharPref("extensions.formautofill.available");
+
+  if (prefAvailable == "on") {
+    featureAvailable = true;
+  } else if (prefAvailable == "detect") {
+    let locale = Services.locale.getRequestedLocale();
+    let region = Services.prefs.getCharPref("browser.search.region", "");
+    featureAvailable = (locale == "en-US" && region == "US");
+  }
+
+  if (!featureAvailable) {
     Services.prefs.clearUserPref("dom.forms.autocomplete.formautofill");
     return;
   }
 
   // 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);