mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Bug 193078 - cookies file loses entries if you switch to a new profile and then quit. r=mvl@exedo.nl/sr=darin/a=asa
This commit is contained in:
parent
94be522015
commit
d265cec7f1
@ -123,7 +123,7 @@ nsresult nsCookieManager::Init()
|
||||
|
||||
NS_IMETHODIMP nsCookieManager::RemoveAll(void) {
|
||||
::COOKIE_RemoveAll();
|
||||
::COOKIE_Write(nsnull);
|
||||
::COOKIE_Write();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -80,18 +80,13 @@ nsresult nsCookieService::Init()
|
||||
COOKIE_RegisterPrefCallbacks();
|
||||
nsresult rv;
|
||||
|
||||
// cache mDir
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mDir));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
COOKIE_Read();
|
||||
}
|
||||
COOKIE_Read();
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this, "profile-before-change", PR_TRUE);
|
||||
observerService->AddObserver(this, "profile-do-change", PR_TRUE);
|
||||
observerService->AddObserver(this, "xpcom-shutdown", PR_TRUE);
|
||||
observerService->AddObserver(this, "cookieIcon", PR_FALSE);
|
||||
}
|
||||
|
||||
@ -214,9 +209,9 @@ NS_IMETHODIMP nsCookieService::Observe(nsISupports *aSubject, const char *aTopic
|
||||
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
|
||||
// The profile is about to change,
|
||||
// or is going away because the application is shutting down.
|
||||
|
||||
COOKIE_Write(mDir);
|
||||
COOKIE_Write();
|
||||
COOKIE_RemoveAll();
|
||||
|
||||
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get()))
|
||||
COOKIE_DeletePersistentUserData();
|
||||
} else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
|
||||
|
@ -63,11 +63,6 @@ public:
|
||||
nsCookieService();
|
||||
virtual ~nsCookieService(void);
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
// cached IOService
|
||||
nsCOMPtr<nsIFile> mDir;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsCookieService_h__ */
|
||||
|
@ -1750,7 +1750,7 @@ COOKIE_SetCookieStringFromHttp(nsIURI * curURL, nsIURI * firstURL, nsIPrompt *aP
|
||||
|
||||
/* saves out the HTTP cookies to disk */
|
||||
PUBLIC nsresult
|
||||
COOKIE_Write(nsIFile* dir) {
|
||||
COOKIE_Write() {
|
||||
if (!cookie_changed) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1758,19 +1758,10 @@ COOKIE_Write(nsIFile* dir) {
|
||||
time_t cur_date = get_current_time();
|
||||
char date_string[36];
|
||||
nsFileSpec dirSpec;
|
||||
nsCOMPtr<nsIFileSpec> dirSpec0;
|
||||
nsresult rv;
|
||||
if (dir == nsnull) {
|
||||
rv = CKutil_ProfileDirectory(dirSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
rv = NS_NewFileSpecFromIFile(dir, getter_AddRefs(dirSpec0));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = dirSpec0->GetFileSpec(&dirSpec);
|
||||
rv = CKutil_ProfileDirectory(dirSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
dirSpec += kCookiesFileName;
|
||||
PRBool ignored;
|
||||
@ -2093,7 +2084,7 @@ COOKIE_Remove
|
||||
cookie_list->RemoveElementAt(count);
|
||||
deleteCookie((void*)cookie, nsnull);
|
||||
cookie_changed = PR_TRUE;
|
||||
COOKIE_Write(nsnull);
|
||||
COOKIE_Write();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class nsIPrompt;
|
||||
class nsIHttpChannel;
|
||||
|
||||
extern nsresult COOKIE_Read();
|
||||
extern nsresult COOKIE_Write(nsIFile* dir);
|
||||
extern nsresult COOKIE_Write();
|
||||
extern nsresult COOKIE_Notify();
|
||||
//XXX these should operate on |const char*|
|
||||
extern char * COOKIE_GetCookie(nsIURI * address);
|
||||
|
Loading…
Reference in New Issue
Block a user