Bug 689330 - update LauncherShortcuts to use the new web apps repository [r=mfinkle]
authorFabrice Desré <fabrice@mozilla.com>
Mon, 26 Sep 2011 17:32:16 -0700
changeset 77649 db9f10c18560f582e2e5b064362e6ff950f8906b
parent 77648 b620680b7f08ba31d449a9077c4b3eae9d6b4997
child 77650 6d691de3932bf3d3a6b1a244ab7cb17aa8e226f7
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmfinkle
bugs689330
milestone9.0a1
Bug 689330 - update LauncherShortcuts to use the new web apps repository [r=mfinkle]
toolkit/mozapps/webapps/OpenWebapps.jsm
--- a/toolkit/mozapps/webapps/OpenWebapps.jsm
+++ b/toolkit/mozapps/webapps/OpenWebapps.jsm
@@ -134,16 +134,24 @@ let OpenWebapps = {
     this.webapps[id] = {
       title: aApplication.title,
       storeURI: aApplication.storeURI,
       appURI: aApplication.appURI,
       installData: aApplication.installData,
       installTime: (new Date()).getTime()
     };
     this._writeFile(this.appsFile, JSON.stringify(this.webapps));
+
+    // now save the icon as icon.png in the app directory
+    let iconFile = dir.clone();
+    iconFile.append("icon.png");
+    let uri = Services.io.newURI(aApplication.iconURI, null, null);
+    let persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Ci.nsIWebBrowserPersist);
+    persist.persistFlags = persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES | persist.PERSIST_FLAGS_BYPASS_CACHE;
+    persist.saveURI(uri, null, null, null, "", iconFile);
   },
  
   _appId: function(aURI) {
     for (let id in this.webapps) {
       if (this.webapps[id].appURI == aURI)
         return id;
     }
     return null;