Bug 1385196 - [Form Autofill] Enable the feature based on locale and geoip. r=MattN
authorLuke Chang <lchang@mozilla.com>
Thu, 10 Aug 2017 21:36:34 -0700
changeset 374104 e0975a1eefb231fd7605b3186b1d38a272c779d2
parent 374103 63ebcdc4d3ab1ef3f2a70590f04a41291253f536
child 374105 5f8a0a826ad167bf90a6001705694b4c7fb5b461
push id32317
push userkwierso@gmail.com
push dateFri, 11 Aug 2017 19:47:12 +0000
treeherdermozilla-central@e7dc8329e2d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1385196
milestone57.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 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
@@ -45,18 +45,30 @@ function onMaybeOpenPopup(evt) {
 
 function addUpgradeListener(instanceID) {
   AddonManager.addUpgradeListener(instanceID, upgrade => {
     // don't install the upgrade by doing nothing here.
     // The upgrade will be installed upon next restart.
   });
 }
 
+function isAvailable() {
+  let availablePref = Services.prefs.getCharPref("extensions.formautofill.available");
+  if (availablePref == "on") {
+    return true;
+  } else if (availablePref == "detect") {
+    let locale = Services.locale.getRequestedLocale();
+    let region = Services.prefs.getCharPref("browser.search.region", "");
+    return locale == "en-US" && region == "US";
+  }
+  return false;
+}
+
 function startup(data) {
-  if (Services.prefs.getStringPref("extensions.formautofill.available") != "on") {
+  if (!isAvailable()) {
     Services.prefs.clearUserPref("dom.forms.autocomplete.formautofill");
     return;
   }
 
   if (data.hasOwnProperty("instanceID") && data.instanceID) {
     if (AddonManagerPrivate.isDBLoaded()) {
       addUpgradeListener(data.instanceID);
     } else {