mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 873771 - TabRestoreQueue should keep track of and evaluate restore_on_demand prefs; r=yoric
This commit is contained in:
parent
528e894d58
commit
f5695d2000
@ -290,12 +290,6 @@ let SessionStoreInternal = {
|
||||
// number of tabs currently restoring
|
||||
_tabsRestoringCount: 0,
|
||||
|
||||
// overrides MAX_CONCURRENT_TAB_RESTORES and restore_hidden_tabs when true
|
||||
_restoreOnDemand: false,
|
||||
|
||||
// whether to restore app tabs on demand or not, pref controlled.
|
||||
_restorePinnedTabsOnDemand: null,
|
||||
|
||||
// The state from the previous session (after restoring pinned tabs). This
|
||||
// state is persisted and passed through to the next session during an app
|
||||
// restart to make the third party add-on warning not trash the deferred
|
||||
@ -371,14 +365,6 @@ let SessionStoreInternal = {
|
||||
this._sessionhistory_max_entries =
|
||||
this._prefBranch.getIntPref("sessionhistory.max_entries");
|
||||
|
||||
this._restoreOnDemand =
|
||||
this._prefBranch.getBoolPref("sessionstore.restore_on_demand");
|
||||
this._prefBranch.addObserver("sessionstore.restore_on_demand", this, true);
|
||||
|
||||
this._restorePinnedTabsOnDemand =
|
||||
this._prefBranch.getBoolPref("sessionstore.restore_pinned_tabs_on_demand");
|
||||
this._prefBranch.addObserver("sessionstore.restore_pinned_tabs_on_demand", this, true);
|
||||
|
||||
gSessionStartup.onceInitialized.then(
|
||||
this.initSession.bind(this)
|
||||
);
|
||||
@ -1188,14 +1174,6 @@ let SessionStoreInternal = {
|
||||
_SessionFile.wipe();
|
||||
this.saveState(true);
|
||||
break;
|
||||
case "sessionstore.restore_on_demand":
|
||||
this._restoreOnDemand =
|
||||
this._prefBranch.getBoolPref("sessionstore.restore_on_demand");
|
||||
break;
|
||||
case "sessionstore.restore_pinned_tabs_on_demand":
|
||||
this._restorePinnedTabsOnDemand =
|
||||
this._prefBranch.getBoolPref("sessionstore.restore_pinned_tabs_on_demand");
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -3266,10 +3244,8 @@ let SessionStoreInternal = {
|
||||
if (this._loadState == STATE_QUITTING)
|
||||
return;
|
||||
|
||||
// If it's not possible to restore anything, then just bail out.
|
||||
if ((this._restoreOnDemand &&
|
||||
(this._restorePinnedTabsOnDemand || !TabRestoreQueue.hasPriorityTabs)) ||
|
||||
this._tabsRestoringCount >= MAX_CONCURRENT_TAB_RESTORES)
|
||||
// Don't exceed the maximum number of concurrent tab restores.
|
||||
if (this._tabsRestoringCount >= MAX_CONCURRENT_TAB_RESTORES)
|
||||
return;
|
||||
|
||||
let tab = TabRestoreQueue.shift();
|
||||
@ -4496,20 +4472,50 @@ let TabRestoreQueue = {
|
||||
// The separate buckets used to store tabs.
|
||||
tabs: {priority: [], visible: [], hidden: []},
|
||||
|
||||
// Returns whether we have any high priority tabs in the queue.
|
||||
get hasPriorityTabs() !!this.tabs.priority.length,
|
||||
// Preferences used by the TabRestoreQueue to determine which tabs
|
||||
// are restored automatically and which tabs will be on-demand.
|
||||
prefs: {
|
||||
// Lazy getter that returns whether tabs are restored on demand.
|
||||
get restoreOnDemand() {
|
||||
let updateValue = () => {
|
||||
let value = Services.prefs.getBoolPref(PREF);
|
||||
let definition = {value: value, configurable: true};
|
||||
Object.defineProperty(this, "restoreOnDemand", definition);
|
||||
return value;
|
||||
}
|
||||
|
||||
// Lazy getter that returns whether we should restore hidden tabs.
|
||||
get restoreHiddenTabs() {
|
||||
let updateValue = () => {
|
||||
let value = Services.prefs.getBoolPref(PREF);
|
||||
let definition = {value: value, configurable: true};
|
||||
Object.defineProperty(this, "restoreHiddenTabs", definition);
|
||||
const PREF = "browser.sessionstore.restore_on_demand";
|
||||
Services.prefs.addObserver(PREF, updateValue, false);
|
||||
return updateValue();
|
||||
},
|
||||
|
||||
// Lazy getter that returns whether pinned tabs are restored on demand.
|
||||
get restorePinnedTabsOnDemand() {
|
||||
let updateValue = () => {
|
||||
let value = Services.prefs.getBoolPref(PREF);
|
||||
let definition = {value: value, configurable: true};
|
||||
Object.defineProperty(this, "restorePinnedTabsOnDemand", definition);
|
||||
return value;
|
||||
}
|
||||
|
||||
const PREF = "browser.sessionstore.restore_pinned_tabs_on_demand";
|
||||
Services.prefs.addObserver(PREF, updateValue, false);
|
||||
return updateValue();
|
||||
},
|
||||
|
||||
// Lazy getter that returns whether we should restore hidden tabs.
|
||||
get restoreHiddenTabs() {
|
||||
let updateValue = () => {
|
||||
let value = Services.prefs.getBoolPref(PREF);
|
||||
let definition = {value: value, configurable: true};
|
||||
Object.defineProperty(this, "restoreHiddenTabs", definition);
|
||||
return value;
|
||||
}
|
||||
|
||||
const PREF = "browser.sessionstore.restore_hidden_tabs";
|
||||
Services.prefs.addObserver(PREF, updateValue, false);
|
||||
return updateValue();
|
||||
}
|
||||
|
||||
const PREF = "browser.sessionstore.restore_hidden_tabs";
|
||||
Services.prefs.addObserver(PREF, updateValue, false);
|
||||
updateValue();
|
||||
},
|
||||
|
||||
// Resets the queue and removes all tabs.
|
||||
@ -4554,12 +4560,16 @@ let TabRestoreQueue = {
|
||||
let set;
|
||||
let {priority, hidden, visible} = this.tabs;
|
||||
|
||||
if (priority.length) {
|
||||
let {restoreOnDemand, restorePinnedTabsOnDemand} = this.prefs;
|
||||
let restorePinned = !(restoreOnDemand && restorePinnedTabsOnDemand);
|
||||
if (restorePinned && priority.length) {
|
||||
set = priority;
|
||||
} else if (visible.length) {
|
||||
set = visible;
|
||||
} else if (this.restoreHiddenTabs && hidden.length) {
|
||||
set = hidden;
|
||||
} else if (!restoreOnDemand) {
|
||||
if (visible.length) {
|
||||
set = visible;
|
||||
} else if (this.prefs.restoreHiddenTabs && hidden.length) {
|
||||
set = hidden;
|
||||
}
|
||||
}
|
||||
|
||||
return set && set.shift();
|
||||
|
Loading…
Reference in New Issue
Block a user