# HG changeset patch # User Thom Chiovoloni # Date 1515010963 18000 # Node ID fcec2e929c2ca950a5cca97d3d8d308fa12e4213 # Parent 24ffa5badbfc6ebf5aa623a42dcacd05c1757f44 Bug 1427850 - Check that sync is ready directly instead of reading the sync username to determine it r=markh MozReview-Commit-ID: LnQ6Em0GCvM diff --git a/services/sync/Weave.js b/services/sync/Weave.js --- a/services/sync/Weave.js +++ b/services/sync/Weave.js @@ -5,18 +5,17 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.defineModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm"); XPCOMUtils.defineLazyGetter(this, "Utils", () => { return ChromeUtils.import("resource://services-sync/util.js", {}).Utils; }); -const SYNC_PREFS_BRANCH = "services.sync."; - +XPCOMUtils.defineLazyPreferenceGetter(this, "syncUsername", "services.sync.username"); /** * Sync's XPCOM service. * * It is named "Weave" for historical reasons. * * It's worth noting how Sync is lazily loaded. We register a timer that * loads Sync a few seconds after app startup. This is so Sync does not @@ -120,18 +119,17 @@ WeaveService.prototype = { * Whether Sync appears to be enabled. * * This returns true if we have an associated FxA account * * It does *not* perform a robust check to see if the client is working. * For that, you'll want to check Weave.Status.checkSetup(). */ get enabled() { - let prefs = Services.prefs.getBranch(SYNC_PREFS_BRANCH); - return prefs.prefHasUserValue("username"); + return !!syncUsername; } }; function AboutWeaveLog() {} AboutWeaveLog.prototype = { classID: Components.ID("{d28f8a0b-95da-48f4-b712-caf37097be41}"), QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule, diff --git a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm --- a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm +++ b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm @@ -109,18 +109,17 @@ Services.obs.addObserver(observe, "weave Services.prefs.addObserver(PREF_SHOW_REMOTE_ICONS, observe); observe(null, "nsPref:changed", PREF_SHOW_REMOTE_ICONS); // This public object is a static singleton. var PlacesRemoteTabsAutocompleteProvider = { // a promise that resolves with an array of matching remote tabs. getMatches(searchString) { // If Sync isn't configured we bail early. - if (Weave === null || - !Services.prefs.prefHasUserValue("services.sync.username")) { + if (!weaveXPCService.ready || !weaveXPCService.enabled) { return Promise.resolve([]); } let re = new RegExp(escapeRegExp(searchString), "i"); let matches = []; let { tabs, clients } = ensureItems(); for (let [url, { clientId, tab }] of tabs) { let title = tab.title;