Getting tab URL in C++
Vaibhav <[email protected]> Thu, 8 Apr 2010 06:04:44 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <710a740a-374a-4cc8-bb6f-dbbf85d2aa4d@u34g2000yqu.googlegroups.com> |
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.