views:

70

answers:

1

Hi,

I am writing Firefox extension using C++.

I am enumerating the tabs to get their respective URLs.

Following is pseudocode:

nsCOMPtr<nsIWindowMediator> windowMediator = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
windowMediator->GetMostRecentWindow(L"navigator:browser", getter_AddRefs(dwi));
dwi->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocumentXBL> xbl(do_QueryInterface(doc));
doc->GetElementById(NS_LITERAL_STRING("content"), getter_AddRefs(domEl));
nsCOMPtr<nsIDOMElement> pAnoEl;
xbl->GetAnonymousElementByAttribute(
                                domEl,
                                NS_LITERAL_STRING("anonid"),
                                NS_LITERAL_STRING("tabcontainer"),
                                getter_AddRefs(pAnoEl)
                                );
nsString retval;
PRBool bRet = 0;
nsCOMPtr<nsIDOMNodeList> nodeList;
pAnoEl->GetChildNodes(getter_AddRefs(nodeList));
nsCOMPtr<nsIDOMNode> domNode;
rv = nodeList->GetLength(&len);
for (PRUint32 i = 0; i < len; i++)
{
    nodeList->Item(i, getter_AddRefs(domNode));
    nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(domNode);
    nsCOMPtr<nsIBoxObject> boxObject;
    xulElement->GetBoxObject(getter_AddRefs(boxObject));
    nsCOMPtr<nsIBrowserBoxObject> browserboxObject = do_QueryInterface(boxObject);
}

In the above code QueryInterface for getting nsIBrowserBoxObject fails with error code: NS_ERROR_NO_INTERFACE.

Please suggest me the ways to get tab URL.

Help Me !!!

Thanks, Vaibhav.

+1  A: 

Please at least cross-reference your posts when asking in multiple forums. This was answered in http://groups.google.com/group/mozilla.dev.tech.dom/browse_frm/thread/52ff471516662056#

Nickolay