diff options
Diffstat (limited to 'services/sync/tps/extensions/tps/resource/quit.sys.mjs')
-rw-r--r-- | services/sync/tps/extensions/tps/resource/quit.sys.mjs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/services/sync/tps/extensions/tps/resource/quit.sys.mjs b/services/sync/tps/extensions/tps/resource/quit.sys.mjs new file mode 100644 index 0000000000..e2cb8d8c22 --- /dev/null +++ b/services/sync/tps/extensions/tps/resource/quit.sys.mjs @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil -*- */ +/* 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/. */ + +/* + From mozilla/toolkit/content + These files did not have a license +*/ +function canQuitApplication() { + try { + var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance( + Ci.nsISupportsPRBool + ); + Services.obs.notifyObservers(cancelQuit, "quit-application-requested"); + + // Something aborted the quit process. + if (cancelQuit.data) { + return false; + } + } catch (ex) {} + + return true; +} + +export function goQuitApplication() { + if (!canQuitApplication()) { + return false; + } + + try { + Services.startup.quit(Ci.nsIAppStartup.eForceQuit); + } catch (ex) { + throw new Error(`goQuitApplication: ${ex.message}`); + } + + return true; +} |