Bug 677975 - Exception [nsIShellService.createShortcut] @ BookmarkHelper.js :: <TOP_LEVEL> :: line 92 [r=wjohnston]
authorMark Finkle <mfinkle@mozilla.com>
Fri, 12 Aug 2011 14:00:12 -0400
changeset 74320 3e0b5ad76bca5eb18d2a59ae55f9d55e64abfbf9
parent 74319 5c8b3f1db588e35673ef7c746aad7b00da558318
child 74321 1dd81c324ac739060ab16ad9bf444beecd7e2406
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewerswjohnston
bugs677975
milestone8.0a1
Bug 677975 - Exception [nsIShellService.createShortcut] @ BookmarkHelper.js :: <TOP_LEVEL> :: line 92 [r=wjohnston]
mobile/chrome/content/BookmarkHelper.js
--- a/mobile/chrome/content/BookmarkHelper.js
+++ b/mobile/chrome/content/BookmarkHelper.js
@@ -71,16 +71,19 @@ var BookmarkHelper = {
 
     BrowserUI.popDialog();
     this.box.hidden = true;
   },
 
   createShortcut: function BH_createShortcut(aTitle, aURL, aIconURL) {
     const kIconSize = 64;
 
+    aTitle = aTitle || aURL;
+    aIconURL = aIconURL || "chrome://browser/skin/images/favicon-default-32.png";
+
     let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
     canvas.setAttribute("style", "display: none");
 
     let self = this;
     let image = new Image();
     image.onload = function() {
       canvas.width = canvas.height = kIconSize; // clears the canvas
       let ctx = canvas.getContext("2d");
@@ -90,16 +93,20 @@ var BookmarkHelper = {
       try {
         let shell = Cc["@mozilla.org/browser/shell-service;1"].createInstance(Ci.nsIShellService);
         shell.createShortcut(aTitle, aURL, icon, "bookmark");
       } catch(e) {
         Cu.reportError(e);
       }
     }
 
+    image.onerror = function() {
+      Cu.reportError("CreateShortcut: image load error");
+    }
+
     image.src = aIconURL;
   },
 
   removeBookmarksForURI: function BH_removeBookmarksForURI(aURI) {
     //XXX blargle xpconnect! might not matter, but a method on
     // nsINavBookmarksService that takes an array of items to
     // delete would be faster. better yet, a method that takes a URI!
     let itemIds = PlacesUtils.getBookmarksForURI(aURI);