Bug 343182 - Password Manager asks multiple times to save a password. patch=mwu, r=jst, sr=bzbarsky

This commit is contained in:
rob_strong%exchangecode.com 2006-07-18 00:18:32 +00:00
Родитель 063e887ba0
Коммит 9aab7b5b89
6 изменённых файлов: 28 добавлений и 9 удалений

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

@ -57,6 +57,8 @@ class nsIURI;
{ 0xa6cf9106, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
#define NS_FORMSUBMIT_SUBJECT "formsubmit"
// used when actionURL is not needed and accuracy of form data is more important
#define NS_EARLYFORMSUBMIT_SUBJECT "earlyformsubmit"
#define NS_FIRST_FORMSUBMIT_CATEGORY "firstformsubmit"
#define NS_PASSWORDMANAGER_CATEGORY "passwordmanager"

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

@ -291,7 +291,8 @@ protected:
* @param aCancelSubmit out param where submit observers can specify that the
* submit should be cancelled.
*/
nsresult NotifySubmitObservers(nsIURI* aActionURL, PRBool* aCancelSubmit);
nsresult NotifySubmitObservers(nsIURI* aActionURL, PRBool* aCancelSubmit,
PRBool aEarlyNotify);
/**
* Just like GetElementCount(), but doesn't flush
@ -571,7 +572,11 @@ nsHTMLFormElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
// the second argument is not playing a role at all.
FlushPendingSubmission();
}
// Don't forget we've notified the password manager already if the
// page sets the action/target in the during submit. (bug 343182)
PRBool notifiedObservers = mNotifiedObservers;
ForgetCurrentSubmission();
mNotifiedObservers = notifiedObservers;
}
return nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue,
aNotify);
@ -960,7 +965,7 @@ nsHTMLFormElement::SubmitSubmission(nsIFormSubmission* aFormSubmission)
if (mNotifiedObservers) {
cancelSubmit = mNotifiedObserversResult;
} else {
rv = NotifySubmitObservers(actionURI, &cancelSubmit);
rv = NotifySubmitObservers(actionURI, &cancelSubmit, PR_TRUE);
NS_ENSURE_SUBMIT_SUCCESS(rv);
}
@ -969,6 +974,15 @@ nsHTMLFormElement::SubmitSubmission(nsIFormSubmission* aFormSubmission)
return NS_OK;
}
cancelSubmit = PR_FALSE;
rv = NotifySubmitObservers(actionURI, &cancelSubmit, PR_FALSE);
NS_ENSURE_SUBMIT_SUCCESS(rv);
if (cancelSubmit) {
mIsSubmitting = PR_FALSE;
return NS_OK;
}
//
// Submit
//
@ -1010,7 +1024,8 @@ nsHTMLFormElement::SubmitSubmission(nsIFormSubmission* aFormSubmission)
nsresult
nsHTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
PRBool* aCancelSubmit)
PRBool* aCancelSubmit,
PRBool aEarlyNotify)
{
// If this is the first form, bring alive the first form submit
// category observers
@ -1028,7 +1043,9 @@ nsHTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISimpleEnumerator> theEnum;
rv = service->EnumerateObservers(NS_FORMSUBMIT_SUBJECT,
rv = service->EnumerateObservers(aEarlyNotify ?
NS_EARLYFORMSUBMIT_SUBJECT :
NS_FORMSUBMIT_SUBJECT,
getter_AddRefs(theEnum));
NS_ENSURE_SUCCESS(rv, rv);
@ -1323,7 +1340,7 @@ nsHTMLFormElement::OnSubmitClickBegin()
// Notify observers of submit
//
PRBool cancelSubmit = PR_FALSE;
rv = NotifySubmitObservers(actionURI, &cancelSubmit);
rv = NotifySubmitObservers(actionURI, &cancelSubmit, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
mNotifiedObservers = PR_TRUE;
mNotifiedObserversResult = cancelSubmit;

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

@ -299,7 +299,7 @@ nsresult nsWalletlibService::Init()
do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_SUCCEEDED(rv) && svc) {
// Register as an observer of form submission
svc->AddObserver(this, NS_FORMSUBMIT_SUBJECT, PR_TRUE);
svc->AddObserver(this, NS_EARLYFORMSUBMIT_SUBJECT, PR_TRUE);
// Register as an observer of profile changes
svc->AddObserver(this, "profile-before-change", PR_TRUE);
// Register as an observer for login

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

@ -278,7 +278,7 @@ nsPasswordManager::Init()
nsCOMPtr<nsIObserverService> obsService = do_GetService("@mozilla.org/observer-service;1");
NS_ASSERTION(obsService, "No observer service");
obsService->AddObserver(this, NS_FORMSUBMIT_SUBJECT, PR_TRUE);
obsService->AddObserver(this, NS_EARLYFORMSUBMIT_SUBJECT, PR_TRUE);
nsCOMPtr<nsIWebProgress> progress = do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
NS_ASSERTION(progress, "No web progress service");

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

@ -115,7 +115,7 @@ nsFormHistory::Init()
{
nsCOMPtr<nsIObserverService> service = do_GetService("@mozilla.org/observer-service;1");
if (service)
service->AddObserver(this, NS_FORMSUBMIT_SUBJECT, PR_TRUE);
service->AddObserver(this, NS_EARLYFORMSUBMIT_SUBJECT, PR_TRUE);
return NS_OK;
}

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

@ -180,7 +180,7 @@ nsFormHistory::Init()
nsCOMPtr<nsIObserverService> service = do_GetService("@mozilla.org/observer-service;1");
if (service)
service->AddObserver(this, NS_FORMSUBMIT_SUBJECT, PR_TRUE);
service->AddObserver(this, NS_EARLYFORMSUBMIT_SUBJECT, PR_TRUE);
return NS_OK;
}