[tbb-commits] [tor-browser] branch tor-browser-102.5.0esr-12.5-1 updated: fixup! Bug 40926: Implemented the New Identity feature

gitolite role git at cupani.torproject.org
Tue Dec 6 09:59:31 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch tor-browser-102.5.0esr-12.5-1
in repository tor-browser.

The following commit(s) were added to refs/heads/tor-browser-102.5.0esr-12.5-1 by this push:
     new b92006098180 fixup! Bug 40926: Implemented the New Identity feature
b92006098180 is described below

commit b9200609818021476cc21c523c147435d814c74f
Author: Pier Angelo Vendrame <pierov at torproject.org>
AuthorDate: Tue Nov 22 10:13:45 2022 +0100

    fixup! Bug 40926: Implemented the New Identity feature
    
    Bug 41448: Use `danger` style for primary button in new identity modal
---
 .../newidentity/content/newIdentityDialog.css      |  7 ++++
 .../newidentity/content/newIdentityDialog.js       | 24 +++++++++++
 .../newidentity/content/newIdentityDialog.xhtml    | 46 ++++++++++++++++++++++
 .../components/newidentity/content/newidentity.js  | 31 ++++++---------
 browser/components/newidentity/jar.mn              |  5 ++-
 5 files changed, 92 insertions(+), 21 deletions(-)

diff --git a/browser/components/newidentity/content/newIdentityDialog.css b/browser/components/newidentity/content/newIdentityDialog.css
new file mode 100644
index 000000000000..850e7c7da625
--- /dev/null
+++ b/browser/components/newidentity/content/newIdentityDialog.css
@@ -0,0 +1,7 @@
+/* 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;
+}
diff --git a/browser/components/newidentity/content/newIdentityDialog.js b/browser/components/newidentity/content/newIdentityDialog.js
new file mode 100644
index 000000000000..7b29fdaabd19
--- /dev/null
+++ b/browser/components/newidentity/content/newIdentityDialog.js
@@ -0,0 +1,24 @@
+/* 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.querySelector("#neverAskAgain").checked;
+});
+
+document.addEventListener("DOMContentLoaded", () => {
+  const { NewIdentityStrings } = window.arguments[0];
+  const dialog = document.querySelector("#newIdentityDialog");
+
+  dialog.querySelector("#infoTitle").textContent =
+    NewIdentityStrings.new_identity_prompt_title;
+  dialog.querySelector("#infoBody").textContent =
+    NewIdentityStrings.new_identity_prompt;
+  dialog.querySelector("#neverAskAgain").label =
+    NewIdentityStrings.new_identity_ask_again;
+  const accept = dialog.getButton("accept");
+  accept.label = NewIdentityStrings.new_identity_restart;
+  accept.classList.add("danger-button");
+});
diff --git a/browser/components/newidentity/content/newIdentityDialog.xhtml b/browser/components/newidentity/content/newIdentityDialog.xhtml
new file mode 100644
index 000000000000..067c64015a31
--- /dev/null
+++ b/browser/components/newidentity/content/newIdentityDialog.xhtml
@@ -0,0 +1,46 @@
+<?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 -->
+
+<?xml-stylesheet href="chrome://global/skin/global.css"?>
+<?xml-stylesheet href="chrome://global/content/commonDialog.css"?>
+<?xml-stylesheet href="chrome://global/skin/commonDialog.css"?>
+<?xml-stylesheet href="chrome://browser/content/newIdentityDialog.css"?>
+
+<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-describedby="infoBody">
+<dialog id="newIdentityDialog"
+        buttons="accept,cancel"
+        defaultButton="accept">
+
+  <linkset>
+    <!-- Without this document.l10n is not initialized, and we need it for the
+    cancel button. -->
+    <html:link rel="localization" href="branding/brand.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"/>
+          <xul:description id="infoBody" context="contentAreaContextMenu" noinitialfocus="true"/>
+          <xul:checkbox id="neverAskAgain"/>
+        </div>
+      </div>
+    </div>
+  </div>
+
+  <script src="chrome://browser/content/newIdentityDialog.js"/>
+</dialog>
+</window>
diff --git a/browser/components/newidentity/content/newidentity.js b/browser/components/newidentity/content/newidentity.js
index cad74e9cddf9..7c1332da6e63 100644
--- a/browser/components/newidentity/content/newidentity.js
+++ b/browser/components/newidentity/content/newidentity.js
@@ -528,26 +528,17 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
         const prefConfirm = "browser.new_identity.confirm_newnym";
         const shouldConfirm = Services.prefs.getBoolPref(prefConfirm, true);
         if (shouldConfirm) {
-          // Display two buttons, both with string titles.
-          const flags =
-            Services.prompt.BUTTON_TITLE_IS_STRING *
-              Services.prompt.BUTTON_POS_0 +
-            Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1;
-          const askAgain = { value: false };
-          const confirmed =
-            Services.prompt.confirmEx(
-              window,
-              NewIdentityStrings.new_identity_prompt_title,
-              NewIdentityStrings.new_identity_prompt,
-              flags,
-              NewIdentityStrings.new_identity_restart,
-              null,
-              null,
-              NewIdentityStrings.new_identity_ask_again,
-              askAgain
-            ) == 0;
-          Services.prefs.setBoolPref(prefConfirm, !askAgain.value);
-          if (!confirmed) {
+          const params = {
+            NewIdentityStrings,
+            confirmed: false,
+            neverAskAgain: false,
+          };
+          await window.gDialogBox.open(
+            "chrome://browser/content/newIdentityDialog.xhtml",
+            params
+          );
+          Services.prefs.setBoolPref(prefConfirm, !params.neverAskAgain);
+          if (!params.confirmed) {
             return;
           }
         }
diff --git a/browser/components/newidentity/jar.mn b/browser/components/newidentity/jar.mn
index 57b30b32c0e1..51b9770fc635 100644
--- a/browser/components/newidentity/jar.mn
+++ b/browser/components/newidentity/jar.mn
@@ -1,5 +1,8 @@
 browser.jar:
-    content/browser/newidentity.js       (content/newidentity.js)
+    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)
 
 newidentity.jar:
 # We need to list at least one locale here, to make Firefox load the localized

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list