Bug 927959 - Cannot preinstall a hosted app with appcache in a SIM customization variant r=ferjm
authorFabrice Desré <fabrice@mozilla.com>
Wed, 23 Oct 2013 16:50:57 -0700
changeset 165649 8f80ef327cd088e1d9cecb2a44e62f6ec957ef2b
parent 165648 235b9647fe75ab7a0456675626d50ef85fec27f7
child 165650 845f75c5a16cb2e1e47cd887d94ef15bcb076d0c
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersferjm
bugs927959
milestone27.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 927959 - Cannot preinstall a hosted app with appcache in a SIM customization variant r=ferjm
dom/apps/src/OperatorApps.jsm
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/OperatorApps.jsm
+++ b/dom/apps/src/OperatorApps.jsm
@@ -161,17 +161,18 @@ this.OperatorAppsRegistry = {
       app: {
         installOrigin: aMetadata.installOrigin,
         origin: aMetadata.origin,
         manifestURL: aMetadata.manifestURL,
         manifestHash: AppsUtils.computeHash(JSON.stringify(aManifest))
       },
       appId: undefined,
       isBrowser: false,
-      isPackage: isPackage
+      isPackage: isPackage,
+      forceSuccessAck: true
     };
 
     if (isPackage) {
       debug("aId:" + aId + ". Installing as packaged app.");
       let installPack = OS.Path.join(this.appsDir.path, aId, APPLICATION_ZIP);
       OS.File.exists(installPack).then(
         function(aExists) {
           if (!aExists) {
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -2150,16 +2150,30 @@ this.DOMApplicationRegistry = {
 
   // This function is called after we called the onsuccess callback on the
   // content side. This let the webpage the opportunity to set event handlers
   // on the app before we start firing progress events.
   queuedDownload: {},
   queuedPackageDownload: {},
 
   onInstallSuccessAck: function onInstallSuccessAck(aManifestURL) {
+    // If we are offline, register to run when we'll be online.
+    if (Services.io.offline) {
+      let onlineWrapper = {
+        observe: function(aSubject, aTopic, aData) {
+          Services.obs.removeObserver(onlineWrapper,
+                                      "network:offline-status-changed");
+          DOMApplicationRegistry.onInstallSuccessAck(aManifestURL);
+        }
+      }
+      Services.obs.addObserver(onlineWrapper,
+                               "network:offline-status-changed", false);
+      return;
+    }
+
     let cacheDownload = this.queuedDownload[aManifestURL];
     if (cacheDownload) {
       this.startOfflineCacheDownload(cacheDownload.manifest,
                                      cacheDownload.app,
                                      cacheDownload.profileDir);
       delete this.queuedDownload[aManifestURL];
 
       return;
@@ -2366,22 +2380,22 @@ this.DOMApplicationRegistry = {
       // can't be used to resolve package paths.
       manifest = new ManifestHelper(jsonManifest, app.manifestURL);
 
       this.queuedPackageDownload[app.manifestURL] = {
         manifest: manifest,
         app: appObject,
         callback: aInstallSuccessCallback
       };
-
-      if (aData.app.localInstallPath) {
-        // if it's a local install, there's no content process so just
-        // ack the install
-        this.onInstallSuccessAck(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);
     }
   },
 
   _nextLocalId: function() {
     let id = Services.prefs.getIntPref("dom.mozApps.maxLocalId") + 1;
 
     while (this.getManifestURLByLocalId(id)) {
       id++;