[Pkg-mozext-commits] [tabmixplus] 38/48: Call saveSessionsData after Session manager finished to restore at startup, use window with readyState complete instead of most recent window
David Prévot
taffit at moszumanska.debian.org
Sun Aug 20 03:14:37 UTC 2017
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit 919753c4c4f52da98a765e913702b99502e87769
Author: onemen <tabmix.onemen at gmail.com>
Date: Wed Aug 16 20:05:29 2017 +0300
Call saveSessionsData after Session manager finished to restore at startup, use window with readyState complete instead of most recent window
---
chrome/content/tabmix.js | 5 +++++
modules/TabmixSvc.jsm | 1 +
modules/extensions/EmbeddedWebExtension.jsm | 25 ++++++++++++++++++++-----
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 61465f3..ce8d6d9 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -54,6 +54,11 @@ Tabmix.beforeDelayedStartup = function() {
// after TabmixSessionManager and SessionStore initialized
Tabmix.sessionInitialized = function() {
+ // Let EmbeddedWebExtension know we're done.
+ if (this.firstWindowInSession && TabmixSvc.sm.deferredInitialized) {
+ TabmixSvc.sm.deferredInitialized.resolve();
+ }
+
var SM = TabmixSessionManager;
if (SM.enableManager) {
window.restoreLastSession = function restoreLastSession() {
diff --git a/modules/TabmixSvc.jsm b/modules/TabmixSvc.jsm
index 4002cb6..70e98a1 100644
--- a/modules/TabmixSvc.jsm
+++ b/modules/TabmixSvc.jsm
@@ -262,6 +262,7 @@ this.TabmixSvc = {
private: true,
settingPreference: false,
statesToRestore: {},
+ deferredInitialized: null,
},
isAustralisBgStyle(orient) {
diff --git a/modules/extensions/EmbeddedWebExtension.jsm b/modules/extensions/EmbeddedWebExtension.jsm
index f4f2255..f957d2b 100644
--- a/modules/extensions/EmbeddedWebExtension.jsm
+++ b/modules/extensions/EmbeddedWebExtension.jsm
@@ -71,6 +71,8 @@ this.EmbeddedWebExtension = {
}
this._initialized = true;
+ TabmixSvc.sm.deferredInitialized = PromiseUtils.defer();
+
this.initPrefsObserver();
this.startWebExtension();
},
@@ -116,7 +118,7 @@ this.EmbeddedWebExtension = {
port.onMessage.addListener(message => this.handleResponse(message));
this.savePreferencesData();
- this.saveSessionsData();
+ TabmixSvc.sm.deferredInitialized.promise.then(() => this.saveSessionsData());
},
messageID: 0,
@@ -263,8 +265,12 @@ this.EmbeddedWebExtension = {
getCurrentSessionsData(currentHashList) {
const newHashList = [];
const sessionsData = {};
- const sessions = this.getSessionList();
- const {TabmixConvertSession} = TabmixSvc.topWin();
+ const window = this.getBrowserWindow();
+ if (!window) {
+ return Promise.reject("can't find a window with readyState complete");
+ }
+ const {TabmixSessionManager, TabmixConvertSession} = window;
+ const sessions = this.getSessionList(TabmixSessionManager);
const changedSessions = sessions.filter(session => {
const hash = session.info.hash;
@@ -359,8 +365,7 @@ this.EmbeddedWebExtension = {
_currentHash: null,
- getSessionList() {
- const {TabmixSessionManager: SM} = TabmixSvc.topWin();
+ getSessionList(SM) {
const sessions = SM.getSessionList() || {list: [], path: []};
const crashedSession = SM.gSessionPath[3];
@@ -426,6 +431,16 @@ this.EmbeddedWebExtension = {
return {name, path, info};
},
+
+ getBrowserWindow() {
+ const windows = Services.wm.getEnumerator("navigator:browser");
+ while (windows.hasMoreElements()) {
+ const win = windows.getNext();
+ if (!win.closed && win.document.readyState == "complete")
+ return win;
+ }
+ return null;
+ },
};
/**
--
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