bug 157480, crash if password deleted while select-user prompt is up, r=sgehani, sr=darin

This commit is contained in:
morse%netscape.com 2002-08-28 23:50:07 +00:00
Родитель 105a2411db
Коммит 34e12d71f8
2 изменённых файлов: 55 добавлений и 8 удалений

Просмотреть файл

@ -26,6 +26,7 @@
var kObserverService;
var kSignonBundle;
var gSelectUserInUse = false;
// interface variables
var signonviewer = null;
@ -82,6 +83,13 @@ function Startup() {
var element;
if (isPasswordManager) {
// be prepared to reload the display if anything changes
kObserverService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
kObserverService.addObserver(signonReloadDisplay, "signonChanged", false);
// be prepared to disable the buttons when selectuser dialog is in use
kObserverService.addObserver(signonReloadDisplay, "signonSelectUser", false);
signonsTree = document.getElementById("signonsTree");
rejectsTree = document.getElementById("rejectsTree");
@ -127,15 +135,13 @@ function Startup() {
// label the close button
document.documentElement.getButton("accept").label = kSignonBundle.getString("close");
// be prepared to reload the display if anything changes
kObserverService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
kObserverService.addObserver(signonReloadDisplay, "signonChanged", false);
}
function Shutdown() {
kObserverService.removeObserver(signonReloadDisplay, "signonChanged");
if (isPasswordManager) {
kObserverService.removeObserver(signonReloadDisplay, "signonChanged");
kObserverService.removeObserver(signonReloadDisplay, "signonSelectUser");
}
}
var signonReloadDisplay = {
@ -154,6 +160,23 @@ var signonReloadDisplay = {
nopreviews.length = 0;
LoadNopreview();
}
} else if (topic == "signonSelectUser") {
if (state == "suspend") {
gSelectUserInUse = true;
document.getElementById("removeSignon").disabled = true;
document.getElementById("removeAllSignons").disabled = true;
} else if (state == "resume") {
gSelectUserInUse = false;
var selections = GetTreeSelections(signonsTree);
if (selections.length > 0) {
document.getElementById("removeSignon").disabled = false;
}
if (signons.length > 0) {
document.getElementById("removeAllSignons").disabled = false;
}
} else if (state == "inUse") {
gSelectUserInUse = true;
}
}
}
}
@ -243,7 +266,7 @@ function LoadSignons() {
// disable "remove all signons" button if there are no signons
var element = document.getElementById("removeAllSignons");
if (signons.length == 0) {
if (signons.length == 0 || gSelectUserInUse) {
element.setAttribute("disabled","true");
} else {
element.removeAttribute("disabled");
@ -254,7 +277,7 @@ function LoadSignons() {
function SignonSelected() {
var selections = GetTreeSelections(signonsTree);
if (selections.length) {
if (selections.length && !gSelectUserInUse) {
document.getElementById("removeSignon").removeAttribute("disabled");
}
}

Просмотреть файл

@ -104,6 +104,7 @@ si_SaveSignonDataInKeychain();
char* signonFileName = nsnull;
static PRBool gLoadedUserData = PR_FALSE;
static PRUint32 gSelectUserDialogCount = 0;
/***************************
@ -390,7 +391,21 @@ si_SelectDialog(const PRUnichar* szMessage, nsIPrompt* dialog, PRUnichar** pList
PRInt32 selectedIndex;
PRBool rtnValue;
PRUnichar * title_string = Wallet_Localize("SelectUserTitleLine");
/* Notify signon manager dialog to update its display */
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
gSelectUserDialogCount++;
if (os) {
os->NotifyObservers(nsnull, "signonSelectUser", NS_LITERAL_STRING("suspend").get());
}
rv = dialog->Select( title_string, szMessage, *pCount, NS_CONST_CAST(const PRUnichar**, pList), &selectedIndex, &rtnValue );
gSelectUserDialogCount--;
if (os) {
os->NotifyObservers(nsnull, "signonSelectUser", NS_LITERAL_STRING("resume").get());
}
Recycle(title_string);
if (selectedIndex >= *pCount) {
return PR_FALSE; // out-of-range selection
@ -2702,6 +2717,15 @@ SINGSIGN_Enumerate
(PRInt32 hostNumber, PRInt32 userNumber, char **host,
PRUnichar ** user, PRUnichar ** pswd) {
if (gSelectUserDialogCount>0 && hostNumber==0 && userNumber==0) {
// starting to enumerate over all saved logins
// notify recipients if login list is in use by SelectUserDialog
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
if (os) {
os->NotifyObservers(nsnull, "signonSelectUser", NS_LITERAL_STRING("inUse").get());
}
}
if (hostNumber > SINGSIGN_HostCount() || userNumber > SINGSIGN_UserCount(hostNumber)) {
return NS_ERROR_FAILURE;
}