[Pkg-mozext-commits] [tabmixplus] 80/123: Send "sessionstore-windows-restored" notification as soon as _init function finished

David Prévot taffit at moszumanska.debian.org
Wed Sep 17 21:16:29 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 f94bf341cfa93a2143b699aad57e2a64008b47b2
Author: onemen <tabmix.onemen at gmail.com>
Date:   Fri Sep 5 10:05:35 2014 +0300

    Send "sessionstore-windows-restored" notification as soon as _init function finished
---
 chrome/content/links/setup.js     |  4 +++-
 chrome/content/session/session.js | 29 ++++++++++++++++++-----------
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/chrome/content/links/setup.js b/chrome/content/links/setup.js
index 0b6b518..70a5918 100644
--- a/chrome/content/links/setup.js
+++ b/chrome/content/links/setup.js
@@ -120,8 +120,10 @@ Tabmix.beforeBrowserInitOnLoad = function() {
     if (setStateRunning) {
       let STATE_STOPPED = 0;
       let STATE_RUNNING = 1;
-      if (SM.SessionStore._loadState == STATE_STOPPED)
+      if (SM.SessionStore._loadState == STATE_STOPPED) {
         SM.SessionStore._loadState = STATE_RUNNING;
+        SM.notifyObservers = true;
+      }
     }
 
     var afterSessionRestore = !this.isVersion(250) && this.isWindowAfterSessionRestore;
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 7d16f65..3a70c90 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -232,6 +232,7 @@ var TabmixSessionManager = {
     windowClosed: false,
     overrideHomepage: null,
     waitForCallBack: false,
+    notifyObservers: false,
 
     afterCrash: false,
     lastSessionWasEmpty: false,
@@ -766,6 +767,7 @@ var TabmixSessionManager = {
    restoreWindowArguments: function() {
       if (this.overrideHomepage)
         window.arguments[0] = this.overrideHomepage;
+      this.overrideHomepage = null;
    },
 
    loadHomePage: function SM_loadHomePage() {
@@ -788,7 +790,7 @@ var TabmixSessionManager = {
         }
         else
           afterLoad(browser);
-        this.restoreWindowArguments(true);
+        this.restoreWindowArguments();
       }
       else if (gBrowser.mCurrentTab.loadOnStartup) {
         for (var i = 0; i < gBrowser.tabs.length ; i++)
@@ -1103,12 +1105,6 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
             this.saveState();
             break;
          case "sessionstore-windows-restored":
-            // 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
-            // need to override tab
-            if (!Tabmix.isVersion(250))
-              this.restoreWindowArguments();
          case "sessionstore-browser-state-restored":
             // session restored update buttons state
             TMP_ClosedTabs.setButtonDisableState();
@@ -2306,7 +2302,8 @@ try{
         this.prefBranch.setBoolPref("crashRecovery", true); // enable Crash Recovery
         Services.prefs.savePrefFile(null); // store the pref immediately
       }
-      this._sendRestoreCompletedNotifications(true);
+      if (this.waitForCallBack)
+        this._sendRestoreCompletedNotifications(true);
    },
 
    onFirstWindowPromptCallBack: function SM_onFirstWindowPromptCallBack(aResult) {
@@ -2327,10 +2324,20 @@ try{
 
    _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;
+      // we send sessionstore-windows-restored notification as soon as _init
+      // function finished, if there are pending call back from one of our
+      // dialog 2nd notification will be send once the call back function finished.
+      if (this.notifyObservers) {
+        this.notifyObservers = false;
+        if (!waitForCallBack)
+          Services.obs.notifyObservers(null, "sessionstore-windows-restored", "");
+        else if (this.waitForCallBack == waitForCallBack) {
+          Services.obs.notifyObservers(null, "sessionstore-browser-state-restored", "");
+          this.waitForCallBack = false;
+        }
       }
+      if (!this.waitForCallBack)
+        this.restoreWindowArguments();
    },
 
    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