Backed out changeset 72affddbc575 (bug 860782) for mochitest-bc orange.
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 20 Jun 2013 15:07:31 -0400
changeset 147357 05697f33c32c0e3c13bcbac95f40d80e070d94d5
parent 147356 b56c913f6519f6ae1f9ae4a5a1728a6d22580f8e
child 147358 2ff16cbb28301b7c21cdb4b017067a346c15b4df
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs860782
milestone24.0a1
backs out72affddbc575bdca731b3a570a0f12ae38cfe2e8
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
Backed out changeset 72affddbc575 (bug 860782) for mochitest-bc orange.
dom/apps/src/Webapps.jsm
mobile/android/chrome/content/WebAppRT.js
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -253,29 +253,26 @@ this.DOMApplicationRegistry = {
 
   updatePermissionsForApp: function updatePermissionsForApp(aId) {
     if (!this.webapps[aId]) {
       return;
     }
 
     // Install the permissions for this app, as if we were updating
     // to cleanup the old ones if needed.
-    // TODO It's not clear what this should do when there are multiple profiles.
-#ifdef MOZ_B2G
     this._readManifests([{ id: aId }], (function(aResult) {
       let data = aResult[0];
       PermissionsInstaller.installPermissions({
         manifest: data.manifest,
         manifestURL: this.webapps[aId].manifestURL,
         origin: this.webapps[aId].origin
       }, true, function() {
         debug("Error installing permissions for " + aId);
       });
     }).bind(this));
-#endif
   },
 
   updateOfflineCacheForApp: function updateOfflineCacheForApp(aId) {
     let app = this.webapps[aId];
     this._readManifests([{ id: aId }], function(aResult) {
       let manifest = new ManifestHelper(aResult[0].manifest, app.origin);
       OfflineCacheInstaller.installCache({
         cachePath: app.cachePath,
@@ -1235,23 +1232,21 @@ this.DOMApplicationRegistry = {
           delete app.staged;
         }
 
         delete app.retryingDownload;
 
         this._saveApps((function() {
           // Update the handlers and permissions for this app.
           this.updateAppHandlers(aOldManifest, aData, app);
-#ifdef MOZ_B2G
           PermissionsInstaller.installPermissions(
             { manifest: aData,
               origin: app.origin,
               manifestURL: app.manifestURL },
             true);
-#endif
           this.broadcastMessage("Webapps:PackageEvent",
                                 { type: "applied",
                                   manifestURL: app.manifestURL,
                                   app: app,
                                   manifest: aData });
         }).bind(this));
       }).bind(this));
     }).bind(this));
@@ -1462,24 +1457,23 @@ this.DOMApplicationRegistry = {
 
         // Store the new manifest.
         let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
         let manFile = dir.clone();
         manFile.append("manifest.webapp");
         this._writeFile(manFile, JSON.stringify(aNewManifest), function() { });
         manifest = new ManifestHelper(aNewManifest, app.origin);
 
-#ifdef MOZ_B2G
         // Update the permissions for this app.
         PermissionsInstaller.installPermissions({
           manifest: app.manifest,
           origin: app.origin,
           manifestURL: aData.manifestURL
         }, true);
-#endif
+
         app.name = manifest.name;
         app.csp = manifest.csp || "";
         app.updateTime = Date.now();
       } else {
         manifest = new ManifestHelper(aOldManifest, app.origin);
       }
 
       // Update the registry.
@@ -2013,24 +2007,22 @@ this.DOMApplicationRegistry = {
     appObject.installerAppId = aData.appId;
     appObject.installerIsBrowser = aData.isBrowser;
 
     this.webapps[id] = appObject;
 
     // For package apps, the permissions are not in the mini-manifest, so
     // don't update the permissions yet.
     if (!aData.isPackage) {
-#ifdef MOZ_B2G
       PermissionsInstaller.installPermissions({ origin: appObject.origin,
                                                 manifestURL: appObject.manifestURL,
                                                 manifest: jsonManifest },
                                               isReinstall, (function() {
         this.uninstall(aData, aData.mm);
       }).bind(this));
-#endif
     }
 
     ["installState", "downloadAvailable",
      "downloading", "downloadSize", "readyToApplyDownload"].forEach(function(aProp) {
       aData.app[aProp] = appObject[aProp];
      });
 
     this.queuedDownload[app.manifestURL] = {
@@ -2078,23 +2070,22 @@ this.DOMApplicationRegistry = {
         manFile.append("manifest.webapp");
         this._writeFile(manFile, JSON.stringify(aManifest), function() { });
         // Set state and fire events.
         app.installState = "installed";
         app.downloading = false;
         app.downloadAvailable = false;
         this._saveApps((function() {
           this.updateAppHandlers(null, aManifest, appObject);
-#ifdef MOZ_B2G
+
           // Update the permissions for this app.
           PermissionsInstaller.installPermissions({ manifest: aManifest,
                                                     origin: appObject.origin,
                                                     manifestURL: appObject.manifestURL },
                                                   true);
-#endif
           debug("About to fire Webapps:PackageEvent 'installed'");
           this.broadcastMessage("Webapps:PackageEvent",
                                 { type: "installed",
                                   manifestURL: appObject.manifestURL,
                                   app: app,
                                   manifest: aManifest });
           if (aInstallSuccessCallback) {
             aInstallSuccessCallback(aManifest);
--- a/mobile/android/chrome/content/WebAppRT.js
+++ b/mobile/android/chrome/content/WebAppRT.js
@@ -3,17 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 let Cc = Components.classes;
 let Ci = Components.interfaces;
 let Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
-Cu.import("resource://gre/modules/PermissionsInstaller.jsm");
 
 function pref(name, value) {
   return {
     name: name,
     value: value
   }
 }
 
@@ -47,71 +46,58 @@ let WebAppRT = {
       Services.perms.add(uri, "offline-app", Ci.nsIPermissionManager.ALLOW_ACTION);
       Services.perms.add(uri, "indexedDB", Ci.nsIPermissionManager.ALLOW_ACTION);
       Services.perms.add(uri, "indexedDB-unlimited", Ci.nsIPermissionManager.ALLOW_ACTION);
 
       // update the blocklist url to use a different app id
       let blocklist = Services.prefs.getCharPref("extensions.blocklist.url");
       blocklist = blocklist.replace(/%APP_ID%/g, "webapprt-mobile@mozilla.org");
       Services.prefs.setCharPref("extensions.blocklist.url", blocklist);
-
-      this.getManifestFor(aUrl, function (aManifest, aManifestURL) {
-        if (aManifest) {
-          PermissionsInstaller.installPermissions(
-            { manifest: aManifest,
-              origin: aUrl,
-              manifestURL: aManifestURL },
-            true);
-        }
-      });
     }
 
     this.findManifestUrlFor(aUrl, aCallback);
   },
 
-  getManifestFor: function (aUrl, aCallback) {
+  findManifestUrlFor: function(aUrl, aCallback) {
     let request = navigator.mozApps.mgmt.getAll();
     request.onsuccess = function() {
       let apps = request.result;
       for (let i = 0; i < apps.length; i++) {
         let app = apps[i];
         let manifest = new ManifestHelper(app.manifest, app.origin);
 
-        // if this is a path to the manifest, or the launch path, then we have a hit.
-        if (app.manifestURL == aUrl || manifest.fullLaunchPath() == aUrl) {
-          aCallback(manifest, app.manifestURL);
+        // First see if this url matches any manifests we have registered
+        // If so, get the launchUrl from the manifest and we'll launch with that
+        //let app = DOMApplicationRegistry.getAppByManifestURL(aUrl);
+        if (app.manifestURL == aUrl) {
+          BrowserApp.manifest = app.manifest;
+          BrowserApp.manifestUrl = aUrl;
+          aCallback(manifest.fullLaunchPath());
+          return;
+        }
+
+        // Otherwise, see if the apps launch path is this url
+        if (manifest.fullLaunchPath() == aUrl) {
+          BrowserApp.manifest = app.manifest;
+          BrowserApp.manifestUrl = app.manifestURL;
+          aCallback(aUrl);
           return;
         }
       }
 
-      // Otherwise, once we loop through all of them, we have a miss.
-      aCallback(undefined);
+      // Finally, just attempt to open the webapp as a normal web page
+      aCallback(aUrl);
     };
 
     request.onerror = function() {
-      // Treat an error like a miss. We can't find the manifest.
-      aCallback(undefined);
+      // Attempt to open the webapp as a normal web page
+      aCallback(aUrl);
     };
   },
 
-  findManifestUrlFor: function(aUrl, aCallback) {
-    this.getManifestFor(aUrl, function(aManifest, aManifestURL) {
-      if (!aManifest) {
-        // we can't find the manifest, so open it like a web page
-        aCallback(aUrl);
-        return;
-      }
-
-      BrowserApp.manifest = aManifest;
-      BrowserApp.manifestUrl = aManifestURL;
-
-      aCallback(aManifest.fullLaunchPath());
-    });
-  },
-
   getDefaultPrefs: function() {
     // read default prefs from the disk
     try {
       let defaultPrefs = [];
       try {
           defaultPrefs = this.readDefaultPrefs(FileUtils.getFile("ProfD", [this.DEFAULT_PREFS_FILENAME]));
       } catch(ex) {
           // this can throw if the defaultprefs.js file doesn't exist
@@ -143,32 +129,32 @@ let WebAppRT = {
       case "number":
         Services.prefs.setIntPref(aPref.name, aPref.value);
         break;
     }
   },
 
   handleEvent: function(event) {
     let target = event.target;
-
+  
     // walk up the tree to find the nearest link tag
     while (target && !(target instanceof HTMLAnchorElement)) {
       target = target.parentNode;
     }
 
     if (!target || target.getAttribute("target") != "_blank") {
       return;
     }
-
+  
     let uri = Services.io.newURI(target.href, target.ownerDocument.characterSet, null);
-
+  
     // Direct the URL to the browser.
     Cc["@mozilla.org/uriloader/external-protocol-service;1"].
       getService(Ci.nsIExternalProtocolService).
       getProtocolHandlerInfo(uri.scheme).
       launchWithURI(uri);
-
+  
     // Prevent the runtime from loading the URL.  We do this after directing it
     // to the browser to give the runtime a shot at handling the URL if we fail
     // to direct it to the browser for some reason.
     event.preventDefault();
   }
 }