Bug 823040 - We should update the app's manifest during update (for hosted apps with appcache). r=ferjm, a=blocking-basecamp
authorFabrice Desré <fabrice@mozilla.com>
Thu, 20 Dec 2012 12:08:58 -0800
changeset 117824 1eaf5b0d8c633ed65109fdefa457eb95c5869fb5
parent 117823 a93cb30fc7610519db8198975aec11aaa9c996d5
child 117825 16d8a3a6cddba99932016a15036259b148464462
push id84
push userryanvm@gmail.com
push dateMon, 24 Dec 2012 17:20:34 +0000
reviewersferjm, blocking-basecamp
bugs823040
milestone18.0
Bug 823040 - We should update the app's manifest during update (for hosted apps with appcache). r=ferjm, a=blocking-basecamp
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -1117,20 +1117,22 @@ this.DOMApplicationRegistry = {
       let manifest = new ManifestHelper(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
+        downloadSize: manifest.size,
+        updateManifest: aManifest
       }
       DOMApplicationRegistry._saveApps(function() {
         aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:OK", aData);
+        delete aData.app.updateManifest;
       });
     }
 
     function updateHostedApp(aManifest) {
       debug("updateHostedApp " + aData.manifestURL);
       let id = this._appId(app.origin);
 
       // Clean up the deprecated manifest cache if needed.
@@ -1169,16 +1171,17 @@ this.DOMApplicationRegistry = {
       app.csp = aManifest.csp || "";
       app.updateTime = Date.now();
 
       // Update the registry.
       this.webapps[id] = app;
 
       this._saveApps(function() {
         aData.app = app;
+        app.manifest = aManifest;
         if (!manifest.appcache_path) {
           aData.event = "downloadapplied";
           aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:OK", aData);
         } else {
           // Check if the appcache is updatable, and send "downloadavailable" or
           // "downloadapplied".
           let updateObserver = {
             observe: function(aSubject, aTopic, aObsData) {
@@ -1186,16 +1189,17 @@ this.DOMApplicationRegistry = {
                 aTopic == "offline-cache-update-available" ? "downloadavailable"
                                                            : "downloadapplied";
               aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:OK", aData);
             }
           }
           updateSvc.checkForUpdate(Services.io.newURI(aData.manifestURL, null, null),
                                    app.localId, false, updateObserver);
         }
+        delete app.manifest;
       });
 
       // Update the permissions for this app.
       PermissionsInstaller.installPermissions({ manifest: aManifest,
                                                 origin: app.origin,
                                                 manifestURL: aData.manifestURL },
                                               true);
     }