Bug 1250453 - Remove DOMApplicationRegistry._isLaunchable property. r=myk
authorMarco Castelluccio <mcastelluccio@mozilla.com>
Mon, 14 Mar 2016 16:28:25 +0000
changeset 288560 61492626c26afd375cfd7982e7fb751fa45a5f45
parent 288559 96b5a49990152aeb3198bdd08b94557cf7ec65f3
child 288561 f8c0b81cce33c310c142e125a3680471a6e13b7a
push id73456
push usermcastelluccio@mozilla.com
push dateMon, 14 Mar 2016 16:31:16 +0000
treeherdermozilla-inbound@81fb57cf9486 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmyk
bugs1250453
milestone48.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 1250453 - Remove DOMApplicationRegistry._isLaunchable property. r=myk
dom/apps/Webapps.jsm
--- a/dom/apps/Webapps.jsm
+++ b/dom/apps/Webapps.jsm
@@ -2542,18 +2542,17 @@ this.DOMApplicationRegistry = {
     let checkManifest = (function() {
       if (!app.manifest) {
         sendError("MANIFEST_PARSE_ERROR");
         return false;
       }
 
       // Disallow reinstalls from the same manifest url for now.
       for (let id in this.webapps) {
-        if (this.webapps[id].manifestURL == app.manifestURL &&
-            this._isLaunchable(this.webapps[id])) {
+        if (this.webapps[id].manifestURL == app.manifestURL) {
           sendError("REINSTALL_FORBIDDEN");
           return false;
         }
       }
 
       if (!AppsUtils.checkManifest(app.manifest, app)) {
         sendError("INVALID_MANIFEST");
         return false;
@@ -2674,17 +2673,17 @@ this.DOMApplicationRegistry = {
       }
     }
 
     let checkUpdateManifest = (function() {
       let manifest = app.updateManifest;
 
       // Disallow reinstalls from the same manifest URL for now.
       let id = this._appIdForManifestURL(app.manifestURL);
-      if (id !== null && this._isLaunchable(this.webapps[id])) {
+      if (id !== null) {
         sendError("REINSTALL_FORBIDDEN");
         return false;
       }
 
       if (!(AppsUtils.checkManifest(manifest, app) && manifest.package_path)) {
         sendError("INVALID_MANIFEST");
         return false;
       }
@@ -3136,23 +3135,17 @@ this.DOMApplicationRegistry = {
 
     aData.isPackage ? appObject.updateManifest = jsonManifest :
                       appObject.manifest = jsonManifest;
     MessageBroadcaster.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.
-        }
+        yield aInstallSuccessCallback(app, app.manifest);
       }
     }
 
     // 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
       // a WebappsRegistry to receive Webapps:Install:Return:OK and respond
       // Webapps:Install:Return:Ack when an app is being auto-installed.
@@ -3232,23 +3225,17 @@ this.DOMApplicationRegistry = {
         kind: this.webapps[aId].kind
       }, true);
     }
 
     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.
-      }
+      yield aInstallSuccessCallback(aNewApp, aManifest, zipFile.path);
     }
 
     MessageBroadcaster.broadcastMessage("Webapps:UpdateState", {
       app: app,
       manifest: aManifest,
       manifestURL: aNewApp.manifestURL
     });
 
@@ -4013,17 +4000,17 @@ this.DOMApplicationRegistry = {
         }
         // Nothing else to do for an update... since the
         // origin can't change we don't need to move the
         // app nor can we have a duplicated origin
       } else {
         debug("Setting origin to " + uri.prePath +
               " for " + aOldApp.manifestURL);
         let newId = uri.prePath.substring(6); // "app://".length
-        if (newId in this.webapps && this._isLaunchable(this.webapps[newId])) {
+        if (newId in this.webapps) {
           throw "DUPLICATE_ORIGIN";
         }
         aOldApp.origin = uri.prePath;
         // Update the registry.
         let oldId = aOldApp.id;
 
         if (oldId == newId) {
           // This could happen when we have an app in the registry
@@ -4292,18 +4279,17 @@ this.DOMApplicationRegistry = {
       aMm.sendAsyncMessage("Webapps:GetSelf:Return:OK", this.formatMessage(aData));
       return;
     }
 
     let tmp = [];
 
     for (let id in this.webapps) {
       if (this.webapps[id].origin == aData.origin &&
-          this.webapps[id].localId == aData.appId &&
-          this._isLaunchable(this.webapps[id])) {
+          this.webapps[id].localId == aData.appId) {
         let app = AppsUtils.cloneAppObject(this.webapps[id]);
         aData.apps.push(app);
         tmp.push({ id: id });
         break;
       }
     }
 
     if (!aData.apps.length) {
@@ -4318,18 +4304,17 @@ this.DOMApplicationRegistry = {
     });
   },
 
   checkInstalled: function(aData, aMm) {
     aData.app = null;
     let tmp = [];
 
     for (let appId in this.webapps) {
-      if (this.webapps[appId].manifestURL == aData.manifestURL &&
-          this._isLaunchable(this.webapps[appId])) {
+      if (this.webapps[appId].manifestURL == aData.manifestURL) {
         aData.app = AppsUtils.cloneAppObject(this.webapps[appId]);
         tmp.push({ id: appId });
         break;
       }
     }
 
     this._readManifests(tmp).then((aResult) => {
       for (let i = 0; i < aResult.length; i++) {
@@ -4340,46 +4325,32 @@ this.DOMApplicationRegistry = {
     });
   },
 
   getInstalled: function(aData, aMm) {
     aData.apps = [];
     let tmp = [];
 
     for (let id in this.webapps) {
-      if (this.webapps[id].installOrigin == aData.origin &&
-          this._isLaunchable(this.webapps[id])) {
+      if (this.webapps[id].installOrigin == aData.origin) {
         aData.apps.push(AppsUtils.cloneAppObject(this.webapps[id]));
         tmp.push({ id: id });
       }
     }
 
     this._readManifests(tmp).then((aResult) => {
       for (let i = 0; i < aResult.length; i++)
         aData.apps[i].manifest = aResult[i].manifest;
       aMm.sendAsyncMessage("Webapps:GetInstalled:Return:OK", this.formatMessage(aData));
     });
   },
 
   getNotInstalled: function(aData, aMm) {
     aData.apps = [];
-    let tmp = [];
-
-    for (let id in this.webapps) {
-      if (!this._isLaunchable(this.webapps[id])) {
-        aData.apps.push(AppsUtils.cloneAppObject(this.webapps[id]));
-        tmp.push({ id: id });
-      }
-    }
-
-    this._readManifests(tmp).then((aResult) => {
-      for (let i = 0; i < aResult.length; i++)
-        aData.apps[i].manifest = aResult[i].manifest;
-      aMm.sendAsyncMessage("Webapps:GetNotInstalled:Return:OK", this.formatMessage(aData));
-    });
+    aMm.sendAsyncMessage("Webapps:GetNotInstalled:Return:OK", this.formatMessage(aData));
   },
 
   getIcon: function(aData, aMm) {
     let sendError = (aError) => {
       debug("getIcon error: " + aError);
       aData.error = aError;
       aMm.sendAsyncMessage("Webapps:GetIcon:Return", this.formatMessage(aData));
     };
@@ -4798,20 +4769,16 @@ this.DOMApplicationRegistry = {
 
   updateDataStoreEntriesFromLocalId: function(aLocalId) {
     let app = appsService.getAppByLocalId(aLocalId);
     if (app) {
       this.updateDataStoreForApp(app.id);
     }
   },
 
-  _isLaunchable: function(aApp) {
-    return true;
-  },
-
   _notifyCategoryAndObservers: function(subject, topic, data,  msg) {
     const serviceMarker = "service,";
 
     // First create observers from the category manager.
     let cm =
       Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
     let enumerator = cm.enumerateCategory(topic);