Bug 1434480 - added highlighting support via spotlightURL additions to updateAddress and updateCreditCard r?MattN draft
authormbkupfer <mbkupfer@gmail.com>
Thu, 26 Apr 2018 15:06:20 -0700
changeset 788786 5ad119f9aaaa8c21b5fd7ff93c3030c455d1e25d
parent 785586 cc0d7de218cb0c260c8ba0cf6637845ad2222f49
push id108092
push userbmo:mbkupfer@gmail.com
push dateFri, 27 Apr 2018 01:26:05 +0000
reviewersMattN
bugs1434480
milestone61.0a1
Bug 1434480 - added highlighting support via spotlightURL additions to updateAddress and updateCreditCard r?MattN MozReview-Commit-ID: DcQ3DXgKjJ0
browser/extensions/formautofill/FormAutofillDoorhanger.jsm
--- a/browser/extensions/formautofill/FormAutofillDoorhanger.jsm
+++ b/browser/extensions/formautofill/FormAutofillDoorhanger.jsm
@@ -70,16 +70,17 @@ const CONTENT = {
     },
   },
   updateAddress: {
     notificationId: "autofill-address",
     message: GetStringFromName("updateAddressMessage"),
     descriptionLabel: GetStringFromName("updateAddressDescriptionLabel"),
     descriptionIcon: false,
     linkMessage: GetStringFromName(autofillOptsKey),
+    spotlightURL: "about:preferences#privacy-address-autofill",
     anchor: {
       id: "autofill-address-notification-icon",
       URL: "chrome://formautofill/content/formfill-anchor.svg",
       tooltiptext: GetStringFromName("openAutofillMessagePanel"),
     },
     mainAction: {
       label: GetStringFromName("updateAddressLabel"),
       accessKey: GetStringFromName("updateAddressAccessKey"),
@@ -97,16 +98,17 @@ const CONTENT = {
     },
   },
   addCreditCard: {
     notificationId: "autofill-credit-card",
     message: formatStringFromName("saveCreditCardMessage", [brandShortName], 1),
     descriptionLabel: GetStringFromName("saveCreditCardDescriptionLabel"),
     descriptionIcon: true,
     linkMessage: GetStringFromName(autofillSecurityOptionsKey),
+    spotlightURL: "about:preferences#privacy-credit-card-autofill",
     anchor: {
       id: "autofill-credit-card-notification-icon",
       URL: "chrome://formautofill/content/formfill-anchor.svg",
       tooltiptext: GetStringFromName("openAutofillMessagePanel"),
     },
     mainAction: {
       label: GetStringFromName("saveCreditCardLabel"),
       accessKey: GetStringFromName("saveCreditCardAccessKey"),
@@ -152,16 +154,17 @@ const CONTENT = {
     },
   },
   updateCreditCard: {
     notificationId: "autofill-credit-card",
     message: GetStringFromName("updateCreditCardMessage"),
     descriptionLabel: GetStringFromName("updateCreditCardDescriptionLabel"),
     descriptionIcon: true,
     linkMessage: GetStringFromName(autofillOptsKey),
+    spotlightURL: "about:preferences#privacy-credit-card-autofill",
     anchor: {
       id: "autofill-credit-card-notification-icon",
       URL: "chrome://formautofill/content/formfill-anchor.svg",
       tooltiptext: GetStringFromName("openAutofillMessagePanel"),
     },
     mainAction: {
       label: GetStringFromName("updateCreditCardLabel"),
       accessKey: GetStringFromName("updateCreditCardAccessKey"),
@@ -225,23 +228,25 @@ let FormAutofillDoorhanger = {
     return chromeDoc.getElementById(notificationId);
   },
   /**
    * Append the link label element to the popupnotificationcontent.
    * @param  {XULElement} content
    *         popupnotificationcontent
    * @param  {string} message
    *         The localized string for link title.
+   * @param  {string} link
+   *         Makes it possible to open and highlight a section in preferences
    */
-  _appendPrivacyPanelLink(content, message) {
+  _appendPrivacyPanelLink(content, message, link) {
     let chromeDoc = content.ownerDocument;
     let privacyLinkElement = chromeDoc.createElement("label");
     privacyLinkElement.className = "text-link";
     privacyLinkElement.setAttribute("useoriginprincipal", true);
-    privacyLinkElement.setAttribute("href", "about:preferences#privacy");
+    privacyLinkElement.setAttribute("href", link || "about:preferences#privacy");
     privacyLinkElement.setAttribute("value", message);
     content.appendChild(privacyLinkElement);
   },
 
   /**
    * Append the description section to the popupnotificationcontent.
    * @param  {XULElement} content
    *         popupnotificationcontent
@@ -342,16 +347,17 @@ let FormAutofillDoorhanger = {
     log.debug("show doorhanger with type:", type);
     return new Promise((resolve) => {
       let {
         notificationId,
         message,
         descriptionLabel,
         descriptionIcon,
         linkMessage,
+        spotlightURL,
         anchor,
         mainAction,
         secondaryActions,
         options,
       } = CONTENT[type];
 
       const {
         ownerGlobal: chromeWin,
@@ -378,17 +384,17 @@ let FormAutofillDoorhanger = {
 
         const notificationElementId = notificationId + "-notification";
         const notification = chromeDoc.getElementById(notificationElementId);
         const notificationContent = notification.querySelector("popupnotificationcontent") ||
                                     chromeDoc.createElement("popupnotificationcontent");
         if (!notification.contains(notificationContent)) {
           notificationContent.setAttribute("orient", "vertical");
           this._appendDescription(notificationContent, descriptionLabel, descriptionIcon);
-          this._appendPrivacyPanelLink(notificationContent, linkMessage);
+          this._appendPrivacyPanelLink(notificationContent, linkMessage, spotlightURL);
           notification.append(notificationContent);
         }
         this._updateDescription(notificationContent, description);
       };
       this._setAnchor(browser, anchor);
       chromeWin.PopupNotifications.show(
         browser,
         notificationId,