Bug 1364337 - Remove a deprecated RemovePages call from WindowsJumpLists.jsm. r=mak draft
authortiago <tiago.paez11@gmail.com>
Wed, 07 Jun 2017 04:21:18 -0300
changeset 590148 510c1a960f7a585a7552192ae58e85ae3bd56a52
parent 589954 5801aa478de12a62b2b2982659e787fcc4268d67
child 632101 c41bbb25b96d1bb6f6d9c51840e02fc22d162893
push id62608
push userbmo:tiago.paez11@gmail.com
push dateWed, 07 Jun 2017 07:21:43 +0000
reviewersmak
bugs1364337
milestone55.0a1
Bug 1364337 - Remove a deprecated RemovePages call from WindowsJumpLists.jsm. r=mak MozReview-Commit-ID: ElQaYVRDpLj
browser/modules/WindowsJumpLists.jsm
--- a/browser/modules/WindowsJumpLists.jsm
+++ b/browser/modules/WindowsJumpLists.jsm
@@ -1,22 +1,17 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 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");
-Components.utils.import("resource://gre/modules/Services.jsm");
+ const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 
-/**
- * Constants
- */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
 
 // Stop updating jumplists after some idle time.
 const IDLE_TIMEOUT_SECONDS = 5 * 60;
 
 // Prefs
 const PREF_TASKBAR_BRANCH    = "browser.taskbar.lists.";
 const PREF_TASKBAR_ENABLED   = "enabled";
 const PREF_TASKBAR_ITEMCOUNT = "maxListItemCount";
@@ -47,38 +42,31 @@ XPCOMUtils.defineLazyGetter(this, "_pref
   return Services.prefs.getBranch(PREF_TASKBAR_BRANCH);
 });
 
 XPCOMUtils.defineLazyGetter(this, "_stringBundle", function() {
   return Services.strings
                  .createBundle("chrome://browser/locale/taskbar.properties");
 });
 
-XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
-  Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
-  return PlacesUtils;
-});
-
-XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
-  Components.utils.import("resource://gre/modules/NetUtil.jsm");
-  return NetUtil;
-});
-
 XPCOMUtils.defineLazyServiceGetter(this, "_idle",
                                    "@mozilla.org/widget/idleservice;1",
                                    "nsIIdleService");
 
 XPCOMUtils.defineLazyServiceGetter(this, "_taskbarService",
                                    "@mozilla.org/windows-taskbar;1",
                                    "nsIWinTaskbar");
 
 XPCOMUtils.defineLazyServiceGetter(this, "_winShellService",
                                    "@mozilla.org/browser/shell-service;1",
                                    "nsIWindowsShellService");
 
+XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
+"resource://gre/modules/PlacesUtils.jsm");
+
 XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
   "resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 /**
  * Global functions
  */
 
 function _getString(name) {
@@ -432,17 +420,17 @@ this.WinTaskbarJumpList =
             aCallback.call(aScope,
                            { uri: row.getResultByIndex(1)
                            , title: row.getResultByIndex(2)
                            });
           } catch (e) {}
         }
       },
       handleError(aError) {
-        Components.utils.reportError(
+        Cu.reportError(
           "Async execution error (" + aError.result + "): " + aError.message);
       },
       handleCompletion(aReason) {
         aCallback.call(WinTaskbarJumpList, null);
       },
     });
   },
 
@@ -451,22 +439,22 @@ this.WinTaskbarJumpList =
       return;
     var URIsToRemove = [];
     var e = items.enumerate();
     while (e.hasMoreElements()) {
       let oldItem = e.getNext().QueryInterface(Ci.nsIJumpListShortcut);
       if (oldItem) {
         try { // in case we get a bad uri
           let uriSpec = oldItem.app.getParameter(0);
-          URIsToRemove.push(NetUtil.newURI(uriSpec));
+          URIsToRemove.push(Services.io.newURI(uriSpec));
         } catch (err) { }
       }
     }
     if (URIsToRemove.length > 0) {
-      PlacesUtils.bhistory.removePages(URIsToRemove, URIsToRemove.length, true);
+      PlacesUtils.history.remove(URIsToRemove).catch(Cu.reportError);
     }
   },
 
   /**
    * Prefs utilities
    */
 
   _refreshPrefs: function WTBJL__refreshPrefs() {