Index: extensions/p3p/src/nsP3PService.cpp
===================================================================
RCS file: /cvsroot/mozilla/extensions/p3p/src/nsP3PService.cpp,v
retrieving revision 1.27
diff -u -3 -p -r1.27 nsP3PService.cpp
--- extensions/p3p/src/nsP3PService.cpp	25 Feb 2005 20:46:27 -0000	1.27
+++ extensions/p3p/src/nsP3PService.cpp	5 Apr 2006 17:43:34 -0000
@@ -129,6 +129,7 @@ NS_IMETHODIMP
 nsP3PService::GetConsent(nsIURI         *aURI, 
                          nsIHttpChannel *aHttpChannel, 
                          PRBool          aIsForeign,
+                         const char     *cookieString,
                          nsCookiePolicy *aPolicy,
                          nsCookieStatus *aStatus)
 {
Index: netwerk/cookie/public/nsICookieConsent.idl
===================================================================
RCS file: /cvsroot/mozilla/netwerk/cookie/public/nsICookieConsent.idl,v
retrieving revision 1.4
diff -u -3 -p -r1.4 nsICookieConsent.idl
--- netwerk/cookie/public/nsICookieConsent.idl	18 Apr 2004 21:59:11 -0000	1.4
+++ netwerk/cookie/public/nsICookieConsent.idl	5 Apr 2006 17:43:35 -0000
@@ -58,6 +58,8 @@ interface nsICookieConsent : nsISupports
    * @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 @@ interface nsICookieConsent : nsISupports
   nsCookieStatus getConsent(in  nsIURI         uri,
                             in  nsIHttpChannel httpChannel,
                             in  boolean        isForeign,
+                            in  string         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 -3 -p -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	5 Apr 2006 17:43:35 -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,35 @@ nsCookieService::GetCookieStringFromHttp
     }
   }
 
+  if (mObserverService && !cookieData.IsEmpty()) {
+      nsresult nr = NS_OK;
+
+      // Send a notification with the cookie string and the channel so
+      // that Javascript components can modify the list of cookies before
+      // it's sent out
+      nsCOMPtr<nsIMutableArray> notifyData;
+      NS_NewArray(getter_AddRefs(notifyData));
+      notifyData = do_CreateInstance("@mozilla.org/array;1");
+      nr = notifyData->AppendElement( aChannel, false );
+      
+      mObserverService->NotifyObservers(notifyData, "cookie-getter", NS_ConvertUTF8toUTF16(cookieData).get());
+      
+      // extract the new cookie string
+      PRUint32 len;
+      nr = notifyData->GetLength(&len);
+      if ( NS_SUCCEEDED(nr) && len > 1) {
+	  nsCOMPtr<nsIWritableVariant> cookieDataVariant = 
+	      do_QueryElementAt(notifyData, 1);
+      
+	  if (cookieDataVariant) {
+	      nsCAutoString newCookieData;
+	      nr = cookieDataVariant->GetAsACString(newCookieData);
+	      if ( NS_SUCCEEDED(nr) )
+		  cookieData = newCookieData;
+	  }
+      }
+  }
+
   // 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 +1780,7 @@ nsCookieService::CheckPrefs(nsIURI      
     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, aCookieHeader, &aPolicy, &p3pStatus);
     }
 
     if (p3pStatus == nsICookie::STATUS_REJECTED) {
