From 9f2ec357d2660fcbe8ae6d16117688da1afd0978 Mon Sep 17 00:00:00 2001 From: "morse%netscape.com" Date: Tue, 18 Jul 2000 02:03:57 +0000 Subject: [PATCH] fix bug 44146, parent window for dialogs, r=dveditz --- extensions/wallet/public/nsIWalletService.idl | 3 +- extensions/wallet/src/nsWalletService.cpp | 4 +- extensions/wallet/src/singsign.cpp | 1 + extensions/wallet/src/wallet.cpp | 41 ++++++++++++------- extensions/wallet/src/wallet.h | 4 +- extensions/wallet/src/wallet.properties | 1 + xpfe/browser/src/nsBrowserInstance.cpp | 2 +- 7 files changed, 36 insertions(+), 20 deletions(-) diff --git a/extensions/wallet/public/nsIWalletService.idl b/extensions/wallet/public/nsIWalletService.idl index 89ee377f884e..cc0a7c9cb9f6 100644 --- a/extensions/wallet/public/nsIWalletService.idl +++ b/extensions/wallet/public/nsIWalletService.idl @@ -22,6 +22,7 @@ #include "nsISupports.idl" #include "nsIPrompt.idl" +#include "domstubs.idl" %{ C++ #include "nsString.h" @@ -51,7 +52,7 @@ interface nsIWalletService : nsISupports { [noscript]void WALLET_PostEdit(in nsAutoString walletList); boolean WALLET_ChangePassword(); void WALLET_DeleteAll(); - PRUint32 WALLET_RequestToCapture(in nsIPresShell shell); + PRUint32 WALLET_RequestToCapture(in nsIPresShell shell, in nsIDOMWindow win); boolean WALLET_Prefill(in nsIPresShell shell, in boolean quick); [noscript]void WALLET_PrefillReturn(in nsAutoString results); void WALLET_FetchFromNetCenter(); diff --git a/extensions/wallet/src/nsWalletService.cpp b/extensions/wallet/src/nsWalletService.cpp index 31bc627d5c89..69db61087194 100644 --- a/extensions/wallet/src/nsWalletService.cpp +++ b/extensions/wallet/src/nsWalletService.cpp @@ -89,8 +89,8 @@ NS_IMETHODIMP nsWalletlibService::WALLET_DeleteAll() { return NS_OK; } -NS_IMETHODIMP nsWalletlibService::WALLET_RequestToCapture(nsIPresShell* shell, PRUint32* status) { - ::WLLT_RequestToCapture(shell, status); +NS_IMETHODIMP nsWalletlibService::WALLET_RequestToCapture(nsIPresShell* shell, nsIDOMWindow* win, PRUint32* status) { + ::WLLT_RequestToCapture(shell, win, status); return NS_OK; } diff --git a/extensions/wallet/src/singsign.cpp b/extensions/wallet/src/singsign.cpp index 88c68b642faa..0f797455babc 100644 --- a/extensions/wallet/src/singsign.cpp +++ b/extensions/wallet/src/singsign.cpp @@ -1912,6 +1912,7 @@ si_RememberSignonData data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j)); if (si_OkToSave(passwordRealm, data2->value, window)) { + Wallet_GiveCaveat(window); for (j=0; jCount(); j++) { data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j)); nsAutoString value = data2->value; diff --git a/extensions/wallet/src/wallet.cpp b/extensions/wallet/src/wallet.cpp index 0bca2a16ef21..60a4656daaff 100644 --- a/extensions/wallet/src/wallet.cpp +++ b/extensions/wallet/src/wallet.cpp @@ -841,16 +841,18 @@ Wallet_3ButtonConfirm(PRUnichar * szMessage, nsIDOMWindow* window) } PUBLIC void -Wallet_Alert(PRUnichar * szMessage) +Wallet_Alert(PRUnichar * szMessage, nsIDOMWindow* window) { nsresult res; - NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res); + NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &res); if (NS_FAILED(res)) { return; // XXX should return the error } const nsAutoString message = szMessage; - res = dialog->Alert(nsnull, message.GetUnicode()); + PRUnichar * title = Wallet_Localize("CaveatTitle"); + res = dialog->Alert(window, title, message.GetUnicode()); + Recycle(title); return; // XXX should return the error } @@ -1021,14 +1023,6 @@ PRIVATE nsresult EncryptString (const char * text, char *& crypt) { crypt[PL_strlen(PREFIX) + PL_strlen(crypt0)] = '\0'; Recycle(crypt0); - /* test for first obscuring ever and give caveat if so */ - if (!SI_GetBoolPref(pref_Caveat, PR_FALSE)) { - SI_SetBoolPref(pref_Caveat, PR_TRUE); - PRUnichar * message = Wallet_Localize("Caveat"); - Wallet_Alert(message); - Recycle(message); - } - return NS_OK; } @@ -1891,6 +1885,17 @@ wallet_ReadFromURLFieldToSchemaFile /*********************************************************************/ /* The following are utility routines for the main wallet processing */ /*********************************************************************/ + +PUBLIC void +Wallet_GiveCaveat(nsIDOMWindow* window) { + /* test for first capturing of data ever and give caveat if so */ + if (!SI_GetBoolPref(pref_Caveat, PR_FALSE)) { + SI_SetBoolPref(pref_Caveat, PR_TRUE); + PRUnichar * message = Wallet_Localize("Caveat"); + Wallet_Alert(message, window); + Recycle(message); + } +} static void wallet_GetHostFile(nsIURI * url, nsString& outHostFile) @@ -2947,7 +2952,7 @@ if (!changingPassword) { SI_SetBoolPref(pref_Crypto, SI_GetBoolPref(pref_Crypto, PR_TRUE)); // message = Wallet_Localize("Converted"); -// Wallet_Alert(message); +//????? Wallet_Alert(message); // Recycle(message); level--; return 0; /* this is PREF_NOERROR but we no longer include prefapi.h */ @@ -2957,7 +2962,7 @@ fail: /* alert the user to the failure */ message = Wallet_Localize("NotConverted"); - Wallet_Alert(message); +//????? Wallet_Alert(message); Recycle(message); level--; return 1; @@ -3259,7 +3264,8 @@ WLLT_Prefill(nsIPresShell* shell, PRBool quick, PRBool* doPrefillMessage) } PUBLIC void -WLLT_RequestToCapture(nsIPresShell* shell, PRUint32* status) { +WLLT_RequestToCapture(nsIPresShell* shell, nsIDOMWindow* win, PRUint32* status) { + /* starting with the present shell, get each form element and put them on a list */ nsresult result; PRInt32 captureCount = 0; @@ -3346,6 +3352,8 @@ WLLT_RequestToCapture(nsIPresShell* shell, PRUint32* status) { if (gEncryptionFailure) { *status = -1; /* UnableToCapture */ } else if (captureCount) { + /* give caveat if this is the first time data is being captured */ + Wallet_GiveCaveat(win); *status = 0; /* Captured */ } else { *status = +1; /* NotCaptured */ @@ -3527,7 +3535,7 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindow* window) { /* conditions all met, now give notification */ PRUnichar * notification = Wallet_Localize("WalletNotification"); wallet_SetWalletNotificationPref(PR_TRUE); - Wallet_Alert(notification); + Wallet_Alert(notification, window); Recycle(notification); } #else @@ -3535,6 +3543,9 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindow* window) { if (wallet_GetFormsCapturingPref() && (OKToPrompt) && wallet_OKToCapture(URLName, window)) { + /* give caveat if this is the first time data is being captured */ + Wallet_GiveCaveat(window); + /* conditions all met, now save it */ for (PRUint32 elementY = 0; elementY < numElements; elementY++) { nsIDOMNode* elementNode = nsnull; diff --git a/extensions/wallet/src/wallet.h b/extensions/wallet/src/wallet.h index 9b6583b4bc89..e1816d2984e1 100644 --- a/extensions/wallet/src/wallet.h +++ b/extensions/wallet/src/wallet.h @@ -60,7 +60,7 @@ extern void WLLT_PrefillReturn(const nsString& results); extern void -WLLT_RequestToCapture(nsIPresShell* shell, PRUint32* status); +WLLT_RequestToCapture(nsIPresShell* shell, nsIDOMWindow * win, PRUint32* status); extern nsresult WLLT_Prefill(nsIPresShell* shell, PRBool quick, PRBool* doPrefillMessage); @@ -102,6 +102,8 @@ extern PRBool Wallet_ConfirmYN(PRUnichar * szMessage, nsIDOMWindow* window); extern PRInt32 Wallet_3ButtonConfirm(PRUnichar * szMessage, nsIDOMWindow* window); +extern void Wallet_GiveCaveat(nsIDOMWindow* window); + extern nsresult Wallet_Encrypt2(const nsString& text, nsString& crypt); diff --git a/extensions/wallet/src/wallet.properties b/extensions/wallet/src/wallet.properties index fa730a742d23..c80b9462c4a2 100644 --- a/extensions/wallet/src/wallet.properties +++ b/extensions/wallet/src/wallet.properties @@ -64,3 +64,4 @@ PasswordNotChanged = Unable to change the password that protects your sensitive PasswordExpired = Your sensitive information is now locked. PasswordNotExpired = Unable to lock your sensitive information. Caveat = Saving Passwords and Other Sensitive Information##Password Manager and Form Manager will save passwords, user names, and other sensitive information and enter them for you automatically when they are required.#This sensitive information is stored on your computer in a file that's difficult, but not impossible, to read.#If other people have access to your computer, you may want to password protect the stored sensitive information by choosing a Personal Security Password.#If you choose to password protect your stored information, you will be asked to provide your Personal Security Password from time to time. This approach provides better security but is slightly less convenient.#To password protect stored information, choose Preferences from the Edit menu, open the Advanced category, choose Forms and Passwords, and check 'Use encryption when storing sensitive data.' +CaveatTitle = Warning diff --git a/xpfe/browser/src/nsBrowserInstance.cpp b/xpfe/browser/src/nsBrowserInstance.cpp index 6351313aa27d..38b432493ece 100644 --- a/xpfe/browser/src/nsBrowserInstance.cpp +++ b/xpfe/browser/src/nsBrowserInstance.cpp @@ -929,7 +929,7 @@ nsBrowserInstance::WalletRequestToCapture(nsIDOMWindow* aWin, PRUint32* status) kIWalletServiceIID, (nsISupports **)&walletservice); if ((NS_OK == res) && (nsnull != walletservice)) { - res = walletservice->WALLET_RequestToCapture(presShell, status); + res = walletservice->WALLET_RequestToCapture(presShell, aWin, status); nsServiceManager::ReleaseService(kWalletServiceCID, walletservice); return NS_OK; } else {