morgan pushed to branch tor-browser-140.2.0esr-15.0-1 at The Tor Project / Applications / Tor Browser

Commits:

8 changed files:

Changes:

  • browser/components/securitylevel/content/securityLevelDialog.js
    ... ... @@ -39,8 +39,8 @@ const gSecurityLevelDialog = {
    39 39
       async init() {
    
    40 40
         const dialog = document.getElementById("security-level-dialog");
    
    41 41
         dialog.addEventListener("dialogaccept", event => {
    
    42
    +      event.preventDefault();
    
    42 43
           if (this._acceptButton.disabled) {
    
    43
    -        event.preventDefault();
    
    44 44
             return;
    
    45 45
           }
    
    46 46
           this._commitChange();
    
    ... ... @@ -158,7 +158,41 @@ const gSecurityLevelDialog = {
    158 158
       /**
    
    159 159
        * Commit the change in security level and restart the browser.
    
    160 160
        */
    
    161
    -  _commitChange() {
    
    161
    +  async _commitChange() {
    
    162
    +    const doNotWarnPref = "browser.security_level.disable_warn_before_restart";
    
    163
    +    if (!Services.prefs.getBoolPref(doNotWarnPref, false)) {
    
    164
    +      const [titleString, bodyString, checkboxString, restartString] =
    
    165
    +        await document.l10n.formatValues([
    
    166
    +          { id: "security-level-restart-warning-dialog-title" },
    
    167
    +          { id: "security-level-restart-warning-dialog-body" },
    
    168
    +          { id: "restart-warning-dialog-do-not-warn-checkbox" },
    
    169
    +          { id: "restart-warning-dialog-restart-button" },
    
    170
    +        ]);
    
    171
    +      const flags =
    
    172
    +        Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
    
    173
    +        Services.prompt.BUTTON_POS_0_DEFAULT +
    
    174
    +        Services.prompt.BUTTON_DEFAULT_IS_DESTRUCTIVE +
    
    175
    +        Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL;
    
    176
    +      const propBag = await Services.prompt.asyncConfirmEx(
    
    177
    +        window.browsingContext.top,
    
    178
    +        Services.prompt.MODAL_TYPE_CONTENT,
    
    179
    +        titleString,
    
    180
    +        bodyString,
    
    181
    +        flags,
    
    182
    +        restartString,
    
    183
    +        null,
    
    184
    +        null,
    
    185
    +        checkboxString,
    
    186
    +        false,
    
    187
    +        { useTitle: true, noIcon: true }
    
    188
    +      );
    
    189
    +      if (propBag.get("buttonNumClicked") !== 0) {
    
    190
    +        return;
    
    191
    +      }
    
    192
    +      if (propBag.get("checked")) {
    
    193
    +        Services.prefs.setBoolPref(doNotWarnPref, true);
    
    194
    +      }
    
    195
    +    }
    
    162 196
         SecurityLevelPrefs.setSecurityLevelBeforeRestart(this._selectedLevel);
    
    163 197
         Services.startup.quit(
    
    164 198
           Services.startup.eAttemptQuit | Services.startup.eRestart
    

  • browser/modules/SecurityLevelRestartNotification.sys.mjs
    ... ... @@ -42,11 +42,13 @@ export const SecurityLevelRestartNotification = {
    42 42
           await lazy.NotificationStrings.formatValues([
    
    43 43
             { id: "security-level-restart-prompt-title" },
    
    44 44
             { id: "security-level-restart-prompt-body" },
    
    45
    -        { id: "security-level-restart-prompt-button-restart" },
    
    45
    +        { id: "restart-warning-dialog-restart-button" },
    
    46 46
             { id: "security-level-restart-prompt-button-ignore" },
    
    47 47
           ]);
    
    48 48
         const buttonFlags =
    
    49 49
           Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
    
    50
    +      Services.prompt.BUTTON_POS_0_DEFAULT +
    
    51
    +      Services.prompt.BUTTON_DEFAULT_IS_DESTRUCTIVE +
    
    50 52
           Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_1;
    
    51 53
     
    
    52 54
         const propBag = await Services.prompt.asyncConfirmEx(
    

  • netwerk/base/nsIPrompt.idl
    ... ... @@ -67,6 +67,8 @@ interface nsIPrompt : nsISupports
    67 67
     
    
    68 68
         const unsigned long BUTTON_POS_1_IS_SECONDARY  = 1 << 29;
    
    69 69
     
    
    70
    +    const unsigned long BUTTON_DEFAULT_IS_DESTRUCTIVE = 1 << 30;
    
    71
    +
    
    70 72
         const unsigned long STD_OK_CANCEL_BUTTONS      = (BUTTON_TITLE_OK * BUTTON_POS_0) +
    
    71 73
                                                         (BUTTON_TITLE_CANCEL * BUTTON_POS_1);
    
    72 74
         const unsigned long STD_YES_NO_BUTTONS         = (BUTTON_TITLE_YES * BUTTON_POS_0) +
    

  • toolkit/components/prompts/content/commonDialog.js
    ... ... @@ -39,7 +39,7 @@ function commonDialogOnLoad() {
    39 39
         ["promptUserAndPass", "promptPassword"].includes(args.promptType) ||
    
    40 40
         args.headerIconCSSValue;
    
    41 41
       let root = document.documentElement;
    
    42
    -  if (needIconifiedHeader) {
    
    42
    +  if (needIconifiedHeader && !args.noIcon) {
    
    43 43
         root.setAttribute("neediconheader", "true");
    
    44 44
       }
    
    45 45
       let title = { raw: args.title };
    
    ... ... @@ -107,6 +107,10 @@ function commonDialogOnLoad() {
    107 107
         dialog.setAttribute("extra1-is-secondary", true);
    
    108 108
       }
    
    109 109
     
    
    110
    +  if (args.isDefaultDestructive) {
    
    111
    +    dialog.setAttribute("default-is-destructive", true);
    
    112
    +  }
    
    113
    +
    
    110 114
       Dialog = new CommonDialog(args, ui);
    
    111 115
       window.addEventListener("dialogclosing", function (aEvent) {
    
    112 116
         if (aEvent.detail?.abort) {
    

  • toolkit/components/prompts/src/Prompter.sys.mjs
    ... ... @@ -1507,6 +1507,10 @@ class ModalPrompter {
    1507 1507
           args.isExtra1Secondary = true;
    
    1508 1508
         }
    
    1509 1509
     
    
    1510
    +    if (flags & Ci.nsIPrompt.BUTTON_DEFAULT_IS_DESTRUCTIVE) {
    
    1511
    +      args.isDefaultDestructive = true;
    
    1512
    +    }
    
    1513
    +
    
    1510 1514
         if (flags & Ci.nsIPrompt.SHOW_SPINNER) {
    
    1511 1515
           args.headerIconCSSValue = "url('chrome://global/skin/icons/loading.svg')";
    
    1512 1516
         }
    

  • toolkit/components/windowwatcher/nsIPromptService.idl
    ... ... @@ -287,6 +287,8 @@ interface nsIPromptService : nsISupports
    287 287
        */
    
    288 288
       const unsigned long BUTTON_POS_1_IS_SECONDARY  = 1 << 29;
    
    289 289
     
    
    290
    +  const unsigned long BUTTON_DEFAULT_IS_DESTRUCTIVE = 1 << 30;
    
    291
    +
    
    290 292
       /**
    
    291 293
        * Selects the standard set of OK/Cancel buttons.
    
    292 294
        */
    

  • toolkit/content/widgets/dialog.js
    ... ... @@ -21,7 +21,8 @@
    21 21
         static get observedAttributes() {
    
    22 22
           return super.observedAttributes.concat(
    
    23 23
             "subdialog",
    
    24
    -        "extra1-is-secondary"
    
    24
    +        "extra1-is-secondary",
    
    25
    +        "default-is-destructive"
    
    25 26
           );
    
    26 27
         }
    
    27 28
     
    
    ... ... @@ -40,6 +41,12 @@
    40 41
           if (name === "extra1-is-secondary" && AppConstants.XP_UNIX) {
    
    41 42
             this.getButton("cancel").after(this.getButton("extra1"));
    
    42 43
           }
    
    44
    +      if (name === "default-is-destructive") {
    
    45
    +        this.#setButtonIsDestructive(
    
    46
    +          this.getButton(this.defaultButton),
    
    47
    +          this.hasAttribute("default-is-destructive")
    
    48
    +        );
    
    49
    +      }
    
    43 50
           super.attributeChangedCallback(name, oldValue, newValue);
    
    44 51
         }
    
    45 52
     
    
    ... ... @@ -491,12 +498,17 @@
    491 498
           var oldDefaultButton = this.getButton(this.defaultButton);
    
    492 499
           if (oldDefaultButton) {
    
    493 500
             oldDefaultButton.removeAttribute("default");
    
    501
    +        this.#setButtonIsDestructive(oldDefaultButton, false);
    
    494 502
           }
    
    495 503
     
    
    496 504
           var newDefaultButton = this.getButton(aNewDefault);
    
    497 505
           if (newDefaultButton) {
    
    498 506
             this.setAttribute("defaultButton", aNewDefault);
    
    499 507
             newDefaultButton.setAttribute("default", "true");
    
    508
    +        this.#setButtonIsDestructive(
    
    509
    +          newDefaultButton,
    
    510
    +          this.hasAttribute("default-is-destructive")
    
    511
    +        );
    
    500 512
           } else {
    
    501 513
             this.setAttribute("defaultButton", "none");
    
    502 514
             if (aNewDefault != "none") {
    
    ... ... @@ -507,6 +519,16 @@
    507 519
           }
    
    508 520
         }
    
    509 521
     
    
    522
    +    /**
    
    523
    +     * Mark or un-mark a button as a destructive action.
    
    524
    +     *
    
    525
    +     * @param {?Element} button - The button to mark.
    
    526
    +     * @param {boolean} isDestructive - Whether the button is destructive.
    
    527
    +     */
    
    528
    +    #setButtonIsDestructive(button, isDestructive) {
    
    529
    +      button?.classList.toggle("danger-button", isDestructive);
    
    530
    +    }
    
    531
    +
    
    510 532
         _handleButtonCommand(aEvent) {
    
    511 533
           return this._doButtonCommand(aEvent.target.getAttribute("dlgtype"));
    
    512 534
         }
    

  • toolkit/locales/en-US/toolkit/global/base-browser.ftl
    ... ... @@ -177,6 +177,13 @@ security-level-preferences-bullet-limit-media = Audio and video (HTML5 media), a
    177 177
     security-level-preferences-bullet-disabled-javascript = JavaScript is disabled by default on all sites.
    
    178 178
     security-level-preferences-bullet-limit-font-and-symbols-and-images = Some fonts, icons, math symbols, and images are disabled.
    
    179 179
     
    
    180
    +## Security level dialog warning the user about a restart.
    
    181
    +
    
    182
    +# '-brand-short-name' is the localized browser name, like "Tor Browser".
    
    183
    +security-level-restart-warning-dialog-title = Restart { -brand-short-name } to apply changes?
    
    184
    +# '-brand-short-name' is the localized browser name, like "Tor Browser".
    
    185
    +security-level-restart-warning-dialog-body = { -brand-short-name } needs to restart to apply your changes. This will close all your windows and tabs.
    
    186
    +
    
    180 187
     ## Custom security level.
    
    181 188
     ## Some custom preferences configuration has placed the user outside one of the standard three levels.
    
    182 189
     
    
    ... ... @@ -188,5 +195,12 @@ security-level-summary-custom = Your custom browser preferences have resulted in
    188 195
     
    
    189 196
     security-level-restart-prompt-title = Your security level settings require a restart
    
    190 197
     security-level-restart-prompt-body = You must restart { -brand-short-name } for your security level settings to be applied. This will close all your windows and tabs.
    
    191
    -security-level-restart-prompt-button-restart = Restart
    
    192 198
     security-level-restart-prompt-button-ignore = Ignore
    
    199
    +
    
    200
    +## Part of the restart dialogs for security level and new identity.
    
    201
    +
    
    202
    +# Checkbox to never show the restart warning dialog again.
    
    203
    +restart-warning-dialog-do-not-warn-checkbox = Don’t show this warning again
    
    204
    +# Button to restart the browser.
    
    205
    +# '-brand-short-name' is the localized browser name, like "Tor Browser".
    
    206
    +restart-warning-dialog-restart-button = Restart { -brand-short-name }