Skip to content

Instantly share code, notes, and snippets.

@satyr
Created December 12, 2008 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/35040 to your computer and use it in GitHub Desktop.
Save satyr/35040 to your computer and use it in GitHub Desktop.
Quick-restarts Firefox.
CmdUtils.CreateCommand({
name: 'restart',
icon: 'chrome://ubiquity/skin/icons/arrow_redo.png',
description:
(''+<>Restarts Firefox quickly.
( based on <a href="chrome://mozapps/content/extensions/extensions.js"
>restartApp</a>)</>),
execute: function(){
const os = (Cc['@mozilla.org/observer-service;1']
.getService(Ci.nsIObserverService));
const cancelQuit = (Cc['@mozilla.org/supports-PRBool;1']
.createInstance(Ci.nsISupportsPRBool));
os.notifyObservers(cancelQuit, 'quit-application-requested', 'restart');
if(cancelQuit.data) return displayMessage({
icon: this.icon, title: this.name,
text: 'Something aborted the quit process',
});
const {nsIAppStartup} = Ci;
Cc['@mozilla.org/toolkit/app-startup;1'].getService(nsIAppStartup)
.quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
},
author: 'satyr'.link('http://d.hatena.ne.jp/murky-satyr'),
license: 'MIT',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment