Bug 797048 - Firefox Marketplace does not launch from the Apps Dashboard [r=wesj]
authorFabrice Desré <fabrice@mozilla.com>
Thu, 04 Oct 2012 11:18:39 -0700
changeset 109260 4f7a6eba114024606e901208f3c3121602e17ac2
parent 109259 4f4898cca1c5ab3fc294dad80a5f125428292a22
child 109261 6f37149454382667f6b1a156e6e2caaabc685782
push id23619
push useremorley@mozilla.com
push dateFri, 05 Oct 2012 10:54:02 +0000
treeherdermozilla-central@3b458f4e0f42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs797048
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 797048 - Firefox Marketplace does not launch from the Apps Dashboard [r=wesj]
dom/apps/src/Webapps.js
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.js
+++ b/dom/apps/src/Webapps.js
@@ -510,26 +510,28 @@ WebappsApplication.prototype = {
         break;
       case "Webapps:Uninstall:Return:KO":
         Services.DOMRequest.fireError(req, "NOT_INSTALLED");
         break;
       case "Webapps:OfflineCache":
         if (msg.manifest != this.manifestURL)
           return;
 
-        if (installState in msg) {
+        if ("installState" in msg) {
           this.installState = msg.installState;
           if (this.installState == "installed") {
+            this._downloadError = null;
             this._fireEvent("downloadsuccess", this._ondownloadsuccess);
             this._fireEvent("downloadapplied", this._ondownloadapplied);
           } else {
             this._fireEvent("downloadprogress", this._onprogress);
           }
         } else if (msg.error) {
           this._downloadError = msg.error;
+          this.downloading = false;
           this._fireEvent("downloaderror", this._ondownloaderror);
         }
         break;
         case "Webapps:CheckForUpdate:Return:OK":
           for (let prop in msg.app) {
             this[prop] = msg.app[prop];
             if (msg.event == "downloadapplied") {
               Services.DOMRequest.fireSuccess(req, this.manifestURL);
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -686,17 +686,19 @@ let DOMApplicationRegistry = {
       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,
+                                                                aOfflineCacheObserver) {
     // if the manifest has an appcache_path property, use it to populate the appcache
     if (aManifest.appcache_path) {
       let appcacheURI = Services.io.newURI(aManifest.fullAppcachePath(), null, null);
       let updateService = Cc["@mozilla.org/offlinecacheupdate-service;1"]
                             .getService(Ci.nsIOfflineCacheUpdateService);
       let docURI = Services.io.newURI(aManifest.fullLaunchPath(), null, null);
       let cacheUpdate = aProfileDir ? updateService.scheduleCustomProfileUpdate(appcacheURI, docURI, aProfileDir)
                                     : updateService.scheduleUpdate(appcacheURI, docURI, null);
@@ -940,17 +942,17 @@ let DOMApplicationRegistry = {
 
 #ifdef MOZ_SYS_MSG
     if (!aData.isPackage) {
       this._registerSystemMessages(app.manifest, app);
       this._registerActivities(app.manifest, app);
     }
 #endif
 
-    this.startOfflineCacheDownload(manifest, appObject, aProfileDir);
+    this.startOfflineCacheDownload(manifest, appObject, aProfileDir, aOfflineCacheObserver);
     if (manifest.package_path) {
       // origin for install apps is meaningless here, since it's app:// and this
       // can't be used to resolve package paths.
       manifest = new ManifestHelper(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);
@@ -1603,25 +1605,28 @@ AppcacheObserver.prototype = {
   // nsIOfflineCacheUpdateObserver implementation
   updateStateChanged: function appObs_Update(aUpdate, aState) {
     let mustSave = false;
     let app = this.app;
 
     let setStatus = function appObs_setStatus(aStatus) {
       mustSave = (app.installState != aStatus);
       app.installState = aStatus;
+      app.downloading = false;
       DOMApplicationRegistry.broadcastMessage("Webapps:OfflineCache",
                                               { manifest: app.manifestURL,
                                                 installState: app.installState });
     }
 
     let setError = function appObs_setError(aError) {
       DOMApplicationRegistry.broadcastMessage("Webapps:OfflineCache",
                                               { manifest: app.manifestURL,
                                                 error: aError });
+      app.downloading = false;
+      mustSave = true;
     }
 
     switch (aState) {
       case Ci.nsIOfflineCacheUpdateObserver.STATE_ERROR:
         aUpdate.removeObserver(this);
         setError("APP_CACHE_DOWNLOAD_ERROR");
         break;
       case Ci.nsIOfflineCacheUpdateObserver.STATE_NOUPDATE: