if (!(*user = ToNewUnicode(username))) { return NS_ERROR_OUT_OF_MEMORY; } if (!(*pwd = ToNewUnicode(password))) { PR_Free(*user); return NS_ERROR_OUT_OF_MEMORY;
if (!username.IsEmpty()) { if (!(*user = ToNewUnicode(username))) { return NS_ERROR_OUT_OF_MEMORY; } if (!(*pwd = ToNewUnicode(password))) { PR_Free(*user); return NS_ERROR_OUT_OF_MEMORY; }
SINGSIGN_PromptUsernameAndPassword    (const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd,     const char *passwordRealm, nsIPrompt* dialog, PRBool *pressedOK, PRUint32 savePassword) {  nsresult res;  /* do only the dialog if signon preference is not enabled */  if (!si_GetSignonRememberingPref()){    return si_DoDialogIfPrefIsOff(dialogTitle,                                  text,                                  user,                                  pwd,                                  nsnull,                                  nsnull,                                  passwordRealm,                                  dialog,                                  pressedOK,                                   savePassword,                                  promptUsernameAndPassword);  }  /* prefill with previous username/password if any */  nsAutoString username, password;  si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, PR_FALSE, username, password);  /* get new username/password from user */  if (!(*user = ToNewUnicode(username))) {    return NS_ERROR_OUT_OF_MEMORY;  }  if (!(*pwd = ToNewUnicode(password))) {    PR_Free(*user);    return NS_ERROR_OUT_OF_MEMORY;  }  PRBool checked = (**user != 0);  PRBool remembered = checked;  res = si_CheckGetUsernamePassword(user, pwd, dialogTitle, text, dialog, savePassword, &checked);  if (NS_FAILED(res)) {    /* user pressed Cancel */    PR_FREEIF(*user);    PR_FREEIF(*pwd);    *pressedOK = PR_FALSE;    return NS_OK;  }  if (checked) {    Wallet_GiveCaveat(nsnull, dialog);    si_RememberSignonDataFromBrowser (passwordRealm, nsAutoString(*user), nsAutoString(*pwd));  } else if (remembered) {    /* a login was remembered but user unchecked the box; we forget the remembered login */    si_RemoveUser(passwordRealm, username, PR_TRUE, PR_FALSE, PR_TRUE);    }  /* cleanup and return */  *pressedOK = PR_TRUE;  return NS_OK;}