Uhhhhhh...I think the nsIWebProgressListener::onLocationChange will help me out in this situation. Sometimes you can't tell the forest from the trees. Thanks

Roy wrote:
I have an extension that listens for new tabs and performs some tasks when a new tab is opened. One piece of information I need from the new tab is where it's navigating to. The code can retrieve the URL in Firefox 1.5, but not in Firefox 2.

When a new tab opens in Firefox 1.5, I can grab the URL from the request object when STATE_START is passed to my nsIWebProgressListener::onStateChange implementation. In FF2, the request object never contains the URL. Should this be possible in FF2? Is there another way to get the URL when the progress listener flag is STATE_START?

A snippet is shown below...

Thanks,
Roy


// Register for "new tab" event notifications
var container = gBrowser.tabContainer;
container.addEventListener("TabOpen", TabAddedListener2, false);

function TabAddedListener2(event)
{
   var browser = event.target.linkedBrowser;

   // Add our listener to the tab
   browser.addProgressListener(
      MyListener,
      Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
}

// Implement web progress listener
var MyListener =
{
   QueryInterface: function(aIID)
   {
      if (aIID.equals(Components.interfaces.nsIWebProgressListener)
         || aIID.equals(Components.interfaces.nsISupportsWeakReference)
         || aIID.equals(Components.interfaces.nsISupports))
      {
         return this;
      }
      throw Components.results.NS_NOINTERFACE;
   },

   // Since we added a web progress listener in the new tab event handler,
   // this function gets called immediately after the new tab is opened.
   onStateChange: function(aProgress, aRequest, aFlag, aStatus)
   {
      if (aFlag & STATE_START)
      {
         // Theoretically, XPCOM component can grab the URL from aRequest.
         // Not working in FF2.
         XPCOMComponent.doSomething(aProgress, aRequest, aStatus);
      }
      return Components.results.NS_OK;
   }

   // Other functions...
}
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to