1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/shell/src/nsSetDefaultBrowser.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +/* 1.9 + * -setDefaultBrowser commandline handler 1.10 + * Makes the current executable the "default browser". 1.11 + */ 1.12 + 1.13 +const Cc = Components.classes; 1.14 +const Ci = Components.interfaces; 1.15 +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); 1.16 + 1.17 +function nsSetDefaultBrowser() {} 1.18 + 1.19 +nsSetDefaultBrowser.prototype = { 1.20 + handle: function nsSetDefault_handle(aCmdline) { 1.21 + if (aCmdline.handleFlag("setDefaultBrowser", false)) { 1.22 + var shell = Cc["@mozilla.org/browser/shell-service;1"]. 1.23 + getService(Ci.nsIShellService); 1.24 + shell.setDefaultBrowser(true, true); 1.25 + } 1.26 + }, 1.27 + 1.28 + helpInfo: " -setDefaultBrowser Set this app as the default browser.\n", 1.29 + 1.30 + classID: Components.ID("{F57899D0-4E2C-4ac6-9E29-50C736103B0C}"), 1.31 + QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), 1.32 +}; 1.33 + 1.34 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSetDefaultBrowser]);