Bug 1426627 - Avoid loading sync modules for non-sync users in UnifiedComplete r?florian draft
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Mon, 08 Jan 2018 17:10:33 -0500
changeset 717884 d90adf976a77c80ca6a689d5076fdbae17138805
parent 717183 ca379fcca95b1f4a3744242ea8647004b99b3507
child 745377 c91c23adbceecc2b905d20fd81c1332bf473fcf8
push id94810
push userbmo:tchiovoloni@mozilla.com
push dateTue, 09 Jan 2018 19:53:09 +0000
reviewersflorian
bugs1426627
milestone59.0a1
Bug 1426627 - Avoid loading sync modules for non-sync users in UnifiedComplete r?florian MozReview-Commit-ID: 3e90VbuGv7Z
toolkit/components/places/UnifiedComplete.js
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -325,16 +325,19 @@ XPCOMUtils.defineLazyModuleGetters(this,
   BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
   ProfileAge: "resource://gre/modules/ProfileAge.jsm",
 });
 
 XPCOMUtils.defineLazyServiceGetter(this, "textURIService",
                                    "@mozilla.org/intl/texttosuburi;1",
                                    "nsITextToSubURI");
 
+XPCOMUtils.defineLazyPreferenceGetter(this, "syncUsernamePref",
+                                      "services.sync.username");
+
 function setTimeout(callback, ms) {
   let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
   timer.initWithCallback(callback, ms, timer.TYPE_ONE_SHOT);
   return timer;
 }
 
 function convertBucketsCharPrefToArray(str) {
   return str.split(",")
@@ -1675,16 +1678,20 @@ Search.prototype = {
     // results, we add a timeout racing with the addition.
     let timeoutPromise = new Promise(resolve => {
       setTimeout(resolve, MAXIMUM_ALLOWED_EXTENSION_TIME_MS);
     });
     return Promise.race([timeoutPromise, promise]).catch(Cu.reportError);
   },
 
   async _matchRemoteTabs() {
+    // Bail out early for non-sync users.
+    if (!syncUsernamePref) {
+      return;
+    }
     let matches = await PlacesRemoteTabsAutocompleteProvider.getMatches(this._originalSearchString);
     for (let {url, title, icon, deviceName} of matches) {
       // It's rare that Sync supplies the icon for the page (but if it does, it
       // is a string URL)
       if (!icon) {
         icon = "page-icon:" + url;
       } else {
         icon = PlacesUtils.favicons