[Pkg-mozext-commits] [tabmixplus] 64/123: Add lazy getter to SessionStoreInternal

David Prévot taffit at moszumanska.debian.org
Wed Sep 17 21:16:27 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 2503fce6c074757a2530e8b85a7378d957be2f81
Author: onemen <tabmix.onemen at gmail.com>
Date:   Tue Sep 2 19:21:30 2014 +0300

    Add lazy getter to SessionStoreInternal
---
 chrome/content/minit/tablib.js    |  5 +----
 chrome/content/session/session.js | 27 ++++++++++++---------------
 2 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index a497847..4d8d0b2 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -884,10 +884,7 @@ var tablib = {
       var newTab = this.duplicateTab(aTab, url, null, url == null);
       if (!newTab.selected &&
           Services.prefs.getBoolPref("browser.sessionstore.restore_on_demand")) {
-        let tmp = {}
-        Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
-        let global = Cu.getGlobalForObject(tmp.SessionStore);
-        global.SessionStoreInternal.restoreTabContent(newTab);
+        TabmixSessionManager.SessionStore.restoreTabContent(newTab);
       }
 
       if (!url) {
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 448177c..1528b29 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -243,6 +243,14 @@ var TabmixSessionManager = {
       return this.prefBranch = Services.prefs.getBranch("extensions.tabmix.sessions.");
    },
 
+  get SessionStore() {
+    delete this.SessionStore;
+    let tmp = {}
+    Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
+    let global = Cu.getGlobalForObject(tmp.SessionStore);
+    return this.SessionStore = global.SessionStoreInternal;
+  },
+
    // call by Tabmix.beforeSessionStoreInit
    init: function SM_init(aPromise) {
       if (this._inited)
@@ -3159,25 +3167,16 @@ try{
       this._saveTabviewData();
 
       // call internal SessionStore functions to restore tabs
-      let getSSmodule = function() {
-        if (Tabmix.isVersion(250))
-          return TabmixSvc.ss;
-        let tmp = {}
-        Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
-        return tmp.SessionStore;
-      }
-      let global = Cu.getGlobalForObject(getSSmodule());
-      let SessionStore = global.SessionStoreInternal;
       if (overwrite) {
         for (let i = 0; i < gBrowser.tabs.length; i++) {
           let tab = gBrowser.tabs[i];
           if (gBrowser.browsers[i].__SS_restoreState)
-            SessionStore._resetTabRestoringState(tab);
+            this.SessionStore._resetTabRestoringState(tab);
         }
       }
       let fnName = Tabmix.isVersion(280) ? "restoreTabs" :
                                            "restoreHistoryPrecursor";
-      SessionStore[fnName](window, tabs, tabsData, 0);
+      this.SessionStore[fnName](window, tabs, tabsData, 0);
 
       // SessionStore.restoreTabs send SSWindowStateReady
       // show notification and clean up our data
@@ -3345,10 +3344,8 @@ try{
       if (!aOverwrite)
          closedTabsData = closedTabsData.concat(TMP_ClosedTabs.getClosedTabData);
       closedTabsData.splice(Services.prefs.getIntPref("browser.sessionstore.max_tabs_undo"));
-      if (Tabmix.isVersion(260)) {
-        let global = Cu.getGlobalForObject(TabmixSvc.ss);
-        global.SessionStoreInternal._windows[window.__SSi]._closedTabs = closedTabsData;
-      }
+      if (Tabmix.isVersion(260))
+        this.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);

-- 
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