Bug 724963 - Port bug 728813: Restart in safe-mode in help menu when in safe-mode. r=mkmelin
authorRichard Marti <richard.marti@gmail.com>
Thu, 27 Jun 2019 20:50:38 +0200
changeset 35975 d714bac9fcfa78997c1de9d92118b61d028dedd9
parent 35974 ca1b8ae86f9bd685de4c9c2cc019c38637996977
child 35976 2bca1ea4631ec2d92364984d9e91a44ad1028c22
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersmkmelin
bugs724963, 728813
Bug 724963 - Port bug 728813: Restart in safe-mode in help menu when in safe-mode. r=mkmelin
mail/base/content/helpMenu.inc.xul
mail/base/content/mailCore.js
mail/base/content/msgMail3PaneWindow.js
mail/components/customizableui/content/panelUI.inc.xul
mail/locales/en-US/chrome/messenger/baseMenuOverlay.dtd
--- a/mail/base/content/helpMenu.inc.xul
+++ b/mail/base/content/helpMenu.inc.xul
@@ -36,16 +36,18 @@
           <menuseparator id="functionsSeparator"/>
           <menuitem id="aboutsupport_open"
                     label="&helpTroubleshootingInfo.label;"
                     accesskey="&helpTroubleshootingInfo.accesskey;"
                     oncommand="openAboutSupport();"/>
           <menuitem id="helpSafeMode"
                     label="&helpSafeMode.label;"
                     accesskey="&helpSafeMode.accesskey;"
+                    stoplabel="&helpSafeMode.stop.label;"
+                    stopaccesskey="&helpSafeMode.stop.accesskey;"
                     oncommand="safeModeRestart();"/>
 #ifndef XP_MACOSX
           <menuseparator id="aboutSeparator"/>
 #endif
           <menuitem id="aboutName"
                     label="&aboutProduct2.label;"
                     accesskey="&aboutProduct2.accesskey;"
                     oncommand="openAboutDialog();"
--- a/mail/base/content/mailCore.js
+++ b/mail/base/content/mailCore.js
@@ -625,16 +625,28 @@ function openAboutSupport() {
   tabmail.openTab("contentTab", {contentPage: "about:support",
                   clickHandler: "specialTabs.aboutClickHandler(event);" });
 }
 
 /**
  * Prompt the user to restart the browser in safe mode.
  */
 function safeModeRestart() {
+  // Is TB in safe mode?
+  if (Services.appinfo.inSafeMode) {
+    let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].
+                     createInstance(Ci.nsISupportsPRBool);
+    Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
+
+    if (cancelQuit.data)
+      return;
+
+    Services.startup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
+    return;
+  }
   // prompt the user to confirm
   let bundle = Services.strings.createBundle(
     "chrome://messenger/locale/messenger.properties");
   let promptTitle = bundle.GetStringFromName("safeModeRestartPromptTitle");
   let promptMessage = bundle.GetStringFromName("safeModeRestartPromptMessage");
   let restartText = bundle.GetStringFromName("safeModeRestartButton");
   let buttonFlags = (Services.prompt.BUTTON_POS_0 *
                      Services.prompt.BUTTON_TITLE_IS_STRING) +
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -629,16 +629,24 @@ function LoadPostAccountWizard() {
     }
     // All core modal dialogs are done, the user can now interact with the 3-pane window
     Services.obs.notifyObservers(window, "mail-startup-done");
     Services.obs.notifyObservers(this, "marionette-startup-requested");
   }
 
   setTimeout(completeStartup, 0);
 
+  let safeMode = document.getElementById("helpSafeMode");
+  let appSafeMode = document.getElementById("appmenu_safeMode");
+  if (Services.appinfo.inSafeMode) {
+    safeMode.label = safeMode.getAttribute("stoplabel");
+    safeMode.accessKey = safeMode.getAttribute("stopaccesskey");
+    appSafeMode.label = appSafeMode.getAttribute("stoplabel");
+  }
+
   // FIX ME - later we will be able to use onload from the overlay
   OnLoadMsgHeaderPane();
 
   // Set focus to the Thread Pane the first time the window is opened.
   SetFocusThreadPane();
 
   // initialize the customizeDone method on the customizeable toolbar
   var toolbox = document.getElementById("mail-toolbox");
--- a/mail/components/customizableui/content/panelUI.inc.xul
+++ b/mail/components/customizableui/content/panelUI.inc.xul
@@ -1835,16 +1835,17 @@
         <toolbarseparator/>
         <toolbarbutton id="appmenu_troubleshootingInfo"
                        class="subviewbutton subviewbutton-iconic"
                        label="&helpTroubleshootingInfo.label;"
                        oncommand="openAboutSupport();"/>
         <toolbarbutton id="appmenu_safeMode"
                        class="subviewbutton subviewbutton-iconic"
                        label="&helpSafeMode.label;"
+                       stoplabel="&helpSafeMode.stop.label;"
                        oncommand="safeModeRestart();"/>
         <toolbarseparator/>
         <toolbarbutton id="appmenu_about"
                        class="subviewbutton subviewbutton-iconic"
                        label="&aboutProduct2.label;"
                        oncommand="openAboutDialog();"/>
       </vbox>
     </panelview>
--- a/mail/locales/en-US/chrome/messenger/baseMenuOverlay.dtd
+++ b/mail/locales/en-US/chrome/messenger/baseMenuOverlay.dtd
@@ -10,16 +10,18 @@
 <!ENTITY helpMenuWin.label "Help">
 <!ENTITY helpMenuWin.accesskey "H">
 <!ENTITY aboutProduct2.label "About &brandShorterName;">
 <!ENTITY aboutProduct2.accesskey "A">
 <!ENTITY helpTroubleshootingInfo.label     "Troubleshooting Information">
 <!ENTITY helpTroubleshootingInfo.accesskey "T">
 <!ENTITY helpSafeMode.label     "Restart with Add-ons Disabled…">
 <!ENTITY helpSafeMode.accesskey "R">
+<!ENTITY helpSafeMode.stop.label     "Restart with Add-ons Enabled">
+<!ENTITY helpSafeMode.stop.accesskey "R">
 <!ENTITY productHelp.label "&brandShortName; Help">
 <!ENTITY productHelp.accesskey "H">
 <!ENTITY productHelp.commandkey "VK_F1">
 <!ENTITY productHelpMac.commandkey "?">
 <!ENTITY productHelpMac.modifiers "accel">
 
 <!ENTITY helpKeyboardShortcuts.label "Keyboard Shortcuts">
 <!ENTITY helpKeyboardShortcuts.accesskey "K">