Skip to content

Commit 3eac12b

Browse files
committed
Bug 1845311 - Use ChromeUtils.defineLazyGetter in more places r=arai,webdriver-reviewers,geckoview-reviewers,extension-reviewers,application-update-reviewers,credential-management-reviewers,devtools-reviewers,fxview-reviewers,anti-tracking-reviewers,sessionstore-reviewers,pbz,joschmidt,robwu,issammani,bytesized,owlish,dao
Differential Revision: https://phabricator.services.mozilla.com/D184481
1 parent eeac47b commit 3eac12b

File tree

313 files changed

+528
-868
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+528
-868
lines changed

browser/actors/AboutProtectionsParent.sys.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
2020
FXA_PWDMGR_REALM: "resource://gre/modules/FxAccountsCommon.js",
2121
});
2222

23-
XPCOMUtils.defineLazyGetter(lazy, "fxAccounts", () => {
23+
ChromeUtils.defineLazyGetter(lazy, "fxAccounts", () => {
2424
return ChromeUtils.importESModule(
2525
"resource://gre/modules/FxAccounts.sys.mjs"
2626
).getFxAccountsSingleton();

browser/actors/DecoderDoctorParent.sys.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
99

1010
const lazy = {};
1111

12-
XPCOMUtils.defineLazyGetter(lazy, "gNavigatorBundle", function () {
12+
ChromeUtils.defineLazyGetter(lazy, "gNavigatorBundle", function () {
1313
return Services.strings.createBundle(
1414
"chrome://browser/locale/browser.properties"
1515
);

browser/actors/EncryptedMediaParent.sys.mjs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@
22
/* This Source Code Form is subject to the terms of the Mozilla Public
33
* License, v. 2.0. If a copy of the MPL was not distributed with this
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5-
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
65

76
const lazy = {};
87

9-
XPCOMUtils.defineLazyGetter(lazy, "gBrandBundle", function () {
8+
ChromeUtils.defineLazyGetter(lazy, "gBrandBundle", function () {
109
return Services.strings.createBundle(
1110
"chrome://branding/locale/brand.properties"
1211
);
1312
});
1413

15-
XPCOMUtils.defineLazyGetter(lazy, "gNavigatorBundle", function () {
14+
ChromeUtils.defineLazyGetter(lazy, "gNavigatorBundle", function () {
1615
return Services.strings.createBundle(
1716
"chrome://browser/locale/browser.properties"
1817
);
1918
});
2019

21-
XPCOMUtils.defineLazyGetter(lazy, "gFluentStrings", function () {
20+
ChromeUtils.defineLazyGetter(lazy, "gFluentStrings", function () {
2221
return new Localization(["branding/brand.ftl", "browser/browser.ftl"], true);
2322
});
2423

browser/actors/PluginParent.sys.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
55

66
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
7-
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
87

98
const lazy = {};
109

1110
ChromeUtils.defineESModuleGetters(lazy, {
1211
CrashSubmit: "resource://gre/modules/CrashSubmit.sys.mjs",
1312
});
1413

15-
XPCOMUtils.defineLazyGetter(lazy, "gNavigatorBundle", function () {
14+
ChromeUtils.defineLazyGetter(lazy, "gNavigatorBundle", function () {
1615
const url = "chrome://browser/locale/browser.properties";
1716
return Services.strings.createBundle(url);
1817
});

browser/actors/PromptParent.sys.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
2525
false
2626
);
2727

28-
XPCOMUtils.defineLazyGetter(lazy, "gTabBrowserLocalization", function () {
28+
ChromeUtils.defineLazyGetter(lazy, "gTabBrowserLocalization", function () {
2929
return new Localization(["browser/tabbrowser.ftl"], true);
3030
});
3131

browser/components/BrowserContentHandler.sys.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ XPCOMUtils.defineLazyServiceGetters(lazy, {
2828
WindowsUIUtils: ["@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"],
2929
});
3030

31-
XPCOMUtils.defineLazyGetter(lazy, "gSystemPrincipal", () =>
31+
ChromeUtils.defineLazyGetter(lazy, "gSystemPrincipal", () =>
3232
Services.scriptSecurityManager.getSystemPrincipal()
3333
);
3434

35-
XPCOMUtils.defineLazyGetter(lazy, "gWindowsAlertsService", () => {
35+
ChromeUtils.defineLazyGetter(lazy, "gWindowsAlertsService", () => {
3636
// We might not have the Windows alerts service: e.g., on Windows 7 and Windows 8.
3737
if (!("nsIWindowsAlertsService" in Ci)) {
3838
return null;

browser/components/BrowserGlue.sys.mjs

+6-6
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ XPCOMUtils.defineLazyServiceGetters(lazy, {
118118
PushService: ["@mozilla.org/push/Service;1", "nsIPushService"],
119119
});
120120

121-
XPCOMUtils.defineLazyGetter(
121+
ChromeUtils.defineLazyGetter(
122122
lazy,
123123
"accountsL10n",
124124
() =>
@@ -821,7 +821,7 @@ let JSWINDOWACTORS = {
821821
},
822822
};
823823

824-
XPCOMUtils.defineLazyGetter(
824+
ChromeUtils.defineLazyGetter(
825825
lazy,
826826
"WeaveService",
827827
() => Cc["@mozilla.org/weave/service;1"].getService().wrappedJSObject
@@ -833,19 +833,19 @@ if (AppConstants.MOZ_CRASHREPORTER) {
833833
});
834834
}
835835

836-
XPCOMUtils.defineLazyGetter(lazy, "gBrandBundle", function () {
836+
ChromeUtils.defineLazyGetter(lazy, "gBrandBundle", function () {
837837
return Services.strings.createBundle(
838838
"chrome://branding/locale/brand.properties"
839839
);
840840
});
841841

842-
XPCOMUtils.defineLazyGetter(lazy, "gBrowserBundle", function () {
842+
ChromeUtils.defineLazyGetter(lazy, "gBrowserBundle", function () {
843843
return Services.strings.createBundle(
844844
"chrome://browser/locale/browser.properties"
845845
);
846846
});
847847

848-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
848+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
849849
let { ConsoleAPI } = ChromeUtils.importESModule(
850850
"resource://gre/modules/Console.sys.mjs"
851851
);
@@ -920,7 +920,7 @@ export function BrowserGlue() {
920920
"nsIUserIdleService"
921921
);
922922

923-
XPCOMUtils.defineLazyGetter(this, "_distributionCustomizer", function () {
923+
ChromeUtils.defineLazyGetter(this, "_distributionCustomizer", function () {
924924
const { DistributionCustomizer } = ChromeUtils.importESModule(
925925
"resource:///modules/distribution.sys.mjs"
926926
);

browser/components/aboutlogins/AboutLoginsParent.sys.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
2121
UIState: "resource://services-sync/UIState.sys.mjs",
2222
});
2323

24-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
24+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
2525
return lazy.LoginHelper.createLogger("AboutLoginsParent");
2626
});
2727
XPCOMUtils.defineLazyPreferenceGetter(
@@ -48,7 +48,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
4848
"signon.management.page.vulnerable-passwords.enabled",
4949
false
5050
);
51-
XPCOMUtils.defineLazyGetter(lazy, "AboutLoginsL10n", () => {
51+
ChromeUtils.defineLazyGetter(lazy, "AboutLoginsL10n", () => {
5252
return new Localization(["branding/brand.ftl", "browser/aboutLogins.ftl"]);
5353
});
5454

browser/components/aboutlogins/LoginBreaches.sys.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* RemoteSettings.
88
*/
99

10-
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
11-
1210
const lazy = {};
1311

1412
ChromeUtils.defineESModuleGetters(lazy, {
@@ -168,6 +166,6 @@ export const LoginBreaches = {
168166
},
169167
};
170168

171-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
169+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
172170
return lazy.LoginHelper.createLogger("LoginBreaches");
173171
});

browser/components/attribution/AttributionCode.sys.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ export const AttributionIOUtils = {
1212
exists: async path => IOUtils.exists(path),
1313
};
1414

15-
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
1615
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
1716

1817
const lazy = {};
1918
ChromeUtils.defineESModuleGetters(lazy, {
2019
MacAttribution: "resource:///modules/MacAttribution.sys.mjs",
2120
});
22-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
21+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
2322
let { ConsoleAPI } = ChromeUtils.importESModule(
2423
"resource://gre/modules/Console.sys.mjs"
2524
);

browser/components/attribution/MacAttribution.sys.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
6-
75
const lazy = {};
8-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
6+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
97
let { ConsoleAPI } = ChromeUtils.importESModule(
108
"resource://gre/modules/Console.sys.mjs"
119
);

browser/components/customizableui/CustomizableUI.sys.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
1919
ShortcutUtils: "resource://gre/modules/ShortcutUtils.sys.mjs",
2020
});
2121

22-
XPCOMUtils.defineLazyGetter(lazy, "gWidgetsBundle", function () {
22+
ChromeUtils.defineLazyGetter(lazy, "gWidgetsBundle", function () {
2323
const kUrl =
2424
"chrome://browser/locale/customizableui/customizableWidgets.properties";
2525
return Services.strings.createBundle(kUrl);
@@ -185,7 +185,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
185185
}
186186
);
187187

188-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
188+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
189189
let { ConsoleAPI } = ChromeUtils.importESModule(
190190
"resource://gre/modules/Console.sys.mjs"
191191
);

browser/components/customizableui/CustomizableWidgets.sys.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
2222
const kPrefCustomizationDebug = "browser.uiCustomization.debug";
2323
const kPrefScreenshots = "extensions.screenshots.disabled";
2424

25-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
25+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
2626
let { ConsoleAPI } = ChromeUtils.importESModule(
2727
"resource://gre/modules/Console.sys.mjs"
2828
);

browser/components/customizableui/CustomizeMode.sys.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
3131
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
3232
URILoadingHelper: "resource:///modules/URILoadingHelper.sys.mjs",
3333
});
34-
XPCOMUtils.defineLazyGetter(lazy, "gWidgetsBundle", function () {
34+
ChromeUtils.defineLazyGetter(lazy, "gWidgetsBundle", function () {
3535
const kUrl =
3636
"chrome://browser/locale/customizableui/customizableWidgets.properties";
3737
return Services.strings.createBundle(kUrl);
@@ -44,7 +44,7 @@ XPCOMUtils.defineLazyServiceGetter(
4444
);
4545

4646
let gDebug;
47-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
47+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
4848
let { ConsoleAPI } = ChromeUtils.importESModule(
4949
"resource://gre/modules/Console.sys.mjs"
5050
);

browser/components/customizableui/PanelMultiView.sys.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,12 @@
9797
* └───┴───┴── Open views
9898
*/
9999

100-
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
101-
102100
const lazy = {};
103101
ChromeUtils.defineESModuleGetters(lazy, {
104102
CustomizableUI: "resource:///modules/CustomizableUI.sys.mjs",
105103
});
106104

107-
XPCOMUtils.defineLazyGetter(lazy, "gBundle", function () {
105+
ChromeUtils.defineLazyGetter(lazy, "gBundle", function () {
108106
return Services.strings.createBundle(
109107
"chrome://browser/locale/browser.properties"
110108
);

browser/components/downloads/DownloadsCommon.sys.mjs

+17-13
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ XPCOMUtils.defineLazyServiceGetters(lazy, {
4848
gMIMEService: ["@mozilla.org/mime;1", "nsIMIMEService"],
4949
});
5050

51-
XPCOMUtils.defineLazyGetter(lazy, "DownloadsLogger", () => {
51+
ChromeUtils.defineLazyGetter(lazy, "DownloadsLogger", () => {
5252
let { ConsoleAPI } = ChromeUtils.importESModule(
5353
"resource://gre/modules/Console.sys.mjs"
5454
);
@@ -115,7 +115,7 @@ var PrefObserver = {
115115
kPrefBranch.addObserver("", this, true);
116116
for (let key in prefs) {
117117
let name = key;
118-
XPCOMUtils.defineLazyGetter(this, name, function () {
118+
ChromeUtils.defineLazyGetter(this, name, function () {
119119
return PrefObserver.getPref(name);
120120
});
121121
}
@@ -744,10 +744,10 @@ export var DownloadsCommon = {
744744
},
745745
};
746746

747-
XPCOMUtils.defineLazyGetter(DownloadsCommon, "log", () => {
747+
ChromeUtils.defineLazyGetter(DownloadsCommon, "log", () => {
748748
return lazy.DownloadsLogger.log.bind(lazy.DownloadsLogger);
749749
});
750-
XPCOMUtils.defineLazyGetter(DownloadsCommon, "error", () => {
750+
ChromeUtils.defineLazyGetter(DownloadsCommon, "error", () => {
751751
return lazy.DownloadsLogger.error.bind(lazy.DownloadsLogger);
752752
});
753753

@@ -999,18 +999,18 @@ DownloadsDataCtor.prototype = {
999999
},
10001000
};
10011001

1002-
XPCOMUtils.defineLazyGetter(lazy, "HistoryDownloadsData", function () {
1002+
ChromeUtils.defineLazyGetter(lazy, "HistoryDownloadsData", function () {
10031003
return new DownloadsDataCtor({ isHistory: true });
10041004
});
10051005

1006-
XPCOMUtils.defineLazyGetter(lazy, "LimitedHistoryDownloadsData", function () {
1006+
ChromeUtils.defineLazyGetter(lazy, "LimitedHistoryDownloadsData", function () {
10071007
return new DownloadsDataCtor({
10081008
isHistory: true,
10091009
maxHistoryResults: kMaxHistoryResultsForLimitedView,
10101010
});
10111011
});
10121012

1013-
XPCOMUtils.defineLazyGetter(
1013+
ChromeUtils.defineLazyGetter(
10141014
lazy,
10151015
"LimitedPrivateHistoryDownloadData",
10161016
function () {
@@ -1022,11 +1022,11 @@ XPCOMUtils.defineLazyGetter(
10221022
}
10231023
);
10241024

1025-
XPCOMUtils.defineLazyGetter(lazy, "PrivateDownloadsData", function () {
1025+
ChromeUtils.defineLazyGetter(lazy, "PrivateDownloadsData", function () {
10261026
return new DownloadsDataCtor({ isPrivate: true });
10271027
});
10281028

1029-
XPCOMUtils.defineLazyGetter(lazy, "DownloadsData", function () {
1029+
ChromeUtils.defineLazyGetter(lazy, "DownloadsData", function () {
10301030
return new DownloadsDataCtor();
10311031
});
10321032

@@ -1459,11 +1459,15 @@ Object.setPrototypeOf(
14591459
DownloadsViewPrototype
14601460
);
14611461

1462-
XPCOMUtils.defineLazyGetter(lazy, "PrivateDownloadsIndicatorData", function () {
1463-
return new DownloadsIndicatorDataCtor(true);
1464-
});
1462+
ChromeUtils.defineLazyGetter(
1463+
lazy,
1464+
"PrivateDownloadsIndicatorData",
1465+
function () {
1466+
return new DownloadsIndicatorDataCtor(true);
1467+
}
1468+
);
14651469

1466-
XPCOMUtils.defineLazyGetter(lazy, "DownloadsIndicatorData", function () {
1470+
ChromeUtils.defineLazyGetter(lazy, "DownloadsIndicatorData", function () {
14671471
return new DownloadsIndicatorDataCtor(false);
14681472
});
14691473

browser/components/downloads/DownloadsTaskbar.sys.mjs

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@
1010

1111
// Globals
1212

13-
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
14-
1513
const lazy = {};
1614

1715
ChromeUtils.defineESModuleGetters(lazy, {
1816
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
1917
Downloads: "resource://gre/modules/Downloads.sys.mjs",
2018
});
2119

22-
XPCOMUtils.defineLazyGetter(lazy, "gWinTaskbar", function () {
20+
ChromeUtils.defineLazyGetter(lazy, "gWinTaskbar", function () {
2321
if (!("@mozilla.org/windows-taskbar;1" in Cc)) {
2422
return null;
2523
}
@@ -29,14 +27,14 @@ XPCOMUtils.defineLazyGetter(lazy, "gWinTaskbar", function () {
2927
return winTaskbar.available && winTaskbar;
3028
});
3129

32-
XPCOMUtils.defineLazyGetter(lazy, "gMacTaskbarProgress", function () {
30+
ChromeUtils.defineLazyGetter(lazy, "gMacTaskbarProgress", function () {
3331
return (
3432
"@mozilla.org/widget/macdocksupport;1" in Cc &&
3533
Cc["@mozilla.org/widget/macdocksupport;1"].getService(Ci.nsITaskbarProgress)
3634
);
3735
});
3836

39-
XPCOMUtils.defineLazyGetter(lazy, "gGtkTaskbarProgress", function () {
37+
ChromeUtils.defineLazyGetter(lazy, "gGtkTaskbarProgress", function () {
4038
return (
4139
"@mozilla.org/widget/taskbarprogress/gtk;1" in Cc &&
4240
Cc["@mozilla.org/widget/taskbarprogress/gtk;1"].getService(

browser/components/enterprisepolicies/Policies.sys.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const ABOUT_CONTRACT = "@mozilla.org/network/protocol/about;1?what=";
3737

3838
const isXpcshell = Services.env.exists("XPCSHELL_TEST_PROFILE_DIR");
3939

40-
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
40+
ChromeUtils.defineLazyGetter(lazy, "log", () => {
4141
let { ConsoleAPI } = ChromeUtils.importESModule(
4242
"resource://gre/modules/Console.sys.mjs"
4343
);

0 commit comments

Comments
 (0)