Bug 746369. Add support for installing apps that do not provide an icon, falling back to the standard webapp icon. r=gavin a=desktop-only
authorFelipe Gomes <felipc@gmail.com>
Thu, 19 Apr 2012 18:47:56 -0700
changeset 95284 22bfdebf5cae295b3aa946406d7654c356b55801
parent 95283 ebec7bc561e1905612befb1d07292903e702472c
child 95291 cd8b66649278a03fc9bfff2e52422c9c7e7d8338
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)
reviewersgavin, desktop-only
bugs746369
milestone14.0a1
first release with
nightly linux32
22bfdebf5cae / 14.0a1 / 20120420030653 / files
nightly linux64
22bfdebf5cae / 14.0a1 / 20120420030653 / files
nightly mac
22bfdebf5cae / 14.0a1 / 20120420030653 / files
nightly win32
22bfdebf5cae / 14.0a1 / 20120420030653 / files
nightly win64
22bfdebf5cae / 14.0a1 / 20120420030653 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 746369. Add support for installing apps that do not provide an icon, falling back to the standard webapp icon. r=gavin a=desktop-only
browser/modules/WebappsIconHelpers.js
--- a/browser/modules/WebappsIconHelpers.js
+++ b/browser/modules/WebappsIconHelpers.js
@@ -11,19 +11,23 @@
  *               aIcons = {
  *                 "16": "http://www.example.org/icon16.png",
  *                 "32": "http://www.example.org/icon32.png"
  *               };
  *
  * @returns the URL string for the largest specified icon
  */
 function getBiggestIconURL(aIcons) {
+  if (!aIcons) {
+    return "chrome://browser/skin/webapps-64.png";
+  }
+
   let iconSizes = Object.keys(aIcons);
   if (iconSizes.length == 0) {
-    return "";
+    return "chrome://browser/skin/webapps-64.png";
   }
   iconSizes.sort(function(a, b) a - b);
   return aIcons[iconSizes.pop()];
 }
 
 /**
  * This function retrieves the icon for an app as specified
  * in the iconURI on the shell object.
@@ -58,17 +62,17 @@ function getIconForApp(aShell, callback)
     if(aShell.useTmpForIcon) {
       let downloadObserver = {
         onDownloadComplete: function(downloader, request, cx, aStatus, file) {
           // pass downloader just to keep reference around
           onIconDownloaded(aShell, mimeType, aStatus, file, callback, downloader);
         }
       };
 
-      tmpIcon = Services.dirsvc.get("TmpD", Ci.nsIFile);
+      let tmpIcon = Services.dirsvc.get("TmpD", Ci.nsIFile);
       tmpIcon.append("tmpicon." + mimeService.getPrimaryExtension(mimeType, ""));
       tmpIcon.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
 
       listener = Cc["@mozilla.org/network/downloader;1"]
                    .createInstance(Ci.nsIDownloader);
       listener.init(downloadObserver, tmpIcon);
     } else {
       let pipe = Cc["@mozilla.org/pipe;1"]