Bug 1301160 - Part 1 - Include tab IDs in the session store data. r?sebastian
Having the previous tab ID in the session store data is required in order to be able to create a mapping between old and new IDs on starting up.
Likewise, the parent ID now needs to be tracked on the Gecko side as well, so it can be saved by the session store and later used when restoring a tab/session.
MozReview-Commit-ID: 3zwoZ9YpZlC
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3478,22 +3478,24 @@ Tab.prototype = {
{ name: "getNextTabId", sig: "()I" }
],
});
this.id = jTabs.getNextTabId();
JNI.UnloadClasses(jenv);
}
this.desktopMode = ("desktopMode" in aParams) ? aParams.desktopMode : false;
+ this.parentId = ("parentId" in aParams && typeof aParams.parentId == "number")
+ ? aParams.parentId : -1;
let message = {
type: "Tab:Added",
tabID: this.id,
uri: truncate(uri, MAX_URI_LENGTH),
- parentId: ("parentId" in aParams) ? aParams.parentId : -1,
+ parentId: this.parentId,
tabIndex: ("tabIndex" in aParams) ? aParams.tabIndex : -1,
external: ("external" in aParams) ? aParams.external : false,
selected: ("selected" in aParams || aParams.cancelEditMode === true)
? aParams.selected !== false || aParams.cancelEditMode === true : true,
cancelEditMode: aParams.cancelEditMode === true,
title: truncate(title, MAX_TITLE_LENGTH),
delayLoad: aParams.delayLoad || false,
desktopMode: this.desktopMode,
@@ -3533,26 +3535,28 @@ Tab.prototype = {
this.browser.addEventListener("PluginBindingAttached", this, true, true);
this.browser.addEventListener("VideoBindingAttached", this, true, true);
this.browser.addEventListener("VideoBindingCast", this, true, true);
Services.obs.addObserver(this, "before-first-paint", false);
Services.obs.addObserver(this, "media-playback", false);
Services.obs.addObserver(this, "media-playback-resumed", false);
- // Always intialise new tabs with basic session store data to avoid
+ // Always initialise new tabs with basic session store data to avoid
// problems with functions that always expect it to be present
this.browser.__SS_data = {
entries: [{
url: aURL,
title: truncate(title, MAX_TITLE_LENGTH)
}],
index: 1,
desktopMode: this.desktopMode,
- isPrivate: isPrivate
+ isPrivate: isPrivate,
+ tabId: this.id,
+ parentId: this.parentId
};
if (aParams.delayLoad) {
// If this is a zombie tab, mark the browser for delay loading, which will
// restore the tab when selected using the session data added above
this.browser.__SS_restore = true;
} else {
let flags = "flags" in aParams ? aParams.flags : Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -1018,21 +1018,24 @@ SessionStore.prototype = {
// If this browser is being restored, skip any session save activity
if (aBrowser.__SS_restore) {
return;
}
aHistory = aHistory || { entries: [{ url: aBrowser.currentURI.spec, title: aBrowser.contentTitle }], index: 1 };
let tabData = {};
+ let tab = aWindow.BrowserApp.getTabForBrowser(aBrowser);
tabData.entries = aHistory.entries;
tabData.index = aHistory.index;
tabData.attributes = { image: aBrowser.mIconURL };
- tabData.desktopMode = aWindow.BrowserApp.getTabForBrowser(aBrowser).desktopMode;
+ tabData.desktopMode = tab.desktopMode;
tabData.isPrivate = aBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing;
+ tabData.tabId = tab.id;
+ tabData.parentId = tab.parentId;
aBrowser.__SS_data = tabData;
},
_collectWindowData: function ss__collectWindowData(aWindow) {
// Ignore windows not tracked by SessionStore
if (!aWindow.__SSID || !this._windows[aWindow.__SSID]) {
return;
@@ -1639,20 +1642,20 @@ SessionStore.prototype = {
delayLoad: true,
title: entry.title,
desktopMode: (tabData.desktopMode == true),
isPrivate: (tabData.isPrivate == true)
};
tab = window.BrowserApp.addTab(entry.url, params);
} else {
tab = window.BrowserApp.getTabForId(tabData.tabId);
- delete tabData.tabId;
// Don't restore tab if user has closed it
if (tab == null) {
+ delete tabData.tabId;
continue;
}
}
tab.browser.__SS_data = tabData;
tab.browser.__SS_extdata = tabData.extData;
if (window.BrowserApp.selectedTab == tab) {