Bug 1116446 - Part 2: Use BookmarkJSONUtils.importFromFile instead of PlacesUtils.restoreBookmarksFromJSONFile in bookmarksManager.js. r=Neil a=IanN for comm-aurora comm-beta CLOSED TREE
authorTooru Fujisawa <arai_a@mac.com>
Wed, 31 Dec 2014 02:04:47 +0900
changeset 25633 f611e79f87d6d3c551fbb298aab75f31aa4d202e
parent 25632 5b15f41fa855b8380f1e0008d3b58b7844dd7cc5
child 25634 3e14df96f8554bf74feac15766ee317811b4c845
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, IanN
bugs1116446
Bug 1116446 - Part 2: Use BookmarkJSONUtils.importFromFile instead of PlacesUtils.restoreBookmarksFromJSONFile in bookmarksManager.js. r=Neil a=IanN for comm-aurora comm-beta CLOSED TREE
suite/common/bookmarks/bookmarksManager.js
--- a/suite/common/bookmarks/bookmarksManager.js
+++ b/suite/common/bookmarks/bookmarksManager.js
@@ -1,13 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "BookmarkJSONUtils",
+                                  "resource://gre/modules/BookmarkJSONUtils.jsm");
+
 var PlacesOrganizer = {
   _places: null,
   _content: null,
 
   // IDs of fields from editBookmarkOverlay that should be hidden when infoBox
   // is minimal. IDs should be kept in sync with the IDs of the elements
   // observing additionalInfoBroadcaster.
   _additionalInfoFields: [
@@ -427,22 +431,19 @@ var PlacesOrganizer = {
     }
 
     // confirm ok to delete existing bookmarks
     if (!Services.prompt.confirm(null,
                                  PlacesUIUtils.getString("bookmarksRestoreAlertTitle"),
                                  PlacesUIUtils.getString("bookmarksRestoreAlert")))
       return;
 
-    try {
-      PlacesUtils.restoreBookmarksFromJSONFile(aFile);
-    }
-    catch(ex) {
+    BookmarkJSONUtils.importFromFile(aFile.path, true).catch(() => {
       this._showErrorAlert(PlacesUIUtils.getString("bookmarksRestoreParseError"));
-    }
+    });
   },
 
   _showErrorAlert: function PO__showErrorAlert(aMsg) {
     var brandShortName = document.getElementById("brandStrings")
                                  .getString("brandShortName");
 
     Services.prompt.alert(window, brandShortName, aMsg);
   },