Bug 679773 - Replace custom helpers with Services.jsm (Port Bug 648364). r=Neil a=Callek
authorJens Hatlak <jh@junetz.de>
Fri, 19 Aug 2011 08:43:22 +0200
changeset 8495 c521b24510c94369a4ab66a2255e14c4d9029d68
parent 8494 af1001813b05dba4a4c2d816d8544f60fc80280c
child 8496 4d2fab5dcade3dc58da3820fd436250b4607331f
push id112
push userjh@junetz.de
push dateSat, 20 Aug 2011 20:09:55 +0000
treeherdercomm-aurora@c521b24510c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, Callek
bugs679773, 648364
Bug 679773 - Replace custom helpers with Services.jsm (Port Bug 648364). r=Neil a=Callek
suite/common/sync/syncSetup.js
suite/common/sync/syncUtils.js
--- a/suite/common/sync/syncSetup.js
+++ b/suite/common/sync/syncSetup.js
@@ -53,16 +53,17 @@ const EXISTING_ACCOUNT_CONNECT_PAGE = 4;
 const EXISTING_ACCOUNT_LOGIN_PAGE   = 5;
 const OPTIONS_PAGE                  = 6;
 const OPTIONS_CONFIRM_PAGE          = 7;
 const SETUP_SUCCESS_PAGE            = 8;
 
 Cu.import("resource://services-sync/main.js");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/PlacesUtils.jsm");
 Cu.import("resource://gre/modules/PluralForm.jsm");
 
 var gSyncSetup = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
                                          Ci.nsIWebProgressListener,
                                          Ci.nsISupportsWeakReference]),
 
   captchaBrowser: null,
@@ -770,17 +771,19 @@ var gSyncSetup = {
   _handleChoice: function () {
     let desc = document.getElementById("mergeChoiceRadio").selectedIndex;
     document.getElementById("chosenActionDeck").selectedIndex = desc;
     switch (desc) {
       case 1:
         if (this._case1Setup)
           break;
 
-        let places_db = Weave.Svc.History.DBConnection;
+        let places_db = PlacesUtils.history
+                                   .QueryInterface(Ci.nsPIPlacesDatabase)
+                                   .DBConnection;
         if (Weave.Engines.get("history").enabled) {
           let daysOfHistory = 0;
           let stm = places_db.createStatement(
             "SELECT ROUND(( " +
               "strftime('%s','now','localtime','utc') - " +
               "( " +
                 "SELECT visit_date FROM moz_historyvisits " +
                 "ORDER BY visit_date ASC LIMIT 1 " +
@@ -801,31 +804,31 @@ var gSyncSetup = {
 
         if (Weave.Engines.get("bookmarks").enabled) {
           let bookmarks = 0;
           let stm = places_db.createStatement(
             "SELECT count(*) AS bookmarks " +
             "FROM moz_bookmarks b " +
             "LEFT JOIN moz_bookmarks t ON " +
             "b.parent = t.id WHERE b.type = 1 AND t.parent <> :tag");
-          stm.params.tag = Weave.Svc.Bookmark.tagsFolder;
+          stm.params.tag = PlacesUtils.tagsFolderId;
           if (stm.executeStep())
             bookmarks = stm.row.bookmarks;
           // Support %S for historical reasons (see bug 600141)
           document.getElementById("bookmarkCount").value =
             PluralForm.get(bookmarks,
                            this._stringBundle.GetStringFromName("bookmarksCount.label"))
                       .replace("%S", bookmarks)
                       .replace("#1", bookmarks);
         } else {
           document.getElementById("bookmarkCount").hidden = true;
         }
 
         if (Weave.Engines.get("passwords").enabled) {
-          let logins = Weave.Svc.Login.getAllLogins({});
+          let logins = Services.logins.getAllLogins({});
           // Support %S for historical reasons (see bug 600141)
           document.getElementById("passwordCount").value =
             PluralForm.get(logins.length,
                            this._stringBundle.GetStringFromName("passwordsCount.label"))
                       .replace("%S", logins.length)
                       .replace("#1", logins.length);
         } else {
           document.getElementById("passwordCount").hidden = true;
--- a/suite/common/sync/syncUtils.js
+++ b/suite/common/sync/syncUtils.js
@@ -37,40 +37,40 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // Weave should always exist before before this file gets included.
 let gSyncUtils = {
   _openLink: function (url) {
     if (document.documentElement.id == "change-dialog")
-      Weave.Svc.WinMediator.getMostRecentWindow("navigator:browser")
-                           .openUILinkIn(url, "tab");
+      Services.wm.getMostRecentWindow("navigator:browser")
+                 .openUILinkIn(url, "tab");
     else
       openUILinkIn(url, "tab");
   },
 
   changeName: function changeName(input) {
     // Make sure to update to a modified name, e.g., empty-string -> default
     Weave.Clients.localName = input.value;
     input.value = Weave.Clients.localName;
   },
 
   openChange: function openChange(type) {
     // Just re-show the dialog if it's already open
-    let openedDialog = Weave.Svc.WinMediator.getMostRecentWindow("Sync:" + type);
+    let openedDialog = Services.wm.getMostRecentWindow("Sync:" + type);
     if (openedDialog != null) {
       openedDialog.focus();
       return;
     }
 
     // Open up the change dialog
     let changeXUL = "chrome://communicator/content/sync/syncGenericChange.xul";
     let changeOpt = "centerscreen,chrome,dialog,modal,resizable=no";
-    Weave.Svc.WinWatcher.activeWindow.openDialog(changeXUL, "", changeOpt, type);
+    Services.ww.activeWindow.openDialog(changeXUL, "", changeOpt, type);
   },
 
   changePassword: function () {
     if (Weave.Utils.ensureMPUnlocked())
       this.openChange("ChangePassword");
   },
 
   resetPassphrase: function () {