Fix pref observer usage so that nsFormHistory notices when the user has turned off form autofill (bug 254485). r=ben.
git-svn-id: svn://10.0.0.236/trunk@165194 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
d046585f1b
commit
50bfc9ec48
@ -143,12 +143,15 @@ nsFormHistory::FormHistoryEnabled()
|
||||
{
|
||||
if (!gPrefsInitialized) {
|
||||
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIPrefBranch> branch;
|
||||
prefService->GetBranch(PREF_FORMFILL_BRANCH, getter_AddRefs(branch));
|
||||
branch->GetBoolPref(PREF_FORMFILL_ENABLE, &gFormHistoryEnabled);
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> branchInternal = do_QueryInterface(branch);
|
||||
branchInternal->AddObserver(PREF_FORMFILL_BRANCH, gFormHistory, PR_TRUE);
|
||||
prefService->GetBranch(PREF_FORMFILL_BRANCH,
|
||||
getter_AddRefs(gFormHistory->mPrefBranch));
|
||||
gFormHistory->mPrefBranch->GetBoolPref(PREF_FORMFILL_ENABLE,
|
||||
&gFormHistoryEnabled);
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> branchInternal =
|
||||
do_QueryInterface(gFormHistory->mPrefBranch);
|
||||
branchInternal->AddObserver(PREF_FORMFILL_ENABLE, gFormHistory, PR_TRUE);
|
||||
|
||||
gPrefsInitialized = PR_TRUE;
|
||||
}
|
||||
@ -338,8 +341,7 @@ NS_IMETHODIMP
|
||||
nsFormHistory::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
||||
{
|
||||
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
||||
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(aSubject);
|
||||
branch->GetBoolPref(PREF_FORMFILL_ENABLE, &gFormHistoryEnabled);
|
||||
mPrefBranch->GetBoolPref(PREF_FORMFILL_ENABLE, &gFormHistoryEnabled);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "mdb.h"
|
||||
|
||||
@ -101,6 +102,7 @@ protected:
|
||||
static PRBool gPrefsInitialized;
|
||||
|
||||
nsCOMPtr<nsIMdbFactory> mMdbFactory;
|
||||
nsCOMPtr<nsIPrefBranch> mPrefBranch;
|
||||
nsIMdbEnv* mEnv;
|
||||
nsIMdbStore* mStore;
|
||||
nsIMdbTable* mTable;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user