Commit 7535773c authored by henry's avatar henry Committed by morgan
Browse files

fixup! BB 40926: Implemented the New Identity feature

TB 44034: Update new identity checkbox string.

TB 44040: Use the prompt API for new identity.
parent 8f29664e
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#infoTitle {
  font-weight: 600;
}
+0 −17
Original line number Diff line number Diff line
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

document.addEventListener("dialogaccept", () => {
  const retvals = window.arguments[0];
  retvals.confirmed = true;
  retvals.neverAskAgain = document.getElementById("neverAskAgain").checked;
});

document.addEventListener("DOMContentLoaded", () => {
  const dialog = document.getElementById("newIdentityDialog");

  const accept = dialog.getButton("accept");
  document.l10n.setAttributes(accept, "new-identity-dialog-confirm");
  accept.classList.add("danger-button");
});
+0 −65
Original line number Diff line number Diff line
<?xml version="1.0"?>

<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<!-- based on resetProfile.xhtml -->

<?csp default-src chrome: ?>

<window
  id="newIdentityDialogWindow"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  aria-labelledby="infoTitle"
  aria-describedby="infoBody"
>
  <dialog id="newIdentityDialog" buttons="accept,cancel" defaultButton="accept">
    <linkset>
      <html:link rel="stylesheet" href="chrome://global/skin/global.css" />
      <html:link
        rel="stylesheet"
        href="chrome://global/content/commonDialog.css"
      />
      <html:link
        rel="stylesheet"
        href="chrome://global/skin/commonDialog.css"
      />
      <html:link
        rel="stylesheet"
        href="chrome://browser/content/newIdentityDialog.css"
      />

      <html:link rel="localization" href="branding/brand.ftl" />
      <html:link rel="localization" href="toolkit/global/base-browser.ftl" />
    </linkset>

    <div xmlns="http://www.w3.org/1999/xhtml">
      <div id="dialogGrid">
        <div class="dialogRow" id="infoRow">
          <div id="iconContainer">
            <xul:image id="infoIcon" />
          </div>
          <div id="infoContainer">
            <xul:description
              id="infoTitle"
              data-l10n-id="new-identity-dialog-title"
            />
            <xul:description
              id="infoBody"
              data-l10n-id="new-identity-dialog-description"
            />
            <xul:checkbox
              id="neverAskAgain"
              data-l10n-id="new-identity-dialog-never-ask-checkbox"
            />
          </div>
        </div>
      </div>
    </div>

    <script src="chrome://browser/content/newIdentityDialog.js" />
  </dialog>
</window>
+28 −9
Original line number Diff line number Diff line
@@ -513,18 +513,37 @@ ChromeUtils.defineLazyGetter(this, "NewIdentityButton", () => {
        const prefConfirm = "browser.new_identity.confirm_newnym";
        const shouldConfirm = Services.prefs.getBoolPref(prefConfirm, true);
        if (shouldConfirm) {
          const params = {
            confirmed: false,
            neverAskAgain: false,
          };
          await window.gDialogBox.open(
            "chrome://browser/content/newIdentityDialog.xhtml",
            params
          const [titleString, bodyString, checkboxString, restartString] =
            await document.l10n.formatValues([
              { id: "new-identity-dialog-title" },
              { id: "new-identity-dialog-description" },
              { id: "restart-warning-dialog-do-not-warn-checkbox" },
              { id: "restart-warning-dialog-restart-button" },
            ]);
          const flags =
            Services.prompt.BUTTON_POS_0 *
              Services.prompt.BUTTON_TITLE_IS_STRING +
            Services.prompt.BUTTON_POS_0_DEFAULT +
            Services.prompt.BUTTON_DEFAULT_IS_DESTRUCTIVE +
            Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL;
          const propBag = await Services.prompt.asyncConfirmEx(
            window.browsingContext,
            Services.prompt.MODAL_TYPE_INTERNAL_WINDOW,
            titleString,
            bodyString,
            flags,
            restartString,
            null,
            null,
            checkboxString,
            false
          );
          Services.prefs.setBoolPref(prefConfirm, !params.neverAskAgain);
          if (!params.confirmed) {
          if (propBag.get("buttonNumClicked") !== 0) {
            return;
          }
          if (propBag.get("checked")) {
            Services.prefs.setBoolPref(prefConfirm, false);
          }
        }

        const impl = new NewIdentityImpl();
+0 −3
Original line number Diff line number Diff line
browser.jar:
    content/browser/newidentity.js             (content/newidentity.js)
    content/browser/newIdentityDialog.xhtml    (content/newIdentityDialog.xhtml)
    content/browser/newIdentityDialog.css      (content/newIdentityDialog.css)
    content/browser/newIdentityDialog.js       (content/newIdentityDialog.js)