[Project_owners] Getting Source Tab When Listening to http-on-modify-request

Kyle Wilgus wigginz at gmail.com
Wed Feb 28 08:50:59 PST 2007


I've thought about using the domain as an identifier but I don't know
if it will help solve my situation. Basically my extension
(cookiestore) has multiple cookie containers (jars) that are sticky to
a tab. The extension intercepts an outgoing requests and adds cookie
headers from the jar. This lets you have separate session cookies for
the same domain each sticky from to a tab. The issue I'm facing is
when a tab that is not the selected one makes an HTTP request in the
background, I need to replace the cookies for the correct jar. To do
this I need to know which tab is making the request so I can use the
correct cookie jar.

Someone suggested the following code on the mozillazine forums, and it
seems to get me close to what I want. I'm able to get information from
the window and document which is for the correct tab, but I'm not sure
how to get the tab object from the window or document so I can use the
tab Id which points to the jar for that tab.

var oHttp = aSubject.QueryInterface(Components.interfaces.nsIHttpChannel);
var interfaceRequestor =
oHttp.notificationCallbacks.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
var DOMWindow =
interfaceRequestor.getInterface(Components.interfaces.nsIDOMWindow);
var loadedDoc = DOMWindow.document;

Does anyone know where I can go from here? Is it possible to get the
tab object from the window or document?

Thanks!

Kyle


On 2/28/07, Adam Judson <adamsplugins at gmail.com> wrote:
> Not really.
>
> You might be able to guess by comparing the url.
>
> E.g. the tab for example.com is probably the one trying to retrieve
> resources from example.com/xxx
>
> I've had a lot of folks ask for this in tamperdata, but filtering by
> domain is generally sufficient.
>
> What's the problem you're trying to solve with this information?
>
> Adam
>
> On 28/02/07, Kyle Wilgus <wigginz at gmail.com> wrote:
> > In my extension, I am listening to the topic http-on-modify-request.
> > I'd like to be able to get a reference to the tab that was actually
> > triggering the topic.
> >
> > For example, if I have 5 tabs open, and the page loaded in tab 3 (not
> > necessarily the selected tab) has a meta refresh or makes an AJAX
> > request, I want to be able to identify that tab 3 was the source when
> > I get the message in my observe method.
> >
> > Does anyone know how this can be done?
> >
> > Thanks!
> >
> > Kyle
> > _______________________________________________
> > Project_owners mailing list
> > Project_owners at mozdev.org
> > http://mozdev.org/mailman/listinfo/project_owners
> >
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>


More information about the Project_owners mailing list