mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 768276. Part 1 - Implement Webapps._isLaunchable on desktop platforms to verify if a webapp is launchable. r=myk
Original patches for Windows by Tim in bug 756306, for Mac by Dan in bug 762698, and for Linux by Marco in bug 756307
This commit is contained in:
parent
40da7d584c
commit
ed7fc180c7
@ -35,6 +35,7 @@ XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
|
||||
let DOMApplicationRegistry = {
|
||||
appsFile: null,
|
||||
webapps: { },
|
||||
allAppsLaunchable: false,
|
||||
|
||||
init: function() {
|
||||
this.messages = ["Webapps:Install", "Webapps:Uninstall",
|
||||
@ -445,6 +446,61 @@ let DOMApplicationRegistry = {
|
||||
}
|
||||
}
|
||||
this._saveApps(aCallback);
|
||||
},
|
||||
|
||||
_isLaunchable: function(aOrigin) {
|
||||
if (this.allAppsLaunchable)
|
||||
return true;
|
||||
|
||||
#ifdef XP_WIN
|
||||
let uninstallKey = Cc["@mozilla.org/windows-registry-key;1"]
|
||||
.createInstance(Ci.nsIWindowsRegKey);
|
||||
try {
|
||||
uninstallKey.open(uninstallKey.ROOT_KEY_CURRENT_USER,
|
||||
"SOFTWARE\\Microsoft\\Windows\\" +
|
||||
"CurrentVersion\\Uninstall\\" +
|
||||
aOrigin,
|
||||
uninstallKey.ACCESS_READ);
|
||||
uninstallKey.close();
|
||||
return true;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
#elifdef XP_MACOSX
|
||||
let mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]
|
||||
.createInstance(Ci.nsIMacWebAppUtils);
|
||||
|
||||
return !!mwaUtils.pathForAppWithIdentifier(aOrigin);
|
||||
#elifdef XP_UNIX
|
||||
let env = Cc["@mozilla.org/process/environment;1"]
|
||||
.getService(Ci.nsIEnvironment);
|
||||
let xdg_data_home_env = env.get("XDG_DATA_HOME");
|
||||
|
||||
let desktopINI;
|
||||
if (xdg_data_home_env != "") {
|
||||
desktopINI = Cc["@mozilla.org/file/local;1"]
|
||||
.createInstance(Ci.nsIFile);
|
||||
desktopINI.initWithPath(xdg_data_home_env);
|
||||
}
|
||||
else {
|
||||
desktopINI = Services.dirsvc.get("Home", Ci.nsIFile);
|
||||
desktopINI.append(".local");
|
||||
desktopINI.append("share");
|
||||
}
|
||||
desktopINI.append("applications");
|
||||
|
||||
let origin = Services.io.newURI(aOrigin, null, null);
|
||||
let uniqueName = origin.scheme + ";" +
|
||||
origin.host +
|
||||
(origin.port != -1 ? ";" + origin.port : "");
|
||||
|
||||
desktopINI.append("owa-" + uniqueName + ".desktop");
|
||||
|
||||
return desktopINI.exists();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user