mirror of
https://github.com/zen-browser/desktop.git
synced 2026-02-22 19:36:40 +00:00
feat: Always restore sessions but clear unpinned tabs when persistent private mode is enabled, b=closes #11751, c=no-component
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/sessionstore/SessionSaver.sys.mjs b/browser/components/sessionstore/SessionSaver.sys.mjs
|
||||
index 9141793550f7c7ff6aa63d4c85bf571b4499e2d0..f00314ebf75ac826e1c9cca8af264ff8aae106c0 100644
|
||||
index 9141793550f7c7ff6aa63d4c85bf571b4499e2d0..6906fd9be7ae6ca4316133e0d6552b797c54a7ec 100644
|
||||
--- a/browser/components/sessionstore/SessionSaver.sys.mjs
|
||||
+++ b/browser/components/sessionstore/SessionSaver.sys.mjs
|
||||
@@ -20,6 +20,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
@@ -10,6 +10,15 @@ index 9141793550f7c7ff6aa63d4c85bf571b4499e2d0..f00314ebf75ac826e1c9cca8af264ff8
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -250,7 +251,7 @@ var SessionSaverInternal = {
|
||||
// Cancel any pending timeouts.
|
||||
this.cancel();
|
||||
|
||||
- if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
+ if (false) {
|
||||
// Don't save (or even collect) anything in permanent private
|
||||
// browsing mode
|
||||
|
||||
@@ -305,6 +306,7 @@ var SessionSaverInternal = {
|
||||
this._maybeClearCookiesAndStorage(state);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/sessionstore/SessionStartup.sys.mjs b/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||
index be23213ae9ec7e59358a17276c6c3764d38d9996..b6a4110ee50e5977125feb7bd32e84e5e527adc6 100644
|
||||
index be23213ae9ec7e59358a17276c6c3764d38d9996..229bb1346f9349892acb1e9e05109b28f5a5b45f 100644
|
||||
--- a/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||
+++ b/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||
@@ -40,6 +40,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
@@ -10,6 +10,15 @@ index be23213ae9ec7e59358a17276c6c3764d38d9996..b6a4110ee50e5977125feb7bd32e84e5
|
||||
});
|
||||
|
||||
const STATE_RUNNING_STR = "running";
|
||||
@@ -85,7 +86,7 @@ export var SessionStartup = {
|
||||
}
|
||||
|
||||
// do not need to initialize anything in auto-started private browsing sessions
|
||||
- if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
+ if (false) {
|
||||
this._initialized = true;
|
||||
gOnceInitializedDeferred.resolve();
|
||||
return;
|
||||
@@ -179,6 +180,8 @@ export var SessionStartup = {
|
||||
this._initialState = parsed;
|
||||
}
|
||||
@@ -29,7 +38,7 @@ index be23213ae9ec7e59358a17276c6c3764d38d9996..b6a4110ee50e5977125feb7bd32e84e5
|
||||
- ) ||
|
||||
- Services.prefs.getIntPref("browser.startup.page") ==
|
||||
- BROWSER_STARTUP_RESUME_SESSION);
|
||||
+ !lazy.PrivateBrowsingUtils.permanentPrivateBrowsing;
|
||||
+ true;
|
||||
}
|
||||
|
||||
return this._resumeSessionEnabled;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..697dde4378c43ae6db46a6b7eb2997982201ec27 100644
|
||||
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf297aae78c6 100644
|
||||
--- a/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
|
||||
@@ -27,7 +27,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..697dde4378c43ae6db46a6b7eb299798
|
||||
- (Services.prefs.getBoolPref("browser.sessionstore.resume_session_once") ||
|
||||
- Services.prefs.getIntPref("browser.startup.page") ==
|
||||
- BROWSER_STARTUP_RESUME_SESSION)
|
||||
+ !PrivateBrowsingUtils.permanentPrivateBrowsing
|
||||
+ true
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
||||
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..00a9810cc894b6a21adb78b70a15049cc1db3edf 100644
|
||||
index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..2dfe1edc8d893e216d6003fbe7bd8bbe4942586b 100644
|
||||
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
||||
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
||||
@@ -386,6 +386,7 @@
|
||||
@@ -440,10 +440,10 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..00a9810cc894b6a21adb78b70a15049c
|
||||
+ gZenWorkspaces._initialTab._shouldRemove = true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ else {
|
||||
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
|
||||
}
|
||||
+ }
|
||||
+ this._hasAlreadyInitializedZenSessionStore = true;
|
||||
|
||||
if (tabs.length > 1 || !tabs[0].selected) {
|
||||
@@ -931,7 +931,17 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..00a9810cc894b6a21adb78b70a15049c
|
||||
});
|
||||
break;
|
||||
case "TabGroupCreateByUser":
|
||||
@@ -8589,6 +8793,7 @@
|
||||
@@ -7800,7 +8004,9 @@
|
||||
|
||||
let filter = this._tabFilters.get(tab);
|
||||
if (filter) {
|
||||
+ try {
|
||||
browser.webProgress.removeProgressListener(filter);
|
||||
+ } catch {}
|
||||
|
||||
let listener = this._tabListeners.get(tab);
|
||||
if (listener) {
|
||||
@@ -8589,6 +8795,7 @@
|
||||
aWebProgress.isTopLevel
|
||||
) {
|
||||
this.mTab.setAttribute("busy", "true");
|
||||
@@ -939,7 +949,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..00a9810cc894b6a21adb78b70a15049c
|
||||
gBrowser._tabAttrModified(this.mTab, ["busy"]);
|
||||
this.mTab._notselectedsinceload = !this.mTab.selected;
|
||||
}
|
||||
@@ -8670,6 +8875,7 @@
|
||||
@@ -8670,6 +8877,7 @@
|
||||
// known defaults. Note we use the original URL since about:newtab
|
||||
// redirects to a prerendered page.
|
||||
const shouldRemoveFavicon =
|
||||
@@ -947,7 +957,7 @@ index 42027bfa55eab8ea9298a7d425f2ded45188f7f3..00a9810cc894b6a21adb78b70a15049c
|
||||
!this.mBrowser.mIconURL &&
|
||||
!ignoreBlank &&
|
||||
!(originalLocation.spec in FAVICON_DEFAULTS);
|
||||
@@ -9623,7 +9829,7 @@ var TabContextMenu = {
|
||||
@@ -9623,7 +9831,7 @@ var TabContextMenu = {
|
||||
);
|
||||
contextUnpinSelectedTabs.hidden =
|
||||
!this.contextTab.pinned || !this.multiselected;
|
||||
|
||||
@@ -638,6 +638,7 @@
|
||||
if (!isTab(draggedTab)) {
|
||||
return;
|
||||
}
|
||||
this.#maybeClearVerticalPinnedGridDragOver(draggedTab);
|
||||
this.clearSpaceSwitchTimer();
|
||||
const { clientX, clientY } = event;
|
||||
const { innerWidth, innerHeight } = window;
|
||||
|
||||
@@ -187,10 +187,10 @@ export class nsZenSessionManager {
|
||||
}
|
||||
// When we don't have browser.startup.page set to resume session,
|
||||
// we only want to restore the pinned tabs into the new windows.
|
||||
if (
|
||||
Services.prefs.getIntPref('browser.startup.page', 1) !== BROWSER_STARTUP_RESUME_SESSION &&
|
||||
this.#sidebar?.tabs
|
||||
) {
|
||||
const shouldRestoreOnlyPinned =
|
||||
Services.prefs.getIntPref('browser.startup.page', 1) !== BROWSER_STARTUP_RESUME_SESSION ||
|
||||
lazy.PrivateBrowsingUtils.permanentPrivateBrowsing;
|
||||
if (shouldRestoreOnlyPinned && this.#sidebar?.tabs) {
|
||||
this.log('Restoring only pinned tabs into windows');
|
||||
const sidebar = this.#sidebar;
|
||||
sidebar.tabs = (sidebar.tabs || []).filter((tab) => tab.pinned);
|
||||
@@ -227,7 +227,7 @@ export class nsZenSessionManager {
|
||||
* The current session state.
|
||||
*/
|
||||
saveState(state) {
|
||||
if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing || !state?.windows?.length) {
|
||||
if (!state?.windows?.length) {
|
||||
// Don't save (or even collect) anything in permanent private
|
||||
// browsing mode. We also don't want to save if there are no windows.
|
||||
return;
|
||||
@@ -340,15 +340,10 @@ export class nsZenSessionManager {
|
||||
* The window to restore.
|
||||
* @param SessionStoreInternal
|
||||
* The SessionStore module instance.
|
||||
* @param resolvePromise
|
||||
* The promise resolver to call when done. We use a promise
|
||||
* here because out workspace manager always waits for SessionStore
|
||||
* to restore all the windows before initializing, but when opening
|
||||
* a new window, that promise is always resolved, meaning it may run
|
||||
* into a race condition if we try to restore the window synchronously
|
||||
* here.
|
||||
* @param fromClosedWindow
|
||||
* Whether this new window is being restored from a closed window.
|
||||
*/
|
||||
restoreNewWindow(aWindow, SessionStoreInternal) {
|
||||
restoreNewWindow(aWindow, SessionStoreInternal, fromClosedWindow = false) {
|
||||
if (aWindow.gZenWorkspaces?.privateWindowOrDisabled) {
|
||||
return;
|
||||
}
|
||||
@@ -373,14 +368,16 @@ export class nsZenSessionManager {
|
||||
// windows would appear overlapping the previous one, or with
|
||||
// the same size and position, which should be decided by the
|
||||
// window manager.
|
||||
delete newWindow.selected;
|
||||
delete newWindow.screenX;
|
||||
delete newWindow.screenY;
|
||||
delete newWindow.width;
|
||||
delete newWindow.height;
|
||||
delete newWindow.sizemode;
|
||||
delete newWindow.sizemodeBeforeMinimized;
|
||||
delete newWindow.zIndex;
|
||||
if (!fromClosedWindow) {
|
||||
delete newWindow.selected;
|
||||
delete newWindow.screenX;
|
||||
delete newWindow.screenY;
|
||||
delete newWindow.width;
|
||||
delete newWindow.height;
|
||||
delete newWindow.sizemode;
|
||||
delete newWindow.sizemodeBeforeMinimized;
|
||||
delete newWindow.zIndex;
|
||||
}
|
||||
|
||||
const newState = { windows: [newWindow] };
|
||||
this.log(`Cloning window with ${newWindow.tabs.length} tabs`);
|
||||
|
||||
@@ -703,6 +703,7 @@ class nsZenWindowSync {
|
||||
if (!mostRecentWindow || !aWindow.gZenWorkspaces) {
|
||||
return;
|
||||
}
|
||||
lazy.TabStateFlusher.flushWindow(aWindow);
|
||||
const activeTabsOnClosedWindow = aWindow.gZenWorkspaces.allStoredTabs.filter(
|
||||
(tab) => tab._zenContentsVisible
|
||||
);
|
||||
@@ -889,6 +890,7 @@ class nsZenWindowSync {
|
||||
);
|
||||
});
|
||||
this.#makeSureTabSyncsPermanentKey(tab);
|
||||
lazy.TabStateFlusher.flush(tab.linkedBrowser);
|
||||
}
|
||||
|
||||
on_ZenTabIconChanged(aEvent) {
|
||||
|
||||
Reference in New Issue
Block a user