Bug 41390. js prompt() contains remember this value checkbox. r=morse

git-svn-id: svn://10.0.0.236/trunk@72472 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
warren%netscape.com 2000-06-17 01:57:36 +00:00
parent dc0d9afb5a
commit 662f0fe1e7
16 changed files with 187 additions and 123 deletions

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
@ -1176,8 +1176,6 @@ NS_IMETHODIMP GlobalWindowImpl::Alert(JSContext* cx, jsval* argv, PRUint32 argc)
if(argc > 0)
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
else
str.AssignWithConversion("undefined");
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
@ -1195,8 +1193,6 @@ NS_IMETHODIMP GlobalWindowImpl::Confirm(JSContext* cx, jsval* argv,
*aReturn = PR_FALSE;
if(argc > 0)
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
else
str.AssignWithConversion("undefined");
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
@ -1210,15 +1206,23 @@ NS_IMETHODIMP GlobalWindowImpl::Prompt(JSContext* cx, jsval* argv,
NS_ENSURE_STATE(mDocShell);
nsresult ret = NS_OK;
nsAutoString message, initial;
nsAutoString message, initial, title;
PRUint32 savePassword = nsIPrompt::SAVE_PASSWORD_NEVER;
if(argc > 0) {
nsJSUtils::nsConvertJSValToString(message, cx, argv[0]);
nsJSUtils::nsConvertJSValToString(message, cx, argv[0]);
if(argc > 1)
nsJSUtils::nsConvertJSValToString(initial, cx, argv[1]);
else
initial.AssignWithConversion("undefined");
if(argc > 1) {
nsJSUtils::nsConvertJSValToString(initial, cx, argv[1]);
if (argc > 2) {
nsJSUtils::nsConvertJSValToString(title, cx, argv[2]);
if (argc > 3) {
nsJSUtils::nsConvertJSValToUint32(&savePassword, cx, argv[3]);
}
}
}
}
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
@ -1227,7 +1231,7 @@ NS_IMETHODIMP GlobalWindowImpl::Prompt(JSContext* cx, jsval* argv,
PRBool b;
PRUnichar* uniResult = nsnull;
ret = prompter->Prompt(nsnull, message.GetUnicode(), nsnull,
ret = prompter->Prompt(title.GetUnicode(), message.GetUnicode(), nsnull, savePassword,
initial.GetUnicode(), &uniResult, &b);
if (NS_SUCCEEDED(ret) && uniResult && b) {

View File

@ -413,6 +413,23 @@ nsJSUtils::nsConvertJSValToBool(PRBool* aProp,
return JS_TRUE;
}
NS_EXPORT PRBool
nsJSUtils::nsConvertJSValToUint32(PRUint32* aProp,
JSContext* aContext,
jsval aValue)
{
uint32 temp;
if (JS_ValueToECMAUint32(aContext, aValue, &temp)) {
*aProp = (PRUint32)temp;
}
else {
JS_ReportError(aContext, "Parameter must be an integer");
return JS_FALSE;
}
return JS_TRUE;
}
NS_EXPORT PRBool
nsJSUtils::nsConvertJSValToFunc(nsIDOMEventListener** aListener,
JSContext* aContext,

View File

@ -102,6 +102,10 @@ public:
JSContext* aContext,
jsval aValue);
static NS_EXPORT PRBool nsConvertJSValToUint32(PRUint32* aProp,
JSContext* aContext,
jsval aValue);
static NS_EXPORT PRBool nsConvertJSValToFunc(nsIDOMEventListener** aListener,
JSContext* aContext,
JSObject* aObj,

View File

@ -117,14 +117,14 @@ NS_IMETHODIMP CWebBrowserContainer::ConfirmCheck(const PRUnichar* dialogTitle, c
/* boolean prompt (in wstring text, in wstring defaultText, out wstring result); */
NS_IMETHODIMP CWebBrowserContainer::Prompt(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar* passwordRealm,
const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
PRUint32 savePassword, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean promptUsernameAndPassword (in wstring text, out wstring user, out wstring pwd); */
NS_IMETHODIMP CWebBrowserContainer::PromptUsernameAndPassword(const PRUnichar* dialogTitle, const PRUnichar *text,
const PRUnichar* passwordRealm, PRBool persistPassword,
const PRUnichar* passwordRealm, PRUint32 savePassword,
PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
@ -132,7 +132,7 @@ NS_IMETHODIMP CWebBrowserContainer::PromptUsernameAndPassword(const PRUnichar* d
/* boolean promptPassword (in wstring text, in wstring title, out wstring pwd); */
NS_IMETHODIMP CWebBrowserContainer::PromptPassword(const PRUnichar* dialogTitle, const PRUnichar *text,
const PRUnichar* passwordRealm, PRBool persistPassword,
const PRUnichar* passwordRealm, PRUint32 savePassword,
PRUnichar **pwd, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;

View File

@ -60,7 +60,7 @@ interface nsIWalletService : nsISupports {
void SI_RemoveUser(in string key, in wstring userName);
void SI_StorePassword(in string key, in wstring userName, in wstring pwd);
boolean haveData(in string key, in wstring userName);
boolean haveData(in nsIPrompt dialog, in string key, in wstring userName);
[noscript] void WALLET_GetNopreviewListForViewer(in nsAutoStringRef aNopreviewList);
[noscript] void WALLET_GetNocaptureListForViewer(in nsAutoStringRef aNocaptureList);

View File

@ -40,8 +40,10 @@
#include "nsIFormControl.h"
#include "nsIDocShell.h"
#include "nsIDOMWindow.h"
#include "nsINetSupportDialogService.h"
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
nsWalletlibService::nsWalletlibService()
{
@ -317,7 +319,10 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch
rv = inputElement->GetValue(value);
if (NS_FAILED(rv) || value.Length() == 0) {
PRUnichar* valueString = NULL;
SINGSIGN_RestoreSignonData(URLName, nameString, &valueString, elementNumber++);
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);
if (NS_SUCCEEDED(rv)) {
SINGSIGN_RestoreSignonData(dialog, URLName, nameString, &valueString, elementNumber++);
}
if (valueString) {
nsAutoString value(valueString);
rv = inputElement->SetValue(value);
@ -377,9 +382,9 @@ nsWalletlibService::GetPassword(PRUnichar **password)
}
NS_IMETHODIMP
nsWalletlibService::HaveData(const char *key, const PRUnichar *userName, PRBool *_retval)
nsWalletlibService::HaveData(nsIPrompt* dialog, const char *key, const PRUnichar *userName, PRBool *_retval)
{
return ::SINGSIGN_HaveData(key, userName, _retval);
return ::SINGSIGN_HaveData(dialog, key, userName, _retval);
}
NS_IMETHODIMP
@ -426,38 +431,39 @@ nsSingleSignOnPrompt::ConfirmCheck(const PRUnichar *dialogTitle, const PRUnichar
NS_IMETHODIMP
nsSingleSignOnPrompt::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
const PRUnichar *passwordRealm, const PRUnichar *defaultText,
PRUnichar **result, PRBool *_retval)
const PRUnichar *passwordRealm, PRUint32 savePassword,
const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
{
nsresult rv;
nsCAutoString realm;
realm.AssignWithConversion(passwordRealm); // XXX should be PRUnichar*
rv = SINGSIGN_Prompt(dialogTitle, text, defaultText, result, realm.GetBuffer(), mPrompt, _retval);
rv = SINGSIGN_Prompt(dialogTitle, text, defaultText, result, realm.GetBuffer(), mPrompt, _retval, savePassword);
return rv;
}
NS_IMETHODIMP
nsSingleSignOnPrompt::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
const PRUnichar *passwordRealm, PRBool persistPassword,
const PRUnichar *passwordRealm, PRUint32 savePassword,
PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
{
nsresult rv;
nsCAutoString realm;
realm.AssignWithConversion(passwordRealm); // XXX should be PRUnichar*
rv = SINGSIGN_PromptUsernameAndPassword(dialogTitle, text, user, pwd,
realm.GetBuffer(), mPrompt, _retval, persistPassword);
realm.GetBuffer(), mPrompt, _retval, savePassword);
return rv;
}
NS_IMETHODIMP
nsSingleSignOnPrompt::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm,
PRBool persistPassword, PRUnichar **pwd, PRBool *_retval)
nsSingleSignOnPrompt::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
const PRUnichar *passwordRealm, PRUint32 savePassword,
PRUnichar **pwd, PRBool *_retval)
{
nsresult rv;
nsCAutoString realm;
realm.AssignWithConversion(passwordRealm); // XXX should be PRUnichar*
rv = SINGSIGN_PromptPassword(dialogTitle, text, pwd,
realm.GetBuffer(), mPrompt, _retval, persistPassword);
realm.GetBuffer(), mPrompt, _retval, savePassword);
return rv;
}

View File

@ -51,7 +51,6 @@
static NS_DEFINE_IID(kIPrefServiceIID, NS_IPREF_IID);
static NS_DEFINE_IID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
@ -335,17 +334,13 @@ si_3ButtonConfirm(PRUnichar * szMessage) {
#include "nsAppShellCIDs.h" // TODO remove later
PRIVATE PRBool
si_SelectDialog(const PRUnichar* szMessage, PRUnichar** pList, PRInt32* pCount) {
si_SelectDialog(const PRUnichar* szMessage, nsIPrompt* dialog, PRUnichar** pList, PRInt32* pCount) {
if (si_UserHasBeenSelected) {
/* a user was already selected for this form, use same one again */
*pCount = 0; /* last user selected is now at head of list */
return PR_TRUE;
}
nsresult rv;
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);
if (NS_FAILED(rv)) {
return PR_FALSE;
}
PRInt32 selectedIndex;
PRBool rtnValue;
PRUnichar * title_string = Wallet_Localize("SelectUserTitleLine");
@ -359,19 +354,22 @@ si_SelectDialog(const PRUnichar* szMessage, PRUnichar** pList, PRInt32* pCount)
static nsresult
si_CheckGetPassword
(PRUnichar ** password,
const PRUnichar * szMessage,
PRBool* checkValue)
const PRUnichar* dialogTitle,
const PRUnichar * szMessage,
nsIPrompt* dialog,
PRUint32 savePassword,
PRBool* checkValue)
{
nsresult res;
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res);
if (NS_FAILED(res)) {
return res;
}
nsresult res;
PRInt32 buttonPressed = 1; /* in case user exits dialog by clickin X */
PRUnichar * prompt_string = Wallet_Localize("PromptForPassword");
PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
if (dialogTitle == nsnull || nsCRT::strlen(dialogTitle) == 0)
prompt_string = Wallet_Localize("PromptForPassword");
PRUnichar * check_string;
if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
if (savePassword != SINGSIGN_SAVE_PERMANENTLY) {
check_string = nsnull;
} else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
check_string = Wallet_Localize("SaveThisValueEncrypted");
} else {
check_string = Wallet_Localize("SaveThisValueObscured");
@ -397,8 +395,12 @@ si_CheckGetPassword
1, /* is first edit field a password field */
&buttonPressed);
Recycle(prompt_string);
Recycle(check_string);
if (dialogTitle == nsnull)
Recycle(prompt_string);
if (check_string)
Recycle(check_string);
else
*checkValue = PR_FALSE;
if (NS_FAILED(res)) {
return res;
@ -413,19 +415,22 @@ si_CheckGetPassword
static nsresult
si_CheckGetData
(PRUnichar ** data,
const PRUnichar * szMessage,
PRBool* checkValue)
const PRUnichar* dialogTitle,
const PRUnichar * szMessage,
nsIPrompt* dialog,
PRUint32 savePassword,
PRBool* checkValue)
{
nsresult res;
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res);
if (NS_FAILED(res)) {
return res;
}
PRInt32 buttonPressed = 1; /* in case user exits dialog by clickin X */
PRUnichar * prompt_string = Wallet_Localize("PromptForData");
PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
if (dialogTitle == nsnull || nsCRT::strlen(dialogTitle) == 0)
prompt_string = Wallet_Localize("PromptForData");
PRUnichar * check_string;
if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
if (savePassword != SINGSIGN_SAVE_PERMANENTLY) {
check_string = nsnull;
} else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
check_string = Wallet_Localize("SaveThisValueEncrypted");
} else {
check_string = Wallet_Localize("SaveThisValueObscured");
@ -451,8 +456,12 @@ si_CheckGetData
0, /* is first edit field a password field */
&buttonPressed);
Recycle(prompt_string);
Recycle(check_string);
if (dialogTitle == nsnull)
Recycle(prompt_string);
if (check_string)
Recycle(check_string);
else
*checkValue = PR_FALSE;
if (NS_FAILED(res)) {
return res;
@ -467,22 +476,24 @@ si_CheckGetData
static nsresult
si_CheckGetUsernamePassword
(PRUnichar ** username,
PRUnichar ** password,
const PRUnichar * szMessage,
PRBool* checkValue)
PRUnichar ** password,
const PRUnichar* dialogTitle,
const PRUnichar * szMessage,
nsIPrompt* dialog,
PRUint32 savePassword,
PRBool* checkValue)
{
nsresult res;
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res);
if (NS_FAILED(res)) {
return res;
}
PRInt32 buttonPressed = 1; /* in case user exits dialog by clickin X */
PRUnichar * prompt_string = Wallet_Localize("PromptForPassword");
PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
if (dialogTitle == nsnull || nsCRT::strlen(dialogTitle) == 0)
prompt_string = Wallet_Localize("PromptForPassword");
PRUnichar * user_string = Wallet_Localize("UserName");
PRUnichar * password_string = Wallet_Localize("Password");
PRUnichar * check_string;
if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
if (savePassword != SINGSIGN_SAVE_PERMANENTLY) {
check_string = nsnull;
} else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
check_string = Wallet_Localize("SaveTheseValuesEncrypted");
} else {
check_string = Wallet_Localize("SaveTheseValuesObscured");
@ -508,10 +519,14 @@ si_CheckGetUsernamePassword
0, /* is first edit field a password field */
&buttonPressed);
Recycle(prompt_string);
Recycle(check_string);
if (dialogTitle == nsnull)
Recycle(prompt_string);
Recycle(user_string);
Recycle(password_string);
if (check_string)
Recycle(check_string);
else
*checkValue = PR_FALSE;
if (NS_FAILED(res)) {
return res;
@ -817,7 +832,7 @@ si_CheckForUser(const char *passwordRealm, const nsString& userName) {
* This routine is called only if signon pref is enabled!!!
*/
PRIVATE si_SignonUserStruct*
si_GetUser(const char* passwordRealm, PRBool pickFirstUser, const nsString& userText) {
si_GetUser(nsIPrompt* dialog, const char* passwordRealm, PRBool pickFirstUser, const nsString& userText) {
si_SignonURLStruct* url;
si_SignonUserStruct* user = nsnull;
si_SignonDataStruct* data;
@ -898,7 +913,7 @@ si_GetUser(const char* passwordRealm, PRBool pickFirstUser, const nsString& user
} else if (user_count == 1) {
/* only one user for this form at this url, so select it */
user = users[0];
} else if ((user_count > 1) && si_SelectDialog(selectUser, list, &user_count)) {
} else if ((user_count > 1) && si_SelectDialog(selectUser, dialog, list, &user_count)) {
/* user pressed OK */
if (user_count == -1) {
user_count = 0; /* user didn't select, so use first one */
@ -989,7 +1004,7 @@ si_GetSpecificUser(const char* passwordRealm, const nsString& userName, const ns
* This routine is called only if signon pref is enabled!!!
*/
PRIVATE si_SignonUserStruct*
si_GetURLAndUserForChangeForm(const nsString& password)
si_GetURLAndUserForChangeForm(nsIPrompt* dialog, const nsString& password)
{
si_SignonURLStruct* url;
si_SignonUserStruct* user;
@ -1060,7 +1075,7 @@ si_GetURLAndUserForChangeForm(const nsString& password)
/* query user */
PRUnichar * msg = Wallet_Localize("SelectUserWhosePasswordIsBeingChanged");
if (user_count && si_SelectDialog(msg, list, &user_count)) {
if (user_count && si_SelectDialog(msg, dialog, list, &user_count)) {
user = users[user_count];
url = urls[user_count];
/*
@ -1837,7 +1852,7 @@ si_OkToSave(const char *passwordRealm, const nsString& userName) {
* Check for a signon submission and remember the data if so
*/
PRIVATE void
si_RememberSignonData (const char* passwordRealm, nsVoidArray * signonData)
si_RememberSignonData (nsIPrompt* dialog, const char* passwordRealm, nsVoidArray * signonData)
{
int passwordCount = 0;
int pswd[3];
@ -1908,7 +1923,7 @@ si_RememberSignonData (const char* passwordRealm, nsVoidArray * signonData)
/* ask user if this is a password change */
si_lock_signon_list();
user = si_GetURLAndUserForChangeForm(data0->value);
user = si_GetURLAndUserForChangeForm(dialog, data0->value);
/* return if user said no */
if (!user) {
@ -1948,7 +1963,7 @@ si_RememberSignonData (const char* passwordRealm, nsVoidArray * signonData)
}
PUBLIC void
SINGSIGN_RememberSignonData (const char* passwordRealm, nsVoidArray * signonData)
SINGSIGN_RememberSignonData (nsIPrompt* dialog, const char* passwordRealm, nsVoidArray * signonData)
{
nsresult rv;
NS_WITH_SERVICE(nsIURL, uri, "component://netscape/network/standard-url", &rv);
@ -1964,12 +1979,12 @@ SINGSIGN_RememberSignonData (const char* passwordRealm, nsVoidArray * signonData
if (NS_FAILED(rv)) {
return;
}
si_RememberSignonData (strippedRealm, signonData);
si_RememberSignonData(dialog, strippedRealm, signonData);
PR_Free(strippedRealm);
}
PRIVATE void
si_RestoreSignonData (const char* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) {
si_RestoreSignonData(nsIPrompt* dialog, const char* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) {
si_SignonUserStruct* user;
si_SignonDataStruct* data;
nsAutoString correctedName;
@ -2002,7 +2017,7 @@ si_RestoreSignonData (const char* passwordRealm, const PRUnichar* name, PRUnicha
/* determine if name has been saved (avoids unlocking the database if not) */
PRBool nameFound = PR_FALSE;
user = si_GetUser(passwordRealm, PR_FALSE, correctedName);
user = si_GetUser(dialog, passwordRealm, PR_FALSE, correctedName);
if (user) {
PRInt32 dataCount = LIST_COUNT(user->signonData_list);
for (PRInt32 i=0; i<dataCount; i++) {
@ -2053,7 +2068,7 @@ si_RestoreSignonData (const char* passwordRealm, const PRUnichar* name, PRUnicha
/* restore the data from previous time this URL was visited */
user = si_GetUser(passwordRealm, PR_FALSE, correctedName);
user = si_GetUser(dialog, passwordRealm, PR_FALSE, correctedName);
if (user) {
PRInt32 dataCount = LIST_COUNT(user->signonData_list);
for (PRInt32 i=0; i<dataCount; i++) {
@ -2072,7 +2087,7 @@ si_RestoreSignonData (const char* passwordRealm, const PRUnichar* name, PRUnicha
}
PUBLIC void
SINGSIGN_RestoreSignonData (const char* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) {
SINGSIGN_RestoreSignonData(nsIPrompt* dialog, const char* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) {
nsresult rv;
NS_WITH_SERVICE(nsIURL, uri, "component://netscape/network/standard-url", &rv);
if (NS_FAILED(rv)) {
@ -2087,7 +2102,7 @@ SINGSIGN_RestoreSignonData (const char* passwordRealm, const PRUnichar* name, PR
if (NS_FAILED(rv)) {
return;
}
si_RestoreSignonData (strippedRealm, name, value, elementNumber);
si_RestoreSignonData(dialog, strippedRealm, name, value, elementNumber);
PR_Free(strippedRealm);
}
@ -2132,7 +2147,7 @@ si_RememberSignonDataFromBrowser(const char* passwordRealm, const nsString& user
*/
PRIVATE void
si_RestoreOldSignonDataFromBrowser
(const char* passwordRealm, PRBool pickFirstUser, nsString& username, nsString& password) {
(nsIPrompt* dialog, const char* passwordRealm, PRBool pickFirstUser, nsString& username, nsString& password) {
si_SignonUserStruct* user;
si_SignonDataStruct* data;
@ -2141,7 +2156,7 @@ si_RestoreOldSignonDataFromBrowser
if (username.Length() != 0) {
user = si_GetSpecificUser(passwordRealm, username, NS_ConvertToString(USERNAMEFIELD));
} else {
user = si_GetUser(passwordRealm, pickFirstUser, NS_ConvertToString(USERNAMEFIELD));
user = si_GetUser(dialog, passwordRealm, pickFirstUser, NS_ConvertToString(USERNAMEFIELD));
}
if (!user) {
/* leave original username and password from caller unchanged */
@ -2191,7 +2206,7 @@ SINGSIGN_StorePassword(const char *passwordRealm, const PRUnichar *user, const P
PUBLIC nsresult
SINGSIGN_PromptUsernameAndPassword
(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd,
const char *passwordRealm, nsIPrompt* dialog, PRBool *pressedOK, PRBool persistPassword) {
const char *passwordRealm, nsIPrompt* dialog, PRBool *pressedOK, PRUint32 savePassword) {
nsresult res;
@ -2199,18 +2214,18 @@ SINGSIGN_PromptUsernameAndPassword
if (!si_GetSignonRememberingPref()){
nsString realm = NS_ConvertToString(passwordRealm); // XXX hack
return dialog->PromptUsernameAndPassword(dialogTitle, text, realm.GetUnicode(),
persistPassword, user, pwd, pressedOK);
savePassword, user, pwd, pressedOK);
}
/* prefill with previous username/password if any */
nsAutoString username, password;
si_RestoreOldSignonDataFromBrowser(passwordRealm, PR_FALSE, username, password);
si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, PR_FALSE, username, password);
/* get new username/password from user */
*user = username.ToNewUnicode();
*pwd = password.ToNewUnicode();
PRBool checked = PR_FALSE;
res = si_CheckGetUsernamePassword(user, pwd, text, &checked);
res = si_CheckGetUsernamePassword(user, pwd, dialogTitle, text, dialog, savePassword, &checked);
if (NS_FAILED(res)) {
/* user pressed Cancel */
PR_FREEIF(*user);
@ -2230,7 +2245,7 @@ SINGSIGN_PromptUsernameAndPassword
PUBLIC nsresult
SINGSIGN_PromptPassword
(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **pwd, const char *passwordRealm,
nsIPrompt* dialog, PRBool *pressedOK, PRBool persistPassword)
nsIPrompt* dialog, PRBool *pressedOK, PRUint32 savePassword)
{
nsresult res;
@ -2238,17 +2253,15 @@ SINGSIGN_PromptPassword
/* do only the dialog if signon preference is not enabled */
if (!si_GetSignonRememberingPref()){
PRUnichar * prompt_string = Wallet_Localize("PromptForPassword");
nsString realm = NS_ConvertToString(passwordRealm); // XXX hack
res = dialog->PromptPassword(prompt_string,
text, realm.GetUnicode(), persistPassword,
res = dialog->PromptPassword(dialogTitle,
text, realm.GetUnicode(), savePassword,
pwd, pressedOK);
Recycle(prompt_string);
return res;
}
/* get previous password used with this username, pick first user if no username found */
si_RestoreOldSignonDataFromBrowser(passwordRealm, (username.Length() == 0), username, password);
si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, (username.Length() == 0), username, password);
/* return if a password was found */
if (password.Length() != 0) {
@ -2260,7 +2273,7 @@ SINGSIGN_PromptPassword
/* no password found, get new password from user */
*pwd = password.ToNewUnicode();
PRBool checked = PR_FALSE;
res = si_CheckGetPassword(pwd, text, &checked);
res = si_CheckGetPassword(pwd, dialogTitle, text, dialog, savePassword, &checked);
if (NS_FAILED(res)) {
/* user pressed Cancel */
PR_FREEIF(*pwd);
@ -2279,22 +2292,20 @@ SINGSIGN_PromptPassword
PUBLIC nsresult
SINGSIGN_Prompt
(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **resultText,
const char *passwordRealm, nsIPrompt* dialog, PRBool *pressedOK)
const char *passwordRealm, nsIPrompt* dialog, PRBool *pressedOK, PRUint32 savePassword)
{
nsresult res;
nsAutoString data, emptyUsername;
/* do only the dialog if signon preference is not enabled */
if (!si_GetSignonRememberingPref()){
PRUnichar * prompt_string = Wallet_Localize("PromptForData");
nsString realm = NS_ConvertToString(passwordRealm); // XXX hack
res = dialog->Prompt(dialogTitle, text, realm.GetUnicode(), prompt_string, resultText, pressedOK);
Recycle(prompt_string);
res = dialog->Prompt(dialogTitle, text, realm.GetUnicode(), savePassword, defaultText, resultText, pressedOK);
return res;
}
/* get previous data used with this hostname */
si_RestoreOldSignonDataFromBrowser(passwordRealm, PR_TRUE, emptyUsername, data);
si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, PR_TRUE, emptyUsername, data);
/* return if data was found */
if (data.Length() != 0) {
@ -2304,9 +2315,10 @@ SINGSIGN_Prompt
}
/* no data found, get new data from user */
data = defaultText;
*resultText = data.ToNewUnicode();
PRBool checked = PR_FALSE;
res = si_CheckGetData(resultText, text, &checked);
res = si_CheckGetData(resultText, dialogTitle, text, dialog, savePassword, &checked);
if (NS_FAILED(res)) {
/* user pressed Cancel */
PR_FREEIF(*resultText);
@ -2554,7 +2566,7 @@ SINGSIGN_GetRejectListForViewer(nsString& aRejectList)
}
PUBLIC nsresult
SINGSIGN_HaveData(const char *passwordRealm, const PRUnichar *userName, PRBool *retval)
SINGSIGN_HaveData(nsIPrompt* dialog, const char *passwordRealm, const PRUnichar *userName, PRBool *retval)
{
nsAutoString data, usernameForLookup;
@ -2565,7 +2577,7 @@ SINGSIGN_HaveData(const char *passwordRealm, const PRUnichar *userName, PRBool *
}
/* get previous data used with this username, pick first user if no username found */
si_RestoreOldSignonDataFromBrowser(passwordRealm, (usernameForLookup.Length() == 0), usernameForLookup, data);
si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, (usernameForLookup.Length() == 0), usernameForLookup, data);
if (data.Length()) {
*retval = PR_TRUE;

View File

@ -34,6 +34,11 @@
#include "nsVoidArray.h"
#include "nsIPref.h"
/* Duplicates defines as in nsIPrompt.idl -- keep in sync! */
#define SINGSIGN_SAVE_PASSWORD_NEVER 0
#define SINGSIGN_SAVE_FOR_SESSION 1
#define SINGSIGN_SAVE_PERMANENTLY 2
class nsIPrompt;
XP_BEGIN_PROTOS
@ -47,22 +52,22 @@ extern void
SINGSIGN_SignonViewerReturn(const nsString& results);
extern void
SINGSIGN_RestoreSignonData(const char* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber);
SINGSIGN_RestoreSignonData(nsIPrompt* dialog, const char* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber);
extern nsresult
SINGSIGN_PromptUsernameAndPassword
(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd,
const char* passwordRealm, nsIPrompt* dialog, PRBool *returnValue, PRBool persistPassword = PR_TRUE);
const char* passwordRealm, nsIPrompt* dialog, PRBool *returnValue, PRUint32 savePassword = SINGSIGN_SAVE_PERMANENTLY);
extern nsresult
SINGSIGN_PromptPassword
(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **pwd, const char* passwordRealm,
nsIPrompt* dialog, PRBool *returnValue, PRBool persistPassword = PR_TRUE);
nsIPrompt* dialog, PRBool *returnValue, PRUint32 savePassword = SINGSIGN_SAVE_PERMANENTLY);
extern nsresult
SINGSIGN_Prompt
(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **resultText,
const char* passwordRealm, nsIPrompt* dialog, PRBool *returnValue);
const char* passwordRealm, nsIPrompt* dialog, PRBool *returnValue, PRUint32 savePassword = SINGSIGN_SAVE_PERMANENTLY);
extern PRBool
SINGSIGN_RemoveUser
@ -73,7 +78,7 @@ SINGSIGN_StorePassword
(const char* passwordRealm, const PRUnichar *userName, const PRUnichar *password);
extern nsresult
SINGSIGN_HaveData(const char* passwordRealm, const PRUnichar *userName, PRBool *retval);
SINGSIGN_HaveData(nsIPrompt* dialog, const char* passwordRealm, const PRUnichar *userName, PRBool *retval);
extern void
SI_RegisterCallback(const char* domain, PrefChangedFunc callback, void* instance_data);
@ -105,7 +110,7 @@ extern PRBool
SINGSIGN_ReencryptAll();
extern void
SINGSIGN_RememberSignonData (const char* URLName, nsVoidArray * signonData);
SINGSIGN_RememberSignonData(nsIPrompt* dialog, const char* URLName, nsVoidArray * signonData);
XP_END_PROTOS

View File

@ -3503,7 +3503,10 @@ WLLT_OnSubmit(nsIContent* currentForm) {
/* save login if appropriate */
if (currentFormNode == formNode) {
SINGSIGN_RememberSignonData (URLName, signonData);
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);
if (NS_SUCCEEDED(rv)) {
SINGSIGN_RememberSignonData(dialog, URLName, signonData);
}
}
PRInt32 count2 = signonData->Count();
for (PRInt32 i=count2-1; i>=0; i--) {

View File

@ -41,7 +41,7 @@ No = No
Never = Never for this site
Confirm = Confirm
PromptForPassword = Password
PromptForData = User Name
PromptForData = Prompt
SaveTheseValuesObscured = Use Password Manager to remember these values.
SaveTheseValuesEncrypted = Use Password Manager to remember these values.
SaveThisValueObscured = Use Password Manager to remember this value.

View File

@ -1473,7 +1473,8 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
if (NS_FAILED(rv)) return rv;
nsAutoString realm = NS_ConvertToString(signonURL);
rv = dialog->Prompt(aPromptTitle, aPromptMessage, realm.GetUnicode(), nsnull,
rv = dialog->Prompt(aPromptTitle, aPromptMessage, realm.GetUnicode(),
nsIPrompt::SAVE_PASSWORD_PERMANENTLY, nsnull,
getter_Copies(uniGroupUsername), &okayValue);
if (NS_FAILED(rv)) return rv;

View File

@ -193,5 +193,4 @@ interface nsIIOService : nsISupports
{0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#define DUD 3.14
%}

View File

@ -48,6 +48,14 @@ interface nsIPrompt : nsISupports
in wstring checkMsg,
out boolean checkValue);
/**
* Values for the savePassword parameter to prompt, promptPassword and
* promptUsernameAndPassword.
*/
const PRUint32 SAVE_PASSWORD_NEVER = 0;
const PRUint32 SAVE_PASSWORD_FOR_SESSION = 1;
const PRUint32 SAVE_PASSWORD_PERMANENTLY = 2;
/**
* Puts up a text input dialog with OK and Cancel buttons.
* @return true for OK, false for Cancel
@ -55,6 +63,7 @@ interface nsIPrompt : nsISupports
boolean prompt(in wstring dialogTitle,
in wstring text,
in wstring passwordRealm,
in PRUint32 savePassword,
in wstring defaultText,
out wstring result);
@ -65,7 +74,7 @@ interface nsIPrompt : nsISupports
boolean promptUsernameAndPassword(in wstring dialogTitle,
in wstring text,
in wstring passwordRealm,
in boolean persistPassword,
in PRUint32 savePassword,
out wstring user,
out wstring pwd);
@ -76,7 +85,7 @@ interface nsIPrompt : nsISupports
boolean promptPassword(in wstring dialogTitle,
in wstring text,
in wstring passwordRealm,
in boolean persistPassword,
in PRUint32 savePassword,
out wstring pwd);
/**

View File

@ -2234,6 +2234,7 @@ NS_IMETHODIMP
nsBrowserWindow::Prompt(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *passwordRealm,
PRUint32 savePassword,
const PRUnichar *defaultText,
PRUnichar **result,
PRBool *_retval)
@ -2260,7 +2261,7 @@ NS_IMETHODIMP
nsBrowserWindow::PromptUsernameAndPassword(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *passwordRealm,
PRBool persistPassword,
PRUint32 savePassword,
PRUnichar **user,
PRUnichar **pwd,
PRBool *_retval)
@ -2293,7 +2294,7 @@ NS_IMETHODIMP
nsBrowserWindow::PromptPassword(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *passwordRealm,
PRBool persistPassword,
PRUint32 savePassword,
PRUnichar **pwd,
PRBool *_retval)
{

View File

@ -144,6 +144,7 @@ NS_IMETHODIMP nsNetSupportDialog::UniversalDialog
NS_IMETHODIMP nsNetSupportDialog::Prompt(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *passwordRealm,
PRUint32 savePassword,
const PRUnichar *defaultText,
PRUnichar **resultText,
PRBool *returnValue)
@ -152,7 +153,7 @@ NS_IMETHODIMP nsNetSupportDialog::Prompt(const PRUnichar *dialogTitle,
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr< nsIPrompt> dialogService;
if( GetNSIPrompt( dialogService ) )
rv = dialogService->Prompt(dialogTitle, text, passwordRealm, defaultText, resultText, returnValue);
rv = dialogService->Prompt(dialogTitle, text, passwordRealm, savePassword, defaultText, resultText, returnValue);
return rv;
}
@ -160,7 +161,7 @@ NS_IMETHODIMP nsNetSupportDialog::Prompt(const PRUnichar *dialogTitle,
NS_IMETHODIMP nsNetSupportDialog::PromptUsernameAndPassword(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *passwordRealm,
PRBool persistPassword,
PRUint32 savePassword,
PRUnichar **user,
PRUnichar **pwd,
PRBool *returnValue)
@ -169,21 +170,21 @@ NS_IMETHODIMP nsNetSupportDialog::PromptUsernameAndPassword(const PRUnichar *dia
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr< nsIPrompt> dialogService;
if( GetNSIPrompt( dialogService ) )
rv = dialogService->PromptUsernameAndPassword(dialogTitle, text, passwordRealm, persistPassword, user, pwd, returnValue);
rv = dialogService->PromptUsernameAndPassword(dialogTitle, text, passwordRealm, savePassword, user, pwd, returnValue);
return rv;
}
NS_IMETHODIMP nsNetSupportDialog::PromptPassword(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *passwordRealm,
PRBool persistPassword,
PRUint32 savePassword,
PRUnichar **pwd,
PRBool *_retval)
{
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr< nsIPrompt> dialogService;
if( GetNSIPrompt( dialogService ) )
rv = dialogService->PromptPassword(dialogTitle, text, passwordRealm, persistPassword, pwd, _retval);
rv = dialogService->PromptPassword(dialogTitle, text, passwordRealm, savePassword, pwd, _retval);
return rv;
}

View File

@ -1839,6 +1839,7 @@ NS_IMETHODIMP
nsDOMWindowPrompter::Prompt(const PRUnichar* dialogTitle,
const PRUnichar* text,
const PRUnichar* passwordRealm,
PRUint32 savePassword,
const PRUnichar* defaultText,
PRUnichar* *result,
PRBool *_retval)
@ -1857,12 +1858,12 @@ NS_IMETHODIMP
nsDOMWindowPrompter::PromptUsernameAndPassword(const PRUnichar* dialogTitle,
const PRUnichar* text,
const PRUnichar* passwordRealm,
PRBool persistPassword,
PRUint32 savePassword,
PRUnichar* *user,
PRUnichar* *pwd,
PRBool *_retval)
{
// ignore passwordRealm and persistPassword here?
// ignore passwordRealm and savePassword here?
nsresult rv;
nsAutoString title(dialogTitle);
if (title == nsnull)
@ -1876,11 +1877,11 @@ NS_IMETHODIMP
nsDOMWindowPrompter::PromptPassword(const PRUnichar* dialogTitle,
const PRUnichar* text,
const PRUnichar* passwordRealm,
PRBool persistPassword,
PRUint32 savePassword,
PRUnichar* *pwd,
PRBool *_retval)
{
// ignore passwordRealm and persistPassword here?
// ignore passwordRealm and savePassword here?
nsresult rv;
nsAutoString title(dialogTitle);
if (title == nsnull)
@ -1932,6 +1933,7 @@ nsDOMWindowPrompter::UniversalDialog(const PRUnichar *inTitleMessage,
PRInt32 *outButtonPressed) /* number of button that was pressed (0 to 3) */
{
nsresult rv;
NS_ASSERTION(inDialogTitle, "UniversalDialog must have a dialog title supplied");
rv = mCommonDialogs->UniversalDialog(mDOMWindow,
inTitleMessage,
inDialogTitle,