Bug 1426627 - Avoid loading sync modules for non-sync users in UnifiedComplete r?florian
MozReview-Commit-ID: 3e90VbuGv7Z
--- 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