зеркало из https://github.com/mozilla/pjs.git
Fix pref observer usage so that nsFormHistory notices when the user has turned off form autofill (bug 254485). r=ben.
This commit is contained in:
Родитель
ea2f3df3b9
Коммит
be6b93ebc9
|
@ -143,12 +143,15 @@ nsFormHistory::FormHistoryEnabled()
|
||||||
{
|
{
|
||||||
if (!gPrefsInitialized) {
|
if (!gPrefsInitialized) {
|
||||||
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
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);
|
prefService->GetBranch(PREF_FORMFILL_BRANCH,
|
||||||
branchInternal->AddObserver(PREF_FORMFILL_BRANCH, gFormHistory, PR_TRUE);
|
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;
|
gPrefsInitialized = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -338,8 +341,7 @@ NS_IMETHODIMP
|
||||||
nsFormHistory::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
nsFormHistory::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
||||||
{
|
{
|
||||||
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
||||||
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(aSubject);
|
mPrefBranch->GetBoolPref(PREF_FORMFILL_ENABLE, &gFormHistoryEnabled);
|
||||||
branch->GetBoolPref(PREF_FORMFILL_ENABLE, &gFormHistoryEnabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
|
#include "nsIPrefBranch.h"
|
||||||
#include "nsWeakReference.h"
|
#include "nsWeakReference.h"
|
||||||
#include "mdb.h"
|
#include "mdb.h"
|
||||||
|
|
||||||
|
@ -101,6 +102,7 @@ protected:
|
||||||
static PRBool gPrefsInitialized;
|
static PRBool gPrefsInitialized;
|
||||||
|
|
||||||
nsCOMPtr<nsIMdbFactory> mMdbFactory;
|
nsCOMPtr<nsIMdbFactory> mMdbFactory;
|
||||||
|
nsCOMPtr<nsIPrefBranch> mPrefBranch;
|
||||||
nsIMdbEnv* mEnv;
|
nsIMdbEnv* mEnv;
|
||||||
nsIMdbStore* mStore;
|
nsIMdbStore* mStore;
|
||||||
nsIMdbTable* mTable;
|
nsIMdbTable* mTable;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче