Firefox: vAPI.tabs.onNavigation() for about: pages

This commit is contained in:
Deathamns 2015-01-27 11:13:33 +01:00
parent 3d0eb2f928
commit d24263aa17
1 changed files with 38 additions and 31 deletions

View File

@ -252,19 +252,6 @@ vAPI.storage = {
/******************************************************************************/
var windowWatcher = {
onTabClose: function(e) {
var tabId = vAPI.tabs.getTabId(e.target);
vAPI.tabs.onClosed(tabId);
delete vAPI.toolbarButton.tabs[tabId];
},
onTabSelect: function(e) {
vAPI.setIcon(
vAPI.tabs.getTabId(e.target),
e.target.ownerDocument.defaultView
);
},
onReady: function(e) {
if ( e ) {
this.removeEventListener(e.type, windowWatcher.onReady);
@ -282,9 +269,9 @@ var windowWatcher = {
var tC = this.gBrowser.tabContainer;
this.gBrowser.addTabsProgressListener(tabsProgressListener);
tC.addEventListener('TabClose', windowWatcher.onTabClose);
tC.addEventListener('TabSelect', windowWatcher.onTabSelect);
this.gBrowser.addTabsProgressListener(tabWatcher);
tC.addEventListener('TabClose', tabWatcher.onTabClose);
tC.addEventListener('TabSelect', tabWatcher.onTabSelect);
vAPI.contextMenu.register(this.document);
@ -300,7 +287,30 @@ var windowWatcher = {
/******************************************************************************/
var tabsProgressListener = {
var tabWatcher = {
onTabClose: function({target: tab}) {
var tabId = vAPI.tabs.getTabId(tab);
vAPI.tabs.onClosed(tabId);
delete vAPI.toolbarButton.tabs[tabId];
},
onTabSelect: function({target: tab}) {
var URI = tab.linkedBrowser.currentURI;
var aboutPath = URI.schemeIs('about') && URI.path;
var tabId = vAPI.tabs.getTabId(tab);
if ( !aboutPath || (aboutPath !== 'blank' && aboutPath !== 'newtab') ) {
vAPI.setIcon(tabId, tab.ownerDocument.defaultView);
return;
}
vAPI.tabs.onNavigation({
frameId: 0,
tabId: tabId,
url: URI.asciiSpec
});
},
onLocationChange: function(browser, webProgress, request, location, flags) {
if ( !webProgress.isTopLevel ) {
return;
@ -330,10 +340,6 @@ var tabsProgressListener = {
/******************************************************************************/
vAPI.tabs = {};
/******************************************************************************/
vAPI.isNoTabId = function(tabId) {
return tabId.toString() === '-1';
};
@ -342,10 +348,14 @@ vAPI.noTabId = '-1';
/******************************************************************************/
vAPI.tabs = {};
/******************************************************************************/
vAPI.tabs.registerListeners = function() {
// onNavigation and onUpdated handled with tabsProgressListener
// onClosed - handled in windowWatcher.onTabClose
// onPopup ?
// onNavigation and onUpdated handled with tabWatcher.onLocationChange
// onClosed - handled in tabWatcher.onTabClose
// onPopup - handled in httpObserver.handlePopup
for ( var win of this.getWindows() ) {
windowWatcher.onReady.call(win);
@ -360,11 +370,11 @@ vAPI.tabs.registerListeners = function() {
vAPI.contextMenu.unregister(win.document);
win.removeEventListener('DOMContentLoaded', windowWatcher.onReady);
win.gBrowser.removeTabsProgressListener(tabsProgressListener);
win.gBrowser.removeTabsProgressListener(tabWatcher);
var tC = win.gBrowser.tabContainer;
tC.removeEventListener('TabClose', windowWatcher.onTabClose);
tC.removeEventListener('TabSelect', windowWatcher.onTabSelect);
tC.removeEventListener('TabClose', tabWatcher.onTabClose);
tC.removeEventListener('TabSelect', tabWatcher.onTabSelect);
// close extension tabs
for ( var tab of win.gBrowser.tabs ) {
@ -636,10 +646,7 @@ vAPI.setIcon = function(tabId, iconStatus, badge) {
if ( tabId === undefined ) {
tabId = curTabId;
} else if ( badge !== undefined ) {
tb.tabs[tabId] = {
badge: badge,
img: iconStatus === 'on'
};
tb.tabs[tabId] = { badge: badge, img: iconStatus === 'on' };
}
if ( tabId !== curTabId ) {