Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/browser/base/content/zen-assets.inc.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@
<script type="text/javascript" src="chrome://browser/content/zen-components/ZenDownloadAnimation.mjs"></script>
<script type="text/javascript" src="chrome://browser/content/zen-components/ZenEmojiPicker.mjs"></script>
<script type="text/javascript" src="chrome://browser/content/zen-components/ZenWorkspaceCreation.mjs"></script>
<script type="text/javascript" src="chrome://browser/content/zen-components/ZenWindowSyncing.mjs"></script>
1 change: 1 addition & 0 deletions src/browser/base/content/zen-assets.jar.inc.mn
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
content/browser/zen-components/ZenWorkspaceIcons.mjs (../../zen/workspaces/ZenWorkspaceIcons.mjs)
content/browser/zen-components/ZenWorkspace.mjs (../../zen/workspaces/ZenWorkspace.mjs)
content/browser/zen-components/ZenWorkspaces.mjs (../../zen/workspaces/ZenWorkspaces.mjs)
content/browser/zen-components/ZenWindowSyncing.mjs (../../zen/workspaces/ZenWindowSyncing.mjs)
content/browser/zen-components/ZenWorkspaceCreation.mjs (../../zen/workspaces/ZenWorkspaceCreation.mjs)
content/browser/zen-components/ZenWorkspacesStorage.mjs (../../zen/workspaces/ZenWorkspacesStorage.mjs)
content/browser/zen-components/ZenWorkspacesSync.mjs (../../zen/workspaces/ZenWorkspacesSync.mjs)
Expand Down
27 changes: 27 additions & 0 deletions src/zen/sessionstore/ZenSessionFile.sys.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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/.

const FILE_NAME = 'zen-sessions.jsonlz4';

export class nsZenSessionFile {
#path;

#windows;

Check failure on line 10 in src/zen/sessionstore/ZenSessionFile.sys.mjs

View workflow job for this annotation

GitHub Actions / lint

'#windows' is defined but never used

constructor() {
this.#path = PathUtils.join(profileDir, FILE_NAME);

Check failure on line 13 in src/zen/sessionstore/ZenSessionFile.sys.mjs

View workflow job for this annotation

GitHub Actions / lint

'profileDir' is not defined
}

async read() {
try {
return await IOUtils.readJSON(this.#path, { compress: true });
} catch (e) {

Check failure on line 19 in src/zen/sessionstore/ZenSessionFile.sys.mjs

View workflow job for this annotation

GitHub Actions / lint

'e' is defined but never used
return {};
}
}

async write(data) {
await IOUtils.writeJSON(this.#path, data, { compress: true });
}
}
50 changes: 50 additions & 0 deletions src/zen/sessionstore/ZenSessionManager.sys.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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 {
cancelIdleCallback,

Check failure on line 6 in src/zen/sessionstore/ZenSessionManager.sys.mjs

View workflow job for this annotation

GitHub Actions / lint

'cancelIdleCallback' is defined but never used
clearTimeout,

Check failure on line 7 in src/zen/sessionstore/ZenSessionManager.sys.mjs

View workflow job for this annotation

GitHub Actions / lint

'clearTimeout' is defined but never used
requestIdleCallback,

Check failure on line 8 in src/zen/sessionstore/ZenSessionManager.sys.mjs

View workflow job for this annotation

GitHub Actions / lint

'requestIdleCallback' is defined but never used
setTimeout,

Check failure on line 9 in src/zen/sessionstore/ZenSessionManager.sys.mjs

View workflow job for this annotation

GitHub Actions / lint

'setTimeout' is defined but never used
} from 'resource://gre/modules/Timer.sys.mjs';

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
ZenSessionFile: 'resource://gre/modules/ZenSessionFile.sys.mjs',
PrivateBrowsingUtils: 'resource://gre/modules/PrivateBrowsingUtils.sys.mjs',
RunState: 'resource:///modules/sessionstore/RunState.sys.mjs',
});

class nsZenSessionManager {
#file;

constructor() {
this.#file = null;
}

get file() {
if (!this.#file) {
this.#file = lazy.ZenSessionFile;
}
return this.#file;
}

/**
* Saves the current session state. Collects data and writes to disk.
*
* @param forceUpdateAllWindows (optional)
* Forces us to recollect data for all windows and will bypass and
* update the corresponding caches.
*/
saveState(forceUpdateAllWindows = false) {

Check failure on line 41 in src/zen/sessionstore/ZenSessionManager.sys.mjs

View workflow job for this annotation

GitHub Actions / lint

'forceUpdateAllWindows' is assigned a value but never used
if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing) {
// Don't save (or even collect) anything in permanent private
// browsing mode
return Promise.resolve();
}
}
}

export const ZenSessionStore = new nsZenSessionManager();
35 changes: 35 additions & 0 deletions src/zen/sessionstore/ZenSessionWindow.sys.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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/.

export class ZenSessionWindow {
#id;
#selectedWorkspace;
#selectedTab;

constructor(id) {
this.#id = id;
this.#selectedWorkspace = null;
this.#selectedTab = null;
}

get id() {
return this.#id;
}

get selectedWorkspace() {
return this.#selectedWorkspace;
}

set selectedWorkspace(workspace) {
this.#selectedWorkspace = workspace;
}

get selectedTab() {
return this.#selectedTab;
}

set selectedTab(tab) {
this.#selectedTab = tab;
}
}
2 changes: 2 additions & 0 deletions src/zen/tabs/ZenPinnedTabManager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
}

onTabIconChanged(tab, url = null) {
tab.dispatchEvent(new CustomEvent('ZenTabIconChanged', { bubbles: true, detail: { tab } }));
const iconUrl = url ?? tab.iconImage.src;
if (!iconUrl && tab.hasAttribute('zen-pin-id')) {
try {
Expand Down Expand Up @@ -1555,6 +1556,7 @@
}

async onTabLabelChanged(tab) {
tab.dispatchEvent(new CustomEvent('ZenTabLabelChanged', { detail: { tab } }));
if (!this._pinsCache) {
return;
}
Expand Down
Loading