forked from mirrors/gecko-dev
		
	 75ea156d47
			
		
	
	
		75ea156d47
		
	
	
	
	
		
			
			Differential Revision: https://phabricator.services.mozilla.com/D55857 --HG-- rename : toolkit/components/alerts/resources/content/alert.xul => toolkit/components/alerts/resources/content/alert.xhtml rename : toolkit/components/apppicker/content/appPicker.xul => toolkit/components/apppicker/content/appPicker.xhtml rename : toolkit/components/extensions/dummy.xul => toolkit/components/extensions/dummy.xhtml rename : toolkit/components/passwordmgr/content/passwordManager.xul => toolkit/components/passwordmgr/content/passwordManager.xhtml rename : toolkit/components/printing/content/printPageSetup.xul => toolkit/components/printing/content/printPageSetup.xhtml rename : toolkit/components/printing/content/printPreviewProgress.xul => toolkit/components/printing/content/printPreviewProgress.xhtml rename : toolkit/components/printing/content/printProgress.xul => toolkit/components/printing/content/printProgress.xhtml rename : toolkit/components/prompts/content/commonDialog.xul => toolkit/components/prompts/content/commonDialog.xhtml rename : toolkit/components/prompts/content/selectDialog.xul => toolkit/components/prompts/content/selectDialog.xhtml rename : toolkit/components/viewconfig/content/config.xul => toolkit/components/viewconfig/content/config.xhtml rename : toolkit/content/editMenuKeys.inc.xul => toolkit/content/editMenuKeys.inc.xhtml rename : toolkit/content/resetProfile.xul => toolkit/content/resetProfile.xhtml rename : toolkit/content/resetProfileProgress.xul => toolkit/content/resetProfileProgress.xhtml rename : toolkit/modules/win.xul => toolkit/modules/win.xhtml rename : toolkit/profile/content/createProfileWizard.xul => toolkit/profile/content/createProfileWizard.xhtml rename : toolkit/profile/content/profileDowngrade.xul => toolkit/profile/content/profileDowngrade.xhtml rename : toolkit/profile/content/profileSelection.xul => toolkit/profile/content/profileSelection.xhtml extra : moz-landing-system : lando
		
			
				
	
	
		
			90 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 | |
| /* 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/. */
 | |
| 
 | |
| const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 | |
| 
 | |
| const appStartup = Services.startup;
 | |
| 
 | |
| const { ResetProfile } = ChromeUtils.import(
 | |
|   "resource://gre/modules/ResetProfile.jsm"
 | |
| );
 | |
| 
 | |
| var defaultToReset = false;
 | |
| 
 | |
| function restartApp() {
 | |
|   appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
 | |
| }
 | |
| 
 | |
| function resetProfile() {
 | |
|   // Set the reset profile environment variable.
 | |
|   let env = Cc["@mozilla.org/process/environment;1"].getService(
 | |
|     Ci.nsIEnvironment
 | |
|   );
 | |
|   env.set("MOZ_RESET_PROFILE_RESTART", "1");
 | |
| }
 | |
| 
 | |
| function showResetDialog() {
 | |
|   // Prompt the user to confirm the reset.
 | |
|   let retVals = {
 | |
|     reset: false,
 | |
|   };
 | |
|   window.openDialog(
 | |
|     "chrome://global/content/resetProfile.xhtml",
 | |
|     null,
 | |
|     "chrome,modal,centerscreen,titlebar,dialog=yes",
 | |
|     retVals
 | |
|   );
 | |
|   if (!retVals.reset) {
 | |
|     return;
 | |
|   }
 | |
|   resetProfile();
 | |
|   restartApp();
 | |
| }
 | |
| 
 | |
| function onDefaultButton(event) {
 | |
|   if (defaultToReset) {
 | |
|     // Prevent starting into safe mode while restarting.
 | |
|     event.preventDefault();
 | |
|     // Restart to reset the profile.
 | |
|     resetProfile();
 | |
|     restartApp();
 | |
|   }
 | |
|   // Dialog will be closed by default Event handler.
 | |
|   // Continue in safe mode. No restart needed.
 | |
| }
 | |
| 
 | |
| function onCancel() {
 | |
|   appStartup.quit(appStartup.eForceQuit);
 | |
| }
 | |
| 
 | |
| function onExtra1() {
 | |
|   if (defaultToReset) {
 | |
|     // Continue in safe mode
 | |
|     window.close();
 | |
|   }
 | |
|   // The reset dialog will handle starting the reset process if the user confirms.
 | |
|   showResetDialog();
 | |
| }
 | |
| 
 | |
| function onLoad() {
 | |
|   const dialog = document.getElementById("safeModeDialog");
 | |
|   if (appStartup.automaticSafeModeNecessary) {
 | |
|     document.getElementById("autoSafeMode").hidden = false;
 | |
|     document.getElementById("safeMode").hidden = true;
 | |
|     if (ResetProfile.resetSupported()) {
 | |
|       document.getElementById("resetProfile").hidden = false;
 | |
|     } else {
 | |
|       // Hide the reset button is it's not supported.
 | |
|       dialog.getButton("extra1").hidden = true;
 | |
|     }
 | |
|   } else if (!ResetProfile.resetSupported()) {
 | |
|     // Hide the reset button and text if it's not supported.
 | |
|     dialog.getButton("extra1").hidden = true;
 | |
|     document.getElementById("resetProfileInstead").hidden = true;
 | |
|   }
 | |
|   document.addEventListener("dialogaccept", onDefaultButton);
 | |
|   document.addEventListener("dialogcancel", onCancel);
 | |
|   document.addEventListener("dialogextra1", onExtra1);
 | |
| }
 |