[Pkg-mozext-commits] [tabmixplus] 67/123: Set SessionStore._loadState to running on first window in session to prevent it from restoring pinned tabs.
David Prévot
taffit at moszumanska.debian.org
Wed Sep 17 21:16:28 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit 37e37619c7dd9d94654b30e3fab1c83c0c0e9de6
Author: onemen <tabmix.onemen at gmail.com>
Date: Tue Sep 2 18:42:46 2014 +0300
Set SessionStore._loadState to running on first window in session to prevent it from restoring pinned tabs.
---
chrome/content/links/setup.js | 12 ++++++++++++
chrome/content/minit/tablib.js | 4 ----
chrome/content/session/session.js | 41 ++++++++++++++++++++-------------------
3 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/chrome/content/links/setup.js b/chrome/content/links/setup.js
index dd8a12d..0b6b518 100644
--- a/chrome/content/links/setup.js
+++ b/chrome/content/links/setup.js
@@ -112,6 +112,18 @@ Tabmix.beforeBrowserInitOnLoad = function() {
this.prefs.prefHasUserValue("sessions.crashed"));
var notRestore = firstWindow && !disabled && sessionManager &&
this.prefs.getIntPref("sessions.onStart") > 1;
+
+ // Set SessionStore._loadState to running on first window in the session
+ // to prevent it from restoring pinned tabs.
+ let setStateRunning = Tabmix.isVersion(250) && (willRestore || notRestore) &&
+ this.firstWindowInSession && !this.isWindowAfterSessionRestore;
+ if (setStateRunning) {
+ let STATE_STOPPED = 0;
+ let STATE_RUNNING = 1;
+ if (SM.SessionStore._loadState == STATE_STOPPED)
+ SM.SessionStore._loadState = STATE_RUNNING;
+ }
+
var afterSessionRestore = !this.isVersion(250) && this.isWindowAfterSessionRestore;
SM.doRestore = willRestore && !(SM.isPrivateWindow || afterSessionRestore);
var willOverrideHomepage = willRestore && !SM.isPrivateWindow;
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index 4d8d0b2..1f954d2 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -68,10 +68,6 @@ var tablib = {
Tabmix.changeCode(obj, "gBrowser." + fnName)._replace(
'{','{\n\
- if (!TabmixSvc.sm.promiseInitialized && !this.tabs[0].loadOnStartup && isRestoringTab && !Tabmix.isWindowAfterSessionRestore)\n\
- return this.tabs[0];\n', {check: Tabmix.isVersion(250) && TabmixSessionManager.doRestore}
- )._replace(
- '{','{\n\
let dontMove, isPending, isRestoringTab = Tabmix.callerName() == "ssi_restoreWindow";\n'
)._replace(
'params = arguments[1];',
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index a493c95..7d16f65 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -231,6 +231,7 @@ var TabmixSessionManager = {
_inited: false,
windowClosed: false,
overrideHomepage: null,
+ waitForCallBack: false,
afterCrash: false,
lastSessionWasEmpty: false,
@@ -262,7 +263,7 @@ var TabmixSessionManager = {
let initializeSM = function() {
TabmixSvc.sm.promiseInitialized = true;
this._init();
- this.restoreWindowArguments();
+ this._sendRestoreCompletedNotifications(false);
}.bind(this);
Tabmix.ssPromise = aPromise || TabmixSvc.ss.promiseInitialized;
Tabmix.ssPromise.then(initializeSM)
@@ -271,15 +272,15 @@ var TabmixSessionManager = {
else {
let forceInit = !Tabmix.isVersion(250) && this.doRestore;
// make sure sessionstore initialize without restoring pinned tabs
- // for Firefox 25+ we block new tab in gbrowser.addtab
+ // for Firefox 25+ we set SessionStore._loadState = STATE_RUNNING
if (forceInit)
TabmixSvc.ss.init(null);
this._init();
// restart-less extensions observers for this notification on startup
// notify observers things are complete when we call SessionStore.init
// with null.
- if (forceInit)
- Services.obs.notifyObservers(null, "sessionstore-windows-restored", "");
+ if (Tabmix.isVersion(250) && this.firstNonPrivateWindow || forceInit)
+ this._sendRestoreCompletedNotifications(false);
}
},
@@ -387,26 +388,11 @@ var TabmixSessionManager = {
return;
}
-/**
-//XXX TODO - fix the case that last session contained more then one window
- with pinned tabs. in this case SessionStore will open more windows
-*/
if (Tabmix.isWindowAfterSessionRestore) {
let self = this;
setTimeout(function(){self.onSessionRestored()}, 0);
}
else {
- // remove extra tab that was opened by SessionStore if last session
- // contained pinned tab(s).
- let tab = gBrowser.tabs[0];
- if (this.doRestore && Tabmix.isVersion(250) && tab.pinned && !tab.loadOnStartup) {
- this.resetTab(tab);
- this.removeTab(tab);
- try {
- if (TMP_ClosedTabs.count)
- TabmixSvc.ss.forgetClosedTab(window, 0);
- } catch(ex) {}
- }
if (TabmixSvc.sm.crashed && this.enableBackup)
this.openAfterCrash(TabmixSvc.sm.status);
else if (this.enableManager)
@@ -1117,7 +1103,6 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
this.saveState();
break;
case "sessionstore-windows-restored":
- // before Firefox 25, our session manager run before SessionStore
// we prevent SessionStore from adding the home page when last
// session contained only pinned tab(s).
// SessionStore._isCmdLineEmpty use the arguments to determine if it
@@ -2088,6 +2073,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
var isAllEmpty = lastSession && prevtoLast && savedSession;
var callBack = function (aResult) {TabmixSessionManager.afterCrashPromptCallBack(aResult);}
this.callBackData = {label: null, whattoLoad: "session"}
+ this.waitForCallBack = true;
if (!this.containerEmpty(this.gSessionPath[3])) { // if Crashed Session is not empty
let crashedContainer = this.initContainer(this.gSessionPath[3]);
let count = this.countWinsAndTabs(crashedContainer);
@@ -2163,6 +2149,8 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
this.loadHomePage();
this.saveStateDelayed();
delete this.callBackData;
+
+ this._sendRestoreCompletedNotifications(true);
},
prepareSavedSessions: function SM_prepareSavedSessions() {
@@ -2242,6 +2230,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
let callBack = function (aResult) {
TabmixSessionManager.enableCrashRecovery(aResult);
}
+ this.waitForCallBack = true;
Tabmix.promptService([Tabmix.BUTTON_CANCEL, Tabmix.HIDE_MENUANDTEXT, chkBoxState],
[title, msg, "", chkBoxLabel, buttons], window, callBack);
}
@@ -2300,6 +2289,7 @@ try{
let callBack = function (aResult) {
TabmixSessionManager.onFirstWindowPromptCallBack(aResult);
}
+ this.waitForCallBack = true;
Tabmix.promptService([Tabmix.BUTTON_OK, Tabmix.SHOW_MENULIST, chkBoxState, Tabmix.SELECT_DEFAULT],
[title, msg, "", chkBoxLabel, buttons], window, callBack);
} catch (ex) {Tabmix.assert(ex);}
@@ -2316,6 +2306,7 @@ try{
this.prefBranch.setBoolPref("crashRecovery", true); // enable Crash Recovery
Services.prefs.savePrefFile(null); // store the pref immediately
}
+ this._sendRestoreCompletedNotifications(true);
},
onFirstWindowPromptCallBack: function SM_onFirstWindowPromptCallBack(aResult) {
@@ -2330,6 +2321,16 @@ try{
// now that we open our tabs init TabView again
TMP_SessionStore.initService();
TMP_TabView.init();
+
+ this._sendRestoreCompletedNotifications(true);
+ },
+
+ _sendRestoreCompletedNotifications: function(waitForCallBack) {
+ // notify observers things are complete.
+ if (Tabmix.isVersion(250) && this.waitForCallBack == waitForCallBack) {
+ Services.obs.notifyObservers(null, "sessionstore-windows-restored", "");
+ this.waitForCallBack = false;
+ }
},
getSessionList: function SM_getSessionList(flag) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list