mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Fixing up basic functionality for Fennec
This commit is contained in:
parent
97028e5032
commit
a8c1cb9dff
@ -269,14 +269,7 @@ var windowWatcher = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tabBrowser.deck ) {
|
if ( tabBrowser.tabContainer ) {
|
||||||
// Fennec
|
|
||||||
tabContainer = tabBrowser.deck;
|
|
||||||
tabContainer.addEventListener(
|
|
||||||
'DOMTitleChanged',
|
|
||||||
tabWatcher.onFennecLocationChange
|
|
||||||
);
|
|
||||||
} else if ( tabBrowser.tabContainer ) {
|
|
||||||
// desktop Firefox
|
// desktop Firefox
|
||||||
tabContainer = tabBrowser.tabContainer;
|
tabContainer = tabBrowser.tabContainer;
|
||||||
tabBrowser.addTabsProgressListener(tabWatcher);
|
tabBrowser.addTabsProgressListener(tabWatcher);
|
||||||
@ -353,23 +346,6 @@ var tabWatcher = {
|
|||||||
url: location.asciiSpec
|
url: location.asciiSpec
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onFennecLocationChange: function({target: doc}) {
|
|
||||||
// Fennec "equivalent" to onLocationChange
|
|
||||||
// note that DOMTitleChanged is selected as it fires very early
|
|
||||||
// (before DOMContentLoaded), and it does fire even if there is no title
|
|
||||||
|
|
||||||
var win = doc.defaultView;
|
|
||||||
if ( win !== win.top ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
vAPI.tabs.onNavigation({
|
|
||||||
frameId: 0,
|
|
||||||
tabId: getOwnerWindow(win).getTabForWindow(win).id,
|
|
||||||
url: Services.io.newURI(win.location.href, null, null).asciiSpec
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -441,14 +417,7 @@ vAPI.tabs.registerListeners = function() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tabBrowser.deck ) {
|
if ( tabBrowser.tabContainer ) {
|
||||||
// Fennec
|
|
||||||
tabContainer = tabBrowser.deck;
|
|
||||||
tabContainer.removeEventListener(
|
|
||||||
'DOMTitleChanged',
|
|
||||||
tabWatcher.onFennecLocationChange
|
|
||||||
);
|
|
||||||
} else if ( tabBrowser.tabContainer ) {
|
|
||||||
tabContainer = tabBrowser.tabContainer;
|
tabContainer = tabBrowser.tabContainer;
|
||||||
tabBrowser.removeTabsProgressListener(tabWatcher);
|
tabBrowser.removeTabsProgressListener(tabWatcher);
|
||||||
}
|
}
|
||||||
@ -482,7 +451,7 @@ vAPI.tabs.getTabId = function(target) {
|
|||||||
|
|
||||||
for ( var win of this.getWindows() ) {
|
for ( var win of this.getWindows() ) {
|
||||||
var tab = win.BrowserApp.getTabForBrowser(target);
|
var tab = win.BrowserApp.getTabForBrowser(target);
|
||||||
if ( tab && tab.id ) {
|
if ( tab && tab.id !== undefined ) {
|
||||||
return tab.id;
|
return tab.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -593,6 +562,9 @@ vAPI.tabs.get = function(tabId, callback) {
|
|||||||
var tabIndex = vAPI.fennec
|
var tabIndex = vAPI.fennec
|
||||||
? tabBrowser.tabs.indexOf(tab)
|
? tabBrowser.tabs.indexOf(tab)
|
||||||
: tabBrowser.browsers.indexOf(browser);
|
: tabBrowser.browsers.indexOf(browser);
|
||||||
|
var tabTitle = vAPI.fennec
|
||||||
|
? browser.contentTitle
|
||||||
|
: tab.label;
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
id: tabId,
|
id: tabId,
|
||||||
@ -600,7 +572,7 @@ vAPI.tabs.get = function(tabId, callback) {
|
|||||||
windowId: windows.indexOf(win),
|
windowId: windows.indexOf(win),
|
||||||
active: tab === tabBrowser.selectedTab,
|
active: tab === tabBrowser.selectedTab,
|
||||||
url: browser.currentURI.asciiSpec,
|
url: browser.currentURI.asciiSpec,
|
||||||
title: tab.label
|
title: tabTitle
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1168,6 +1140,9 @@ var httpObserver = {
|
|||||||
if ( !(channel instanceof Ci.nsIHttpChannel) ) {
|
if ( !(channel instanceof Ci.nsIHttpChannel) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var reqDataKey = location.host + 'reqdata';
|
||||||
|
|
||||||
|
|
||||||
var URI = channel.URI;
|
var URI = channel.URI;
|
||||||
var channelData, result;
|
var channelData, result;
|
||||||
@ -1185,7 +1160,7 @@ var httpObserver = {
|
|||||||
frameId,
|
frameId,
|
||||||
parentFrameId
|
parentFrameId
|
||||||
]*/
|
]*/
|
||||||
channelData = channel.getProperty(location.host + 'reqdata');
|
channelData = channel.getProperty(reqDataKey);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1267,6 +1242,14 @@ var httpObserver = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( lastRequest.type === this.MAIN_FRAME && lastRequest.frameId === 0 ) {
|
||||||
|
vAPI.tabs.onNavigation({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: lastRequest.tabId,
|
||||||
|
url: URI.asciiSpec
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if ( this.handleRequest(channel, URI, lastRequest) ) {
|
if ( this.handleRequest(channel, URI, lastRequest) ) {
|
||||||
return;
|
return;
|
||||||
@ -1275,7 +1258,7 @@ var httpObserver = {
|
|||||||
// If request is not handled we may use the data in on-modify-request
|
// If request is not handled we may use the data in on-modify-request
|
||||||
if ( channel instanceof Ci.nsIWritablePropertyBag ) {
|
if ( channel instanceof Ci.nsIWritablePropertyBag ) {
|
||||||
channel.setProperty(
|
channel.setProperty(
|
||||||
location.host + 'reqdata',
|
reqDataKey,
|
||||||
[
|
[
|
||||||
lastRequest.type,
|
lastRequest.type,
|
||||||
lastRequest.tabId,
|
lastRequest.tabId,
|
||||||
|
Loading…
Reference in New Issue
Block a user