Bug 1772100 - Part 14: Use plain object for lazy getter in browser/components/screenshots/. r=niklas

Differential Revision: https://phabricator.services.mozilla.com/D148024
This commit is contained in:
Tooru Fujisawa
2022-06-06 22:46:24 +00:00
parent 2a15469bc0
commit d005fe9005
2 changed files with 11 additions and 7 deletions

View File

@@ -46,7 +46,9 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyGetter(this, "overlayLocalization", () => {
const lazy = {};
XPCOMUtils.defineLazyGetter(lazy, "overlayLocalization", () => {
return new Localization(["browser/screenshotsOverlay.ftl"], true);
});
@@ -261,7 +263,7 @@ class AnonymousContentOverlay {
instrustions,
download,
copy,
] = overlayLocalization.formatMessagesSync([
] = lazy.overlayLocalization.formatMessagesSync([
{ id: "screenshots-overlay-cancel-button" },
{ id: "screenshots-overlay-instructions" },
{ id: "screenshots-overlay-download-button" },

View File

@@ -12,7 +12,9 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
Downloads: "resource://gre/modules/Downloads.jsm",
FileUtils: "resource://gre/modules/FileUtils.jsm",
});
@@ -443,7 +445,7 @@ var ScreenshotsUtils = {
filename += ".png";
}
const downloadsDir = await Downloads.getPreferredDownloadsDirectory();
const downloadsDir = await lazy.Downloads.getPreferredDownloadsDirectory();
const downloadsDirExists = await IOUtils.exists(downloadsDir);
if (downloadsDirExists) {
// If filename is absolute, it will override the downloads directory and
@@ -452,15 +454,15 @@ var ScreenshotsUtils = {
}
const sourceURI = Services.io.newURI(url);
const targetFile = new FileUtils.File(filename);
const targetFile = new lazy.FileUtils.File(filename);
// Create download and track its progress.
try {
const download = await Downloads.createDownload({
const download = await lazy.Downloads.createDownload({
source: sourceURI,
target: targetFile,
});
const list = await Downloads.getList(Downloads.ALL);
const list = await lazy.Downloads.getList(lazy.Downloads.ALL);
// add the download to the download list in the Downloads list in the Browser UI
list.add(download);