зеркало из https://github.com/mozilla/gecko-dev.git
Bug 999220 - Make confirmInstall call aInstallSuccessCallback after the manifest has been written to disk. r=fabrice
This commit is contained in:
Родитель
96894f1720
Коммит
24c9fb815d
|
@ -2244,8 +2244,7 @@ this.DOMApplicationRegistry = {
|
|||
queuedDownload: {},
|
||||
queuedPackageDownload: {},
|
||||
|
||||
onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
|
||||
aDontNeedNetwork) {
|
||||
onInstallSuccessAck: function(aManifestURL, aDontNeedNetwork) {
|
||||
// If we are offline, register to run when we'll be online.
|
||||
if ((Services.io.offline) && !aDontNeedNetwork) {
|
||||
let onlineWrapper = {
|
||||
|
@ -2345,7 +2344,7 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
|
|||
|
||||
let dir = this._getAppDir(aId).path;
|
||||
let manFile = OS.Path.join(dir, manifestName);
|
||||
this._writeFile(manFile, JSON.stringify(aJsonManifest));
|
||||
return this._writeFile(manFile, JSON.stringify(aJsonManifest));
|
||||
},
|
||||
|
||||
// Add an app that is already installed to the registry.
|
||||
|
@ -2418,7 +2417,7 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
|
|||
});
|
||||
}),
|
||||
|
||||
confirmInstall: function(aData, aProfileDir, aInstallSuccessCallback) {
|
||||
confirmInstall: Task.async(function*(aData, aProfileDir, aInstallSuccessCallback) {
|
||||
debug("confirmInstall");
|
||||
|
||||
let origin = Services.io.newURI(aData.app.origin, null, null);
|
||||
|
@ -2443,7 +2442,7 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
|
|||
let app = this._setupApp(aData, id);
|
||||
|
||||
let jsonManifest = aData.isPackage ? app.updateManifest : app.manifest;
|
||||
this._writeManifestFile(id, aData.isPackage, jsonManifest);
|
||||
yield this._writeManifestFile(id, aData.isPackage, jsonManifest);
|
||||
|
||||
debug("app.origin: " + app.origin);
|
||||
let manifest = new ManifestHelper(jsonManifest, app.origin);
|
||||
|
@ -2477,42 +2476,15 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
|
|||
aData.app[prop] = appObject[prop];
|
||||
}
|
||||
|
||||
let dontNeedNetwork = false;
|
||||
|
||||
if (manifest.appcache_path) {
|
||||
this.queuedDownload[app.manifestURL] = {
|
||||
manifest: manifest,
|
||||
app: appObject,
|
||||
profileDir: aProfileDir
|
||||
}
|
||||
}
|
||||
|
||||
// We notify about the successful installation via mgmt.oninstall and the
|
||||
// corresponging DOMRequest.onsuccess event as soon as the app is properly
|
||||
// saved in the registry.
|
||||
this._saveApps().then(() => {
|
||||
this.broadcastMessage("Webapps:AddApp", { id: id, app: appObject });
|
||||
if (aData.isPackage && aData.autoInstall) {
|
||||
// Skip directly to onInstallSuccessAck, since there isn't
|
||||
// a WebappsRegistry to receive Webapps:Install:Return:OK and respond
|
||||
// Webapps:Install:Return:Ack when an app is being auto-installed.
|
||||
this.onInstallSuccessAck(app.manifestURL);
|
||||
} else {
|
||||
// Broadcast Webapps:Install:Return:OK so the WebappsRegistry can notify
|
||||
// the installing page about the successful install, after which it'll
|
||||
// respond Webapps:Install:Return:Ack, which calls onInstallSuccessAck.
|
||||
this.broadcastMessage("Webapps:Install:Return:OK", aData);
|
||||
}
|
||||
if (!aData.isPackage) {
|
||||
this.updateAppHandlers(null, app.manifest, app);
|
||||
if (aInstallSuccessCallback) {
|
||||
aInstallSuccessCallback(app.manifest);
|
||||
}
|
||||
}
|
||||
Services.obs.notifyObservers(null, "webapps-installed",
|
||||
JSON.stringify({ manifestURL: app.manifestURL }));
|
||||
});
|
||||
|
||||
let dontNeedNetwork = false;
|
||||
if (manifest.package_path) {
|
||||
} else if (manifest.package_path) {
|
||||
// If it is a local app then it must been installed from a local file
|
||||
// instead of web.
|
||||
#ifdef MOZ_ANDROID_SYNTHAPKS
|
||||
|
@ -2537,12 +2509,40 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
|
|||
};
|
||||
}
|
||||
|
||||
// We notify about the successful installation via mgmt.oninstall and the
|
||||
// corresponding DOMRequest.onsuccess event as soon as the app is properly
|
||||
// saved in the registry.
|
||||
yield this._saveApps();
|
||||
|
||||
this.broadcastMessage("Webapps:AddApp", { id: id, app: appObject });
|
||||
if (aData.isPackage && aData.autoInstall) {
|
||||
// Skip directly to onInstallSuccessAck, since there isn't
|
||||
// a WebappsRegistry to receive Webapps:Install:Return:OK and respond
|
||||
// Webapps:Install:Return:Ack when an app is being auto-installed.
|
||||
this.onInstallSuccessAck(app.manifestURL);
|
||||
} else {
|
||||
// Broadcast Webapps:Install:Return:OK so the WebappsRegistry can notify
|
||||
// the installing page about the successful install, after which it'll
|
||||
// respond Webapps:Install:Return:Ack, which calls onInstallSuccessAck.
|
||||
this.broadcastMessage("Webapps:Install:Return:OK", aData);
|
||||
}
|
||||
|
||||
if (!aData.isPackage) {
|
||||
this.updateAppHandlers(null, app.manifest, app);
|
||||
if (aInstallSuccessCallback) {
|
||||
aInstallSuccessCallback(app.manifest);
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.notifyObservers(null, "webapps-installed",
|
||||
JSON.stringify({ manifestURL: app.manifestURL }));
|
||||
|
||||
if (aData.forceSuccessAck) {
|
||||
// If it's a local install, there's no content process so just
|
||||
// ack the install.
|
||||
this.onInstallSuccessAck(app.manifestURL, dontNeedNetwork);
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Install the package after successfully downloading it
|
||||
|
|
Загрузка…
Ссылка в новой задаче