mirror of
https://github.com/zen-browser/desktop.git
synced 2026-02-10 05:48:39 +00:00
feat: Make sure to always restore tabs from a crash, b=no-bug, c=no-component
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/sessionstore/SessionStartup.sys.mjs b/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||
index 86600ffb5178599ab23270a964064ca657a3283f..e7014e5bce547d37ec92377a95bad5be4d52152e 100644
|
||||
index 86600ffb5178599ab23270a964064ca657a3283f..97975af7822a157eafe02ec8bbebdf1a6b564ccb 100644
|
||||
--- a/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||
+++ b/browser/components/sessionstore/SessionStartup.sys.mjs
|
||||
@@ -40,6 +40,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
@@ -28,7 +28,16 @@ index 86600ffb5178599ab23270a964064ca657a3283f..e7014e5bce547d37ec92377a95bad5be
|
||||
if (this._initialState == null) {
|
||||
// No valid session found.
|
||||
this._sessionType = this.NO_SESSION;
|
||||
@@ -336,12 +339,7 @@ export var SessionStartup = {
|
||||
@@ -276,6 +279,8 @@ export var SessionStartup = {
|
||||
`Previous shutdown ok? ${this._previousSessionCrashed}, reason: ${previousSessionCrashedReason}`
|
||||
);
|
||||
|
||||
+ lazy.ZenSessionStore.onCrashCheckpoints(this._initialState);
|
||||
+
|
||||
Services.obs.addObserver(this, "sessionstore-windows-restored", true);
|
||||
|
||||
if (this.sessionType == this.NO_SESSION) {
|
||||
@@ -336,12 +341,7 @@ export var SessionStartup = {
|
||||
isAutomaticRestoreEnabled() {
|
||||
if (this._resumeSessionEnabled === null) {
|
||||
this._resumeSessionEnabled =
|
||||
|
||||
@@ -10,6 +10,7 @@ const lazy = {};
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
||||
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
|
||||
SessionStartup: "resource:///modules/sessionstore/SessionStartup.sys.mjs",
|
||||
gWindowSyncEnabled: "resource:///modules/zen/ZenWindowSync.sys.mjs",
|
||||
gSyncOnlyPinnedTabs: "resource:///modules/zen/ZenWindowSync.sys.mjs",
|
||||
DeferredTask: "resource://gre/modules/DeferredTask.sys.mjs",
|
||||
@@ -231,6 +232,13 @@ export class nsZenSessionManager {
|
||||
);
|
||||
}
|
||||
|
||||
get #shouldRestoreFromCrash() {
|
||||
return (
|
||||
lazy.SessionStartup.previousSessionCrashed &&
|
||||
Services.prefs.getBoolPref("browser.sessionstore.resume_from_crash")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the session file is read. Restores the sidebar data
|
||||
* into all windows.
|
||||
@@ -270,9 +278,22 @@ export class nsZenSessionManager {
|
||||
},
|
||||
];
|
||||
}
|
||||
return initialState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after @onFileRead, when session startup has crash checkpoint information available.
|
||||
* Restores the sidebar data into all windows, and runs any crash checkpoint related logic,
|
||||
* such as restoring only pinned tabs if the previous session was not crashed and the user
|
||||
* preference is set to do so.
|
||||
*
|
||||
* @param {object} initialState
|
||||
* The initial session state read from the session file, possibly modified by onFileRead.
|
||||
*/
|
||||
onCrashCheckpoints(initialState) {
|
||||
// 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 (this.#shouldRestoreOnlyPinned && this.#sidebar?.tabs) {
|
||||
if (this.#shouldRestoreOnlyPinned && !this.#shouldRestoreFromCrash && this.#sidebar?.tabs) {
|
||||
this.log("Restoring only pinned tabs into windows");
|
||||
const sidebar = this.#sidebar;
|
||||
sidebar.tabs = (sidebar.tabs || []).filter((tab) => tab.pinned);
|
||||
@@ -304,7 +325,6 @@ export class nsZenSessionManager {
|
||||
this.saveState(Cu.cloneInto(initialState, {}));
|
||||
}
|
||||
delete this._shouldRunMigration;
|
||||
return initialState;
|
||||
}
|
||||
|
||||
get #sidebar() {
|
||||
|
||||
Reference in New Issue
Block a user