From e8417003899a4ec9274815be30352c1328fc32e9 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 5 Feb 2018 06:28:51 -0500 Subject: Don't use AppConstants in Services.jsm --- toolkit/modules/Services.jsm | 35 ++++++++++++++++++----------------- toolkit/modules/moz.build | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'toolkit') diff --git a/toolkit/modules/Services.jsm b/toolkit/modules/Services.jsm index 1a6c3ea87..1bf1a89fe 100644 --- a/toolkit/modules/Services.jsm +++ b/toolkit/modules/Services.jsm @@ -39,14 +39,14 @@ XPCOMUtils.defineLazyGetter(Services, "dirsvc", function () { .QueryInterface(Ci.nsIProperties); }); -if (AppConstants.MOZ_CRASHREPORTER) { - XPCOMUtils.defineLazyGetter(Services, "crashmanager", () => { - let ns = {}; - Components.utils.import("resource://gre/modules/CrashManager.jsm", ns); +#ifdef MOZ_CRASHREPORTER +XPCOMUtils.defineLazyGetter(Services, "crashmanager", () => { + let ns = {}; + Components.utils.import("resource://gre/modules/CrashManager.jsm", ns); - return ns.CrashManager.Singleton; - }); -} + return ns.CrashManager.Singleton; +}); +#endif XPCOMUtils.defineLazyGetter(Services, "mm", () => { return Cc["@mozilla.org/globalmessagemanager;1"] @@ -61,8 +61,9 @@ XPCOMUtils.defineLazyGetter(Services, "ppmm", () => { }); var initTable = [ - ["androidBridge", "@mozilla.org/android/bridge;1", "nsIAndroidBridge", - AppConstants.platform == "android"], +#ifdef MOZ_WIDGET_ANDROID + ["androidBridge", "@mozilla.org/android/bridge;1", "nsIAndroidBridge"], +#endif ["appShell", "@mozilla.org/appshell/appShellService;1", "nsIAppShellService"], ["cache", "@mozilla.org/network/cache-service;1", "nsICacheService"], ["cache2", "@mozilla.org/netwerk/cache-storage-service;1", "nsICacheStorageService"], @@ -80,12 +81,14 @@ var initTable = [ ["obs", "@mozilla.org/observer-service;1", "nsIObserverService"], ["perms", "@mozilla.org/permissionmanager;1", "nsIPermissionManager"], ["prompt", "@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService"], - ["profiler", "@mozilla.org/tools/profiler;1", "nsIProfiler", - AppConstants.MOZ_ENABLE_PROFILER_SPS], +#ifdef MOZ_ENABLE_PROFILER_SPS + ["profiler", "@mozilla.org/tools/profiler;1", "nsIProfiler"], +#endif ["scriptloader", "@mozilla.org/moz/jssubscript-loader;1", "mozIJSSubScriptLoader"], ["scriptSecurityManager", "@mozilla.org/scriptsecuritymanager;1", "nsIScriptSecurityManager"], - ["search", "@mozilla.org/browser/search-service;1", "nsIBrowserSearchService", - AppConstants.MOZ_TOOLKIT_SEARCH], +#ifdef MOZ_TOOLKIT_SEARCH + ["search", "@mozilla.org/browser/search-service;1", "nsIBrowserSearchService"], +#endif ["storage", "@mozilla.org/storage/service;1", "mozIStorageService"], ["domStorageManager", "@mozilla.org/dom/localStorage-manager;1", "nsIDOMStorageManager"], ["strings", "@mozilla.org/intl/stringbundle;1", "nsIStringBundleService"], @@ -107,10 +110,8 @@ var initTable = [ ["qms", "@mozilla.org/dom/quota-manager-service;1", "nsIQuotaManagerService"], ]; -initTable.forEach(([name, contract, intf, enabled = true]) => { - if (enabled) { - XPCOMUtils.defineLazyServiceGetter(Services, name, contract, intf); - } +initTable.forEach(([name, contract, intf]) => { + XPCOMUtils.defineLazyServiceGetter(Services, name, contract, intf); }); diff --git a/toolkit/modules/moz.build b/toolkit/modules/moz.build index 9e08fe9f0..271c9b8f7 100644 --- a/toolkit/modules/moz.build +++ b/toolkit/modules/moz.build @@ -85,7 +85,6 @@ EXTRA_JS_MODULES += [ 'SelectContentHelper.jsm', 'SelectParentHelper.jsm', 'ServiceRequest.jsm', - 'Services.jsm', 'SessionRecorder.jsm', 'sessionstore/FormData.jsm', 'sessionstore/ScrollPosition.jsm', @@ -116,6 +115,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'): EXTRA_PP_JS_MODULES += [ 'AppConstants.jsm', + 'Services.jsm', ] if 'Android' != CONFIG['OS_TARGET']: -- cgit v1.2.3