--- a/browser/extensions/formautofill/FormAutofillDoorhanger.jsm
+++ b/browser/extensions/formautofill/FormAutofillDoorhanger.jsm
@@ -21,20 +21,22 @@ Cu.import("resource://gre/modules/XPCOMU
Cu.import("resource://formautofill/FormAutofillUtils.jsm");
this.log = null;
FormAutofillUtils.defineLazyLogGetter(this, this.EXPORTED_SYMBOLS[0]);
const BUNDLE_URI = "chrome://formautofill/locale/formautofill.properties";
const GetStringFromName = Services.strings.createBundle(BUNDLE_URI).GetStringFromName;
let changeAutofillOptsKey = "changeAutofillOptions";
-let viewAutofillOptsKey = "viewAutofillOptionsLink";
-if (AppConstants.platform != "macosx") {
+let autofillOptsKey = "autofillOptionsLink";
+let autofillSecurityOptionsKey = "autofillSecurityOptionsLink";
+if (AppConstants.platform == "macosx") {
changeAutofillOptsKey += "OSX";
- viewAutofillOptsKey += "OSX";
+ autofillOptsKey += "OSX";
+ autofillSecurityOptionsKey += "OSX";
}
const CONTENT = {
firstTimeUse: {
notificationId: "autofill-address",
message: GetStringFromName("saveAddressesMessage"),
anchor: {
id: "autofill-address-notification-icon",
@@ -64,16 +66,17 @@ const CONTENT = {
log.debug("Set addresses sync to", checked);
},
},
},
},
update: {
notificationId: "autofill-address",
message: GetStringFromName("updateAddressMessage"),
+ linkMessage: GetStringFromName(autofillOptsKey),
anchor: {
id: "autofill-address-notification-icon",
URL: "chrome://formautofill/content/formfill-anchor.svg",
tooltiptext: GetStringFromName("openAutofillMessagePanel"),
},
mainAction: {
label: GetStringFromName("updateAddressLabel"),
accessKey: "U",
@@ -84,16 +87,44 @@ const CONTENT = {
accessKey: "C",
callbackState: "create",
}],
options: {
persistWhileVisible: true,
popupIconURL: "chrome://formautofill/content/icon-address-update.svg",
},
},
+ creditCard: {
+ notificationId: "autofill-credit-card",
+ message: GetStringFromName("saveCreditCardMessage"),
+ linkMessage: GetStringFromName(autofillSecurityOptionsKey),
+ anchor: {
+ id: "autofill-credit-card-notification-icon",
+ URL: "chrome://formautofill/content/formfill-anchor.svg",
+ tooltiptext: GetStringFromName("openAutofillMessagePanel"),
+ },
+ mainAction: {
+ label: GetStringFromName("saveCreditCardLabel"),
+ accessKey: "S",
+ callbackState: "save",
+ },
+ secondaryActions: [{
+ label: GetStringFromName("cancelCreditCardLabel"),
+ accessKey: "D",
+ callbackState: "cancel",
+ }, {
+ label: GetStringFromName("disableCreditCardLabel"),
+ accessKey: "N",
+ callbackState: "disable",
+ }],
+ options: {
+ persistWhileVisible: true,
+ popupIconURL: "chrome://formautofill/content/icon-credit-card.svg",
+ },
+ },
};
let FormAutofillDoorhanger = {
/**
* Generate the main action and secondary actions from content parameters and
* promise resolve.
*
* @private
@@ -131,29 +162,31 @@ let FormAutofillDoorhanger = {
return [mainAction, secondaryActions];
},
/**
* Append the link label element to the popupnotificationcontent.
* @param {XULElement} browser
* Target browser element for showing doorhanger.
* @param {string} id
* The ID of the doorhanger.
+ * @param {string} message
+ * The localized string for link title.
*/
- _appendPrivacyPanelLink(browser, id) {
+ _appendPrivacyPanelLink(browser, id, message) {
let notificationId = id + "-notification";
let chromeDoc = browser.ownerDocument;
let notification = chromeDoc.getElementById(notificationId);
if (!notification.querySelector("popupnotificationcontent")) {
let notificationcontent = chromeDoc.createElement("popupnotificationcontent");
let privacyLinkElement = chromeDoc.createElement("label");
privacyLinkElement.className = "text-link";
privacyLinkElement.setAttribute("useoriginprincipal", true);
privacyLinkElement.setAttribute("href", "about:preferences#privacy");
- privacyLinkElement.setAttribute("value", GetStringFromName(viewAutofillOptsKey));
+ privacyLinkElement.setAttribute("value", message);
notificationcontent.appendChild(privacyLinkElement);
notification.append(notificationcontent);
}
},
/**
* Create an image element for notification anchor if it doesn't already exist.
* @param {XULElement} browser
* Target browser element for showing doorhanger.
@@ -216,43 +249,52 @@ let FormAutofillDoorhanger = {
* @param {string} type
* The type of the doorhanger. There will have first time use/update/credit card.
* @returns {Promise}
Resolved with action type when action callback is triggered.
*/
async show(browser, type) {
log.debug("show doorhanger with type:", type);
return new Promise((resolve) => {
- let content = CONTENT[type];
+ let {
+ notificationId,
+ message,
+ linkMessage,
+ anchor,
+ mainAction,
+ secondaryActions,
+ options,
+ } = CONTENT[type];
+
let chromeWin = browser.ownerGlobal;
- content.options.eventCallback = (topic) => {
+ options.eventCallback = (topic) => {
log.debug("eventCallback:", topic);
if (topic == "removed" || topic == "dismissed") {
- this._removeCheckboxListener(browser, content);
+ this._removeCheckboxListener(browser, {notificationId, options});
return;
}
// The doorhanger is customizable only when notification box is shown
if (topic != "shown") {
return;
}
- this._addCheckboxListener(browser, content);
+ this._addCheckboxListener(browser, {notificationId, options});
// There's no preferences link or other customization in first time use doorhanger.
if (type == "firstTimeUse") {
return;
}
- this._appendPrivacyPanelLink(browser, content.notificationId);
+ this._appendPrivacyPanelLink(browser, notificationId, linkMessage);
};
- this._setAnchor(browser, content.anchor);
+ this._setAnchor(browser, anchor);
chromeWin.PopupNotifications.show(
browser,
- content.notificationId,
- content.message,
- content.anchor.id,
- ...this._createActions(content.mainAction, content.secondaryActions, resolve),
- content.options,
+ notificationId,
+ message,
+ anchor.id,
+ ...this._createActions(mainAction, secondaryActions, resolve),
+ options,
);
});
},
};