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 const Cc = Components.classes;
6 const Ci = Components.interfaces;
7 const CC = Components.Constructor;
8 const Cu = Components.utils;
10 Cu.import("resource://gre/modules/Services.jsm");
12 let EXPORTED_SYMBOLS = ["WebappOSUtils"];
15 launch: function(aData) {
19 let open = CC("@mozilla.org/windows-registry-key;1",
20 "nsIWindowsRegKey", "open");
21 let initWithPath = CC("@mozilla.org/file/local;1",
22 "nsILocalFile", "initWithPath");
23 let initProcess = CC("@mozilla.org/process/util;1",
24 "nsIProcess", "init");
26 appRegKey = open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
27 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" +
28 aData.origin, Ci.nsIWindowsRegKey.ACCESS_READ);
30 let launchTarget = initWithPath(appRegKey.readStringValue("InstallLocation"));
31 launchTarget.append(appRegKey.readStringValue("AppFilename") + ".exe");
33 let process = initProcess(launchTarget);
34 process.runwAsync([], 0);
45 let mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]
46 .createInstance(Ci.nsIMacWebAppUtils);
49 appPath = mwaUtils.pathForAppWithIdentifier(aData.origin);
53 mwaUtils.launchAppWithIdentifier(aData.origin);
59 let origin = Services.io.newURI(aData.origin, null, null);
60 let installDir = "." + origin.scheme + ";" +
62 (origin.port != -1 ? ";" + origin.port : "");
64 let exeFile = Services.dirsvc.get("Home", Ci.nsIFile);
65 exeFile.append(installDir);
66 exeFile.append("webapprt-stub");
69 if (exeFile.exists()) {
70 let process = Cc["@mozilla.org/process/util;1"]
71 .createInstance(Ci.nsIProcess);
72 process.init(exeFile);
73 process.runAsync([], 0);
82 uninstall: function(aData) {
85 let origin = Services.io.newURI(aData.origin, null, null);
86 let installDir = "." + origin.scheme + ";" +
88 (origin.port != -1 ? ";" + origin.port : "");
90 let exeFile = Services.dirsvc.get("Home", Ci.nsIFile);
91 exeFile.append(installDir);
92 exeFile.append("webapprt-stub");
95 if (exeFile.exists()) {
96 var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
97 process.init(exeFile);
98 process.runAsync(["-remove"], 1);