[Pkg-mozext-commits] [tabmixplus] 39/61: Force Sessionstore to save our persisted tab attributes
David Prévot
taffit at moszumanska.debian.org
Fri Aug 28 19:09:21 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit a42b9e6ad04439a3f3120fd35ee4967dbbf76408
Author: onemen <tabmix.onemen at gmail.com>
Date: Thu Aug 6 15:56:02 2015 +0300
Force Sessionstore to save our persisted tab attributes
---
chrome/content/links/setup.js | 6 +++---
chrome/content/session/session.js | 30 ++++++++----------------------
chrome/content/tab/tab.js | 4 +++-
modules/Services.jsm | 30 ++++++++++++++++++++++++------
modules/extensions/TabGroupsManager.jsm | 2 +-
5 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/chrome/content/links/setup.js b/chrome/content/links/setup.js
index 6cd2388..8815e26 100644
--- a/chrome/content/links/setup.js
+++ b/chrome/content/links/setup.js
@@ -125,12 +125,12 @@ Tabmix.beforeBrowserInitOnLoad = function() {
this.firstWindowInSession && !this.isWindowAfterSessionRestore;
// RunState exist since Firefox 34, bug 1020831
if (setStateRunning) {
- let RunState = SM.SessionStoreGlobal.RunState || {
+ let RunState = TabmixSvc.SessionStoreGlobal.RunState || {
get isStopped() {
- return SM.SessionStore._loadState === 0; // STATE_STOPPED
+ return TabmixSvc.SessionStore._loadState === 0; // STATE_STOPPED
},
setRunning: function() {
- SM.SessionStore._loadState = 1; // STATE_RUNNING
+ TabmixSvc.SessionStore._loadState = 1; // STATE_RUNNING
}
};
if (RunState.isStopped) {
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index b460819..af291a4 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -247,18 +247,6 @@ var TabmixSessionManager = { // jshint ignore:line
return (this.prefBranch = Services.prefs.getBranch("extensions.tabmix.sessions."));
},
- get SessionStoreGlobal() {
- delete this.SessionStoreGlobal;
- let tmp = {};
- Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
- return (this.SessionStoreGlobal = Cu.getGlobalForObject(tmp.SessionStore));
- },
-
- get SessionStore() {
- delete this.SessionStore;
- return (this.SessionStore = this.SessionStoreGlobal.SessionStoreInternal);
- },
-
// call by Tabmix.beforeSessionStoreInit
init: function SM_init(aPromise) {
if (this._inited)
@@ -685,8 +673,6 @@ var TabmixSessionManager = { // jshint ignore:line
clearTimeout(this.afterExitPrivateBrowsing);
this.afterExitPrivateBrowsing = null;
}
- delete this.SessionStoreGlobal;
- delete this.SessionStore;
}
},
@@ -2403,7 +2389,7 @@ try{
return;
let state = this.setLastSession();
- let iniState = this.SessionStore._prepDataForDeferredRestore(state)[0];
+ let iniState = TabmixSvc.SessionStore._prepDataForDeferredRestore(state)[0];
let pinnedExist = iniState.windows.length > 0;
if (pinnedExist) {
// move all tabs and closed tabs into one window
@@ -2411,14 +2397,14 @@ try{
this.prefBranch.getBoolPref("restore.concatenate"))) {
this.mergeWindows(iniState);
}
- let overwrite = this.SessionStore._isCmdLineEmpty(window, iniState);
+ let overwrite = TabmixSvc.SessionStore._isCmdLineEmpty(window, iniState);
if (Tabmix.isVersion(260)) {
let options = {firstWindow: true, overwriteTabs: overwrite};
- this.SessionStore.restoreWindow(window, iniState, options);
+ TabmixSvc.SessionStore.restoreWindow(window, iniState, options);
}
else {
iniState._firstTabs = true;
- this.SessionStore.restoreWindow(window, iniState, overwrite);
+ TabmixSvc.SessionStore.restoreWindow(window, iniState, overwrite);
}
}
this.loadHomePage(pinnedExist);
@@ -2992,7 +2978,7 @@ try{
// to open new window
if (restoring)
window.__SS_lastSessionWindowID = "" + Date.now() + Math.random();
- this.SessionStoreGlobal.LastSession.setState(state);
+ TabmixSvc.SessionStoreGlobal.LastSession.setState(state);
return state;
},
@@ -3372,12 +3358,12 @@ try{
for (let i = 0; i < gBrowser.tabs.length; i++) {
let tab = gBrowser.tabs[i];
if (gBrowser.browsers[i].__SS_restoreState)
- this.SessionStore._resetTabRestoringState(tab);
+ TabmixSvc.SessionStore._resetTabRestoringState(tab);
}
}
let fnName = Tabmix.isVersion(280) ? "restoreTabs" :
"restoreHistoryPrecursor";
- this.SessionStore[fnName](window, tabs, tabsData, 0);
+ TabmixSvc.SessionStore[fnName](window, tabs, tabsData, 0);
// SessionStore.restoreTabs send SSWindowStateReady
// show notification and clean up our data
@@ -3556,7 +3542,7 @@ try{
closedTabsData = closedTabsData.concat(TMP_ClosedTabs.getClosedTabData);
closedTabsData.splice(Services.prefs.getIntPref("browser.sessionstore.max_tabs_undo"));
if (Tabmix.isVersion(260))
- this.SessionStore._windows[window.__SSi]._closedTabs = closedTabsData;
+ TabmixSvc.SessionStore._windows[window.__SSi]._closedTabs = closedTabsData;
else {
let state = { windows: [{ _closedTabs: closedTabsData, selected: 0 }], _firstTabs: true};
TabmixSvc.ss.setWindowState(window, TabmixSvc.JSON.stringify(state), false);
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index f07e8dd..28bedbf 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -1202,8 +1202,10 @@ var gTMPprefObserver = {
else
tab.removeAttribute("_locked");
tab.linkedBrowser.tabmix_allowLoad = !tab.hasAttribute("locked");
- TabmixSvc.saveTabAttributes(tab, "_locked");
+ TabmixSvc.saveTabAttributes(tab, "_locked", false);
}
+ // force Sessionstore to save our changes
+ TabmixSvc.SessionStore.saveStateDelayed(window);
break;
case "extensions.tabmix.extraIcons.autoreload":
case "extensions.tabmix.extraIcons.protected":
diff --git a/modules/Services.jsm b/modules/Services.jsm
index f676ef4..3d69248 100644
--- a/modules/Services.jsm
+++ b/modules/Services.jsm
@@ -197,6 +197,8 @@ this.TabmixSvc = {
let timer = TabmixSvc.console._timers[id];
timer.cancel();
}
+ delete TabmixSvc.SessionStoreGlobal;
+ delete TabmixSvc.SessionStore;
break;
case "browser-delayed-startup-finished":
try {
@@ -207,8 +209,8 @@ this.TabmixSvc = {
}
},
- saveTabAttributes: function(tab, attrib) {
- tabStateCache.saveTabAttributes(tab, attrib);
+ saveTabAttributes: function(tab, attrib, save) {
+ tabStateCache.saveTabAttributes(tab, attrib, save);
},
get ss() {
@@ -296,6 +298,14 @@ XPCOMUtils.defineLazyModuleGetter(TabmixSvc, "FileUtils",
XPCOMUtils.defineLazyModuleGetter(TabmixSvc, "console",
"resource://tabmixplus/log.jsm");
+XPCOMUtils.defineLazyGetter(TabmixSvc, "SessionStoreGlobal", function() {
+ return Cu.getGlobalForObject(this.ss);
+});
+
+XPCOMUtils.defineLazyGetter(TabmixSvc, "SessionStore", function() {
+ return this.SessionStoreGlobal.SessionStoreInternal;
+});
+
var tabStateCache = {
get _update() {
delete this._update;
@@ -307,13 +317,21 @@ var tabStateCache = {
if (isVersion(270))
Cu.import("resource:///modules/sessionstore/TabStateCache.jsm", this);
else
- this.TabStateCache = Cu.getGlobalForObject(TabmixSvc.ss).TabStateCache;
+ this.TabStateCache = TabmixSvc.SessionStoreGlobal.TabStateCache;
return this.TabStateCache;
},
- saveTabAttributes: function(tab, attrib) {
- // After bug 1166757 - Remove browser.__SS_data, we no longer need this function
- if (!isVersion(250) || isVersion(410))
+ saveTabAttributes: function(tab, attrib, save = true) {
+ if (!isVersion(250))
+ return;
+
+ // force Sessionstore to save our persisted tab attributes
+ if (save) {
+ TabmixSvc.SessionStore.saveStateDelayed(tab.ownerDocument.defaultView);
+ }
+
+ // After bug 1166757 - Remove browser.__SS_data, we have nothing more to do.
+ if (isVersion(410))
return;
let attribs = attrib.split(",");
diff --git a/modules/extensions/TabGroupsManager.jsm b/modules/extensions/TabGroupsManager.jsm
index 4c3a2b7..6f7ee88 100644
--- a/modules/extensions/TabGroupsManager.jsm
+++ b/modules/extensions/TabGroupsManager.jsm
@@ -109,7 +109,7 @@ this.TMP_TabGroupsManager = {
' caller=="firstwindowopen" || caller=="windowopenedbytabmix");' +
' $&'
)._replace(
- 'this.SessionStore[fnName](window, tabs, tabsData, 0);',
+ 'TabmixSvc.SessionStore[fnName](window, tabs, tabsData, 0);',
'$&\n' +
' this._moveTabsToGroupByTGM(window, tabs);'
).toCode();
--
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