зеркало из https://github.com/mozilla/gecko-dev.git
fixes bug 199108 "Changes to cookie prefs need restart to take effect"
patch=dwitte r=kaie sr=darin
This commit is contained in:
Родитель
fb42cf1bd8
Коммит
b9fe63f8b7
|
@ -89,9 +89,7 @@ nsCookieService::~nsCookieService()
|
||||||
// clean up memory
|
// clean up memory
|
||||||
COOKIE_RemoveAll();
|
COOKIE_RemoveAll();
|
||||||
|
|
||||||
if (gCookiePrefObserver) {
|
NS_IF_RELEASE(gCookiePrefObserver);
|
||||||
delete gCookiePrefObserver;
|
|
||||||
}
|
|
||||||
if (sCookieList) {
|
if (sCookieList) {
|
||||||
delete sCookieList;
|
delete sCookieList;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +97,8 @@ nsCookieService::~nsCookieService()
|
||||||
|
|
||||||
nsresult nsCookieService::Init()
|
nsresult nsCookieService::Init()
|
||||||
{
|
{
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
// install the main cookie pref observer (defined in nsCookieService.h)
|
// install the main cookie pref observer (defined in nsCookieService.h)
|
||||||
// this will be integrated into nsCookieService when nsCookies is removed.
|
// this will be integrated into nsCookieService when nsCookies is removed.
|
||||||
gCookiePrefObserver = new nsCookiePrefObserver();
|
gCookiePrefObserver = new nsCookiePrefObserver();
|
||||||
|
@ -109,8 +109,12 @@ nsresult nsCookieService::Init()
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init nsCookiePrefObserver, and fail if it can't get the prefbranch
|
||||||
|
NS_ADDREF(gCookiePrefObserver);
|
||||||
|
rv = gCookiePrefObserver->Init();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// cache mCookieFile
|
// cache mCookieFile
|
||||||
nsresult rv;
|
|
||||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mCookieFile));
|
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mCookieFile));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
rv = mCookieFile->AppendNative(NS_LITERAL_CSTRING(kCookieFileName2));
|
rv = mCookieFile->AppendNative(NS_LITERAL_CSTRING(kCookieFileName2));
|
||||||
|
|
|
@ -72,9 +72,7 @@ class nsCookiePrefObserver : public nsIObserver
|
||||||
nsCookiePrefObserver();
|
nsCookiePrefObserver();
|
||||||
virtual ~nsCookiePrefObserver();
|
virtual ~nsCookiePrefObserver();
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
nsresult Install();
|
|
||||||
nsresult ReadPrefs();
|
nsresult ReadPrefs();
|
||||||
nsresult Remove();
|
|
||||||
|
|
||||||
// member variables for caching prefs
|
// member variables for caching prefs
|
||||||
#ifdef MOZ_PHOENIX
|
#ifdef MOZ_PHOENIX
|
||||||
|
@ -115,7 +113,7 @@ public:
|
||||||
NS_DECL_NSICOOKIESERVICE
|
NS_DECL_NSICOOKIESERVICE
|
||||||
|
|
||||||
nsCookieService();
|
nsCookieService();
|
||||||
virtual ~nsCookieService(void);
|
virtual ~nsCookieService();
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -125,15 +125,18 @@ static const char kCookiesStrictDomains[] = "network.cookie.strictDomains";
|
||||||
|
|
||||||
nsCookiePrefObserver::nsCookiePrefObserver()
|
nsCookiePrefObserver::nsCookiePrefObserver()
|
||||||
{
|
{
|
||||||
nsresult rv;
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal;
|
nsresult
|
||||||
|
nsCookiePrefObserver::Init()
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
// install and cache the preferences observer
|
// install and cache the preferences observer
|
||||||
mPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
mPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_FAILED(rv)) return rv;
|
||||||
prefInternal = do_QueryInterface(mPrefBranch, &rv);
|
|
||||||
}
|
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(mPrefBranch, &rv);
|
||||||
|
|
||||||
// add observers
|
// add observers
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
@ -151,20 +154,22 @@ nsCookiePrefObserver::nsCookiePrefObserver()
|
||||||
#endif
|
#endif
|
||||||
prefInternal->AddObserver(kCookiesAskPermission, this, PR_TRUE);
|
prefInternal->AddObserver(kCookiesAskPermission, this, PR_TRUE);
|
||||||
prefInternal->AddObserver(kCookiesStrictDomains, this, PR_TRUE);
|
prefInternal->AddObserver(kCookiesStrictDomains, this, PR_TRUE);
|
||||||
|
|
||||||
// initialize prefs
|
|
||||||
rv = ReadPrefs();
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
NS_WARNING("Error occured reading cookie preferences");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize prefs
|
||||||
|
rv = ReadPrefs();
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
NS_WARNING("Error occured reading cookie preferences");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCookiePrefObserver::~nsCookiePrefObserver()
|
nsCookiePrefObserver::~nsCookiePrefObserver()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsCookiePrefObserver, nsIObserver)
|
NS_IMPL_ISUPPORTS2(nsCookiePrefObserver, nsIObserver, nsISupportsWeakReference)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsCookiePrefObserver::Observe(nsISupports *aSubject,
|
nsCookiePrefObserver::Observe(nsISupports *aSubject,
|
||||||
|
@ -173,9 +178,8 @@ nsCookiePrefObserver::Observe(nsISupports *aSubject,
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
// check the topic, and the cached prefservice
|
// check the topic
|
||||||
if (!mPrefBranch ||
|
if (nsCRT::strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
|
||||||
nsCRT::strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,11 +304,6 @@ nsCookiePrefObserver::ReadPrefs()
|
||||||
{
|
{
|
||||||
nsresult rv, rv2 = NS_OK;
|
nsresult rv, rv2 = NS_OK;
|
||||||
|
|
||||||
// check the prefservice is cached
|
|
||||||
if (!mPrefBranch) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRInt32 tempPrefValue;
|
PRInt32 tempPrefValue;
|
||||||
#ifdef MOZ_PHOENIX
|
#ifdef MOZ_PHOENIX
|
||||||
rv = mPrefBranch->GetBoolPref(kCookiesEnabled, &tempPrefValue);
|
rv = mPrefBranch->GetBoolPref(kCookiesEnabled, &tempPrefValue);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче