[Pkg-mozext-commits] [tabmixplus] 05/47: Show 'Restore Previous Session' button on about:home page when user didn't restore last session with our Session Manager
David Prévot
taffit at moszumanska.debian.org
Fri Sep 26 20:56:59 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch upstream
in repository tabmixplus.
commit a0fa6e72402fbddf6aba8356dec554ff00cdcf81
Author: onemen <tabmix.onemen at gmail.com>
Date: Wed Sep 17 20:48:44 2014 +0300
Show 'Restore Previous Session' button on about:home page when user didn't restore last session with our Session Manager
---
chrome/content/session/session.js | 51 ++++++++++++++++++++++++++++++---------
chrome/content/tabmix.js | 7 +++---
2 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 32959b1..e5e5bde 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -291,6 +291,13 @@ var TabmixSessionManager = {
var _afterTabduplicated = "tabmix_afterTabduplicated" in window && window.tabmix_afterTabduplicated;
var isFirstWindow = (Tabmix.isFirstWindow || this.firstNonPrivateWindow) && !_afterTabduplicated;
+ this.enableManager = this.prefBranch.getBoolPref("manager") && !this.globalPrivateBrowsing;
+ this.enableBackup = this.prefBranch.getBoolPref("crashRecovery");
+ this.enableSaveHistory = this.prefBranch.getBoolPref("save.history");
+ this.saveClosedtabs = this.prefBranch.getBoolPref("save.closedtabs") &&
+ Tabmix.prefs.getBoolPref("undoClose");
+ this._lastSaveTime = Date.now();
+
let obs = Services.obs;
obs.addObserver(this, "browser-window-change-state", true);
obs.addObserver(this, "sessionstore-windows-restored", true);
@@ -302,13 +309,12 @@ var TabmixSessionManager = {
obs.addObserver(this, "private-browsing", true);
obs.addObserver(this, "private-browsing-change-granted", true);
}
+ if (Tabmix.isVersion(270)) {
+ if (this.enableBackup && this.canRestoreLastSession)
+ window.__SS_lastSessionWindowID = "" + Date.now() + Math.random();
+ obs.addObserver(this, "sessionstore-last-session-cleared", true);
+ }
- this.enableManager = this.prefBranch.getBoolPref("manager") && !this.globalPrivateBrowsing;
- this.enableBackup = this.prefBranch.getBoolPref("crashRecovery");
- this.enableSaveHistory = this.prefBranch.getBoolPref("save.history");
- this.saveClosedtabs = this.prefBranch.getBoolPref("save.closedtabs") &&
- Tabmix.prefs.getBoolPref("undoClose");
- this._lastSaveTime = Date.now();
var sanitized = this.enableManager && TabmixSvc.sm.sanitized;
// check if we need to backup
if (Tabmix.firstWindowInSession && this.enableManager && !sanitized) {
@@ -657,6 +663,8 @@ var TabmixSessionManager = {
obs.removeObserver(this, "private-browsing");
obs.removeObserver(this, "private-browsing-change-granted");
}
+ if (Tabmix.isVersion(270))
+ obs.removeObserver(this, "sessionstore-last-session-cleared");
if (this.afterExitPrivateBrowsing) {
clearTimeout(this.afterExitPrivateBrowsing);
this.afterExitPrivateBrowsing = null;
@@ -1103,6 +1111,9 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
case "browser-window-change-state":
this.toggleRecentlyClosedWindowsButton();
break;
+ case "sessionstore-last-session-cleared":
+ TabmixSvc.sm.lastSessionPath = null;
+ break;
case "browser:purge-session-history": // catch sanitization
// curently we don't do anything on exit
// if user set privacy.clearOnShutdown.history
@@ -2196,6 +2207,8 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
// handled by SessionStore
if (this.prefBranch.getBoolPref("restore.concatenate"))
this.deferredRestore();
+ else
+ this.setLastSession();
return; // Don't Restore
}
var loadSession = this.prefBranch.getIntPref("onStart.loadsession");
@@ -2329,7 +2342,7 @@ try{
if (!this.prefBranch.getBoolPref("onStart.restorePinned"))
return;
- let state = TabmixConvertSession.getSessionState(this.gSessionPath[1]);
+ let state = this.setLastSession();
let [iniState, remainingState] = this.SessionStore._prepDataForDeferredRestore(state);
let pinnedExist = iniState.windows.length > 0;
if (pinnedExist) {
@@ -2884,14 +2897,28 @@ try{
TabmixSvc.ss.restoreLastSession();
},
+ setLastSession: function(){
+ let state = TabmixConvertSession.getSessionState(this.gSessionPath[1]);
+ TabmixSvc.sm.lastSessionPath = this.gSessionPath[1];
+ if (!Tabmix.isVersion(270))
+ return state;
+ // add __SS_lastSessionWindowID to force SessionStore.restoreLastSession
+ // to open new window
+ window.__SS_lastSessionWindowID = "" + Date.now() + Math.random();
+ let tmp = {}
+ Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
+ let global = Cu.getGlobalForObject(tmp.SessionStore);
+ global.LastSession.setState(state);
+ return state;
+ },
+
loadSession: function SM_loadSession(path, caller, overwriteWindows) {
let lastSession = this.gSessionPath[1];
- if (caller == "firstwindowopen") {
- if (path != lastSession)
- TabmixSvc.sm.lastSessionPath = lastSession;
- }
- else if (path == lastSession) {
+ if (caller == "firstwindowopen" && path != lastSession)
+ this.setLastSession();
+ if (path == lastSession) {
TabmixSvc.sm.lastSessionPath = null;
+ TabmixSvc.ss.canRestoreLastSession = false;
Tabmix.setItem("Browser:RestoreLastSession", "disabled", true);
if (Tabmix.isVersion(270))
Services.obs.notifyObservers(null, "sessionstore-last-session-cleared", null);
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 8e307f7..f833426 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -83,9 +83,7 @@ Tabmix.sessionInitialized = function() {
).toCode();
}
- if (this.isVersion(260))
- SessionStore.canRestoreLastSession = false;
- else {
+ if (!this.isVersion(260)) {
this.changeCode(window, "window.BrowserOnAboutPageLoad")._replace(
'function updateSearchEngine',
'let updateSearchEngine = function _updateSearchEngine', {silent: true}
@@ -100,6 +98,9 @@ Tabmix.sessionInitialized = function() {
$&'
).toCode();
}
+ // from Firefox 27 SessionStore notify sessionstore-last-session-cleared
+ else if (!this.isVersion(270))
+ SessionStore.canRestoreLastSession = false;
}
var tab = gBrowser.tabContainer.firstChild;
--
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