Bug 628079 Initially import bookmarks from resource: for omnijar compatibility r=Ratty
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Mon, 24 Jan 2011 23:59:31 +0000
changeset 6997 7821b0a1c9f59ed8372be0cb764ef4a76d0bca14
parent 6996 0c665572476a3247a57ee7dfcf2f0d48e1adf52f
child 6998 fd977cea54d26da561f6c80805a8e5d5288287b9
push idunknown
push userunknown
push dateunknown
reviewersRatty
bugs628079
Bug 628079 Initially import bookmarks from resource: for omnijar compatibility r=Ratty
suite/common/src/nsSuiteGlue.js
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -612,40 +612,41 @@ SuiteGlue.prototype = {
       } catch(ex) {}
       var smartBookmarksVersion = 0;
       try {
         smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion");
       } catch(ex) {}
       if (!autoExportHTML && smartBookmarksVersion != -1)
         Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
 
-      // Get bookmarks.html file location.
-      var dirService = Components.classes["@mozilla.org/file/directory_service;1"]
-                                 .getService(Components.interfaces.nsIProperties);
-
-      var bookmarksFile = null;
+      var bookmarksURI = null;
       if (restoreDefaultBookmarks) {
         // User wants to restore bookmarks.html file from default profile folder.
-        bookmarksFile = dirService.get("profDef", Components.interfaces.nsILocalFile);
-        bookmarksFile.append("bookmarks.html");
+        bookmarksURI = Services.io.newURI("resource:///defaults/profile/bookmarks.html", null, null);
       }
-      else
-        bookmarksFile = dirService.get("BMarks", Components.interfaces.nsILocalFile);
+      else {
+        // Get bookmarks.html file location.
+        var bookmarksFile = Components.classes["@mozilla.org/file/directory_service;1"]
+                                      .getService(Components.interfaces.nsIProperties)
+                                      .get("BMarks", Components.interfaces.nsILocalFile);
+        if (bookmarksFile.exists())
+          bookmarksURI = Services.io.newFileURI(bookmarksFile);
+      }
 
-      if (bookmarksFile.exists()) {
+      if (bookmarksURI) {
         // Add an import observer.  It will ensure that smart bookmarks are
         // created once the operation is complete.
         Services.obs.addObserver(this, "bookmarks-restore-success", false);
         Services.obs.addObserver(this, "bookmarks-restore-failed", false);
 
         // Import from bookmarks.html file.
         try {
           var importer = Components.classes["@mozilla.org/browser/places/import-export-service;1"]
                                    .getService(Components.interfaces.nsIPlacesImportExportService);
-          importer.importHTMLFromFile(bookmarksFile, true /* overwrite existing */);
+          importer.importHTMLFromURI(bookmarksURI, true /* overwrite existing */);
         }
         catch(ex) {
           // Report the error, but ignore it.
           Components.utils.reportError("bookmarks.html file could be corrupt. " + err);
           Services.obs.removeObserver(importObserver, "bookmarks-restore-success");
           Services.obs.removeObserver(importObserver, "bookmarks-restore-failed");
         }
       }