зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1390816 - Part 1: Add addresses sync checkbox in first time saving doorhanger. r=lchang
MozReview-Commit-ID: KkpseMw4kRk --HG-- extra : rebase_source : 1dfbacafcedf28bdc2a8a93db35fb5509ff9a889
This commit is contained in:
Родитель
d09db9fb2b
Коммит
e13ae1504d
|
@ -49,6 +49,21 @@ const CONTENT = {
|
||||||
options: {
|
options: {
|
||||||
persistWhileVisible: true,
|
persistWhileVisible: true,
|
||||||
popupIconURL: "chrome://formautofill/content/icon-address-save.svg",
|
popupIconURL: "chrome://formautofill/content/icon-address-save.svg",
|
||||||
|
checkbox: {
|
||||||
|
get checked() {
|
||||||
|
return Services.prefs.getBoolPref("services.sync.engine.addresses");
|
||||||
|
},
|
||||||
|
get label() {
|
||||||
|
// If sync account is not set, return null label to hide checkbox
|
||||||
|
return Services.prefs.prefHasUserValue("services.sync.username") ?
|
||||||
|
GetStringFromName("addressesSyncCheckbox") : null;
|
||||||
|
},
|
||||||
|
callback(event) {
|
||||||
|
let checked = event.target.checked;
|
||||||
|
Services.prefs.setBoolPref("services.sync.engine.addresses", checked);
|
||||||
|
log.debug("Set addresses sync to", checked);
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
|
@ -168,6 +183,32 @@ let FormAutofillDoorhanger = {
|
||||||
notificationPopupBox.appendChild(anchorElement);
|
notificationPopupBox.appendChild(anchorElement);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
_addCheckboxListener(browser, {notificationId, options}) {
|
||||||
|
if (!options.checkbox) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let id = notificationId + "-notification";
|
||||||
|
let chromeDoc = browser.ownerDocument;
|
||||||
|
let notification = chromeDoc.getElementById(id);
|
||||||
|
let cb = notification.checkbox;
|
||||||
|
|
||||||
|
if (cb) {
|
||||||
|
cb.addEventListener("command", options.checkbox.callback);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_removeCheckboxListener(browser, {notificationId, options}) {
|
||||||
|
if (!options.checkbox) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let id = notificationId + "-notification";
|
||||||
|
let chromeDoc = browser.ownerDocument;
|
||||||
|
let notification = chromeDoc.getElementById(id);
|
||||||
|
let cb = notification.checkbox;
|
||||||
|
|
||||||
|
if (cb) {
|
||||||
|
cb.removeEventListener("command", options.checkbox.callback);
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Show different types of doorhanger by leveraging PopupNotifications.
|
* Show different types of doorhanger by leveraging PopupNotifications.
|
||||||
* @param {XULElement} browser
|
* @param {XULElement} browser
|
||||||
|
@ -185,10 +226,16 @@ let FormAutofillDoorhanger = {
|
||||||
content.options.eventCallback = (topic) => {
|
content.options.eventCallback = (topic) => {
|
||||||
log.debug("eventCallback:", topic);
|
log.debug("eventCallback:", topic);
|
||||||
|
|
||||||
|
if (topic == "removed" || topic == "dismissed") {
|
||||||
|
this._removeCheckboxListener(browser, content);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// The doorhanger is customizable only when notification box is shown
|
// The doorhanger is customizable only when notification box is shown
|
||||||
if (topic != "shown") {
|
if (topic != "shown") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this._addCheckboxListener(browser, content);
|
||||||
|
|
||||||
// There's no preferences link or other customization in first time use doorhanger.
|
// There's no preferences link or other customization in first time use doorhanger.
|
||||||
if (type == "firstTimeUse") {
|
if (type == "firstTimeUse") {
|
||||||
|
|
|
@ -10,6 +10,7 @@ viewAutofillOptionsLink = View Form Autofill Options
|
||||||
changeAutofillOptions = Change Form Autofill Options
|
changeAutofillOptions = Change Form Autofill Options
|
||||||
viewAutofillOptionsLinkOSX = View Form Autofill Preferences
|
viewAutofillOptionsLinkOSX = View Form Autofill Preferences
|
||||||
changeAutofillOptionsOSX = Change Form Autofill Preferences
|
changeAutofillOptionsOSX = Change Form Autofill Preferences
|
||||||
|
addressesSyncCheckbox = Share addresses with synced devices
|
||||||
updateAddressMessage = Would you like to update your address with this new information?
|
updateAddressMessage = Would you like to update your address with this new information?
|
||||||
createAddressLabel = Create New Address
|
createAddressLabel = Create New Address
|
||||||
updateAddressLabel = Update Address
|
updateAddressLabel = Update Address
|
||||||
|
|
Загрузка…
Ссылка в новой задаче