mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-04 08:56:34 +00:00
Translated files to a single monorepo
This commit is contained in:
55
src/browser/base/zen-components/ZenCommonUtils.mjs
Normal file
55
src/browser/base/zen-components/ZenCommonUtils.mjs
Normal file
@@ -0,0 +1,55 @@
|
||||
var gZenOperatingSystemCommonUtils = {
|
||||
kZenOSToSmallName: {
|
||||
WINNT: 'windows',
|
||||
Darwin: 'macos',
|
||||
Linux: 'linux',
|
||||
},
|
||||
|
||||
get currentOperatingSystem() {
|
||||
let os = Services.appinfo.OS;
|
||||
return this.kZenOSToSmallName[os];
|
||||
},
|
||||
};
|
||||
|
||||
class ZenMultiWindowFeature {
|
||||
constructor() {}
|
||||
|
||||
static get browsers() {
|
||||
return Services.wm.getEnumerator('navigator:browser');
|
||||
}
|
||||
|
||||
static get currentBrowser() {
|
||||
return Services.wm.getMostRecentWindow('navigator:browser');
|
||||
}
|
||||
|
||||
isActiveWindow() {
|
||||
return ZenMultiWindowFeature.currentBrowser === window;
|
||||
}
|
||||
|
||||
async foreachWindowAsActive(callback) {
|
||||
if (!this.isActiveWindow()) {
|
||||
return;
|
||||
}
|
||||
for (const browser of ZenMultiWindowFeature.browsers) {
|
||||
try {
|
||||
await callback(browser);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ZenDOMOperatedFeature {
|
||||
constructor() {
|
||||
var initBound = this.init.bind(this);
|
||||
document.addEventListener('DOMContentLoaded', initBound, { once: true });
|
||||
}
|
||||
}
|
||||
|
||||
class ZenPreloadedFeature {
|
||||
constructor() {
|
||||
var initBound = this.init.bind(this);
|
||||
document.addEventListener('MozBeforeInitialXULLayout', initBound, { once: true });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user