Bug 1816969 - Fix runtime errors with MOZ_SERVICES_SYNC=False. r=mossop

Some checks on MOZ_SERVICES_SYNC have been removed in Bug 1227361, but
it is still used in a few places in the codebase.
Trying to set it to False results in some runtime errors, that this
commit fixes.

Differential Revision: https://phabricator.services.mozilla.com/D170047
This commit is contained in:
Pier Angelo Vendrame
2023-02-16 13:27:22 +00:00
parent 49ed2741cf
commit 0ce8df939b
3 changed files with 16 additions and 13 deletions

View File

@@ -5,10 +5,6 @@
// This file is loaded into the browser window scope.
/* eslint-env mozilla/browser-window */
const { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs"
);
ChromeUtils.defineModuleGetter(
this,
"FxAccounts",
@@ -21,6 +17,7 @@ ChromeUtils.defineModuleGetter(
);
ChromeUtils.defineESModuleGetters(this, {
SyncedTabs: "resource://services-sync/SyncedTabs.sys.mjs",
UIState: "resource://services-sync/UIState.sys.mjs",
Weave: "resource://services-sync/main.sys.mjs",
});
@@ -337,7 +334,9 @@ var gSync = {
// once syncing completes (bug 1239042).
_syncStartTime: 0,
_syncAnimationTimer: 0,
_obs: ["weave:engine:sync:finish", "quit-application", UIState.ON_UPDATE],
_obs: AppConstants.MOZ_SERVICES_SYNC
? ["weave:engine:sync:finish", "quit-application", UIState.ON_UPDATE]
: [],
get log() {
if (!this._log) {
@@ -455,7 +454,7 @@ var gSync = {
this._definePrefGetters();
if (!this.FXA_ENABLED) {
if (!AppConstants.MOZ_SERVICES_SYNC || !this.FXA_ENABLED) {
this.onFxaDisabled();
return;
}
@@ -1567,7 +1566,7 @@ var gSync = {
// "Send Page to Device" and "Send Link to Device" menu items
updateContentContextMenu(contextMenu) {
if (!this.FXA_ENABLED) {
if (!AppConstants.MOZ_SERVICES_SYNC || !this.FXA_ENABLED) {
// These items are hidden by default. No need to do anything.
return false;
}

View File

@@ -831,11 +831,13 @@ let JSWINDOWACTORS = {
},
};
XPCOMUtils.defineLazyGetter(
lazy,
"WeaveService",
() => Cc["@mozilla.org/weave/service;1"].getService().wrappedJSObject
);
if (AppConstants.MOZ_SERVICES_SYNC) {
XPCOMUtils.defineLazyGetter(
lazy,
"WeaveService",
() => Cc["@mozilla.org/weave/service;1"].getService().wrappedJSObject
);
}
if (AppConstants.MOZ_CRASHREPORTER) {
XPCOMUtils.defineLazyModuleGetters(lazy, {
@@ -2825,7 +2827,7 @@ BrowserGlue.prototype = {
{
name: "WeaveService",
task: async () => {
if (lazy.WeaveService.enabled) {
if (lazy.WeaveService?.enabled) {
await lazy.WeaveService.whenLoaded();
lazy.WeaveService.Weave.Service.scheduler.autoConnect();
}

View File

@@ -177,7 +177,9 @@
@RESPATH@/components/nsUpdateService.manifest
#endif
@RESPATH@/components/ProcessSingleton.manifest
#ifdef MOZ_SERVICES_SYNC
@RESPATH@/components/SyncComponents.manifest
#endif
@RESPATH@/components/servicesComponents.manifest
@RESPATH@/components/servicesSettings.manifest
@RESPATH@/components/cryptoComponents.manifest