зеркало из https://github.com/mozilla/gecko-dev.git
Bug 906114 - Wait local installation before sending messages to content. r=myk
This commit is contained in:
Родитель
70a5917917
Коммит
0c223e94ec
|
@ -134,45 +134,39 @@ this.WebappManager = {
|
|||
|
||||
let manifestURL = aData.app.manifestURL;
|
||||
|
||||
let cleanup = () => {
|
||||
let nativeApp = new NativeApp(aData.app, jsonManifest,
|
||||
aData.app.categories);
|
||||
|
||||
this.installations[manifestURL] = Promise.defer();
|
||||
this.installations[manifestURL].promise.then(() => {
|
||||
notifyInstallSuccess(aData.app, nativeApp, bundle);
|
||||
}, (error) => {
|
||||
Cu.reportError("Error installing webapp: " + error);
|
||||
}).then(() => {
|
||||
popupProgressContent.removeChild(progressMeter);
|
||||
delete this.installations[manifestURL];
|
||||
if (Object.getOwnPropertyNames(this.installations).length == 0) {
|
||||
notification.remove();
|
||||
}
|
||||
};
|
||||
|
||||
this.installations[manifestURL] = Promise.defer();
|
||||
this.installations[manifestURL].promise.then(null, (error) => {
|
||||
Cu.reportError("Error installing webapp: " + error);
|
||||
cleanup();
|
||||
});
|
||||
|
||||
let nativeApp = new NativeApp(aData.app, jsonManifest,
|
||||
aData.app.categories);
|
||||
let localDir;
|
||||
try {
|
||||
localDir = nativeApp.createProfile();
|
||||
} catch (ex) {
|
||||
Cu.reportError("Error installing webapp: " + ex);
|
||||
DOMApplicationRegistry.denyInstall(aData);
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
DOMApplicationRegistry.confirmInstall(aData, localDir,
|
||||
(aApp, aManifest, aZipPath) => Task.spawn((function*() {
|
||||
Task.async(function*(aApp, aManifest, aZipPath) {
|
||||
try {
|
||||
yield nativeApp.install(aApp, aManifest, aZipPath);
|
||||
yield this.installations[manifestURL].promise;
|
||||
notifyInstallSuccess(aApp, nativeApp, bundle);
|
||||
} catch (ex) {
|
||||
Cu.reportError("Error installing webapp: " + ex);
|
||||
// TODO: Notify user that the installation has failed
|
||||
} finally {
|
||||
cleanup();
|
||||
throw ex;
|
||||
}
|
||||
}).bind(this))
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2552,6 +2552,19 @@ this.DOMApplicationRegistry = {
|
|||
|
||||
this.broadcastMessage("Webapps:AddApp", { id: id, app: appObject });
|
||||
|
||||
if (!aData.isPackage) {
|
||||
this.updateAppHandlers(null, app.manifest, app);
|
||||
if (aInstallSuccessCallback) {
|
||||
try {
|
||||
yield aInstallSuccessCallback(app, app.manifest);
|
||||
} catch (e) {
|
||||
// Ignore exceptions during the local installation of
|
||||
// an app. If it fails, the app will anyway be considered
|
||||
// as not installed because isLaunchable will return false.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The presence of a requestID means that we have a page to update.
|
||||
if (aData.isPackage && aData.apkInstall && !aData.requestID) {
|
||||
// Skip directly to onInstallSuccessAck, since there isn't
|
||||
|
@ -2565,13 +2578,6 @@ this.DOMApplicationRegistry = {
|
|||
this.broadcastMessage("Webapps:Install:Return:OK", aData);
|
||||
}
|
||||
|
||||
if (!aData.isPackage) {
|
||||
this.updateAppHandlers(null, app.manifest, app);
|
||||
if (aInstallSuccessCallback) {
|
||||
aInstallSuccessCallback(app, app.manifest);
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.notifyObservers(null, "webapps-installed",
|
||||
JSON.stringify({ manifestURL: app.manifestURL }));
|
||||
|
||||
|
@ -2642,6 +2648,16 @@ this.DOMApplicationRegistry = {
|
|||
this.updateDataStore(this.webapps[aId].localId, aNewApp.origin,
|
||||
aNewApp.manifestURL, aManifest);
|
||||
|
||||
if (aInstallSuccessCallback) {
|
||||
try {
|
||||
yield aInstallSuccessCallback(aNewApp, aManifest, zipFile.path);
|
||||
} catch (e) {
|
||||
// Ignore exceptions during the local installation of
|
||||
// an app. If it fails, the app will anyway be considered
|
||||
// as not installed because isLaunchable will return false.
|
||||
}
|
||||
}
|
||||
|
||||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
manifest: aManifest,
|
||||
|
@ -2655,10 +2671,6 @@ this.DOMApplicationRegistry = {
|
|||
eventType: ["downloadsuccess", "downloadapplied"],
|
||||
manifestURL: aNewApp.manifestURL
|
||||
});
|
||||
|
||||
if (aInstallSuccessCallback) {
|
||||
aInstallSuccessCallback(aNewApp, aManifest, zipFile.path);
|
||||
}
|
||||
}),
|
||||
|
||||
_nextLocalId: function() {
|
||||
|
|
|
@ -79,9 +79,9 @@ this.WebappManager = {
|
|||
}
|
||||
|
||||
DOMApplicationRegistry.confirmInstall(data, localDir,
|
||||
function (aApp, aManifest, aZipPath) {
|
||||
nativeApp.install(aApp, aManifest, aZipPath);
|
||||
}
|
||||
Task.async(function*(aApp, aManifest, aZipPath) {
|
||||
yield nativeApp.install(aApp, aManifest, aZipPath);
|
||||
})
|
||||
);
|
||||
} else {
|
||||
DOMApplicationRegistry.denyInstall(data);
|
||||
|
|
Загрузка…
Ссылка в новой задаче