зеркало из https://github.com/mozilla/gecko-dev.git
Bug 774142. Support webapp uninstallation on Linux through mozApps.uninstall function. r=felipe
This commit is contained in:
Родитель
50a2b14927
Коммит
5271271248
|
@ -18,11 +18,13 @@ let webappsUI = {
|
|||
init: function webappsUI_init() {
|
||||
Services.obs.addObserver(this, "webapps-ask-install", false);
|
||||
Services.obs.addObserver(this, "webapps-launch", false);
|
||||
Services.obs.addObserver(this, "webapps-uninstall", false);
|
||||
},
|
||||
|
||||
uninit: function webappsUI_uninit() {
|
||||
Services.obs.removeObserver(this, "webapps-ask-install");
|
||||
Services.obs.removeObserver(this, "webapps-launch");
|
||||
Services.obs.removeObserver(this, "webapps-uninstall");
|
||||
},
|
||||
|
||||
observe: function webappsUI_observe(aSubject, aTopic, aData) {
|
||||
|
@ -37,6 +39,9 @@ let webappsUI = {
|
|||
case "webapps-launch":
|
||||
WebappOSUtils.launch(data);
|
||||
break;
|
||||
case "webapps-uninstall":
|
||||
WebappOSUtils.uninstall(data);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -221,6 +221,7 @@ let DOMApplicationRegistry = {
|
|||
this.getSelf(msg);
|
||||
break;
|
||||
case "Webapps:Uninstall":
|
||||
Services.obs.notifyObservers(this, "webapps-uninstall", JSON.stringify(msg));
|
||||
this.uninstall(msg);
|
||||
break;
|
||||
case "Webapps:Launch":
|
||||
|
|
|
@ -57,9 +57,9 @@ let WebappOSUtils = {
|
|||
return false;
|
||||
#elifdef XP_UNIX
|
||||
let origin = Services.io.newURI(aData.origin, null, null);
|
||||
let installDir = "." + origin.scheme + ";" + origin.host;
|
||||
if (origin.port != -1)
|
||||
installDir += ";" + origin.port;
|
||||
let installDir = "." + origin.scheme + ";" +
|
||||
origin.host +
|
||||
(origin.port != -1 ? ";" + origin.port : "");
|
||||
|
||||
let exeFile = Services.dirsvc.get("Home", Ci.nsIFile);
|
||||
exeFile.append(installDir);
|
||||
|
@ -76,6 +76,32 @@ let WebappOSUtils = {
|
|||
} catch (e) {}
|
||||
|
||||
return false;
|
||||
#endif
|
||||
},
|
||||
|
||||
uninstall: function(aData) {
|
||||
#ifdef XP_UNIX
|
||||
#ifndef XP_MACOSX
|
||||
let origin = Services.io.newURI(aData.origin, null, null);
|
||||
let installDir = "." + origin.scheme + ";" +
|
||||
origin.host +
|
||||
(origin.port != -1 ? ";" + origin.port : "");
|
||||
|
||||
let exeFile = Services.dirsvc.get("Home", Ci.nsIFile);
|
||||
exeFile.append(installDir);
|
||||
exeFile.append("webapprt-stub");
|
||||
|
||||
try {
|
||||
if (exeFile.exists()) {
|
||||
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||
process.init(exeFile);
|
||||
process.runAsync(["-remove"], 1);
|
||||
return true;
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ let WebappsHandler = {
|
|||
init: function() {
|
||||
Services.obs.addObserver(this, "webapps-ask-install", false);
|
||||
Services.obs.addObserver(this, "webapps-launch", false);
|
||||
Services.obs.addObserver(this, "webapps-uninstall", false);
|
||||
},
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
|
@ -33,6 +34,9 @@ let WebappsHandler = {
|
|||
case "webapps-launch":
|
||||
WebappOSUtils.launch(data);
|
||||
break;
|
||||
case "webapps-uninstall":
|
||||
WebappOSUtils.uninstall(data);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче