Bug 1323987 - Keep saving about:blank and about:newtab to disk. r?mikedeboer
This patch creates a new method that verifies if the tab state we're passed is
something we should keep to be reopened at session restore. This is used when
we are saving the current session state to disk. This method is very similar to
_shouldSaveTabState, however, "about:blank" and "about:newtab" tabs will still
be saved to disk.
MozReview-Commit-ID: 70zKFeUG9uQ
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -383,17 +383,17 @@ this.SessionStore = {
* The browser state for which we remove worth-saving tabs.
* The given object will be modified.
*/
keepOnlyWorthSavingTabs: function (aState) {
for (let i = aState.windows.length - 1; i >= 0; i--) {
let win = aState.windows[i];
for (let j = win.tabs.length - 1; j >= 0; j--) {
let tab = win.tabs[j];
- if (!SessionStoreInternal._shouldSaveTabState(tab)) {
+ if (!SessionStoreInternal._shouldSaveTab(tab)) {
win.tabs.splice(j, 1);
if (win.selected > j) {
win.selected--;
}
}
}
if (!win.tabs.length) {
aState.windows.splice(i, 1);
@@ -4193,21 +4193,40 @@ var SessionStoreInternal = {
_shouldSaveTabState: function ssi_shouldSaveTabState(aTabState) {
// If the tab has only a transient about: history entry, no other
// session history, and no userTypedValue, then we don't actually want to
// store this tab's data.
return aTabState.entries.length &&
!(aTabState.entries.length == 1 &&
(aTabState.entries[0].url == "about:blank" ||
aTabState.entries[0].url == "about:newtab" ||
+ aTabState.entries[0].url == "about:printpreview" ||
aTabState.entries[0].url == "about:privatebrowsing") &&
!aTabState.userTypedValue);
},
/**
+ * Determine if the tab state we're passed is something we should keep to be
+ * reopened at session restore. This is used when we are saving the current
+ * session state to disk. This method is very similar to _shouldSaveTabState,
+ * however, "about:blank" and "about:newtab" tabs will still be saved to disk.
+ *
+ * @param aTabState
+ * The current tab state
+ * @returns boolean
+ */
+ _shouldSaveTab: function ssi_shouldSaveTab(aTabState) {
+ // If the tab has one of the following transient about: history entry,
+ // then we don't actually want to write this tab's data to disk.
+ return aTabState.entries.length &&
+ !(aTabState.entries[0].url == "about:printpreview" ||
+ aTabState.entries[0].url == "about:privatebrowsing");
+ },
+
+ /**
* This is going to take a state as provided at startup (via
* nsISessionStartup.state) and split it into 2 parts. The first part
* (defaultState) will be a state that should still be restored at startup,
* while the second part (state) is a state that should be saved for later.
* defaultState will be comprised of windows with only pinned tabs, extracted
* from state. It will contain the cookies that go along with the history
* entries in those tabs. It will also contain window position information.
*