From b898d4522b80c60e6ff03126a4506d880a940f7f Mon Sep 17 00:00:00 2001 From: "morse%netscape.com" Date: Fri, 15 Feb 2002 03:01:32 +0000 Subject: [PATCH] bug 113143, cookie module to call compact-policy parser, r=sgehani,harishd, sr=jag --- extensions/cookie/MANIFEST_IDL | 1 + extensions/cookie/Makefile.in | 1 + extensions/cookie/makefile.win | 1 + extensions/cookie/nsCookies.cpp | 29 +++++---------- extensions/cookie/nsICookieConsent.idl | 51 ++++++++++++++++++++++++++ extensions/p3p/src/Makefile.in | 1 + extensions/p3p/src/makefile.win | 1 + extensions/p3p/src/nsP3PModule.cpp | 2 +- extensions/p3p/src/nsP3PService.cpp | 2 +- extensions/p3p/src/nsP3PService.h | 10 ++--- 10 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 extensions/cookie/nsICookieConsent.idl diff --git a/extensions/cookie/MANIFEST_IDL b/extensions/cookie/MANIFEST_IDL index cc67ca8f09a9..2a1bb17a075e 100644 --- a/extensions/cookie/MANIFEST_IDL +++ b/extensions/cookie/MANIFEST_IDL @@ -3,3 +3,4 @@ nsICookieManager.idl nsIImgManager.idl nsIPermission.idl nsIPermissionManager.idl +nsICookieConsent.idl diff --git a/extensions/cookie/Makefile.in b/extensions/cookie/Makefile.in index e3ea52c044c7..544f3c5ab62f 100644 --- a/extensions/cookie/Makefile.in +++ b/extensions/cookie/Makefile.in @@ -64,6 +64,7 @@ CPPSRCS = \ XPIDLSRCS = \ nsICookieManager.idl \ + nsICookieConsent.idl \ nsIImgManager.idl \ nsIPermissionManager.idl \ nsICookie.idl \ diff --git a/extensions/cookie/makefile.win b/extensions/cookie/makefile.win index c4f3ff7e7a2e..c08ab215199d 100644 --- a/extensions/cookie/makefile.win +++ b/extensions/cookie/makefile.win @@ -40,6 +40,7 @@ REQUIRES = xpcom \ EXPORTS = nsCookieHTTPNotify.h XPIDLSRCS= .\nsICookieManager.idl \ + .\nsICookieConsent.idl \ .\nsIImgManager.idl \ .\nsIPermissionManager.idl \ .\nsICookie.idl \ diff --git a/extensions/cookie/nsCookies.cpp b/extensions/cookie/nsCookies.cpp index 5a7ac1bd94c5..27200dff37fa 100644 --- a/extensions/cookie/nsCookies.cpp +++ b/extensions/cookie/nsCookies.cpp @@ -52,7 +52,7 @@ #include "nsTextFormatter.h" #include "nsAppDirectoryServiceDefs.h" #include "nsIObserverService.h" -//!!!!!#include "nsIP3PService.h" +#include "nsICookieConsent.h" #define MAX_NUMBER_OF_COOKIES 300 #define MAX_COOKIES_PER_SERVER 20 @@ -131,6 +131,7 @@ PRIVATE char* cookie_P3P = nsnull; * The following defines are used to refer to these character positions and values */ +#define P3P_UnknownPolicy -1 #define P3P_NoPolicy 0 #define P3P_NoConsent 2 #define P3P_ImplicitConsent 4 @@ -404,12 +405,6 @@ cookie_BehaviorPrefChanged(const char * newpref, void * data) { n = PERMISSION_Accept; } - if (n == PERMISSION_P3P) { - // load p3p dll -//!!!!! nsCOMPtr p3p(do_GetService(NS_P3PSERVICE_CONTRACTID)); -//!!!!! if (!p3p) return 0; - } - cookie_SetBehaviorPref((PERMISSION_BehaviorEnum)n); return 0; } @@ -516,12 +511,6 @@ COOKIE_RegisterPrefCallbacks(void) { n = PERMISSION_Accept; } - if (n == PERMISSION_P3P) { - // load p3p dll -//!!!!! nsCOMPtr p3p(do_GetService(NS_P3PSERVICE_CONTRACTID)); -//!!!!! if (!p3p) return; - } - cookie_SetBehaviorPref((PERMISSION_BehaviorEnum)n); prefs->RegisterCallback(cookie_behaviorPref, cookie_BehaviorPrefChanged, nsnull); @@ -856,7 +845,7 @@ cookie_GetPolicy(int policy) { case P3P_NoIdentInfo: return nsICookie::POLICY_NO_II; } - return nsICookie::POLICY_NONE; + return nsICookie::POLICY_UNKNOWN; } /* @@ -865,11 +854,13 @@ cookie_GetPolicy(int policy) { */ int P3P_SitePolicy(char * curURL, nsIHttpChannel* aHttpChannel) { - int consent = P3P_NoPolicy; -//!!!!! nsCOMPtr p3p(do_GetService(NS_P3PSERVICE_CONTRACTID)); -//!!!!! if (p3p) { -//!!!!! p3p->GetConsent(curURL,aHttpChannel,&consent); -//!!!!! } + int consent = P3P_UnknownPolicy; + if (cookie_GetBehaviorPref() == PERMISSION_P3P) { + nsCOMPtr p3p(do_GetService(NS_COOKIECONSENT_CONTRACTID)); + if (p3p) { + p3p->GetConsent(curURL,aHttpChannel,&consent); + } + } return consent; } diff --git a/extensions/cookie/nsICookieConsent.idl b/extensions/cookie/nsICookieConsent.idl new file mode 100644 index 000000000000..af56b2c0b939 --- /dev/null +++ b/extensions/cookie/nsICookieConsent.idl @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +interface nsIHttpChannel; + +[scriptable,uuid(F5A34F50-1F39-11d6-A627-0010A401EB10)] +interface nsICookieConsent : nsISupports { + long getConsent(in string aURI, + in nsIHttpChannel aHttpChannel); +}; + +%{C++ +#define NS_COOKIECONSENT_CONTRACTID "@mozilla.org/cookie-consent;1" +%} diff --git a/extensions/p3p/src/Makefile.in b/extensions/p3p/src/Makefile.in index fd4aa330fe4a..decd737b1f91 100644 --- a/extensions/p3p/src/Makefile.in +++ b/extensions/p3p/src/Makefile.in @@ -37,6 +37,7 @@ REQUIRES = xpcom \ string \ necko \ pref \ + cookie \ $(NULL) CPPSRCS = \ diff --git a/extensions/p3p/src/makefile.win b/extensions/p3p/src/makefile.win index bfa9021cf0e1..29301170a4cf 100644 --- a/extensions/p3p/src/makefile.win +++ b/extensions/p3p/src/makefile.win @@ -46,6 +46,7 @@ REQUIRES = xpcom \ string \ necko \ pref \ + cookie \ $(NULL) include <$(DEPTH)\config\config.mak> diff --git a/extensions/p3p/src/nsP3PModule.cpp b/extensions/p3p/src/nsP3PModule.cpp index 1aa7f3f65b05..323eed770798 100644 --- a/extensions/p3p/src/nsP3PModule.cpp +++ b/extensions/p3p/src/nsP3PModule.cpp @@ -51,7 +51,7 @@ static nsModuleComponentInfo gP3PComponents[] = { {"P3P Service", NS_P3PSERVICE_CID, - NS_P3PSERVICE_CONTRACTID, + NS_COOKIECONSENT_CONTRACTID, nsP3PServiceConstructor, } }; diff --git a/extensions/p3p/src/nsP3PService.cpp b/extensions/p3p/src/nsP3PService.cpp index fae9c7710963..3a18656bec6a 100644 --- a/extensions/p3p/src/nsP3PService.cpp +++ b/extensions/p3p/src/nsP3PService.cpp @@ -83,7 +83,7 @@ StopListeningToHeaders(nsP3PService* aService) { ***********************************/ NS_IMPL_ISUPPORTS3(nsP3PService, - nsIP3PService, + nsICookieConsent, nsIHttpNotify, nsINetNotify); diff --git a/extensions/p3p/src/nsP3PService.h b/extensions/p3p/src/nsP3PService.h index a07ac2b068be..895ed57f995d 100644 --- a/extensions/p3p/src/nsP3PService.h +++ b/extensions/p3p/src/nsP3PService.h @@ -39,14 +39,14 @@ #ifndef NS_P3PSERVICE_H__ #define NS_P3PSERVICE_H__ -#include "nsIP3PService.h" +#include "nsICookieConsent.h" #include "nsIHttpNotify.h" #include "nsCompactPolicy.h" #include "nsIObserver.h" class nsIPrefBranch; -class nsP3PService : public nsIP3PService, +class nsP3PService : public nsICookieConsent, public nsIHttpNotify, public nsIObserver { @@ -55,15 +55,15 @@ public: NS_DECL_ISUPPORTS // nsIHttpNotify NS_DECL_NSIHTTPNOTIFY - // nsIP3PService - NS_DECL_NSIP3PSERVICE + // nsICookieConsent + NS_DECL_NSICOOKIECONSENT // nsIObserver NS_DECL_NSIOBSERVER nsP3PService( ); virtual ~nsP3PService( ); - // nsP3PService + // P3PService nsresult Init(); protected: nsresult ProcessResponseHeader(nsIHttpChannel* aHttpChannel);