Browse Source

Firefox: handle behind-the-scene redirects

pull/2/head
Deathamns 10 years ago
committed by gorhill
parent
commit
6952156891
  1. 26
      platform/firefox/vapi-background.js

26
platform/firefox/vapi-background.js

@ -364,10 +364,15 @@ var tabWatcher = {
return; return;
} }
var loc = win.location;
/*if ( loc.protocol === 'http' || loc.protocol === 'https' ) {
return;
}*/
vAPI.tabs.onNavigation({ vAPI.tabs.onNavigation({
frameId: 0, frameId: 0,
tabId: getOwnerWindow(win).getTabForWindow(win).id,
url: Services.io.newURI(win.location.href, null, null).asciiSpec
tabId: getOwnerWindow(win).BrowserApp.getTabForWindow(win).id,
url: Services.io.newURI(loc.href, null, null).asciiSpec
}); });
} }
}; };
@ -482,7 +487,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;
} }
} }
@ -1028,6 +1033,7 @@ var httpObserver = {
classDescription: 'net-channel-event-sinks for ' + location.host, classDescription: 'net-channel-event-sinks for ' + location.host,
classID: Components.ID('{dc8d6319-5f6e-4438-999e-53722db99e84}'), classID: Components.ID('{dc8d6319-5f6e-4438-999e-53722db99e84}'),
contractID: '@' + location.host + '/net-channel-event-sinks;1', contractID: '@' + location.host + '/net-channel-event-sinks;1',
REQDATAKEY: location.host + 'reqdata',
ABORT: Components.results.NS_BINDING_ABORTED, ABORT: Components.results.NS_BINDING_ABORTED,
ACCEPT: Components.results.NS_SUCCEEDED, ACCEPT: Components.results.NS_SUCCEEDED,
// Request types: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy#Constants // Request types: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy#Constants
@ -1190,7 +1196,7 @@ var httpObserver = {
frameId, frameId,
parentFrameId parentFrameId
]*/ ]*/
channelData = channel.getProperty(location.host + 'reqdata');
channelData = channel.getProperty(this.REQDATAKEY);
} catch (ex) { } catch (ex) {
return; return;
} }
@ -1277,10 +1283,18 @@ var httpObserver = {
return; return;
} }
/*if ( vAPI.fennec && lastRequest.type === this.MAIN_FRAME ) {
vAPI.tabs.onNavigation({
frameId: 0,
tabId: lastRequest.tabId,
url: URI.asciiSpec
});
}*/
// 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',
this.REQDATAKEY,
[ [
lastRequest.type, lastRequest.type,
lastRequest.tabId, lastRequest.tabId,
@ -1740,7 +1754,7 @@ vAPI.contextMenu.create = function(details, callback) {
if ( gContextMenu.inFrame ) { if ( gContextMenu.inFrame ) {
details.tagName = 'iframe'; details.tagName = 'iframe';
// Probably won't work with e01s
// Probably won't work with e10s
details.frameUrl = gContextMenu.focusedWindow.location.href; details.frameUrl = gContextMenu.focusedWindow.location.href;
} else if ( gContextMenu.onImage ) { } else if ( gContextMenu.onImage ) {
details.tagName = 'img'; details.tagName = 'img';

Loading…
Cancel
Save