summaryrefslogtreecommitdiffstats
path: root/comm/suite/components/shell/nsSetDefault.js
diff options
context:
space:
mode:
Diffstat (limited to 'comm/suite/components/shell/nsSetDefault.js')
-rw-r--r--comm/suite/components/shell/nsSetDefault.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/comm/suite/components/shell/nsSetDefault.js b/comm/suite/components/shell/nsSetDefault.js
new file mode 100644
index 0000000000..4d35dc4531
--- /dev/null
+++ b/comm/suite/components/shell/nsSetDefault.js
@@ -0,0 +1,53 @@
+/* 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/. */
+
+/*
+ * This component handles the startup command line arguments of the form:
+ * -setDefaultBrowser
+ * -setDefaultMail
+ * -setDefaultNews
+ * -setDefaultFeed
+ */
+
+const nsICommandLineHandler = Ci.nsICommandLineHandler;
+var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+function nsSetDefault() {
+}
+
+nsSetDefault.prototype = {
+ handle: function nsSetDefault_handle(aCmdline) {
+ if (aCmdline.handleFlag("setDefaultBrowser", false)) {
+ var shell = Cc["@mozilla.org/suite/shell-service;1"]
+ .getService(Ci.nsIShellService);
+ shell.setDefaultClient(true, true, Ci.nsIShellService.BROWSER);
+ }
+ else if (aCmdline.handleFlag("setDefaultMail", false)) {
+ var shell = Cc["@mozilla.org/suite/shell-service;1"]
+ .getService(Ci.nsIShellService);
+ shell.setDefaultClient(true, true, Ci.nsIShellService.MAIL);
+ }
+ else if (aCmdline.handleFlag("setDefaultNews", false)) {
+ var shell = Cc["@mozilla.org/suite/shell-service;1"]
+ .getService(Ci.nsIShellService);
+ shell.setDefaultClient(true, true, Ci.nsIShellService.NEWS);
+ }
+ else if (aCmdline.handleFlag("setDefaultFeed", false)) {
+ var shell = Cc["@mozilla.org/suite/shell-service;1"]
+ .getService(Ci.nsIShellService);
+ shell.setDefaultClient(true, true, Ci.nsIShellService.RSS);
+ }
+ },
+
+ helpInfo: " -setDefaultBrowser Set this app as the default browser client.\n" +
+ " -setDefaultMail Set this app as the default mail client.\n" +
+ " -setDefaultNews Set this app as the default newsreader.\n" +
+ " -setDefaultFeed Set this app as the default feedreader.\n",
+
+ classID: Components.ID("{a3d5b950-690a-491f-a881-2c2cdcd241cb}"),
+ QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler])
+}
+
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSetDefault]);
+