mirror of
https://github.com/zen-browser/desktop.git
synced 2026-01-17 10:27:10 +00:00
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
import { nsZenPreloadedFeature } from "chrome://browser/content/zen-components/ZenCommonUtils.mjs";
|
|
|
|
class ZenSessionStore extends nsZenPreloadedFeature {
|
|
init() {
|
|
this.#waitAndCleanup();
|
|
}
|
|
|
|
promiseInitialized = new Promise((resolve) => {
|
|
this._resolveInitialized = resolve;
|
|
});
|
|
|
|
restoreInitialTabData(tab, tabData) {
|
|
if (tabData.zenWorkspace) {
|
|
tab.setAttribute("zen-workspace-id", tabData.zenWorkspace);
|
|
}
|
|
// Keep for now, for backward compatibility for window sync to work.
|
|
if (tabData.zenSyncId || tabData.zenPinnedId) {
|
|
tab.setAttribute("id", tabData.zenSyncId || tabData.zenPinnedId);
|
|
}
|
|
if (typeof tabData.zenStaticLabel === "string") {
|
|
tab.zenStaticLabel = tabData.zenStaticLabel;
|
|
}
|
|
if (tabData.zenHasStaticIcon && tabData.image) {
|
|
tab.zenStaticIcon = tabData.image;
|
|
}
|
|
if (tabData.zenEssential) {
|
|
tab.setAttribute("zen-essential", "true");
|
|
}
|
|
if (tabData.zenDefaultUserContextId) {
|
|
tab.setAttribute("zenDefaultUserContextId", "true");
|
|
}
|
|
if (tabData._zenPinnedInitialState) {
|
|
tab._zenPinnedInitialState = tabData._zenPinnedInitialState;
|
|
}
|
|
}
|
|
|
|
async #waitAndCleanup() {
|
|
await SessionStore.promiseInitialized;
|
|
this.#cleanup();
|
|
}
|
|
|
|
#cleanup() {
|
|
this._resolveInitialized();
|
|
}
|
|
}
|
|
|
|
window.gZenSessionStore = new ZenSessionStore();
|