char* aContentType; channel->GetContentType(&aContentType); #endif
nsDocumentBindInfo::OnStartBinding(nsIURI* aURL, const char *aContentType)#endif{    nsresult rv = NS_OK;    nsIContentViewer* viewer = nsnull;#ifdef NECKO    nsCOMPtr<nsIChannel> channel = do_QueryInterface(ctxt);    if (channel == nsnull) return NS_ERROR_FAILURE;    nsCOMPtr<nsIURI> aURL;    rv = channel->GetURI(getter_AddRefs(aURL));    if (NS_FAILED(rv)) return rv;#endif#if defined(DEBUG)#ifdef NECKO    char* aContentType;    channel->GetContentType(&aContentType);    char* spec;#else    const char* spec;#endif    (void)aURL->GetSpec(&spec);    PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,            ("DocumentBindInfo:%p OnStartBinding(...) called for %s.  Content-type is %s\n",            this, spec, aContentType));#ifdef NECKO    nsCRT::free(spec);    nsCRT::free(aContentType);#endif#endif /* DEBUG */    /* If the binding has been canceled via Stop() then abort the load... */    if (NS_BINDING_ABORTED == mStatus) {        rv = NS_BINDING_ABORTED;        goto done;    }    if (nsnull == m_NextStream) {        /*         * Now that the content type is available, create a document         * (and viewer) of the appropriate type...         */        if (m_DocLoader) {            rv = m_DocLoader->CreateContentViewer(m_Url,                                                  aContentType,                                                   m_Command,                                                   m_Container,                                                  m_ExtraInfo,                                                  &m_NextStream,                                                   &viewer);        } else {            rv = NS_ERROR_NULL_POINTER;        }        if (NS_FAILED(rv)) {            printf("DocLoaderFactory: Unable to create ContentViewer for command=%s, content-type=%s\n", m_Command ? m_Command : "(null)", aContentType);            if ( m_Container ) {                // Give content container a chance to do something with this URL.#ifndef NECKO                rv = m_Container->HandleUnknownContentType( (nsIDocumentLoader*) m_DocLoader, aURL, aContentType, m_Command );#else                rv = m_Container->HandleUnknownContentType( (nsIDocumentLoader*) m_DocLoader, channel, aContentType, m_Command );#endif // NECKO            }            // Stop the binding.            // This crashes on Unix/Mac... Stop();            goto done;        }        /*         * Give the document container the new viewer...         */        if (m_Container) {            viewer->SetContainer(m_Container);            rv = m_Container->Embed(viewer, m_Command, m_ExtraInfo);            if (NS_FAILED(rv)) {                goto done;            }        }    }    /*     * Pass the OnStartBinding(...) notification out to the document      * IStreamListener.     */    if (nsnull != m_NextStream) {#ifdef NECKO        rv = m_NextStream->OnStartBinding(channel);#else        rv = m_NextStream->OnStartBinding(aURL, aContentType);#endif    }    /*     * Notify the DocumentLoadObserver(s)      */    if ((nsnull == viewer) && (nsnull != m_Container)) {        m_Container->GetContentViewer(&viewer);    }#ifdef NECKO    m_DocLoader->FireOnStartURLLoad((nsIDocumentLoader *)m_DocLoader, channel, aContentType, viewer);#else    m_DocLoader->FireOnStartURLLoad((nsIDocumentLoader *)m_DocLoader, m_Url, aContentType, viewer);#endif    /* Pass the notification out to the Observer... */    if (nsnull != m_Observer) {#ifdef NECKO        nsresult rv2 = m_Observer->OnStartBinding(channel);#else        nsresult rv2 = m_Observer->OnStartBinding(aURL, aContentType);#endif        if (NS_SUCCEEDED(rv))        	rv = rv2;    }  done:    NS_IF_RELEASE(viewer);    return rv;}