зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1417843 - Add supportedCountries pref to configure which countries are supported. r=lchang,steveck
MozReview-Commit-ID: 13m1ezHcR8n --HG-- extra : rebase_source : 4820c37143af678dd5a72b76622fc88be0ed11c4
This commit is contained in:
Родитель
27758db986
Коммит
045d790150
|
@ -1716,6 +1716,8 @@ pref("extensions.formautofill.firstTimeUse", true);
|
|||
pref("extensions.formautofill.heuristics.enabled", true);
|
||||
pref("extensions.formautofill.section.enabled", true);
|
||||
pref("extensions.formautofill.loglevel", "Warn");
|
||||
// Comma separated list of countries Form Autofill supports
|
||||
pref("extensions.formautofill.supportedCountries", "US");
|
||||
|
||||
// Whether or not to restore a session with lazy-browser tabs.
|
||||
pref("browser.sessionstore.restore_tabs_lazily", true);
|
||||
|
|
|
@ -12,9 +12,6 @@ const ADDRESS_METADATA_PATH = "resource://formautofill/addressmetadata/";
|
|||
const ADDRESS_REFERENCES = "addressReferences.js";
|
||||
const ADDRESS_REFERENCES_EXT = "addressReferencesExt.js";
|
||||
|
||||
// TODO: This list should become a pref in Bug 1413494
|
||||
const SUPPORTED_COUNTRY_LIST = ["US"];
|
||||
|
||||
const ADDRESSES_COLLECTION_NAME = "addresses";
|
||||
const CREDITCARDS_COLLECTION_NAME = "creditCards";
|
||||
const ADDRESSES_FIRST_TIME_USE_PREF = "extensions.formautofill.firstTimeUse";
|
||||
|
@ -22,6 +19,7 @@ const ENABLED_AUTOFILL_ADDRESSES_PREF = "extensions.formautofill.addresses.enabl
|
|||
const CREDITCARDS_USED_STATUS_PREF = "extensions.formautofill.creditCards.used";
|
||||
const AUTOFILL_CREDITCARDS_AVAILABLE_PREF = "extensions.formautofill.creditCards.available";
|
||||
const ENABLED_AUTOFILL_CREDITCARDS_PREF = "extensions.formautofill.creditCards.enabled";
|
||||
const SUPPORTED_COUNTRIES_PREF = "extensions.formautofill.supportedCountries";
|
||||
const MANAGE_ADDRESSES_KEYWORDS = ["manageAddressesTitle", "addNewAddressTitle"];
|
||||
const EDIT_ADDRESS_KEYWORDS = [
|
||||
"givenName", "additionalName", "familyName", "organization2", "streetAddress",
|
||||
|
@ -378,7 +376,7 @@ this.FormAutofillUtils = {
|
|||
* @returns {string} The matching country code.
|
||||
*/
|
||||
identifyCountryCode(countryName, countrySpecified) {
|
||||
let countries = countrySpecified ? [countrySpecified] : SUPPORTED_COUNTRY_LIST;
|
||||
let countries = countrySpecified ? [countrySpecified] : this.supportedCountries;
|
||||
|
||||
for (let country of countries) {
|
||||
let collators = this.getCollators(country);
|
||||
|
@ -696,3 +694,6 @@ XPCOMUtils.defineLazyPreferenceGetter(this.FormAutofillUtils,
|
|||
"isAutofillAddressesFirstTimeUse", ADDRESSES_FIRST_TIME_USE_PREF);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this.FormAutofillUtils,
|
||||
"AutofillCreditCardsUsedStatus", CREDITCARDS_USED_STATUS_PREF);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this.FormAutofillUtils,
|
||||
"supportedCountries", SUPPORTED_COUNTRIES_PREF, null, null,
|
||||
val => val.split(","));
|
||||
|
|
|
@ -1216,9 +1216,7 @@ class Addresses extends AutofillRecords {
|
|||
}
|
||||
|
||||
_recordReadProcessor(address) {
|
||||
// TODO: We only support US in MVP so hide the field if it's not. We
|
||||
// are going to support more countries in bug 1370193.
|
||||
if (address.country && address.country != "US") {
|
||||
if (address.country && !FormAutofillUtils.supportedCountries.includes(address.country)) {
|
||||
delete address.country;
|
||||
delete address["country-name"];
|
||||
}
|
||||
|
|
|
@ -59,7 +59,9 @@ function isAvailable() {
|
|||
} else if (availablePref == "detect") {
|
||||
let locale = Services.locale.getRequestedLocale();
|
||||
let region = Services.prefs.getCharPref("browser.search.region", "");
|
||||
return locale == "en-US" && region == "US";
|
||||
let supportedCountries = Services.prefs.getCharPref("extensions.formautofill.supportedCountries")
|
||||
.split(",");
|
||||
return locale == "en-US" && supportedCountries.includes(region);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -49,10 +49,9 @@
|
|||
<span data-localization="country"/>
|
||||
<select id="country">
|
||||
<option/>
|
||||
<option value="US" data-localization="us"/>
|
||||
</select>
|
||||
</label>
|
||||
<p id="country-warning-message" data-localization="countryWarningMessage"/>
|
||||
<p id="country-warning-message" data-localization="countryWarningMessage2"/>
|
||||
<label id="email-container">
|
||||
<span data-localization="email"/>
|
||||
<input id="email" type="email"/>
|
||||
|
|
|
@ -205,6 +205,14 @@ class EditAddress extends EditDialog {
|
|||
if (this._record) {
|
||||
this._elements.title.dataset.localization = "editAddressTitle";
|
||||
}
|
||||
let fragment = document.createDocumentFragment();
|
||||
for (let country of FormAutofillUtils.supportedCountries) {
|
||||
let option = new Option();
|
||||
option.value = country;
|
||||
option.dataset.localization = country.toLowerCase();
|
||||
fragment.appendChild(option);
|
||||
}
|
||||
this._elements.country.appendChild(fragment);
|
||||
FormAutofillUtils.localizeMarkup(REGIONS_BUNDLE_URI, this._elements.country);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ tel = Phone
|
|||
email = Email
|
||||
cancelBtnLabel = Cancel
|
||||
saveBtnLabel = Save
|
||||
countryWarningMessage = Form Autofill is currently available only for US addresses
|
||||
countryWarningMessage2 = Form Autofill is currently available only for certain countries.
|
||||
|
||||
# LOCALIZATION NOTE (addNewCreditCardTitle, editCreditCardTitle): The dialog title for creating or editing
|
||||
# credit cards in browser preferences.
|
||||
|
|
Загрузка…
Ссылка в новой задаче