mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1018661 - Use session store data instead of current browser data for undo close tab toast. r=bnicholson
This commit is contained in:
parent
3597dccb41
commit
73b70d271e
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user