Bug 1018661 - Use session store data instead of current browser data for undo close tab toast. r=bnicholson

This commit is contained in:
Margaret Leibovic 2014-06-04 19:10:05 -07:00
parent 3597dccb41
commit 73b70d271e
3 changed files with 12 additions and 9 deletions

View File

@ -976,13 +976,17 @@ var BrowserApp = {
evt.initUIEvent("TabClose", true, false, window, null);
aTab.browser.dispatchEvent(evt);
// Get a title for the undo close toast. Fall back to the URL if there is no title.
let title = aTab.browser.contentDocument.title || aTab.browser.contentDocument.URL;
aTab.destroy();
this._tabs.splice(this._tabs.indexOf(aTab), 1);
if (aShowUndoToast) {
// Get a title for the undo close toast. Fall back to the URL if there is no title.
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
let closedTabData = ss.getClosedTabs(window)[0];
let historyEntry = closedTabData.entries[closedTabData.index - 1];
let title = historyEntry.title || historyEntry.url;
let message = Strings.browser.formatStringFromName("undoCloseToast.message", [title], 1);
NativeWindow.toast.show(message, "short", {
button: {
@ -990,7 +994,6 @@ var BrowserApp = {
label: Strings.browser.GetStringFromName("undoCloseToast.action2"),
callback: function() {
UITelemetry.addEvent("undo.1", "toast", null, "closetab");
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
ss.undoCloseTab(window, 0);
}
}

View File

@ -14,7 +14,7 @@ interface nsIDOMNode;
* tabs contained in them.
*/
[scriptable, uuid(fe116b56-0226-4562-b52a-a623dad07ead)]
[scriptable, uuid(91eca9cf-6741-4c8f-a3a0-2e957240894d)]
interface nsISessionStore : nsISupports
{
/**
@ -32,9 +32,9 @@ interface nsISessionStore : nsISupports
* Get closed tab data
*
* @param aWindow is the browser window for which to get closed tab data
* @returns a JSON string representing the list of closed tabs.
* @returns a JS array of closed tabs.
*/
AString getClosedTabData(in nsIDOMWindow aWindow);
jsval getClosedTabs(in nsIDOMWindow aWindow);
/**
* @param aWindow is the browser window to reopen a closed tab in.

View File

@ -818,11 +818,11 @@ SessionStore.prototype = {
return this._windows[aWindow.__SSID].closedTabs.length;
},
getClosedTabData: function ss_getClosedTabData(aWindow) {
getClosedTabs: function ss_getClosedTabs(aWindow) {
if (!aWindow.__SSID)
throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
return JSON.stringify(this._windows[aWindow.__SSID].closedTabs);
return this._windows[aWindow.__SSID].closedTabs;
},
undoCloseTab: function ss_undoCloseTab(aWindow, aIndex) {