toolkit/devtools/gcli/commands/restart.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 const { Cc, Ci, Cu } = require("chrome");
     8 const gcli = require("gcli/index");
     9 const Services = require("Services");
    11 const BRAND_SHORT_NAME = Cc["@mozilla.org/intl/stringbundle;1"]
    12                            .getService(Ci.nsIStringBundleService)
    13                            .createBundle("chrome://branding/locale/brand.properties")
    14                            .GetStringFromName("brandShortName");
    16 /**
    17  * Restart command
    18  *
    19  * @param boolean nocache
    20  *        Disables loading content from cache upon restart.
    21  *
    22  * Examples :
    23  * >> restart
    24  * - restarts browser immediately
    25  * >> restart --nocache
    26  * - restarts immediately and starts Firefox without using cache
    27  */
    28 exports.items = [
    29   {
    30     name: "restart",
    31     description: gcli.lookupFormat("restartBrowserDesc", [ BRAND_SHORT_NAME ]),
    32     params: [
    33       {
    34         name: "nocache",
    35         type: "boolean",
    36         description: gcli.lookup("restartBrowserNocacheDesc")
    37       }
    38     ],
    39     returnType: "string",
    40     exec: function Restart(args, context) {
    41       let canceled = Cc["@mozilla.org/supports-PRBool;1"]
    42                       .createInstance(Ci.nsISupportsPRBool);
    43       Services.obs.notifyObservers(canceled, "quit-application-requested", "restart");
    44       if (canceled.data) {
    45         return gcli.lookup("restartBrowserRequestCancelled");
    46       }
    48       // disable loading content from cache.
    49       if (args.nocache) {
    50         Services.appinfo.invalidateCachesOnRestart();
    51       }
    53       // restart
    54       Cc["@mozilla.org/toolkit/app-startup;1"]
    55           .getService(Ci.nsIAppStartup)
    56           .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
    57       return gcli.lookupFormat("restartBrowserRestarting", [ BRAND_SHORT_NAME ]);
    58     }
    59   }
    60 ];

mercurial