if (docTitle != nsnull) { nsAutoString title(docTitle->get()); if (title.Length() > 0) { *aTitle = title.ToNewUnicode(); }
if (docTitle && !docTitle->IsEmpty()) { *aTitle = ToNewUnicode(*docTitle);
DocumentViewerImpl::GetWebShellTitleAndURL(nsIWebShell * aWebShell,                                            PRUnichar**   aTitle,                                            PRUnichar**   aURLStr){  NS_ASSERTION(aWebShell, "Pointer is null!");  NS_ASSERTION(aTitle, "Pointer is null!");  NS_ASSERTION(aURLStr, "Pointer is null!");  *aTitle  = nsnull;  *aURLStr = nsnull;  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebShell));  if (docShell) {    nsCOMPtr<nsIPresShell> presShell;    docShell->GetPresShell(getter_AddRefs(presShell));    if (presShell) {      nsCOMPtr<nsIDocument> doc;      presShell->GetDocument(getter_AddRefs(doc));      if (doc) {        const nsString* docTitle = doc->GetDocumentTitle();        if (docTitle != nsnull) {          nsAutoString title(docTitle->get());          if (title.Length() > 0) {            *aTitle = title.ToNewUnicode();          }        }        nsCOMPtr<nsIURI> url;        doc->GetDocumentURL(getter_AddRefs(url));        if (url) {          char * urlCStr;          url->GetSpec(&urlCStr);          if (urlCStr) {            nsAutoString urlStr;            urlStr.AssignWithConversion(urlCStr);            *aURLStr = urlStr.ToNewUnicode();            nsMemory::Free(urlCStr);          }        }      }    }  }}