Bug 747601. Only create Info.plist file after webapp icon has been downloaded. r=mstange a=desktop-only.
authorFelipe Gomes <felipc@gmail.com>
Sun, 22 Apr 2012 14:30:03 -0700
changeset 95420 3dd8420155656203c86e19299631742c17968923
parent 95419 c823e4f030174242f6f22495e5115a1dbe554a17
child 95421 133c3b95125fc89138885f6ee4cd46d35739ea4f
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, desktop-only
bugs747601
milestone14.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 747601. Only create Info.plist file after webapp icon has been downloaded. r=mstange a=desktop-only. OSX caches the application info when Info.plist is created and if the icon has not yet been embedded in the .app package, Finder might indefinitely cache a no-icon app
browser/modules/WebappsIconHelpers.js
browser/modules/WebappsInstaller.jsm
--- a/browser/modules/WebappsIconHelpers.js
+++ b/browser/modules/WebappsIconHelpers.js
@@ -100,10 +100,12 @@ function getIconForApp(aShell, callback)
   } catch(e) {
     throw("getIconFromURI - Failure getting icon (" + e + ")");
   }
 }
 
 function onIconDownloaded(aShell, aMimeType, aStatusCode, aIcon, aCallback) {
   if (Components.isSuccessCode(aStatusCode)) {
     aShell.processIcon(aMimeType, aIcon, aCallback);
+  } else {
+    aCallback.call(aShell);
   }
 }
--- a/browser/modules/WebappsInstaller.jsm
+++ b/browser/modules/WebappsInstaller.jsm
@@ -490,17 +490,17 @@ MacNativeApp.prototype = {
       this._createDirectoryStructure();
       this._copyPrebuiltFiles();
       this._createConfigFiles();
     } catch (ex) {
       this._removeInstallation(false);
       throw(ex);
     }
 
-    getIconForApp(this);
+    getIconForApp(this, this._createPListFile);
   },
 
   _removeInstallation: function(keepProfile) {
     try {
       if(this.installDir.exists()) {
         this.installDir.followLinks = false;
         this.installDir.remove(true);
       }
@@ -556,17 +556,20 @@ MacNativeApp.prototype = {
 
     let factory = Cc["@mozilla.org/xpcom/ini-processor-factory;1"]
                     .getService(Ci.nsIINIParserFactory);
 
     let writer = factory.createINIParser(applicationINI).QueryInterface(Ci.nsIINIParserWriter);
     writer.setString("Webapp", "Name", this.appName);
     writer.setString("Webapp", "Profile", this.appProfileDir.leafName);
     writer.writeFile();
+  },
 
+  _createPListFile: function() {
+    // ${InstallDir}/Contents/Info.plist
     let infoPListContent = '<?xml version="1.0" encoding="UTF-8"?>\n\
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n\
 <plist version="1.0">\n\
   <dict>\n\
     <key>CFBundleDevelopmentRegion</key>\n\
     <string>English</string>\n\
     <key>CFBundleDisplayName</key>\n\
     <string>' + escapeXML(this.appName) + '</string>\n\
@@ -611,33 +614,35 @@ MacNativeApp.prototype = {
    * the URL by getIconForApp(). This will bundle the icon to the
    * app package at Contents/Resources/appicon.icns.
    *
    * @param aMimeType     the icon mimetype
    * @param aImageStream  the stream for the image data
    * @param aCallback     a callback function to be called
    *                      after the process finishes
    */
-  processIcon: function(aMimeType, aIcon) {
+  processIcon: function(aMimeType, aIcon, aCallback) {
     try {
       let process = Cc["@mozilla.org/process/util;1"]
                     .createInstance(Ci.nsIProcess);
       let sipsFile = Cc["@mozilla.org/file/local;1"]
                     .createInstance(Ci.nsILocalFile);
       sipsFile.initWithPath("/usr/bin/sips");
 
       process.init(sipsFile);
       process.run(true, ["-s",
                   "format", "icns",
                   aIcon.path,
                   "--out", this.iconFile.path,
                   "-z", "128", "128"],
                   9);
     } catch(e) {
       throw(e);
+    } finally {
+      aCallback.call(this);
     }
   }
 
 }
 
 #endif
 
 /* Helper Functions */