Bug 1427850 - Check that sync is ready directly instead of reading the sync username to determine it r?markh
MozReview-Commit-ID: LnQ6Em0GCvM
--- a/services/sync/Weave.js
+++ b/services/sync/Weave.js
@@ -9,18 +9,17 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "Utils", () => {
return Cu.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
@@ -123,18 +122,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,
--- a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
@@ -111,18 +111,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.
this.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;