const char *cmd = mViewSource ? "view-source" : "view" ;  return LoadURL(aURLSpec, cmd, aPostDataStream, aModifyHistory,aType, aLocalIP, aHistoryState, aReferrer);
nsresult rv = NS_OK; PRBool isMail= PR_FALSE; PRBool keywordsEnabled = PR_FALSE;    mViewSource = (0==PL_strcmp("view-source", aCommand));  nsAutoString urlStr(aURLSpec);  nsCOMPtr<nsIURI> uri; nsXPIDLCString  spec; if(0==urlStr.Find("file:",0)) {   nsCAutoString inFSCharset; rv = convertURLToFileCharset(urlStr, inFSCharset); NS_ASSERTION(NS_SUCCEEDED(rv), "convertURLToFielCharset failed"); if (NS_SUCCEEDED(rv)) rv = NS_NewURI(getter_AddRefs(uri), inFSCharset.GetBuffer(), nsnull); } else { rv = NS_NewURI(getter_AddRefs(uri), urlStr, nsnull); } if (NS_FAILED(rv)) {  nsAutoString urlSpec; urlStr.Trim(" ");   convertFileToURL(urlStr, urlSpec); nsCAutoString inFSCharset; rv = convertURLToFileCharset(urlSpec, inFSCharset); NS_ASSERTION(NS_SUCCEEDED(rv), "convertURLToFielCharset failed"); if (NS_SUCCEEDED(rv)) rv = NS_NewURI(getter_AddRefs(uri), inFSCharset.GetBuffer(), nsnull);  if (NS_FAILED(rv)) { NS_ASSERTION(mPrefs, "the webshell's pref service wasn't initialized");  rv = mPrefs->GetBoolPref("keyword.enabled", &keywordsEnabled); if (NS_FAILED(rv)) return rv;  PRInt32 qMarkLoc = -1, spaceLoc = -1;  if (keywordsEnabled) { rv = NS_ERROR_FAILURE;              if (urlStr.FindChar('.') == -1 && urlStr.FindChar(':') == -1) { qMarkLoc = urlStr.FindChar('?'); spaceLoc = urlStr.FindChar(' ');  PRBool keyword = PR_FALSE; if (qMarkLoc == 0) { keyword = PR_TRUE; } else if ( (spaceLoc > 0) && ( (qMarkLoc == -1) || (spaceLoc < qMarkLoc) )) { keyword = PR_TRUE; }  if (keyword) { nsCAutoString keywordSpec("keyword:"); char *utf8Spec = urlStr.ToNewUTF8String(); if(utf8Spec) { char* escapedUTF8Spec = nsEscape(utf8Spec, url_Path); if(escapedUTF8Spec) { keywordSpec.Append(escapedUTF8Spec); rv = NS_NewURI(getter_AddRefs(uri), keywordSpec.GetBuffer(), nsnull); nsAllocator::Free(escapedUTF8Spec); } nsAllocator::Free(utf8Spec); } } } }   PRInt32 colon = -1; if (NS_FAILED(rv)) { PRInt32 fSlash = urlSpec.FindChar('/'); PRUnichar port;  if ( ((colon=urlSpec.FindChar(':')) == -1) || ( (fSlash > -1) && (colon > fSlash) ) || ( (colon < urlSpec.Length()-1) && ((port=urlSpec.CharAt(colon+1)) <= '9') && (port > '0') )) {  PRInt32 hostPos = urlSpec.FindCharInSet("./:"); if (hostPos == -1) { hostPos = urlSpec.Length(); }   nsAutoString hostSpec; urlSpec.Left(hostSpec, hostPos);   if (hostSpec.EqualsIgnoreCase("ftp")) { urlSpec.Insert("ftp: } else { urlSpec.Insert("http: } }   if ((urlSpec.Find("mailto:", PR_TRUE)) >= 0) isMail = PR_TRUE;  if (!isMail) { rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull); if (NS_ERROR_UNKNOWN_PROTOCOL == rv) {  rv = InitDialogVars(); if (NS_FAILED(rv)) return rv;  nsXPIDLString messageStr; nsAutoString name("protocolNotFound"); rv = mStringBundle->GetStringFromName(name.GetUnicode(), getter_Copies(messageStr)); if (NS_FAILED(rv)) return rv;  NS_ASSERTION(colon != -1, "we shouldn't have gotten this far if we didn't have a colon");   nsAutoString scheme; urlSpec.Left(scheme, colon);  nsAutoString dnsMsg(scheme); dnsMsg.Append(' '); dnsMsg.Append(messageStr);  (void)mPrompter->Alert(dnsMsg.GetUnicode()); } } } } }  if (!uri) return rv;  rv = uri->GetSpec(getter_Copies(spec)); if (NS_FAILED(rv)) return rv;   nsCOMPtr<nsIWebShell>  root; nsCOMPtr<nsISessionHistory> shist; PRBool  isLoadingHistory=PR_FALSE; rv = GetRootWebShell(*getter_AddRefs(root));  if (NS_SUCCEEDED(rv) && root) { root->GetSessionHistory(*getter_AddRefs(shist)); } if (shist) shist->GetLoadingFlag(&isLoadingHistory);    if (shist) { PRInt32  indix; shist->GetCurrentIndex(&indix); if (indix >= 0 && (aModifyHistory)) { nsCOMPtr<nsISupports>  historyState; rv = GetHistoryState(getter_AddRefs(historyState)); if (NS_SUCCEEDED(rv) && historyState) shist->SetHistoryObjectForIndex(indix, historyState); } }  SetHistoryState(aHistoryState);   if (aModifyHistory && shist && (!isMail))  { PRInt32  ret; nsCAutoString referrer(aReferrer); ret = shist->Add(spec, referrer, this); }  nsCOMPtr<nsIWebShell> parent; nsresult res = GetParent(*getter_AddRefs(parent)); nsAutoString urlstr;  if ((isLoadingHistory)) {  urlstr = mURL; } else{  urlstr=spec; }  nsCOMPtr<nsIURI>   newURI; res = NS_NewURI(getter_AddRefs(newURI), urlstr, nsnull);  if (NS_SUCCEEDED(res)) {  return LoadURI(newURI, aCommand, aPostDataStream, aModifyHistory, aType, aLocalIP, aHistoryState, aReferrer, aWindowTarget); } return rv;
nsWebShell::LoadURL(const PRUnichar *aURLSpec,                    nsIInputStream* aPostDataStream,                    PRBool aModifyHistory,                    nsLoadFlags aType,                    const PRUint32 aLocalIP,                    nsISupports * aHistoryState,                    const PRUnichar* aReferrer){  const char *cmd = mViewSource ? "view-source" : "view" ;  return LoadURL(aURLSpec, cmd, aPostDataStream,                 aModifyHistory,aType, aLocalIP, aHistoryState,                 aReferrer);}