Skip to content

Commit

Permalink
Bug 1845311 - [Part 2] Use ChromeUtils.defineLazyGetter in more place…
Browse files Browse the repository at this point in the history
…s r=arai,webcompat-reviewers,necko-reviewers,extension-reviewers,settings-reviewers,application-update-reviewers,credential-management-reviewers,devtools-reviewers,fxview-reviewers,sync-reviewers,anti-tracking-reviewers,tabbrowser-reviewers,bytesized,twisniewski,sgalich,mak,kershaw,sclements,pbz,robwu,geckoview-reviewers,amejiamarmol

Differential Revision: https://phabricator.services.mozilla.com/D184623
  • Loading branch information
gregorypappas committed Aug 1, 2023
1 parent f66262a commit 8a35d5c
Show file tree
Hide file tree
Showing 208 changed files with 390 additions and 400 deletions.
2 changes: 1 addition & 1 deletion browser/base/content/browser-addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
SITEPERMS_ADDON_TYPE:
"resource://gre/modules/addons/siteperms-addon-utils.sys.mjs",
});
XPCOMUtils.defineLazyGetter(lazy, "l10n", function () {
ChromeUtils.defineLazyGetter(lazy, "l10n", function () {
return new Localization(
["browser/addonNotifications.ftl", "branding/brand.ftl"],
true
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/browser-fullScreenAndPointerLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ var FullScreen = {
},
};

XPCOMUtils.defineLazyGetter(FullScreen, "_permissionNotificationIDs", () => {
ChromeUtils.defineLazyGetter(FullScreen, "_permissionNotificationIDs", () => {
let { PermissionUI } = ChromeUtils.importESModule(
"resource:///modules/PermissionUI.sys.mjs"
);
Expand Down
43 changes: 23 additions & 20 deletions browser/base/content/browser-siteProtections.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,29 @@ class ProtectionCategory {

l10nId = l10nId || id;
this.strings = {};
XPCOMUtils.defineLazyGetter(this.strings, "subViewBlocked", () =>
ChromeUtils.defineLazyGetter(this.strings, "subViewBlocked", () =>
gNavigatorBundle.getString(`contentBlocking.${l10nId}View.blocked.label`)
);
XPCOMUtils.defineLazyGetter(this.strings, "subViewTitleBlocking", () =>
ChromeUtils.defineLazyGetter(this.strings, "subViewTitleBlocking", () =>
gNavigatorBundle.getString(`protections.blocking.${l10nId}.title`)
);
XPCOMUtils.defineLazyGetter(this.strings, "subViewTitleNotBlocking", () =>
ChromeUtils.defineLazyGetter(this.strings, "subViewTitleNotBlocking", () =>
gNavigatorBundle.getString(`protections.notBlocking.${l10nId}.title`)
);

XPCOMUtils.defineLazyGetter(this, "subView", () =>
ChromeUtils.defineLazyGetter(this, "subView", () =>
document.getElementById(`protections-popup-${this._id}View`)
);

XPCOMUtils.defineLazyGetter(this, "subViewHeading", () =>
ChromeUtils.defineLazyGetter(this, "subViewHeading", () =>
document.getElementById(`protections-popup-${this._id}View-heading`)
);

XPCOMUtils.defineLazyGetter(this, "subViewList", () =>
ChromeUtils.defineLazyGetter(this, "subViewList", () =>
document.getElementById(`protections-popup-${this._id}View-list`)
);

XPCOMUtils.defineLazyGetter(this, "subViewShimAllowHint", () =>
ChromeUtils.defineLazyGetter(this, "subViewShimAllowHint", () =>
document.getElementById(
`protections-popup-${this._id}View-shim-allow-hint`
)
Expand Down Expand Up @@ -363,7 +363,7 @@ let TrackingProtection =
);

// Blocked label has custom key, overwrite the getter.
XPCOMUtils.defineLazyGetter(this.strings, "subViewBlocked", () =>
ChromeUtils.defineLazyGetter(this.strings, "subViewBlocked", () =>
gNavigatorBundle.getString("contentBlocking.trackersView.blocked.label")
);

Expand Down Expand Up @@ -607,19 +607,22 @@ let ThirdPartyCookies =
}
);

XPCOMUtils.defineLazyGetter(this, "categoryLabel", () =>
ChromeUtils.defineLazyGetter(this, "categoryLabel", () =>
document.getElementById("protections-popup-cookies-category-label")
);

// Not blocking title has custom key, overwrite the getter.
XPCOMUtils.defineLazyGetter(this.strings, "subViewTitleNotBlocking", () =>
gNavigatorBundle.getString(
"protections.notBlocking.crossSiteTrackingCookies.title"
)
ChromeUtils.defineLazyGetter(
this.strings,
"subViewTitleNotBlocking",
() =>
gNavigatorBundle.getString(
"protections.notBlocking.crossSiteTrackingCookies.title"
)
);

// Cookie permission state label.
XPCOMUtils.defineLazyGetter(this.strings, "subViewAllowed", () =>
ChromeUtils.defineLazyGetter(this.strings, "subViewAllowed", () =>
gNavigatorBundle.getString("contentBlocking.cookiesView.allowed.label")
);

Expand Down Expand Up @@ -1143,24 +1146,24 @@ let cookieBannerHandling = new (class {
"cookiebanners.ui.desktop.enabled",
false
);
XPCOMUtils.defineLazyGetter(this, "_cookieBannerSection", () =>
ChromeUtils.defineLazyGetter(this, "_cookieBannerSection", () =>
document.getElementById("protections-popup-cookie-banner-section")
);
XPCOMUtils.defineLazyGetter(this, "_cookieBannerSectionSeparator", () =>
ChromeUtils.defineLazyGetter(this, "_cookieBannerSectionSeparator", () =>
document.getElementById(
"protections-popup-cookie-banner-section-separator"
)
);
XPCOMUtils.defineLazyGetter(this, "_cookieBannerSwitch", () =>
ChromeUtils.defineLazyGetter(this, "_cookieBannerSwitch", () =>
document.getElementById("protections-popup-cookie-banner-switch")
);
XPCOMUtils.defineLazyGetter(this, "_cookieBannerSubview", () =>
ChromeUtils.defineLazyGetter(this, "_cookieBannerSubview", () =>
document.getElementById("protections-popup-cookieBannerView")
);
XPCOMUtils.defineLazyGetter(this, "_cookieBannerEnableSite", () =>
ChromeUtils.defineLazyGetter(this, "_cookieBannerEnableSite", () =>
document.getElementById("cookieBannerView-enable-site")
);
XPCOMUtils.defineLazyGetter(this, "_cookieBannerDisableSite", () =>
ChromeUtils.defineLazyGetter(this, "_cookieBannerDisableSite", () =>
document.getElementById("cookieBannerView-disable-site")
);
}
Expand Down
8 changes: 6 additions & 2 deletions browser/base/content/browser-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ var gBrowserThumbnails = {
}
// Delete the defined property
delete this._topSiteURLs;
XPCOMUtils.defineLazyGetter(this, "_topSiteURLs", getTopSiteURLs);
ChromeUtils.defineLazyGetter(this, "_topSiteURLs", getTopSiteURLs);
},

notify: function Thumbnails_notify(timer) {
Expand Down Expand Up @@ -221,4 +221,8 @@ async function getTopSiteURLs() {
}, []);
}

XPCOMUtils.defineLazyGetter(gBrowserThumbnails, "_topSiteURLs", getTopSiteURLs);
ChromeUtils.defineLazyGetter(
gBrowserThumbnails,
"_topSiteURLs",
getTopSiteURLs
);
28 changes: 14 additions & 14 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
CFRPageActions: "resource://activity-stream/lib/CFRPageActions.jsm",
});

XPCOMUtils.defineLazyGetter(this, "fxAccounts", () => {
ChromeUtils.defineLazyGetter(this, "fxAccounts", () => {
return ChromeUtils.importESModule(
"resource://gre/modules/FxAccounts.sys.mjs"
).getFxAccountsSingleton();
Expand Down Expand Up @@ -309,34 +309,34 @@ if (AppConstants.ENABLE_WEBDRIVER) {
this.RemoteAgent = { running: false };
}

XPCOMUtils.defineLazyGetter(this, "RTL_UI", () => {
ChromeUtils.defineLazyGetter(this, "RTL_UI", () => {
return Services.locale.isAppLocaleRTL;
});

XPCOMUtils.defineLazyGetter(this, "gBrandBundle", () => {
ChromeUtils.defineLazyGetter(this, "gBrandBundle", () => {
return Services.strings.createBundle(
"chrome://branding/locale/brand.properties"
);
});

XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", () => {
ChromeUtils.defineLazyGetter(this, "gBrowserBundle", () => {
return Services.strings.createBundle(
"chrome://browser/locale/browser.properties"
);
});

XPCOMUtils.defineLazyGetter(this, "gCustomizeMode", () => {
ChromeUtils.defineLazyGetter(this, "gCustomizeMode", () => {
let { CustomizeMode } = ChromeUtils.importESModule(
"resource:///modules/CustomizeMode.sys.mjs"
);
return new CustomizeMode(window);
});

XPCOMUtils.defineLazyGetter(this, "gNavToolbox", () => {
ChromeUtils.defineLazyGetter(this, "gNavToolbox", () => {
return document.getElementById("navigator-toolbox");
});

XPCOMUtils.defineLazyGetter(this, "gURLBar", () => {
ChromeUtils.defineLazyGetter(this, "gURLBar", () => {
let urlbar = new UrlbarInput({
textbox: document.getElementById("urlbar"),
eventTelemetryCategory: "urlbar",
Expand Down Expand Up @@ -379,7 +379,7 @@ XPCOMUtils.defineLazyGetter(this, "gURLBar", () => {
return urlbar;
});

XPCOMUtils.defineLazyGetter(this, "ReferrerInfo", () =>
ChromeUtils.defineLazyGetter(this, "ReferrerInfo", () =>
Components.Constructor(
"@mozilla.org/referrer-info;1",
"nsIReferrerInfo",
Expand All @@ -388,7 +388,7 @@ XPCOMUtils.defineLazyGetter(this, "ReferrerInfo", () =>
);

// High priority notification bars shown at the top of the window.
XPCOMUtils.defineLazyGetter(this, "gNotificationBox", () => {
ChromeUtils.defineLazyGetter(this, "gNotificationBox", () => {
return new MozElements.NotificationBox(element => {
element.classList.add("global-notificationbox");
element.setAttribute("notificationside", "top");
Expand All @@ -398,14 +398,14 @@ XPCOMUtils.defineLazyGetter(this, "gNotificationBox", () => {
});
});

XPCOMUtils.defineLazyGetter(this, "InlineSpellCheckerUI", () => {
ChromeUtils.defineLazyGetter(this, "InlineSpellCheckerUI", () => {
let { InlineSpellChecker } = ChromeUtils.importESModule(
"resource://gre/modules/InlineSpellChecker.sys.mjs"
);
return new InlineSpellChecker();
});

XPCOMUtils.defineLazyGetter(this, "PopupNotifications", () => {
ChromeUtils.defineLazyGetter(this, "PopupNotifications", () => {
// eslint-disable-next-line no-shadow
let { PopupNotifications } = ChromeUtils.importESModule(
"resource://gre/modules/PopupNotifications.sys.mjs"
Expand Down Expand Up @@ -460,7 +460,7 @@ XPCOMUtils.defineLazyGetter(this, "PopupNotifications", () => {
}
});

XPCOMUtils.defineLazyGetter(this, "MacUserActivityUpdater", () => {
ChromeUtils.defineLazyGetter(this, "MacUserActivityUpdater", () => {
if (AppConstants.platform != "macosx") {
return null;
}
Expand All @@ -470,7 +470,7 @@ XPCOMUtils.defineLazyGetter(this, "MacUserActivityUpdater", () => {
);
});

XPCOMUtils.defineLazyGetter(this, "Win7Features", () => {
ChromeUtils.defineLazyGetter(this, "Win7Features", () => {
if (AppConstants.platform != "win") {
return null;
}
Expand Down Expand Up @@ -2511,7 +2511,7 @@ var gBrowserInit = {
},
};

XPCOMUtils.defineLazyGetter(
ChromeUtils.defineLazyGetter(
gBrowserInit,
"_firstContentWindowPaintDeferred",
() => PromiseUtils.defer()
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/tabbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"nsIMacSharingService",
],
});
XPCOMUtils.defineLazyGetter(this, "tabLocalization", () => {
ChromeUtils.defineLazyGetter(this, "tabLocalization", () => {
return new Localization(
["browser/tabbrowser.ftl", "branding/brand.ftl"],
true
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/popupNotifications/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function checkPopup(popup, notifyObj) {
});
}

XPCOMUtils.defineLazyGetter(this, "gActiveListeners", () => {
ChromeUtils.defineLazyGetter(this, "gActiveListeners", () => {
let listeners = new Map();
registerCleanupFunction(() => {
for (let [listener, eventName] of listeners) {
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/protectionsUI/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ XPCOMUtils.defineLazyServiceGetter(
"nsITrackingDBService"
);

XPCOMUtils.defineLazyGetter(this, "TRACK_DB_PATH", function () {
ChromeUtils.defineLazyGetter(this, "TRACK_DB_PATH", function () {
return PathUtils.join(PathUtils.profileDir, "protections.sqlite");
});

Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/webextensions/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const BASE = getRootDirectory(gTestPath).replace(
"https://example.com/"
);

XPCOMUtils.defineLazyGetter(this, "Management", () => {
ChromeUtils.defineLazyGetter(this, "Management", () => {
// eslint-disable-next-line no-shadow
const { Management } = ChromeUtils.importESModule(
"resource://gre/modules/Extension.sys.mjs"
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/utilityOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ChromeUtils.defineESModuleGetters(this, {
URILoadingHelper: "resource:///modules/URILoadingHelper.sys.mjs",
});

XPCOMUtils.defineLazyGetter(this, "ReferrerInfo", () =>
ChromeUtils.defineLazyGetter(this, "ReferrerInfo", () =>
Components.Constructor(
"@mozilla.org/referrer-info;1",
"nsIReferrerInfo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

XPCOMUtils.defineLazyGetter(this, "DevToolsStartup", () => {
ChromeUtils.defineLazyGetter(this, "DevToolsStartup", () => {
return Cc["@mozilla.org/devtools/startup-clh;1"].getService(
Ci.nsICommandLineHandler
).wrappedJSObject;
Expand Down
6 changes: 3 additions & 3 deletions browser/components/downloads/content/downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -1670,13 +1670,13 @@ var DownloadsBlockedSubview = {
},
};

XPCOMUtils.defineLazyGetter(DownloadsBlockedSubview, "panelMultiView", () =>
ChromeUtils.defineLazyGetter(DownloadsBlockedSubview, "panelMultiView", () =>
document.getElementById("downloadsPanel-multiView")
);
XPCOMUtils.defineLazyGetter(DownloadsBlockedSubview, "mainView", () =>
ChromeUtils.defineLazyGetter(DownloadsBlockedSubview, "mainView", () =>
document.getElementById("downloadsPanel-mainView")
);
XPCOMUtils.defineLazyGetter(DownloadsBlockedSubview, "subview", () =>
ChromeUtils.defineLazyGetter(DownloadsBlockedSubview, "subview", () =>
document.getElementById("downloadsPanel-blockedSubview")
);

Expand Down
6 changes: 1 addition & 5 deletions browser/components/extensions/parent/ext-bookmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

"use strict";

var { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);

ChromeUtils.defineESModuleGetters(this, {
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
});
Expand All @@ -26,7 +22,7 @@ const BOOKMARKS_TYPES_TO_API_TYPES_MAP = new Map([

const BOOKMARK_SEPERATOR_URL = "data:";

XPCOMUtils.defineLazyGetter(this, "API_TYPES_TO_BOOKMARKS_TYPES_MAP", () => {
ChromeUtils.defineLazyGetter(this, "API_TYPES_TO_BOOKMARKS_TYPES_MAP", () => {
let theMap = new Map();

for (let [code, name] of BOOKMARKS_TYPES_TO_API_TYPES_MAP) {
Expand Down
2 changes: 1 addition & 1 deletion browser/components/extensions/parent/ext-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ global.TabContext = class extends EventEmitter {
// None of the code in the WebExtension modules requests that initialization.
// It is assumed that it is started at some point. That might never happen,
// e.g. if the application shuts down before the search service initializes.
XPCOMUtils.defineLazyGetter(global, "searchInitialized", () => {
ChromeUtils.defineLazyGetter(global, "searchInitialized", () => {
if (Services.search.isInitialized) {
return Promise.resolve();
}
Expand Down
2 changes: 1 addition & 1 deletion browser/components/extensions/parent/ext-browserAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const POPUP_PRELOAD_TIMEOUT_MS = 200;
// WeakMap[Extension -> BrowserAction]
const browserActionMap = new WeakMap();

XPCOMUtils.defineLazyGetter(this, "browserAreas", () => {
ChromeUtils.defineLazyGetter(this, "browserAreas", () => {
return {
navbar: CustomizableUI.AREA_NAVBAR,
menupanel: CustomizableUI.AREA_ADDONS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const HOMEPAGE_CONFIRMED_TYPE = "homepageNotification";
const HOMEPAGE_SETTING_TYPE = "prefs";
const HOMEPAGE_SETTING_NAME = "homepage_override";

XPCOMUtils.defineLazyGetter(this, "homepagePopup", () => {
ChromeUtils.defineLazyGetter(this, "homepagePopup", () => {
return new ExtensionControlledPopup({
confirmedType: HOMEPAGE_CONFIRMED_TYPE,
observerTopic: "browser-open-homepage-start",
Expand Down
4 changes: 2 additions & 2 deletions browser/components/extensions/parent/ext-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ChromeUtils.defineESModuleGetters(this, {
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
});

XPCOMUtils.defineLazyGetter(this, "strBundle", function () {
ChromeUtils.defineLazyGetter(this, "strBundle", function () {
return Services.strings.createBundle(
"chrome://global/locale/extensions.properties"
);
Expand All @@ -28,7 +28,7 @@ const TAB_HIDE_CONFIRMED_TYPE = "tabHideNotification";

const TAB_ID_NONE = -1;

XPCOMUtils.defineLazyGetter(this, "tabHidePopup", () => {
ChromeUtils.defineLazyGetter(this, "tabHidePopup", () => {
return new ExtensionControlledPopup({
confirmedType: TAB_HIDE_CONFIRMED_TYPE,
anchorId: "alltabs-button",
Expand Down
2 changes: 1 addition & 1 deletion browser/components/extensions/parent/ext-url-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const NEW_TAB_CONFIRMED_TYPE = "newTabNotification";
const NEW_TAB_PRIVATE_ALLOWED = "browser.newtab.privateAllowed";
const NEW_TAB_EXTENSION_CONTROLLED = "browser.newtab.extensionControlled";

XPCOMUtils.defineLazyGetter(this, "newTabPopup", () => {
ChromeUtils.defineLazyGetter(this, "newTabPopup", () => {
return new ExtensionControlledPopup({
confirmedType: NEW_TAB_CONFIRMED_TYPE,
observerTopic: "browser-open-newtab-start",
Expand Down
Loading

0 comments on commit 8a35d5c

Please sign in to comment.