Skip to content

Commit

Permalink
Simplify way to remove closed private tabs from undo close history
Browse files Browse the repository at this point in the history
Also getTabState() may be undefined on window "unload"
(enhancement for #6, related to #36)
  • Loading branch information
Infocatcher committed Apr 16, 2013
1 parent 5703e5d commit a14a300
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,25 +476,27 @@ var windowsObserver = {
+ "\nTry don't save it in undo close history"
);
var window = tab.ownerDocument.defaultView;
var tabState = this.ss.getTabState(tab);
//_log("Closed tab state:\n" + state);
if(this.isSeaMonkey)
window.setTimeout(this.forgetClosedTab.bind(this, window, tabState), 0);
window.setTimeout(this.forgetClosedTab.bind(this, window), 0);
else
this.forgetClosedTab(window, tabState);
this.forgetClosedTab(window);
},
forgetClosedTab: function(window, tabState) {
forgetClosedTab: function(window) {
var closedTabs = JSON.parse(this.ss.getClosedTabData(window));
for(var i = 0, l = closedTabs.length; i < l; ++i) {
var closedTab = closedTabs[i];
var state = closedTab.state;
//_log("Found closed tab:\n" + JSON.stringify(state));
if(JSON.stringify(state) == tabState) {
if(
"attributes" in state
&& this.privateAttr in state.attributes
) {
this.ss.forgetClosedTab(window, i);
_log("Forget about closed tab #" + i);
break;
return;
}
}
Components.utils.reportError(LOG_PREFIX + "!!! Can't forget about closed tab: tab not found");
},
tabSelectHandler: function(e) {
var tab = e.originalTarget || e.target;
Expand Down

0 comments on commit a14a300

Please sign in to comment.