Back out eae519534b01 (bug 772364), 4935822abf87 (bug 795164) and ddee22deae16 (bug 793082) for orange on a CLOSED TREE

This commit is contained in:
Phil Ringnalda 2012-09-29 13:20:09 -07:00
Родитель e284cc0ba3
Коммит 24ea640675
3 изменённых файлов: 41 добавлений и 195 удалений

Просмотреть файл

@ -187,7 +187,6 @@ var shell = {
}); });
this.contentBrowser.src = homeURL; this.contentBrowser.src = homeURL;
this.isHomeLoaded = false;
ppmm.addMessageListener("content-handler", this); ppmm.addMessageListener("content-handler", this);
}, },
@ -313,17 +312,6 @@ var shell = {
DOMApplicationRegistry.allAppsLaunchable = true; DOMApplicationRegistry.allAppsLaunchable = true;
this.sendEvent(window, 'ContentStart'); this.sendEvent(window, 'ContentStart');
content.addEventListener('load', function shell_homeLoaded() {
content.removeEventListener('load', shell_homeLoaded);
shell.isHomeLoaded = true;
if ('pendingChromeEvents' in shell) {
shell.pendingChromeEvents.forEach((shell.sendChromeEvent).bind(shell));
}
delete shell.pendingChromeEvents;
});
break; break;
case 'MozApplicationManifest': case 'MozApplicationManifest':
try { try {
@ -369,15 +357,6 @@ var shell = {
}, },
sendChromeEvent: function shell_sendChromeEvent(details) { sendChromeEvent: function shell_sendChromeEvent(details) {
if (!this.isHomeLoaded) {
if (!('pendingChromeEvents' in this)) {
this.pendingChromeEvents = [];
}
this.pendingChromeEvents.push(details);
return;
}
this.sendEvent(getContentWindow(), "mozChromeEvent", this.sendEvent(getContentWindow(), "mozChromeEvent",
ObjectWrapper.wrap(details, getContentWindow())); ObjectWrapper.wrap(details, getContentWindow()));
}, },

Просмотреть файл

@ -438,8 +438,7 @@ WebappsApplication.prototype = {
}, },
download: function() { download: function() {
cpmm.sendAsyncMessage("Webapps:Download", throw Cr.NS_ERROR_NOT_IMPLEMENTED;
{ manifestURL: this.manifestURL });
}, },
cancelDownload: function() { cancelDownload: function() {
@ -539,9 +538,6 @@ WebappsApplication.prototype = {
if (msg.event == "downloadapplied") { if (msg.event == "downloadapplied") {
Services.DOMRequest.fireSuccess(req, this.manifestURL); Services.DOMRequest.fireSuccess(req, this.manifestURL);
this._fireEvent("downloadapplied", this._ondownloadapplied); this._fireEvent("downloadapplied", this._ondownloadapplied);
} else if (msg.event == "downloadavailable") {
Services.DOMRequest.fireSuccess(req, this.manifestURL);
this._fireEvent("downloadavailable", this._ondownloadavailable);
} }
} }
break; break;
@ -583,18 +579,6 @@ WebappsApplication.prototype = {
this._downloadError = msg.error; this._downloadError = msg.error;
this._fireEvent("downloaderror", this._ondownloaderror); this._fireEvent("downloaderror", this._ondownloaderror);
break; break;
case "downloaded":
app = msg.app;
this.downloading = app.downloading;
this.downloadavailable = app.downloadavailable;
this.readyToApplyDownload = app.readyToApplyDownload;
this._fireEvent("downloaded", this._ondownloaded);
break;
case "applied":
app = msg.app;
this.readyToApplyDownload = app.readyToApplyDownload;
this._fireEvent("downloadapplied", this._ondownloadapplied);
break;
} }
break; break;
} }
@ -654,12 +638,7 @@ WebappsApplicationMgmt.prototype = {
}, },
applyDownload: function(aApp) { applyDownload: function(aApp) {
if (!aApp.readyToApplyDownload) { return Cr.NS_ERROR_NOT_IMPLEMENTED;
return;
}
cpmm.sendAsyncMessage("Webapps::ApplyDownload",
{ manifestURL: aApp.manifestURL });
}, },
getAll: function() { getAll: function() {

Просмотреть файл

@ -160,8 +160,7 @@ let DOMApplicationRegistry = {
"Webapps:InstallPackage", "Webapps:GetBasePath", "Webapps:InstallPackage", "Webapps:GetBasePath",
"Webapps:GetList", "Webapps:RegisterForMessages", "Webapps:GetList", "Webapps:RegisterForMessages",
"Webapps:UnregisterForMessages", "Webapps:UnregisterForMessages",
"Webapps:CancelDownload", "Webapps:CheckForUpdate", "Webapps:CancelDownload", "Webapps:CheckForUpdate"];
"Webapps::Download", "Webapps::ApplyDownload"];
this.frameMessages = ["Webapps:ClearBrowserData"]; this.frameMessages = ["Webapps:ClearBrowserData"];
@ -508,9 +507,7 @@ let DOMApplicationRegistry = {
if (!(aMsgName in this.children)) { if (!(aMsgName in this.children)) {
this.children[aMsgName] = []; this.children[aMsgName] = [];
} }
if (this.children[aMsgName].indexOf(aMm) === -1) { this.children[aMsgName].push(aMm);
this.children[aMsgName].push(aMm);
}
}, this); }, this);
}, },
@ -581,18 +578,12 @@ let DOMApplicationRegistry = {
case "Webapps:GetList": case "Webapps:GetList":
this.addMessageListener(["Webapps:AddApp", "Webapps:RemoveApp"], mm); this.addMessageListener(["Webapps:AddApp", "Webapps:RemoveApp"], mm);
return this.webapps; return this.webapps;
case "Webapps:Download":
this.startDownload(msg.manifestURL);
break;
case "Webapps:CancelDownload": case "Webapps:CancelDownload":
this.cancelDownload(msg.manifestURL); this.cancelDowload(msg.manifestURL);
break; break;
case "Webapps:CheckForUpdate": case "Webapps:CheckForUpdate":
this.checkForUpdate(msg, mm); this.checkForUpdate(msg, mm);
break; break;
case "Webapps::ApplyDownload":
this.ApplyDownload(msg.manifestURL);
break;
case "Activities:Register:OK": case "Activities:Register:OK":
this.activitiesRegistered++; this.activitiesRegistered++;
if (this.allActivitiesSent && if (this.allActivitiesSent &&
@ -667,20 +658,20 @@ let DOMApplicationRegistry = {
Services.obs.notifyObservers(aMm, "webapps-launch", JSON.stringify(aData)); Services.obs.notifyObservers(aMm, "webapps-launch", JSON.stringify(aData));
}, },
cancelDownload: function cancelDownload(aManifestURL) { cancelDownload: function cancelDowload(aManifestURL) {
// We can't cancel appcache downloads for now. // We can't cancel appcache dowloads for now.
if (!this.downloads[aManifestURL]) { if (!this.downloads[aManifestURL]) {
return; return;
} }
// This is a HTTP channel. // This is a HTTP channel.
let download = this.downloads[aManifestURL] let download = this.downloads[aManifestURL]
download.channel.cancel(Cr.NS_BINDING_ABORTED); download.channel.cancel(Cr.NS_BINDING_ABORTED);
let app = this.webapps[download.appId]; let app = this.webapps[dowload.appId];
app.progress = 0; app.progress = 0;
app.installState = app.previousState; app.installState = app.previousState;
app.downloading = false; app.dowloading = false;
app.downloadavailable = false; app.dowloadavailable = false;
app.downloadSize = 0; app.downloadSize = 0;
this._saveApps((function() { this._saveApps((function() {
this.broadcastMessage("Webapps:PackageEvent", this.broadcastMessage("Webapps:PackageEvent",
@ -691,87 +682,6 @@ let DOMApplicationRegistry = {
}).bind(this)); }).bind(this));
}, },
startDownload: function cancelDownload(aManifestURL) {
let app = this.getAppByManifestURL(manifestURL);
if (!app) {
return;
}
let id = this._appIdForManifestURL(manifestURL);
// We need to get the update manifest here, not the webapp manifest.
let file = FileUtils.getFile(DIRECTORY_NAME,
["webapps", id, "update.webapp"], true);
this._loadJSONAsync(file, (function(aJSON) {
if (!aJSON) {
return;
}
let manifest = new DOMApplicationManifest(aJSON, app.origin);
this.downloadPackage(manifest, { manifestURL: aManifestURL,
origin: app.origin }, true,
function(aId, aManifest) {
// Success! Keep the zip in of TmpD, we'll move it out when
// applyDownload() will be called.
let tmpDir = FileUtils.getDir("TmpD", ["webapps", aId], true, true);
// Save the manifest in TmpD also
let manFile = tmpDir.clone();
manFile.append("manifest.webapp");
DOMApplicationRegistry._writeFile(manFile,
JSON.stringify(aManifest),
function() { });
// Set state and fire events.
app.downloading = false;
app.downloadavailable = false;
app.readyToApplyDownload = true;
DOMApplicationRegistry._saveApps(function() {
debug("About to fire Webapps:PackageEvent");
DOMApplicationRegistry.broadcastMessage("Webapps:PackageEvent",
{ type: "downloaded",
manifestURL: manifestURL,
app: app,
manifest: aManifest });
});
});
}).bind(this));
},
applyDownload: function applyDownload(aManifestURL) {
let app = this.getAppByManifestURL(manifestURL);
if (!app || (app && !app.readyToApplyDownload)) {
return;
}
let id = this._appIdForManifestURL(aApp.manifestURL);
// Move the application.zip and manifest.webapp files out of TmpD
let tmpDir = FileUtils.getDir("TmpD", ["webapps", aId], true, true);
let manFile = tmpDir.clone();
manFile.append("manifest.webapp");
let appFile = tmpDir.clone();
appFile.append("application.zip");
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
appFile.moveTo(dir, "application.zip");
manFile.moveTo(dir, "manifest.webapp");
try {
tmpDir.remove(true);
} catch(e) { }
// Get the manifest, and set properties.
this.getManifestFor(app.origin, function(aData) {
app.readyToApplyDownload = false;
this.broadcastMessage("Webapps:PackageEvent",
{ type: "applied",
manifestURL: aApp.manifestURL,
app: app,
manifest: aData });
});
},
startOfflineCacheDownload: function startOfflineCacheDownload(aManifest, aApp, aProfileDir) { startOfflineCacheDownload: function startOfflineCacheDownload(aManifest, aApp, aProfileDir) {
// if the manifest has an appcache_path property, use it to populate the appcache // if the manifest has an appcache_path property, use it to populate the appcache
if (aManifest.appcache_path) { if (aManifest.appcache_path) {
@ -904,19 +814,6 @@ let DOMApplicationRegistry = {
function updatePackagedApp(aManifest) { function updatePackagedApp(aManifest) {
debug("updatePackagedApp"); debug("updatePackagedApp");
let manifest = new DOMApplicationManifest(aManifest, app.manifestURL);
// A package is available: set downloadAvailable to fire the matching
// event.
app.downloadAvailable = true;
app.downloadSize = manifest.size;
aData.event = "downloadavailable";
aData.app = {
downloadAvailable: true,
downloadSize: manifest.size
}
DOMApplicationRegistry._saveApps(function() {
aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:OK", aData);
});
} }
function updateHostedApp(aManifest) { function updateHostedApp(aManifest) {
@ -988,7 +885,7 @@ let DOMApplicationRegistry = {
} else { } else {
app.etag = xhr.getResponseHeader("Etag"); app.etag = xhr.getResponseHeader("Etag");
app.lastCheckedUpdate = Date.now(); app.lastCheckedUpdate = Date.now();
if (manifest.package_path) { if (package_path in manifest) {
updatePackagedApp(manifest); updatePackagedApp(manifest);
} else { } else {
updateHostedApp(manifest); updateHostedApp(manifest);
@ -1125,39 +1022,7 @@ let DOMApplicationRegistry = {
this.startOfflineCacheDownload(manifest, appObject, aProfileDir); this.startOfflineCacheDownload(manifest, appObject, aProfileDir);
if (manifest.package_path) { if (manifest.package_path) {
// origin for install apps is meaningless here, since it's app:// and this this.downloadPackage(manifest, appObject);
// can't be used to resolve package paths.
manifest = new DOMApplicationManifest(jsonManifest, app.manifestURL);
this.downloadPackage(manifest, appObject, false, function(aId, aManifest) {
// Success! Move the zip out of TmpD.
let app = DOMApplicationRegistry.webapps[id];
let zipFile = FileUtils.getFile("TmpD", ["webapps", aId, "application.zip"], true);
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", aId], true, true);
zipFile.moveTo(dir, "application.zip");
let tmpDir = FileUtils.getDir("TmpD", ["webapps", aId], true, true);
try {
tmpDir.remove(true);
} catch(e) { }
// Save the manifest
let manFile = dir.clone();
manFile.append("manifest.webapp");
DOMApplicationRegistry._writeFile(manFile,
JSON.stringify(aManifest),
function() { });
// Set state and fire events.
app.installState = "installed";
app.downloading = false;
app.downloadavailable = false;
DOMApplicationRegistry._saveApps(function() {
debug("About to fire Webapps:PackageEvent");
DOMApplicationRegistry.broadcastMessage("Webapps:PackageEvent",
{ type: "installed",
manifestURL: appObject.manifestURL,
app: app,
manifest: aManifest });
});
});
} }
}, },
@ -1226,7 +1091,7 @@ let DOMApplicationRegistry = {
}).bind(this)); }).bind(this));
}, },
downloadPackage: function(aManifest, aApp, aIsUpdate, aOnSuccess) { downloadPackage: function(aManifest, aApp) {
// Here are the steps when installing a package: // Here are the steps when installing a package:
// - create a temp directory where to store the app. // - create a temp directory where to store the app.
// - download the zip in this directory. // - download the zip in this directory.
@ -1282,7 +1147,7 @@ let DOMApplicationRegistry = {
this.downloads[aApp.manifestURL] = this.downloads[aApp.manifestURL] =
{ channel:requestChannel, { channel:requestChannel,
appId: id, appId: id,
previousState: aIsUpdate ? "installed" : "pending" previousState: "pending"
}; };
requestChannel.notificationCallbacks = { requestChannel.notificationCallbacks = {
QueryInterface: function notifQI(aIID) { QueryInterface: function notifQI(aIID) {
@ -1351,10 +1216,33 @@ let DOMApplicationRegistry = {
throw "INVALID_SECURITY_LEVEL"; throw "INVALID_SECURITY_LEVEL";
} }
if (aOnSuccess) { // Success! Move the zip out of TmpD.
aOnSuccess(id, manifest); let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
} zipFile.moveTo(dir, "application.zip");
delete DOMApplicationRegistry.downloads[aApp.manifestURL]; let tmpDir = FileUtils.getDir("TmpD", ["webapps", id], true, true);
try {
tmpDir.remove(true);
} catch(e) { }
// Save the manifest
let manFile = dir.clone();
manFile.append("manifest.webapp");
DOMApplicationRegistry._writeFile(manFile,
JSON.stringify(manifest),
function() { });
// Set state and fire events.
app.installState = "installed";
app.dowloading = false;
app.dowloadavailable = false;
DOMApplicationRegistry._saveApps(function() {
debug("About to fire Webapps:PackageEvent");
DOMApplicationRegistry.broadcastMessage("Webapps:PackageEvent",
{ type: "installed",
manifestURL: aApp.manifestURL,
app: app,
manifest: manifest });
delete DOMApplicationRegistry.downloads[aApp.manifestURL]
});
} catch (e) { } catch (e) {
// XXX we may need new error messages. // XXX we may need new error messages.
cleanup(e); cleanup(e);