NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv); PRBool useURILoader = PR_FALSE; if (NS_SUCCEEDED(rv)) prefs->GetBoolPref("browser.uriloader", &useURILoader);  nsXPIDLCString aUrlSpec;    if (useURILoader && aUri) { aUri->GetScheme(getter_Copies(aUrlSpec)); if (nsCRT::strcasecmp(aUrlSpec, "imap") == 0 || nsCRT::strcasecmp(aUrlSpec, "news") == 0 || nsCRT::strcasecmp(aUrlSpec, "mailbox") == 0 || nsCRT::strcasecmp(aUrlSpec, "mailboxMessage") ==0 || nsCRT::strcasecmp(aUrlSpec, "mailto") == 0 || nsCRT::strcasecmp(aUrlSpec, "http") == 0) { nsCOMPtr<nsIProgressEventSink> progressSink = do_QueryInterface(aContainer); nsCOMPtr<nsIURIContentListener> contentListener = do_QueryInterface(aContainer); nsCOMPtr<nsISupports> aOpenContext = do_QueryInterface(mLoadGroup);   NS_WITH_SERVICE(nsIURILoader, pURILoader, kURILoaderCID, &rv); if (NS_SUCCEEDED(rv)) { rv = pURILoader->OpenURI(aUri, nsnull , progressSink, contentListener, nsnull , mLoadGroup, getter_AddRefs(aOpenContext)); if (aOpenContext) mLoadGroup = do_QueryInterface(aOpenContext); }  return rv; } }
nsDocLoaderImpl::LoadDocument(nsIURI * aUri,                               const char* aCommand,                              nsISupports* aContainer,                              nsIInputStream* aPostDataStream,                              nsISupports* aExtraInfo,                              nsLoadFlags aType,                              const PRUint32 aLocalIP,                              const PRUnichar* aReferrer){  nsresult rv = NS_OK;  nsDocumentBindInfo* loader = nsnull;  if (!aUri)    return NS_ERROR_NULL_POINTER;#if defined(DEBUG)  nsXPIDLCString urlSpec;  aUri->GetSpec(getter_Copies(urlSpec));  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,          ("DocLoader:%p: LoadDocument(...) called for %s.",           this, (const char *) urlSpec));#endif /* DEBUG */  /* Check for initial error conditions... */  if (nsnull == aContainer) {      rv = NS_ERROR_NULL_POINTER;      goto done;  }  NS_NEWXPCOM(loader, nsDocumentBindInfo);  if (nsnull == loader) {      rv = NS_ERROR_OUT_OF_MEMORY;      goto done;  }  NS_ADDREF(loader);  loader->Init(this,           // DocLoader               aCommand,       // Command               aContainer,     // Viewer Container               aExtraInfo);    // Extra Info  /*   * Set the flag indicating that the document loader is in the process of   * loading a document.  This flag will remain set until the    * OnConnectionsComplete(...) notification is fired for the loader...   */  mIsLoadingDocument = PR_TRUE;  rv = loader->Bind(aUri, mLoadGroup, aPostDataStream, aReferrer);done:  NS_RELEASE(loader);  return rv;}