aChannel->SetLoadFlags(loadFlags | nsIChannel::LOAD_RETARGETED_DOCUMENT_URI);
newLoadFlags |= nsIChannel::LOAD_RETARGETED_DOCUMENT_URI;
nsDocumentOpenInfo::TryContentListener(nsIURIContentListener* aListener,                                       nsIChannel* aChannel){  LOG(("[0x%p] nsDocumentOpenInfo::TryContentListener; mIsContentPreferred = %s",       this, mIsContentPreferred ? "true" : "false"));  NS_PRECONDITION(aListener, "Must have a non-null listener");  NS_PRECONDITION(aChannel, "Must have a channel");    PRBool listenerWantsContent = PR_FALSE;  nsXPIDLCString typeToUse;    if (mIsContentPreferred) {    aListener->IsPreferred(mContentType.get(),                           getter_Copies(typeToUse),                           &listenerWantsContent);  } else {    aListener->CanHandleContent(mContentType.get(), PR_FALSE,                                getter_Copies(typeToUse),                                &listenerWantsContent);  }  if (!listenerWantsContent) {    LOG(("  Listener is not interested"));    return PR_FALSE;  }  if (!typeToUse.IsEmpty() && typeToUse != mContentType) {    // Need to do a conversion here.    nsresult rv = ConvertData(aChannel, aListener, mContentType, typeToUse);    if (NS_FAILED(rv)) {      // No conversion path -- we don't want this listener, if we got one      m_targetStreamListener = nsnull;    }    LOG(("  Found conversion: %s", m_targetStreamListener ? "yes" : "no"));        // m_targetStreamListener is now the input end of the converter, and we can    // just pump the data in there, if it exists.  If it does not, we need to    // try other nsIURIContentListeners.    return m_targetStreamListener != nsnull;  }  // At this point, aListener wants data of type mContentType.  Let 'em have  // it.  But first, if we are retargeting, set an appropriate flag on the  // channel  nsLoadFlags loadFlags = 0;  aChannel->GetLoadFlags(&loadFlags);  nsCOMPtr<nsIURIContentListener> originalListener =    do_GetInterface(m_originalContext);  if (originalListener != aListener) {    aChannel->SetLoadFlags(loadFlags | nsIChannel::LOAD_RETARGETED_DOCUMENT_URI);  }    PRBool abort = PR_FALSE;  nsresult rv = aListener->DoContent(mContentType.get(),                                     mIsContentPreferred,                                     aChannel,                                     getter_AddRefs(m_targetStreamListener),                                     &abort);      if (NS_FAILED(rv)) {    LOG_ERROR(("  DoContent failed"));        // Unset the RETARGETED_DOCUMENT_URI flag if we set it...    aChannel->SetLoadFlags(loadFlags);    m_targetStreamListener = nsnull;    return PR_FALSE;  }  if (abort) {    // Nothing else to do here -- aListener is handling it all.  Make    // sure m_targetStreamListener is null so we don't do anything    // after this point.    LOG(("  Listener has aborted the load"));    m_targetStreamListener = nsnull;  }  NS_ASSERTION(abort || m_targetStreamListener, "DoContent returned no listener?");  // aListener is handling the load from this point on.    return PR_TRUE;}