diff --git a/extensions/cookie/nsCookieManager.cpp b/extensions/cookie/nsCookieManager.cpp index 6d279782f39..379d2f7125d 100644 --- a/extensions/cookie/nsCookieManager.cpp +++ b/extensions/cookie/nsCookieManager.cpp @@ -123,7 +123,7 @@ nsresult nsCookieManager::Init() NS_IMETHODIMP nsCookieManager::RemoveAll(void) { ::COOKIE_RemoveAll(); - ::COOKIE_Write(nsnull); + ::COOKIE_Write(); return NS_OK; } diff --git a/extensions/cookie/nsCookieService.cpp b/extensions/cookie/nsCookieService.cpp index 58c48d0bb32..300ba2400d4 100644 --- a/extensions/cookie/nsCookieService.cpp +++ b/extensions/cookie/nsCookieService.cpp @@ -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 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")) { diff --git a/extensions/cookie/nsCookieService.h b/extensions/cookie/nsCookieService.h index 15f07448d5c..0145928b744 100644 --- a/extensions/cookie/nsCookieService.h +++ b/extensions/cookie/nsCookieService.h @@ -63,11 +63,6 @@ public: nsCookieService(); virtual ~nsCookieService(void); nsresult Init(); - -protected: - // cached IOService - nsCOMPtr mDir; - }; #endif /* nsCookieService_h__ */ diff --git a/extensions/cookie/nsCookies.cpp b/extensions/cookie/nsCookies.cpp index 0970c4e5fce..dd36ab4b78e 100644 --- a/extensions/cookie/nsCookies.cpp +++ b/extensions/cookie/nsCookies.cpp @@ -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 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; } } diff --git a/extensions/cookie/nsCookies.h b/extensions/cookie/nsCookies.h index 6c64505ba8a..2ee07f2710e 100644 --- a/extensions/cookie/nsCookies.h +++ b/extensions/cookie/nsCookies.h @@ -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);