? netwerk/cookie/src/nsCookieService-orig.cpp Index: netwerk/cookie/public/nsICookieConsent.idl =================================================================== RCS file: /cvsroot/mozilla/netwerk/cookie/public/nsICookieConsent.idl,v retrieving revision 1.4 diff -u -r1.4 nsICookieConsent.idl --- netwerk/cookie/public/nsICookieConsent.idl 18 Apr 2004 21:59:11 -0000 1.4 +++ netwerk/cookie/public/nsICookieConsent.idl 13 Dec 2006 21:34:32 -0000 @@ -41,7 +41,7 @@ interface nsIURI; interface nsIHttpChannel; -[scriptable,uuid(F5A34F50-1F39-11d6-A627-0010A401EB10)] +[scriptable,uuid(3ed2db22-106f-42fa-82c1-63271a530532)] interface nsICookieConsent : nsISupports { /** @@ -58,6 +58,8 @@ * @param isForeign * true if the cookie originates from a third-party site. this is used * to decide the cookie status based on user preferences. + * @param cookieString + * the HTTP header string specifying the cookie * @param policy * the policy for the given URI, or nsICookie::POLICY_UNKNOWN if one * cannot be found. valid values are defined in nsICookie.idl. @@ -67,6 +69,7 @@ nsCookieStatus getConsent(in nsIURI uri, in nsIHttpChannel httpChannel, in boolean isForeign, + in ACString cookieString, out nsCookiePolicy policy); }; Index: netwerk/cookie/src/nsCookieService.cpp =================================================================== RCS file: /cvsroot/mozilla/netwerk/cookie/src/nsCookieService.cpp,v retrieving revision 1.43.8.1 diff -u -r1.43.8.1 nsCookieService.cpp --- netwerk/cookie/src/nsCookieService.cpp 1 Oct 2005 04:17:50 -0000 1.43.8.1 +++ netwerk/cookie/src/nsCookieService.cpp 13 Dec 2006 21:34:32 -0000 @@ -57,6 +57,8 @@ #include "nsIFile.h" #include "nsIObserverService.h" #include "nsILineInputStream.h" +#include "nsIVariant.h" +#include "nsArray.h" #include "nsCOMArray.h" #include "nsArrayEnumerator.h" @@ -632,6 +634,36 @@ } } + if (mObserverService && !cookieData.IsEmpty()) { + // + // Send a notification with the cookie string and the channel so + // that interested components can modify the cookie string before + // it's sent out. + // + // We pass in an array containing the HTTP channel as the data + // parameter to the observer, which should append the modified + // cookie string to the array if modifications are made. This + // also makes it fast to detect if there is a modification. + // + nsCOMPtr notifyData; + NS_NewArray(getter_AddRefs(notifyData)); + nsresult rv = notifyData->AppendElement(aChannel, false); + + mObserverService->NotifyObservers(notifyData, "cookie-getter", NS_ConvertASCIItoUTF16(cookieData).get()); + + // extract the new cookie string + PRUint32 len; + rv = notifyData->GetLength(&len); + if (NS_SUCCEEDED(rv) && len > 1) { + nsCOMPtr cookieDataVariant = + do_QueryElementAt(notifyData, 1); + + if (cookieDataVariant) { + rv = cookieDataVariant->GetAsACString(cookieData); + } + } + } + // it's wasteful to alloc a new string; but we have no other choice, until we // fix the callers to use nsACStrings. if (!cookieData.IsEmpty()) { @@ -1749,7 +1781,7 @@ if (mP3PService) { // get the site policy and a status decision for the cookie PRBool isForeign = IsForeign(aHostURI, aFirstURI); - mP3PService->GetConsent(aHostURI, httpChannel, isForeign, &aPolicy, &p3pStatus); + mP3PService->GetConsent(aHostURI, httpChannel, isForeign, nsCAutoString(aCookieHeader), &aPolicy, &p3pStatus); } if (p3pStatus == nsICookie::STATUS_REJECTED) {