mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 819061 - [Apps] Remove workaround from Bug 813468 once Bug 815523 is done r=ferjm
This commit is contained in:
parent
ab8873ab23
commit
1e58b8faf5
@ -25,13 +25,6 @@ function debug(s) {
|
|||||||
//dump("-*- AppsUtils.jsm: " + s + "\n");
|
//dump("-*- AppsUtils.jsm: " + s + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAbsoluteURI(aURI) {
|
|
||||||
let foo = Services.io.newURI("http://foo", null, null);
|
|
||||||
let bar = Services.io.newURI("http://bar", null, null);
|
|
||||||
return Services.io.newURI(aURI, null, foo).prePath != foo.prePath ||
|
|
||||||
Services.io.newURI(aURI, null, bar).prePath != bar.prePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.AppsUtils = {
|
this.AppsUtils = {
|
||||||
// Clones a app, without the manifest.
|
// Clones a app, without the manifest.
|
||||||
cloneAppObject: function cloneAppObject(aApp) {
|
cloneAppObject: function cloneAppObject(aApp) {
|
||||||
@ -168,13 +161,21 @@ this.AppsUtils = {
|
|||||||
if (aManifest.name == undefined)
|
if (aManifest.name == undefined)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// launch_path, entry_points launch paths, message hrefs, and activity hrefs can't be absolute
|
function isAbsolute(uri) {
|
||||||
if (aManifest.launch_path && isAbsoluteURI(aManifest.launch_path))
|
// See bug 810551
|
||||||
|
let foo = Services.io.newURI("http://foo", null, null);
|
||||||
|
let bar = Services.io.newURI("http://bar", null, null);
|
||||||
|
return Services.io.newURI(uri, null, foo).prePath != foo.prePath ||
|
||||||
|
Services.io.newURI(uri, null, bar).prePath != bar.prePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// launch_path and entry_points launch paths can't be absolute
|
||||||
|
if (aManifest.launch_path && isAbsolute(aManifest.launch_path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
function checkAbsoluteEntryPoints(entryPoints) {
|
function checkAbsoluteEntryPoints(entryPoints) {
|
||||||
for (let name in entryPoints) {
|
for (let name in entryPoints) {
|
||||||
if (entryPoints[name].launch_path && isAbsoluteURI(entryPoints[name].launch_path)) {
|
if (entryPoints[name].launch_path && isAbsolute(entryPoints[name].launch_path)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,35 +191,6 @@ this.AppsUtils = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aManifest.activities) {
|
|
||||||
for (let activityName in aManifest.activities) {
|
|
||||||
let activity = aManifest.activities[activityName];
|
|
||||||
if (activity.href && isAbsoluteURI(activity.href)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// |messages| is an array of items, where each item is either a string or
|
|
||||||
// a {name: href} object.
|
|
||||||
let messages = aManifest.messages;
|
|
||||||
if (messages) {
|
|
||||||
if (!Array.isArray(messages)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (let item of aManifest.messages) {
|
|
||||||
if (typeof item == "object") {
|
|
||||||
let keys = Object.keys(item);
|
|
||||||
if (keys.length != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (isAbsoluteURI(item[keys[0]])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -335,6 +307,10 @@ this.AppsUtils = {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dev1 && !dev2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return (dev1.name === dev2.name && dev1.url === dev2.url);
|
return (dev1.name === dev2.name && dev1.url === dev2.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,10 +444,6 @@ ManifestHelper.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
resolveFromOrigin: function(aURI) {
|
resolveFromOrigin: function(aURI) {
|
||||||
// This should be enforced higher up, but check it here just in case.
|
|
||||||
if (!isAbsoluteURI(aURI)) {
|
|
||||||
throw new Error("Webapps.jsm: non-relative URI passed to resolveFromOrigin");
|
|
||||||
}
|
|
||||||
return this._origin.resolve(aURI);
|
return this._origin.resolve(aURI);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -241,7 +241,6 @@ this.DOMApplicationRegistry = {
|
|||||||
|
|
||||||
// We copy this app to DIRECTORY_NAME/$aId, and set the base path as needed.
|
// We copy this app to DIRECTORY_NAME/$aId, and set the base path as needed.
|
||||||
let destDir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", aId], true, true);
|
let destDir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", aId], true, true);
|
||||||
destDir.permissions = FileUtils.PERMS_DIRECTORY;
|
|
||||||
|
|
||||||
["application.zip", "update.webapp"]
|
["application.zip", "update.webapp"]
|
||||||
.forEach(function(aFile) {
|
.forEach(function(aFile) {
|
||||||
@ -250,7 +249,6 @@ this.DOMApplicationRegistry = {
|
|||||||
file.copyTo(destDir, aFile);
|
file.copyTo(destDir, aFile);
|
||||||
let newFile = destDir.clone();
|
let newFile = destDir.clone();
|
||||||
newFile.append(aFile);
|
newFile.append(aFile);
|
||||||
newFile.permissions = FileUtils.PERMS_FILE;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.basePath = FileUtils.getDir(DIRECTORY_NAME, ["webapps"], true, true)
|
app.basePath = FileUtils.getDir(DIRECTORY_NAME, ["webapps"], true, true)
|
||||||
@ -272,7 +270,6 @@ this.DOMApplicationRegistry = {
|
|||||||
let manifestFile = destDir.clone();
|
let manifestFile = destDir.clone();
|
||||||
manifestFile.append("manifest.webapp");
|
manifestFile.append("manifest.webapp");
|
||||||
zipReader.extract("manifest.webapp", manifestFile);
|
zipReader.extract("manifest.webapp", manifestFile);
|
||||||
manifestFile.permissions = FileUtils.PERMS_FILE;
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// If we are unable to extract the manifest, cleanup and remove this app.
|
// If we are unable to extract the manifest, cleanup and remove this app.
|
||||||
debug("Cleaning up: " + e);
|
debug("Cleaning up: " + e);
|
||||||
@ -408,16 +405,6 @@ this.DOMApplicationRegistry = {
|
|||||||
this.installSystemApps(onAppsLoaded);
|
this.installSystemApps(onAppsLoaded);
|
||||||
else
|
else
|
||||||
onAppsLoaded();
|
onAppsLoaded();
|
||||||
|
|
||||||
// XXX: To be removed as soon as the app:// protocol is remoted.
|
|
||||||
// See Bug 819061
|
|
||||||
let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
|
||||||
dir.initWithPath("/data");
|
|
||||||
dir.permissions = parseInt("755", 8);
|
|
||||||
dir.append("local");
|
|
||||||
dir.permissions = parseInt("755", 8);
|
|
||||||
dir.append("webapps");
|
|
||||||
dir.permissions = parseInt("755", 8);
|
|
||||||
#else
|
#else
|
||||||
onAppsLoaded();
|
onAppsLoaded();
|
||||||
#endif
|
#endif
|
||||||
@ -1540,7 +1527,6 @@ this.DOMApplicationRegistry = {
|
|||||||
appObject.localId = localId;
|
appObject.localId = localId;
|
||||||
appObject.basePath = FileUtils.getDir(DIRECTORY_NAME, ["webapps"], true, true).path;
|
appObject.basePath = FileUtils.getDir(DIRECTORY_NAME, ["webapps"], true, true).path;
|
||||||
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
|
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
|
||||||
dir.permissions = FileUtils.PERMS_DIRECTORY;
|
|
||||||
let manFile = dir.clone();
|
let manFile = dir.clone();
|
||||||
manFile.append(manifestName);
|
manFile.append(manifestName);
|
||||||
let jsonManifest = aData.isPackage ? app.updateManifest : app.manifest;
|
let jsonManifest = aData.isPackage ? app.updateManifest : app.manifest;
|
||||||
@ -1620,7 +1606,6 @@ this.DOMApplicationRegistry = {
|
|||||||
let zipFile = FileUtils.getFile("TmpD", ["webapps", aId, "application.zip"], true);
|
let zipFile = FileUtils.getFile("TmpD", ["webapps", aId, "application.zip"], true);
|
||||||
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", aId], true, true);
|
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", aId], true, true);
|
||||||
zipFile.moveTo(dir, "application.zip");
|
zipFile.moveTo(dir, "application.zip");
|
||||||
zipFile.permissions = FileUtils.PERMS_FILE;
|
|
||||||
let tmpDir = FileUtils.getDir("TmpD", ["webapps", aId], true, true);
|
let tmpDir = FileUtils.getDir("TmpD", ["webapps", aId], true, true);
|
||||||
try {
|
try {
|
||||||
tmpDir.remove(true);
|
tmpDir.remove(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user