From a14ef5f5e4a65180616bbe8913eda8b16c83f45c Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Fri, 9 Mar 2012 22:10:03 +0100 Subject: [PATCH 01/13] Bug 726560 - Add support of Panorama group name (FF10+) for titlebar customization --- extension/chrome/content/browser.js | 60 +++++++++++++++++++ extension/chrome/content/nightly.js | 5 ++ .../chrome/content/titlebar/customize.js | 1 + .../chrome/locale/en-US/variables.properties | 1 + 4 files changed, 67 insertions(+) diff --git a/extension/chrome/content/browser.js b/extension/chrome/content/browser.js index d66440a..7566be3 100644 --- a/extension/chrome/content/browser.js +++ b/extension/chrome/content/browser.js @@ -41,6 +41,9 @@ repository: ['mozilla-central','mozilla-aurora'], storedTitle: document.documentElement.getAttribute("titlemodifier"), +LAST_SESSION_GROUP_NAME_IDENTIFIER: "nightlytt-last-session-group-name", +_lastSessionGroupName: "", + get defaultTitle() { var tabbrowser = document.getElementById("content"); return tabbrowser.getWindowTitleForBrowser(tabbrowser.mCurrentBrowser); @@ -51,6 +54,32 @@ get tabTitle() { return tabbrowser.mCurrentBrowser.contentTitle; }, +get activeTabGroupName() { + // TabView isn't implemented or initialized + if (!TabView || !TabView._window) + return nightlyApp._lastSessionGroupName; + + + // We get the active group this way, instead of querying + // GroupItems.getActiveGroupItem() because the tabSelect event + // will not have happened by the time the browser tries to + // update the title. + let groupItem = null; + let activeTab = window.gBrowser.selectedTab; + let activeTabItem = activeTab._tabViewTabItem; + + if (activeTab.pinned) { + // It's an app tab, so it won't have a .tabItem. However, its .parent + // will already be set as the active group. + groupItem = TabView._window.GroupItems.getActiveGroupItem(); + } else if (activeTabItem) { + groupItem = activeTabItem.parent; + } + + // groupItem may still be null, if the active tab is an orphan. + return groupItem ? groupItem.getTitle() : ""; +}, + init: function() { var brandbundle = document.getElementById("bundle_brand"); @@ -66,6 +95,24 @@ init: function() tabbrowser.updateTitlebar = nightly.updateTitlebar; tabbrowser.addEventListener("DOMTitleChanged", nightly.updateTitlebar, false); + + // Listening to Bug 659591 (landed in FF7) - instead "domwindowclosed" (see Bug 655269), + // to store active group's name for showing at next startup + window.addEventListener("SSWindowClosing", function NightlyTT_onWindowClosing() { + window.removeEventListener("SSWindowClosing", NightlyTT_onWindowClosing, false); + nightlyApp.saveActiveGroupName(window); + }, false); + + // grab the last used group title + // use TabView's property if we are before Bug 682996 (landed in FF10) + nightlyApp._lastSessionGroupName = (TabView && TabView._lastSessionGroupName) + ? TabView._lastSessionGroupName + : Cc["@mozilla.org/browser/sessionstore;1"] + .getService(Ci.nsISessionStore) + .getWindowValue( + window, + nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER + ); }, openURL: function(url) @@ -87,6 +134,19 @@ openNotification: function(id, message, label, accessKey, callback) { message, "urlbar", action, null, options); }, +// Function: saveActiveGroupName +// Saves the active group's name for the given window. +saveActiveGroupName: function NightlyTT_saveActiveGroupName(win) { + let groupName = nightlyApp.activeTabGroupName; + Cc["@mozilla.org/browser/sessionstore;1"] + .getService(Ci.nsISessionStore) + .setWindowValue( + win, + nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER, + groupName + ); +}, + setCustomTitle: function(title) { document.getElementById("content").ownerDocument.title = title; diff --git a/extension/chrome/content/nightly.js b/extension/chrome/content/nightly.js index 9bed17e..8e5efe9 100644 --- a/extension/chrome/content/nightly.js +++ b/extension/chrome/content/nightly.js @@ -69,6 +69,7 @@ variables: { get compiler() this.appInfo.XPCOMABI.split("-")[1], get defaulttitle() { return nightlyApp.defaultTitle; }, get tabtitle() { return nightlyApp.tabTitle; }, + get activetabgroupname() { return nightlyApp.activeTabGroupName || null; }, profile: null, toolkit: "cairo", flags: "" @@ -107,6 +108,10 @@ showAlert: function(id, args) { init: function() { window.removeEventListener("load", nightly.init, false); + setTimeout(nightly.initLazy,800); +}, + +initLazy: function() { var prefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); nightly.preferences = prefs.getBranch("nightly.") diff --git a/extension/chrome/content/titlebar/customize.js b/extension/chrome/content/titlebar/customize.js index 9b3d401..995b833 100644 --- a/extension/chrome/content/titlebar/customize.js +++ b/extension/chrome/content/titlebar/customize.js @@ -59,6 +59,7 @@ init: function() paneTitle.addVariable("DefaultTitle"); paneTitle.addVariable("TabTitle"); + paneTitle.addVariable("ActiveTabGroupName"); paneTitle.addVariable("AppID"); paneTitle.addVariable("Vendor"); paneTitle.addVariable("Name"); diff --git a/extension/chrome/locale/en-US/variables.properties b/extension/chrome/locale/en-US/variables.properties index 5e8cf0f..7918490 100644 --- a/extension/chrome/locale/en-US/variables.properties +++ b/extension/chrome/locale/en-US/variables.properties @@ -52,5 +52,6 @@ variable.Processor.description=Compilation Processor variable.Compiler.description=Compiler variable.DefaultTitle.description=Default Application Title variable.TabTitle.description=Current Tab's Title +variable.ActiveTabGroupName.description=Active TabView group name - may be empty in rare cases variable.Profile.description=Current Profile variable.Toolkit.description=Graphics Toolkit From bcdc71263bf4078427f7ef6f165106ca0f7127b3 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Mon, 12 Mar 2012 23:31:25 +0100 Subject: [PATCH 02/13] Bug 726560 - v2: renaming activeTabGroupName --- extension/chrome/content/browser.js | 4 ++-- extension/chrome/content/nightly.js | 2 +- extension/chrome/content/titlebar/customize.js | 2 +- extension/chrome/locale/en-US/variables.properties | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extension/chrome/content/browser.js b/extension/chrome/content/browser.js index 7566be3..289bb8c 100644 --- a/extension/chrome/content/browser.js +++ b/extension/chrome/content/browser.js @@ -54,7 +54,7 @@ get tabTitle() { return tabbrowser.mCurrentBrowser.contentTitle; }, -get activeTabGroupName() { +get tabGroupTitle() { // TabView isn't implemented or initialized if (!TabView || !TabView._window) return nightlyApp._lastSessionGroupName; @@ -137,7 +137,7 @@ openNotification: function(id, message, label, accessKey, callback) { // Function: saveActiveGroupName // Saves the active group's name for the given window. saveActiveGroupName: function NightlyTT_saveActiveGroupName(win) { - let groupName = nightlyApp.activeTabGroupName; + let groupName = nightlyApp.tabGroupTitle; Cc["@mozilla.org/browser/sessionstore;1"] .getService(Ci.nsISessionStore) .setWindowValue( diff --git a/extension/chrome/content/nightly.js b/extension/chrome/content/nightly.js index 8e5efe9..9cbd159 100644 --- a/extension/chrome/content/nightly.js +++ b/extension/chrome/content/nightly.js @@ -69,7 +69,7 @@ variables: { get compiler() this.appInfo.XPCOMABI.split("-")[1], get defaulttitle() { return nightlyApp.defaultTitle; }, get tabtitle() { return nightlyApp.tabTitle; }, - get activetabgroupname() { return nightlyApp.activeTabGroupName || null; }, + get tabgroup() { return nightlyApp.tabGroupTitle || null; }, profile: null, toolkit: "cairo", flags: "" diff --git a/extension/chrome/content/titlebar/customize.js b/extension/chrome/content/titlebar/customize.js index 995b833..1d5afe7 100644 --- a/extension/chrome/content/titlebar/customize.js +++ b/extension/chrome/content/titlebar/customize.js @@ -59,7 +59,7 @@ init: function() paneTitle.addVariable("DefaultTitle"); paneTitle.addVariable("TabTitle"); - paneTitle.addVariable("ActiveTabGroupName"); + paneTitle.addVariable("TabGroup"); paneTitle.addVariable("AppID"); paneTitle.addVariable("Vendor"); paneTitle.addVariable("Name"); diff --git a/extension/chrome/locale/en-US/variables.properties b/extension/chrome/locale/en-US/variables.properties index 7918490..ef07fb7 100644 --- a/extension/chrome/locale/en-US/variables.properties +++ b/extension/chrome/locale/en-US/variables.properties @@ -52,6 +52,6 @@ variable.Processor.description=Compilation Processor variable.Compiler.description=Compiler variable.DefaultTitle.description=Default Application Title variable.TabTitle.description=Current Tab's Title -variable.ActiveTabGroupName.description=Active TabView group name - may be empty in rare cases +variable.TabGroup.description=Current Tab Group variable.Profile.description=Current Profile variable.Toolkit.description=Graphics Toolkit From 57e2da63d207eab8eee7f18baa868447e2ed810d Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Mon, 12 Mar 2012 23:42:40 +0100 Subject: [PATCH 03/13] Bug 726560 - v2: leave tabGroup empty --- extension/chrome/content/nightly.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/chrome/content/nightly.js b/extension/chrome/content/nightly.js index 9cbd159..8f2a5fa 100644 --- a/extension/chrome/content/nightly.js +++ b/extension/chrome/content/nightly.js @@ -69,7 +69,7 @@ variables: { get compiler() this.appInfo.XPCOMABI.split("-")[1], get defaulttitle() { return nightlyApp.defaultTitle; }, get tabtitle() { return nightlyApp.tabTitle; }, - get tabgroup() { return nightlyApp.tabGroupTitle || null; }, + get tabgroup() { return nightlyApp.tabGroupTitle; }, profile: null, toolkit: "cairo", flags: "" From 7dbf770ac4d9f982a60b016be940a05628a0d436 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Tue, 13 Mar 2012 01:19:26 +0100 Subject: [PATCH 04/13] Bug 726560 - v2: trying to get saved tab group title without delaying startup --- extension/chrome/content/browser.js | 27 ++++++++++++++++++++------- extension/chrome/content/nightly.js | 4 ---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/extension/chrome/content/browser.js b/extension/chrome/content/browser.js index 289bb8c..1e814e4 100644 --- a/extension/chrome/content/browser.js +++ b/extension/chrome/content/browser.js @@ -105,14 +105,27 @@ init: function() // grab the last used group title // use TabView's property if we are before Bug 682996 (landed in FF10) - nightlyApp._lastSessionGroupName = (TabView && TabView._lastSessionGroupName) - ? TabView._lastSessionGroupName - : Cc["@mozilla.org/browser/sessionstore;1"] - .getService(Ci.nsISessionStore) - .getWindowValue( - window, - nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER + if (TabView && TabView._lastSessionGroupName) + { + nightlyApp._lastSessionGroupName = TabView._lastSessionGroupName; + } + else + { + Cc["@mozilla.org/observer-service;1"] + .getService(Ci.nsIObserverService).addObserver({ + observe: function NightlyTT_Restore() { + Cc["@mozilla.org/observer-service;1"] + .getService(Ci.nsIObserverService).removeObserver(this, "sessionstore-windows-restored"); + + nightlyApp._lastSessionGroupName = Cc["@mozilla.org/browser/sessionstore;1"] + .getService(Ci.nsISessionStore) + .getWindowValue( + window, + nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER ); + } + }, "sessionstore-windows-restored", false); + } }, openURL: function(url) diff --git a/extension/chrome/content/nightly.js b/extension/chrome/content/nightly.js index 8f2a5fa..e3c00ab 100644 --- a/extension/chrome/content/nightly.js +++ b/extension/chrome/content/nightly.js @@ -108,10 +108,6 @@ showAlert: function(id, args) { init: function() { window.removeEventListener("load", nightly.init, false); - setTimeout(nightly.initLazy,800); -}, - -initLazy: function() { var prefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); nightly.preferences = prefs.getBranch("nightly.") From e52f841406a6e67fad88fff4112a17a58f7ec2ad Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Tue, 13 Mar 2012 01:36:23 +0100 Subject: [PATCH 05/13] Bug 726560 - v2: commenting saveActiveGroupName --- extension/chrome/content/browser.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extension/chrome/content/browser.js b/extension/chrome/content/browser.js index 1e814e4..d130fbe 100644 --- a/extension/chrome/content/browser.js +++ b/extension/chrome/content/browser.js @@ -147,8 +147,10 @@ openNotification: function(id, message, label, accessKey, callback) { message, "urlbar", action, null, options); }, -// Function: saveActiveGroupName -// Saves the active group's name for the given window. +/** + * Saves the active group's name for the given window. + * @param {nsIDOMWindow} win A window where to save the value. + */ saveActiveGroupName: function NightlyTT_saveActiveGroupName(win) { let groupName = nightlyApp.tabGroupTitle; Cc["@mozilla.org/browser/sessionstore;1"] From 91017e7e455360d1a3970d10b3ebc38af88936e5 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Mon, 19 Mar 2012 08:24:33 +0100 Subject: [PATCH 06/13] Bug 726560 - v3: introducing tabGroupTitle.jsm --- extension/chrome/content/browser.js | 76 +-------- extension/modules/tabGroupTitle.jsm | 254 ++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+), 68 deletions(-) create mode 100644 extension/modules/tabGroupTitle.jsm diff --git a/extension/chrome/content/browser.js b/extension/chrome/content/browser.js index d130fbe..b9ef870 100644 --- a/extension/chrome/content/browser.js +++ b/extension/chrome/content/browser.js @@ -55,29 +55,9 @@ get tabTitle() { }, get tabGroupTitle() { - // TabView isn't implemented or initialized - if (!TabView || !TabView._window) - return nightlyApp._lastSessionGroupName; - - - // We get the active group this way, instead of querying - // GroupItems.getActiveGroupItem() because the tabSelect event - // will not have happened by the time the browser tries to - // update the title. - let groupItem = null; - let activeTab = window.gBrowser.selectedTab; - let activeTabItem = activeTab._tabViewTabItem; - - if (activeTab.pinned) { - // It's an app tab, so it won't have a .tabItem. However, its .parent - // will already be set as the active group. - groupItem = TabView._window.GroupItems.getActiveGroupItem(); - } else if (activeTabItem) { - groupItem = activeTabItem.parent; - } - - // groupItem may still be null, if the active tab is an orphan. - return groupItem ? groupItem.getTitle() : ""; + if (typeof(nightlyApp.getTabGroupTitle) === "function") + return nightlyApp.getTabGroupTitle(window); + return ""; }, init: function() @@ -95,37 +75,12 @@ init: function() tabbrowser.updateTitlebar = nightly.updateTitlebar; tabbrowser.addEventListener("DOMTitleChanged", nightly.updateTitlebar, false); - - // Listening to Bug 659591 (landed in FF7) - instead "domwindowclosed" (see Bug 655269), - // to store active group's name for showing at next startup - window.addEventListener("SSWindowClosing", function NightlyTT_onWindowClosing() { - window.removeEventListener("SSWindowClosing", NightlyTT_onWindowClosing, false); - nightlyApp.saveActiveGroupName(window); - }, false); - - // grab the last used group title - // use TabView's property if we are before Bug 682996 (landed in FF10) - if (TabView && TabView._lastSessionGroupName) - { - nightlyApp._lastSessionGroupName = TabView._lastSessionGroupName; - } - else - { - Cc["@mozilla.org/observer-service;1"] - .getService(Ci.nsIObserverService).addObserver({ - observe: function NightlyTT_Restore() { - Cc["@mozilla.org/observer-service;1"] - .getService(Ci.nsIObserverService).removeObserver(this, "sessionstore-windows-restored"); - - nightlyApp._lastSessionGroupName = Cc["@mozilla.org/browser/sessionstore;1"] - .getService(Ci.nsISessionStore) - .getWindowValue( - window, - nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER - ); - } - }, "sessionstore-windows-restored", false); + + try { // import tabGroupTitle functionality for titlebar customization + Components.utils.import("resource://nightly/tabGroupTitle.jsm", nightlyApp); + nightlyApp.initTabGroup(window); } + catch(e) { Components.utils.reportError(e); } }, openURL: function(url) @@ -147,21 +102,6 @@ openNotification: function(id, message, label, accessKey, callback) { message, "urlbar", action, null, options); }, -/** - * Saves the active group's name for the given window. - * @param {nsIDOMWindow} win A window where to save the value. - */ -saveActiveGroupName: function NightlyTT_saveActiveGroupName(win) { - let groupName = nightlyApp.tabGroupTitle; - Cc["@mozilla.org/browser/sessionstore;1"] - .getService(Ci.nsISessionStore) - .setWindowValue( - win, - nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER, - groupName - ); -}, - setCustomTitle: function(title) { document.getElementById("content").ownerDocument.title = title; diff --git a/extension/modules/tabGroupTitle.jsm b/extension/modules/tabGroupTitle.jsm new file mode 100644 index 0000000..d621e57 --- /dev/null +++ b/extension/modules/tabGroupTitle.jsm @@ -0,0 +1,254 @@ +var EXPORTED_SYMBOLS = ["initTabGroup","getTabGroupTitle"]; + +const Cc = Components.classes; +const Ci = Components.interfaces; +const Cr = Components.results; + +let obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService) +let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); +let sstore = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); + +let _privateBrowsing = {}; +_privateBrowsing.transitionMode = ""; + +let initialized = false; + +function log(m){ + dump(m + '\n'); + Components.utils.reportError(m); +} + +/** + * Waits for a browser window to finish loading before running the callback + * + * @usage runOnLoad(window, callback): Apply a callback to to run on a window when it loads. + * @param [function] callback: 1-parameter function that gets a browser window. + * @param [function] winType: a parameter that defines what kind of window is "browser window". + */ +function runOnLoad(window, callback, winType) { + // Listen for one load event before checking the window type + window.addEventListener("load", function() { + window.removeEventListener("load", arguments.callee, false); + + // Now that the window has loaded, only handle browser windows + if (window.document.documentElement.getAttribute("windowtype") == winType) + callback(window); + }, false); +} + +/** + * Add functionality to existing browser windows + * + * @usage runOnWindows(callback): Apply a callback to each open browser window. + * @param [function] callback: 1-parameter function that gets a browser window. + * @param [function] winType: a parameter that defines what kind of window is "browser window". + */ +function runOnWindows(callback, winType) { + // Wrap the callback in a function that ignores failures + function watcher(window) { + try { + callback(window); + } + catch(ex) {} + } + + // Add functionality to existing windows + let browserWindows = wm.getEnumerator(winType); + while (browserWindows.hasMoreElements()) { + // Only run the watcher immediately if the browser is completely loaded + let browserWindow = browserWindows.getNext(); + if (browserWindow.document.readyState == "complete") + watcher(browserWindow); + // Wait for the window to load before continuing + else + runOnLoad(browserWindow, watcher, winType); + } +} + + +/** + * Runs title loader at startup. + * Fires only once (due to unregistering) + */ +function wrObserver(aSubject, aTopic, aData) { + if (aTopic != "sessionstore-windows-restored") + return; + + log("sessionstore-windows-restored"); + //obs.removeObserver(wrObserver, "sessionstore-windows-restored"); + runOnWindows(loadAndUpdateGroupName, "navigator:browser"); +} + +/** + * Manages Private Browsing transitions + * and takes care about unregistering + */ +function pbObserver(aSubject, aTopic, aData) { + if (aTopic == "private-browsing") { + // We could probably do this in private-browsing-change-granted, but + // this seems like a nicer spot, right in the middle of the process. + if (aData == "enter") { + //log("savestart: pb-enter"); + //runOnWindows(onPBEnter, "navigator:browser"); + } + } else if (aTopic == "private-browsing-change-granted") { + if (aData == "enter" || aData == "exit") { + _privateBrowsing.transitionMode = aData; + } + } else if (aTopic == "private-browsing-transition-complete") { + // We use .transitionMode here, as aData is empty. + if (_privateBrowsing.transitionMode == "enter") { + log("savestart: pb-enter-complete"); + runOnWindows(onPBEnter, "navigator:browser"); + } + else if (_privateBrowsing.transitionMode == "exit") { + log("loadstart: pb-exit-complete"); + runOnWindows(loadAndUpdateGroupName, "navigator:browser"); + } + _privateBrowsing.transitionMode = ""; + } else if (aTopic == "quit-application") { + obs.removeObserver(pbObserver, "quit-application"); + obs.removeObserver(pbObserver, "private-browsing"); + obs.removeObserver(pbObserver, "private-browsing-change-granted"); + obs.removeObserver(pbObserver, "private-browsing-transition-complete"); + obs.removeObserver(wrObserver, "sessionstore-windows-restored"); + log("unregistered"); + } else { + log("aTopic=" + aTopic + ", aData=" + aData); + } +} + +/** + * Runs title loader + * and updates the titlebar if nightly is initialized + * @param {nsIDOMWindow} win A window which contains nightly. + */ +function loadAndUpdateGroupName(win) { + loadActiveGroupName(win); + if (win.nightly.preferences) { + win.nightly.updateTitlebar(); + log("updated: "+win.document.title); + } +} + +/** + * Saves and removes title + * when entering Private Browsing mode + * @param {nsIDOMWindow} win A window which contains nightly. + */ +function onPBEnter(win) { + let nightlyApp = win.nightlyApp; + let nightly = win.nightly; + saveActiveGroupName(win); + nightlyApp._lastSessionGroupName = ""; + if (nightly.preferences) + nightly.updateTitlebar(); +} + +/** + * Loads the active group's name for the given window + * @param {nsIDOMWindow} win A window where to load the value. + */ +function loadActiveGroupName(win) { + let nightlyApp = win.nightlyApp; + nightlyApp._lastSessionGroupName = sstore.getWindowValue( + win, + nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER + ); + log("loaded: "+nightlyApp._lastSessionGroupName+" for "+win.document.title); +} + +/** + * Saves the active group's name for the given window. + * @param {nsIDOMWindow} win A window where to save the value. + */ +function saveActiveGroupName(win) { + let nightlyApp = win.nightlyApp; + let groupName = nightlyApp.tabGroupTitle; + sstore.setWindowValue( + win, + nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER, + groupName + ); + + log("saved: " + groupName); +} + +/** + * How to take care about the (last used) group title + * + * In Gecko 1.x title is set to "Undefined" as in other Apps + * Before FF10 title is managed by TabView + * After that we manages the title: SessionStore to load and save, borrowed code to generate + * @param {nsIDOMWindow} win A window which contains nightly. + */ +function initTabGroup(win) { + + if (typeof(win.TabView) === "undefined") { + win.nightlyApp._lastSessionGroupName = null; + } else if (win.TabView && typeof(win.TabView.getActiveGroupName) === "undefined") { + if (!initialized) { + obs.addObserver(wrObserver, "sessionstore-windows-restored", false); + + obs.addObserver(pbObserver, "quit-application", false); + obs.addObserver(pbObserver, "private-browsing", false); + obs.addObserver(pbObserver, "private-browsing-change-granted", false); + obs.addObserver(pbObserver, "private-browsing-transition-complete", false); + initialized = true; + } + + /** + * Starting from FF7 we could easily save it to SessionStore + * Note: there are workarounds (see Bug 655269) to save it before FF7 but we doesn't mind. + * + * Listening to Bug 659591 (landed in FF7) - instead "domwindowclosed", + * to store active group's name for showing at next startup + */ + win.addEventListener("SSWindowClosing", function() { + win.removeEventListener("SSWindowClosing", arguments.calle, false); + log("SSWindowClosing"); + saveActiveGroupName(win); + }, false); + } +} + +/** + * Calculates Tab Group's title for nightlyApp + * @param {nsIDOMWindow} win A window which contains nightly. + */ +function getTabGroupTitle(win) { + let nightlyApp = win.nightlyApp; + let TabView = win.TabView; + + // TabView isn't implemented + if (typeof(TabView) === "undefined") + return nightlyApp._lastSessionGroupName; + + // If we are before Bug 682996, + // use TabView's own implementation except it is null + if (typeof(TabView.getActiveGroupName) === "function") + return TabView.getActiveGroupName() || ""; + + // TabView isn't initialized + if (!TabView._window) + return nightlyApp._lastSessionGroupName; + + // We get the active group this way, instead of querying + // GroupItems.getActiveGroupItem() because the tabSelect event + // will not have happened by the time the browser tries to + // update the title. + let groupItem = null; + let activeTab = win.gBrowser.selectedTab; + let activeTabItem = activeTab._tabViewTabItem; + + if (activeTab.pinned) { + // It's an app tab, so it won't have a .tabItem. However, its .parent + // will already be set as the active group. + groupItem = TabView._window.GroupItems.getActiveGroupItem(); + } else if (activeTabItem) { + groupItem = activeTabItem.parent; + } + + // groupItem may still be null, if the active tab is an orphan. + return groupItem ? groupItem.getTitle() : ""; +} From 5f86f3d955c122cfb7a8d9906c3ed840ecb37d07 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Mon, 19 Mar 2012 08:38:22 +0100 Subject: [PATCH 07/13] Bug 726560 - v3: addObserver PB exit --- extension/modules/tabGroupTitle.jsm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extension/modules/tabGroupTitle.jsm b/extension/modules/tabGroupTitle.jsm index d621e57..ea65fd0 100644 --- a/extension/modules/tabGroupTitle.jsm +++ b/extension/modules/tabGroupTitle.jsm @@ -71,11 +71,14 @@ function runOnWindows(callback, winType) { * Fires only once (due to unregistering) */ function wrObserver(aSubject, aTopic, aData) { - if (aTopic != "sessionstore-windows-restored") + if (aTopic == "sessionstore-windows-restored") + obs.removeObserver(wrObserver, "sessionstore-windows-restored"); + else if (aTopic == "sessionstore-browser-state-restored") + obs.removeObserver(wrObserver, "sessionstore-browser-state-restored"); + else return; - log("sessionstore-windows-restored"); - //obs.removeObserver(wrObserver, "sessionstore-windows-restored"); + log(aTopic); runOnWindows(loadAndUpdateGroupName, "navigator:browser"); } @@ -104,6 +107,8 @@ function pbObserver(aSubject, aTopic, aData) { else if (_privateBrowsing.transitionMode == "exit") { log("loadstart: pb-exit-complete"); runOnWindows(loadAndUpdateGroupName, "navigator:browser"); + obs.addObserver(wrObserver, "sessionstore-browser-state-restored", false); + } _privateBrowsing.transitionMode = ""; } else if (aTopic == "quit-application") { From 2b7bfbf6e72afef4a480ccd39d15cf3e0e764518 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Mon, 19 Mar 2012 09:22:40 +0100 Subject: [PATCH 08/13] Bug 726560 - v3: listening PB exit --- extension/modules/tabGroupTitle.jsm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/extension/modules/tabGroupTitle.jsm b/extension/modules/tabGroupTitle.jsm index ea65fd0..5929451 100644 --- a/extension/modules/tabGroupTitle.jsm +++ b/extension/modules/tabGroupTitle.jsm @@ -73,8 +73,6 @@ function runOnWindows(callback, winType) { function wrObserver(aSubject, aTopic, aData) { if (aTopic == "sessionstore-windows-restored") obs.removeObserver(wrObserver, "sessionstore-windows-restored"); - else if (aTopic == "sessionstore-browser-state-restored") - obs.removeObserver(wrObserver, "sessionstore-browser-state-restored"); else return; @@ -107,8 +105,6 @@ function pbObserver(aSubject, aTopic, aData) { else if (_privateBrowsing.transitionMode == "exit") { log("loadstart: pb-exit-complete"); runOnWindows(loadAndUpdateGroupName, "navigator:browser"); - obs.addObserver(wrObserver, "sessionstore-browser-state-restored", false); - } _privateBrowsing.transitionMode = ""; } else if (aTopic == "quit-application") { @@ -116,7 +112,6 @@ function pbObserver(aSubject, aTopic, aData) { obs.removeObserver(pbObserver, "private-browsing"); obs.removeObserver(pbObserver, "private-browsing-change-granted"); obs.removeObserver(pbObserver, "private-browsing-transition-complete"); - obs.removeObserver(wrObserver, "sessionstore-windows-restored"); log("unregistered"); } else { log("aTopic=" + aTopic + ", aData=" + aData); @@ -133,6 +128,13 @@ function loadAndUpdateGroupName(win) { if (win.nightly.preferences) { win.nightly.updateTitlebar(); log("updated: "+win.document.title); + } else { + log("update rerun: "+win.document.title); + win.addEventListener("nightlytt-tabgrouptitle-initialized", function() { + win.removeEventListener("nightlytt-tabgrouptitle-initialized", arguments.callee, false); + log("update rerun catched!"); + loadAndUpdateGroupName(win); + }, false); } } @@ -199,8 +201,13 @@ function initTabGroup(win) { obs.addObserver(pbObserver, "private-browsing", false); obs.addObserver(pbObserver, "private-browsing-change-granted", false); obs.addObserver(pbObserver, "private-browsing-transition-complete", false); + initialized = true; } + + win.addEventListener("nightlytt-tabgrouptitle-initialized", function() { + log("catched!"); + }, false); /** * Starting from FF7 we could easily save it to SessionStore @@ -214,6 +221,13 @@ function initTabGroup(win) { log("SSWindowClosing"); saveActiveGroupName(win); }, false); + + + // Notifying ourselves + let event = win.document.createEvent("Events"); + event.initEvent("nightlytt-tabgrouptitle-initialized", true, true); + win.document.dispatchEvent(event); + log("fired "+"nightlytt-tabgrouptitle-initialized"); } } From 2853a69cc19fd28bd9124e10e4706ebc18f434c4 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Mon, 19 Mar 2012 09:53:49 +0100 Subject: [PATCH 09/13] Bug 726560 - v3: NTT logging --- extension/modules/tabGroupTitle.jsm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/extension/modules/tabGroupTitle.jsm b/extension/modules/tabGroupTitle.jsm index 5929451..8a1e37d 100644 --- a/extension/modules/tabGroupTitle.jsm +++ b/extension/modules/tabGroupTitle.jsm @@ -13,9 +13,19 @@ _privateBrowsing.transitionMode = ""; let initialized = false; +try { + log("don't forget to enable: nightly.logging" ); + Components.utils.import("resource://nightly/Logging.jsm"); +} +catch(e) {log(e);} + function log(m){ - dump(m + '\n'); - Components.utils.reportError(m); + if (typeof(LOG) === "function") { + LOG(m); + } else { + dump(m + '\n'); + Components.utils.reportError(m); + } } /** From 0b1787cba81113249b43cbdb1c3cbcda42d23851 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Tue, 20 Mar 2012 01:03:21 +0100 Subject: [PATCH 10/13] Bug 726560 - v4: simply retrieve --- extension/modules/tabGroupTitle.jsm | 78 +++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/extension/modules/tabGroupTitle.jsm b/extension/modules/tabGroupTitle.jsm index 8a1e37d..d47e692 100644 --- a/extension/modules/tabGroupTitle.jsm +++ b/extension/modules/tabGroupTitle.jsm @@ -110,11 +110,11 @@ function pbObserver(aSubject, aTopic, aData) { // We use .transitionMode here, as aData is empty. if (_privateBrowsing.transitionMode == "enter") { log("savestart: pb-enter-complete"); - runOnWindows(onPBEnter, "navigator:browser"); + //onPBEnter(wm.getMostRecentWindow("navigator:browser")); } else if (_privateBrowsing.transitionMode == "exit") { log("loadstart: pb-exit-complete"); - runOnWindows(loadAndUpdateGroupName, "navigator:browser"); + //onPBExit(wm.getMostRecentWindow("navigator:browser")); } _privateBrowsing.transitionMode = ""; } else if (aTopic == "quit-application") { @@ -149,17 +149,30 @@ function loadAndUpdateGroupName(win) { } /** - * Saves and removes title - * when entering Private Browsing mode + * Loads title on Private Browsing mode exit + * if TabView isn't initialized + * @param {nsIDOMWindow} win A window which contains nightly. + */ +function onPBExit(win) { + let TabView = win.TabView; + if (!TabView._window) + loadAndUpdateGroupName(win); +} + +/** + * Saves and removes title on Private Browsing mode enter + * if TabView isn't initialized * @param {nsIDOMWindow} win A window which contains nightly. */ function onPBEnter(win) { let nightlyApp = win.nightlyApp; let nightly = win.nightly; - saveActiveGroupName(win); - nightlyApp._lastSessionGroupName = ""; - if (nightly.preferences) + let TabView = win.TabView; + if (!TabView._window) { + saveActiveGroupName(win); + nightlyApp._lastSessionGroupName = ""; nightly.updateTitlebar(); + } } /** @@ -168,11 +181,25 @@ function onPBEnter(win) { */ function loadActiveGroupName(win) { let nightlyApp = win.nightlyApp; - nightlyApp._lastSessionGroupName = sstore.getWindowValue( - win, - nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER - ); - log("loaded: "+nightlyApp._lastSessionGroupName+" for "+win.document.title); + nightlyApp._lastSessionGroupName = getActiveGroupName(win); +} + +function getActiveGroupName(win) { + let data = "", groupTitle = ""; + try { + data = sstore.getWindowValue(win, win.TabView.GROUPS_IDENTIFIER); + if (data) { + let parsedData = {}; + parsedData = JSON.parse(data); + let activeGroupId = parsedData.activeGroupId; + data = sstore.getWindowValue(win, "tabview-group"); + parsedData = JSON.parse(data); + groupTitle = parsedData[activeGroupId].title; + log("loaded title: " + groupTitle); + } + } catch (e) { log(e); } + + return groupTitle; } /** @@ -182,13 +209,19 @@ function loadActiveGroupName(win) { function saveActiveGroupName(win) { let nightlyApp = win.nightlyApp; let groupName = nightlyApp.tabGroupTitle; + let verify = ""; sstore.setWindowValue( win, nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER, groupName ); - log("saved: " + groupName); + verify = sstore.getWindowValue( + win, + nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER + ); + + log("saved: " + groupName + ", verify: "+ verify); } /** @@ -205,12 +238,12 @@ function initTabGroup(win) { win.nightlyApp._lastSessionGroupName = null; } else if (win.TabView && typeof(win.TabView.getActiveGroupName) === "undefined") { if (!initialized) { - obs.addObserver(wrObserver, "sessionstore-windows-restored", false); + //obs.addObserver(wrObserver, "sessionstore-windows-restored", false); - obs.addObserver(pbObserver, "quit-application", false); - obs.addObserver(pbObserver, "private-browsing", false); - obs.addObserver(pbObserver, "private-browsing-change-granted", false); - obs.addObserver(pbObserver, "private-browsing-transition-complete", false); + //obs.addObserver(pbObserver, "quit-application", false); + //obs.addObserver(pbObserver, "private-browsing", false); + //obs.addObserver(pbObserver, "private-browsing-change-granted", false); + //obs.addObserver(pbObserver, "private-browsing-transition-complete", false); initialized = true; } @@ -229,7 +262,7 @@ function initTabGroup(win) { win.addEventListener("SSWindowClosing", function() { win.removeEventListener("SSWindowClosing", arguments.calle, false); log("SSWindowClosing"); - saveActiveGroupName(win); + //saveActiveGroupName(win); }, false); @@ -251,7 +284,7 @@ function getTabGroupTitle(win) { // TabView isn't implemented if (typeof(TabView) === "undefined") - return nightlyApp._lastSessionGroupName; + return ""; // If we are before Bug 682996, // use TabView's own implementation except it is null @@ -259,8 +292,9 @@ function getTabGroupTitle(win) { return TabView.getActiveGroupName() || ""; // TabView isn't initialized - if (!TabView._window) - return nightlyApp._lastSessionGroupName; + if (!TabView._window) { + return getActiveGroupName(win); + } // We get the active group this way, instead of querying // GroupItems.getActiveGroupItem() because the tabSelect event From 630b02ea30314495b12a55fd8f3987886f78b618 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Tue, 20 Mar 2012 01:32:46 +0100 Subject: [PATCH 11/13] Bug 726560 - v4: cleanup --- extension/chrome/content/browser.js | 1 - extension/modules/tabGroupTitle.jsm | 260 +--------------------------- 2 files changed, 9 insertions(+), 252 deletions(-) diff --git a/extension/chrome/content/browser.js b/extension/chrome/content/browser.js index b9ef870..2bb1f6c 100644 --- a/extension/chrome/content/browser.js +++ b/extension/chrome/content/browser.js @@ -78,7 +78,6 @@ init: function() try { // import tabGroupTitle functionality for titlebar customization Components.utils.import("resource://nightly/tabGroupTitle.jsm", nightlyApp); - nightlyApp.initTabGroup(window); } catch(e) { Components.utils.reportError(e); } }, diff --git a/extension/modules/tabGroupTitle.jsm b/extension/modules/tabGroupTitle.jsm index d47e692..dd770e1 100644 --- a/extension/modules/tabGroupTitle.jsm +++ b/extension/modules/tabGroupTitle.jsm @@ -1,189 +1,16 @@ -var EXPORTED_SYMBOLS = ["initTabGroup","getTabGroupTitle"]; +var EXPORTED_SYMBOLS = ["getTabGroupTitle"]; const Cc = Components.classes; const Ci = Components.interfaces; -const Cr = Components.results; -let obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService) -let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); -let sstore = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - -let _privateBrowsing = {}; -_privateBrowsing.transitionMode = ""; - -let initialized = false; +const GROUP_DATA_IDENTIFIER = "tabview-group"; -try { - log("don't forget to enable: nightly.logging" ); - Components.utils.import("resource://nightly/Logging.jsm"); -} -catch(e) {log(e);} - -function log(m){ - if (typeof(LOG) === "function") { - LOG(m); - } else { - dump(m + '\n'); - Components.utils.reportError(m); - } -} - -/** - * Waits for a browser window to finish loading before running the callback - * - * @usage runOnLoad(window, callback): Apply a callback to to run on a window when it loads. - * @param [function] callback: 1-parameter function that gets a browser window. - * @param [function] winType: a parameter that defines what kind of window is "browser window". - */ -function runOnLoad(window, callback, winType) { - // Listen for one load event before checking the window type - window.addEventListener("load", function() { - window.removeEventListener("load", arguments.callee, false); - - // Now that the window has loaded, only handle browser windows - if (window.document.documentElement.getAttribute("windowtype") == winType) - callback(window); - }, false); -} - -/** - * Add functionality to existing browser windows - * - * @usage runOnWindows(callback): Apply a callback to each open browser window. - * @param [function] callback: 1-parameter function that gets a browser window. - * @param [function] winType: a parameter that defines what kind of window is "browser window". - */ -function runOnWindows(callback, winType) { - // Wrap the callback in a function that ignores failures - function watcher(window) { - try { - callback(window); - } - catch(ex) {} - } - - // Add functionality to existing windows - let browserWindows = wm.getEnumerator(winType); - while (browserWindows.hasMoreElements()) { - // Only run the watcher immediately if the browser is completely loaded - let browserWindow = browserWindows.getNext(); - if (browserWindow.document.readyState == "complete") - watcher(browserWindow); - // Wait for the window to load before continuing - else - runOnLoad(browserWindow, watcher, winType); - } -} - - -/** - * Runs title loader at startup. - * Fires only once (due to unregistering) - */ -function wrObserver(aSubject, aTopic, aData) { - if (aTopic == "sessionstore-windows-restored") - obs.removeObserver(wrObserver, "sessionstore-windows-restored"); - else - return; - - log(aTopic); - runOnWindows(loadAndUpdateGroupName, "navigator:browser"); -} - -/** - * Manages Private Browsing transitions - * and takes care about unregistering - */ -function pbObserver(aSubject, aTopic, aData) { - if (aTopic == "private-browsing") { - // We could probably do this in private-browsing-change-granted, but - // this seems like a nicer spot, right in the middle of the process. - if (aData == "enter") { - //log("savestart: pb-enter"); - //runOnWindows(onPBEnter, "navigator:browser"); - } - } else if (aTopic == "private-browsing-change-granted") { - if (aData == "enter" || aData == "exit") { - _privateBrowsing.transitionMode = aData; - } - } else if (aTopic == "private-browsing-transition-complete") { - // We use .transitionMode here, as aData is empty. - if (_privateBrowsing.transitionMode == "enter") { - log("savestart: pb-enter-complete"); - //onPBEnter(wm.getMostRecentWindow("navigator:browser")); - } - else if (_privateBrowsing.transitionMode == "exit") { - log("loadstart: pb-exit-complete"); - //onPBExit(wm.getMostRecentWindow("navigator:browser")); - } - _privateBrowsing.transitionMode = ""; - } else if (aTopic == "quit-application") { - obs.removeObserver(pbObserver, "quit-application"); - obs.removeObserver(pbObserver, "private-browsing"); - obs.removeObserver(pbObserver, "private-browsing-change-granted"); - obs.removeObserver(pbObserver, "private-browsing-transition-complete"); - log("unregistered"); - } else { - log("aTopic=" + aTopic + ", aData=" + aData); - } -} - -/** - * Runs title loader - * and updates the titlebar if nightly is initialized - * @param {nsIDOMWindow} win A window which contains nightly. - */ -function loadAndUpdateGroupName(win) { - loadActiveGroupName(win); - if (win.nightly.preferences) { - win.nightly.updateTitlebar(); - log("updated: "+win.document.title); - } else { - log("update rerun: "+win.document.title); - win.addEventListener("nightlytt-tabgrouptitle-initialized", function() { - win.removeEventListener("nightlytt-tabgrouptitle-initialized", arguments.callee, false); - log("update rerun catched!"); - loadAndUpdateGroupName(win); - }, false); - } -} - -/** - * Loads title on Private Browsing mode exit - * if TabView isn't initialized - * @param {nsIDOMWindow} win A window which contains nightly. - */ -function onPBExit(win) { - let TabView = win.TabView; - if (!TabView._window) - loadAndUpdateGroupName(win); -} +let sstore = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); -/** - * Saves and removes title on Private Browsing mode enter - * if TabView isn't initialized - * @param {nsIDOMWindow} win A window which contains nightly. - */ -function onPBEnter(win) { - let nightlyApp = win.nightlyApp; - let nightly = win.nightly; - let TabView = win.TabView; - if (!TabView._window) { - saveActiveGroupName(win); - nightlyApp._lastSessionGroupName = ""; - nightly.updateTitlebar(); - } -} /** - * Loads the active group's name for the given window - * @param {nsIDOMWindow} win A window where to load the value. + * Simply retrieves the active tabgroup's title from sessionStore */ -function loadActiveGroupName(win) { - let nightlyApp = win.nightlyApp; - nightlyApp._lastSessionGroupName = getActiveGroupName(win); -} - function getActiveGroupName(win) { let data = "", groupTitle = ""; try { @@ -192,98 +19,29 @@ function getActiveGroupName(win) { let parsedData = {}; parsedData = JSON.parse(data); let activeGroupId = parsedData.activeGroupId; - data = sstore.getWindowValue(win, "tabview-group"); + data = sstore.getWindowValue(win, GROUP_DATA_IDENTIFIER); parsedData = JSON.parse(data); groupTitle = parsedData[activeGroupId].title; - log("loaded title: " + groupTitle); } - } catch (e) { log(e); } + } catch (e) { } return groupTitle; } -/** - * Saves the active group's name for the given window. - * @param {nsIDOMWindow} win A window where to save the value. - */ -function saveActiveGroupName(win) { - let nightlyApp = win.nightlyApp; - let groupName = nightlyApp.tabGroupTitle; - let verify = ""; - sstore.setWindowValue( - win, - nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER, - groupName - ); - - verify = sstore.getWindowValue( - win, - nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER - ); - - log("saved: " + groupName + ", verify: "+ verify); -} - /** - * How to take care about the (last used) group title + * Calculates Tab Group's title for nightlyApp + * @param {nsIDOMWindow} win A window which contains nightly. * * In Gecko 1.x title is set to "Undefined" as in other Apps * Before FF10 title is managed by TabView * After that we manages the title: SessionStore to load and save, borrowed code to generate - * @param {nsIDOMWindow} win A window which contains nightly. - */ -function initTabGroup(win) { - - if (typeof(win.TabView) === "undefined") { - win.nightlyApp._lastSessionGroupName = null; - } else if (win.TabView && typeof(win.TabView.getActiveGroupName) === "undefined") { - if (!initialized) { - //obs.addObserver(wrObserver, "sessionstore-windows-restored", false); - - //obs.addObserver(pbObserver, "quit-application", false); - //obs.addObserver(pbObserver, "private-browsing", false); - //obs.addObserver(pbObserver, "private-browsing-change-granted", false); - //obs.addObserver(pbObserver, "private-browsing-transition-complete", false); - - initialized = true; - } - - win.addEventListener("nightlytt-tabgrouptitle-initialized", function() { - log("catched!"); - }, false); - - /** - * Starting from FF7 we could easily save it to SessionStore - * Note: there are workarounds (see Bug 655269) to save it before FF7 but we doesn't mind. - * - * Listening to Bug 659591 (landed in FF7) - instead "domwindowclosed", - * to store active group's name for showing at next startup - */ - win.addEventListener("SSWindowClosing", function() { - win.removeEventListener("SSWindowClosing", arguments.calle, false); - log("SSWindowClosing"); - //saveActiveGroupName(win); - }, false); - - - // Notifying ourselves - let event = win.document.createEvent("Events"); - event.initEvent("nightlytt-tabgrouptitle-initialized", true, true); - win.document.dispatchEvent(event); - log("fired "+"nightlytt-tabgrouptitle-initialized"); - } -} - -/** - * Calculates Tab Group's title for nightlyApp - * @param {nsIDOMWindow} win A window which contains nightly. */ function getTabGroupTitle(win) { let nightlyApp = win.nightlyApp; let TabView = win.TabView; // TabView isn't implemented - if (typeof(TabView) === "undefined") + if (!("TabView" in win)) return ""; // If we are before Bug 682996, From 5e5edafdb1ff6bdfcdc98fe68b0b7ff69862425f Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Tue, 20 Mar 2012 01:47:24 +0100 Subject: [PATCH 12/13] Bug 726560 - v4: cleanup again --- extension/chrome/content/browser.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/extension/chrome/content/browser.js b/extension/chrome/content/browser.js index 2bb1f6c..d28adcc 100644 --- a/extension/chrome/content/browser.js +++ b/extension/chrome/content/browser.js @@ -41,9 +41,6 @@ repository: ['mozilla-central','mozilla-aurora'], storedTitle: document.documentElement.getAttribute("titlemodifier"), -LAST_SESSION_GROUP_NAME_IDENTIFIER: "nightlytt-last-session-group-name", -_lastSessionGroupName: "", - get defaultTitle() { var tabbrowser = document.getElementById("content"); return tabbrowser.getWindowTitleForBrowser(tabbrowser.mCurrentBrowser); From e11907e1b0e5cfeccffb7013cf42c27671a3b561 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Tue, 20 Mar 2012 02:51:58 +0100 Subject: [PATCH 13/13] Bug 726560 - v4: commenting, let it undefined in gecko 1.x --- extension/chrome/content/browser.js | 6 ++++-- extension/modules/tabGroupTitle.jsm | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/extension/chrome/content/browser.js b/extension/chrome/content/browser.js index d28adcc..9a0b516 100644 --- a/extension/chrome/content/browser.js +++ b/extension/chrome/content/browser.js @@ -52,9 +52,11 @@ get tabTitle() { }, get tabGroupTitle() { - if (typeof(nightlyApp.getTabGroupTitle) === "function") + try + { return nightlyApp.getTabGroupTitle(window); - return ""; + } + catch (e) { } }, init: function() diff --git a/extension/modules/tabGroupTitle.jsm b/extension/modules/tabGroupTitle.jsm index dd770e1..c0fbb30 100644 --- a/extension/modules/tabGroupTitle.jsm +++ b/extension/modules/tabGroupTitle.jsm @@ -9,7 +9,7 @@ let sstore = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionS /** - * Simply retrieves the active tabgroup's title from sessionStore + * Simply retrieves the active tabgroup's title from SessionStore */ function getActiveGroupName(win) { let data = "", groupTitle = ""; @@ -34,7 +34,7 @@ function getActiveGroupName(win) { * * In Gecko 1.x title is set to "Undefined" as in other Apps * Before FF10 title is managed by TabView - * After that we manages the title: SessionStore to load and save, borrowed code to generate + * After that we manages the title: using SessionStore and other borrowed code to generate */ function getTabGroupTitle(win) { let nightlyApp = win.nightlyApp; @@ -42,7 +42,7 @@ function getTabGroupTitle(win) { // TabView isn't implemented if (!("TabView" in win)) - return ""; + return; // If we are before Bug 682996, // use TabView's own implementation except it is null