Fix accumulated P3P build bustage. b=75924 (and 62399) moa=harishd sr=tor

git-svn-id: svn://10.0.0.236/trunk@101397 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%fas.harvard.edu 2001-08-18 03:05:48 +00:00
parent f7df03c0cb
commit 29b48554fd
13 changed files with 299 additions and 448 deletions

View File

@ -30,9 +30,9 @@
#include "nsP3PLogging.h"
#include "nsIDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIProperties.h"
#include "nsIFile.h"
#include "nsStdURL.h"
#include "nsNetUtil.h"
@ -135,25 +135,19 @@ nsP3PDataSchema::PostInit( nsString& aURISpec ) {
// Create a URL of the components directory
rv = compsDir->GetURL( getter_Copies( xcsPath ) );
if (NS_SUCCEEDED( rv )) {
// Make the local path the URI to be read
mUseDOMParser = PR_TRUE;
mReadURISpec.AssignWithConversion((const char *)xcsPath );
mReadURISpec.AppendWithConversion( P3P_BASE_DATASCHEMA_LOCAL_NAME );
mcsReadURISpec.AssignWithConversion( mReadURISpec );
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PDataSchema: %s PostInit, redirecting base DataSchema to %s.\n", (const char *)mcsURISpec, (const char *)mcsReadURISpec) );
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PDataSchema: %s PostInit, compsDirURI->GetSpec failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) );
}
}
else {
// Make the local path the URI to be read
mUseDOMParser = PR_TRUE;
mReadURISpec.AssignWithConversion((const char *)xcsPath );
mReadURISpec.AppendWithConversion( P3P_BASE_DATASCHEMA_LOCAL_NAME );
mcsReadURISpec.AssignWithConversion( mReadURISpec );
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PDataSchema: %s PostInit, redirecting base DataSchema to %s.\n", (const char *)mcsURISpec, (const char *)mcsReadURISpec) );
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PDataSchema: %s PostInit, Creation of nsIFileURL failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) );
("P3PDataSchema: %s PostInit, GetURL failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) );
}
}
else {

View File

@ -271,7 +271,7 @@
printf( "P3P: Request Method: %s\n", (const char *)csMethodDebug ); \
\
nsCOMPtr<nsISimpleEnumerator> pHeadersDebug; \
nsCOMPtr<nsIHTTPHeader> pHeaderDebug; \
nsCOMPtr<nsIHttpHeader> pHeaderDebug; \
nsXPIDLCString xcsKeyDebug, xcsValueDebug; \
PRBool bMoreElementsDebug; \
\
@ -305,7 +305,7 @@
printf( "P3P: Response: %i %s\n", uiStatusDebug, (const char *)xcsStatusDebug ); \
\
nsCOMPtr<nsISimpleEnumerator> pHeadersDebug; \
nsCOMPtr<nsIHTTPHeader> pHeaderDebug; \
nsCOMPtr<nsIHttpHeader> pHeaderDebug; \
nsXPIDLCString xcsKeyDebug, xcsValueDebug; \
PRBool bMoreElementsDebug; \
\

View File

@ -28,7 +28,6 @@
#include "nsIServiceManager.h"
#include "nsIHTTPHeader.h"
#include "nsIURI.h"
#include "nsILoadGroup.h"
@ -46,12 +45,12 @@
static NS_DEFINE_CID( kNetModuleMgrCID, NS_NETMODULEMGR_CID );
// P3P HTTP Notify: nsISupports
NS_IMPL_ISUPPORTS2( nsP3PHTTPNotify, nsIHTTPNotify,
NS_IMPL_ISUPPORTS2( nsP3PHTTPNotify, nsIHttpNotify,
nsINetNotify );
// P3P HTTP Notify: Creation routine
NS_METHOD
NS_NewP3PHTTPNotify( nsIHTTPNotify **aHTTPNotify ) {
NS_NewP3PHTTPNotify( nsIHttpNotify **aHTTPNotify ) {
nsresult rv;
@ -74,7 +73,7 @@ NS_NewP3PHTTPNotify( nsIHTTPNotify **aHTTPNotify ) {
rv = pNewHTTPNotify->Init( );
if (NS_SUCCEEDED( rv )) {
rv = pNewHTTPNotify->QueryInterface( NS_GET_IID( nsIHTTPNotify ),
rv = pNewHTTPNotify->QueryInterface( NS_GET_IID( nsIHttpNotify ),
(void **)aHTTPNotify );
}
@ -125,97 +124,48 @@ nsP3PHTTPNotify::Init( ) {
PR_LOG_NOTICE,
("P3PHTTPNotify: Init, initializing.\n") );
// Create the "P3P" atom
mP3PHeader = NS_NewAtom( P3P_HTTPEXT_P3P_KEY );
if (!mP3PHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: Init, NS_NewAtom for \"P3P\" failed.\n") );
NS_ASSERTION( 0, "P3P: P3PHTTPNotify unable to create \"P3P\" atom.\n" );
rv = NS_ERROR_OUT_OF_MEMORY;
}
// Get the Network Module Manager service to register the listeners
mNetModuleMgr = do_GetService( kNetModuleMgrCID,
&rv );
if (NS_SUCCEEDED( rv )) {
// Create the "Set-Cookie" atom
mSetCookieHeader = NS_NewAtom( P3P_HTTP_SETCOOKIE_KEY );
if (!mSetCookieHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: Init, NS_NewAtom for \"Set-Cookie\" failed.\n") );
NS_ASSERTION( 0, "P3P: P3PHTTPNotify unable to create \"Set-Cookie\" atom.\n" );
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED( rv )) {
// Create the "Content-Type" atom
mContentTypeHeader = NS_NewAtom( P3P_HTTP_CONTENTTYPE_KEY );
if (!mContentTypeHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: Init, NS_NewAtom for \"Content-Type\" failed.\n") );
NS_ASSERTION( 0, "P3P: P3PHTTPNotify unable to create \"Content-Type\" atom.\n" );
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED( rv )) {
// Create the "Referer" atom
mRefererHeader = NS_NewAtom( P3P_HTTP_REFERER_KEY );
if (!mRefererHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: Init, NS_NewAtom for \"Referer\" failed.\n") );
NS_ASSERTION( 0, "P3P: P3PHTTPNotify unable to create \"Referer\" atom.\n" );
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED( rv )) {
// Get the Network Module Manager service to register the listeners
mNetModuleMgr = do_GetService( kNetModuleMgrCID,
&rv );
// Register this object to listen for response headers
rv = mNetModuleMgr->RegisterModule( NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_CONTRACTID,
this );
if (NS_SUCCEEDED( rv )) {
// Register this object to listen for response headers
rv = mNetModuleMgr->RegisterModule( NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_CONTRACTID,
#ifdef DEBUG_P3P
// Only register for request headers for debug build
rv = mNetModuleMgr->RegisterModule( NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_CONTRACTID,
this );
if (NS_SUCCEEDED( rv )) {
#ifdef DEBUG_P3P
// Only register for request headers for debug build
rv = mNetModuleMgr->RegisterModule( NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_CONTRACTID,
this );
if (NS_FAILED( rv )) {
printf( "P3P: HTTPNotify Request registration failed: %X\n", rv );
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: Init, mNetModuleMgr->RegisterModule for HTTP responses failed - %X.\n", rv) );
}
#endif
}
else {
#ifdef DEBUG_P3P
printf( "P3P: HTTPNotify Response registration failed: %X\n", rv );
#endif
if (NS_FAILED( rv )) {
printf( "P3P: HTTPNotify Request registration failed: %X\n", rv );
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: Init, mNetModuleMgr->RegisterModule for HTTP responses failed - %X.\n", rv) );
}
#endif
}
else {
#ifdef DEBUG_P3P
printf( "P3P: Unable to obtain Network Module Manager Service: %X\n", rv );
printf( "P3P: HTTPNotify Response registration failed: %X\n", rv );
#endif
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: Init, do_GetService for Network Module Manager service failed - %X.\n", rv) );
("P3PHTTPNotify: Init, mNetModuleMgr->RegisterModule for HTTP responses failed - %X.\n", rv) );
}
}
else {
#ifdef DEBUG_P3P
printf( "P3P: Unable to obtain Network Module Manager Service: %X\n", rv );
#endif
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: Init, do_GetService for Network Module Manager service failed - %X.\n", rv) );
}
return rv;
@ -223,24 +173,22 @@ nsP3PHTTPNotify::Init( ) {
// ****************************************************************************
// nsIHTTPNotify routines
// nsIHttpNotify routines
// ****************************************************************************
// P3P HTTP Notify: ModifyRequest
// P3P HTTP Notify: OnModifyRequest
//
// Function: Allows modification to the request headers before they are sent to the server.
//
// Parms: 1. In The HTTPChannel object of the request
//
NS_IMETHODIMP
nsP3PHTTPNotify::ModifyRequest( nsISupports *aContext ) {
nsP3PHTTPNotify::OnModifyRequest( nsIHttpChannel* aHttpChannel ) {
// Not used in retail build, just satisfying the interface
#ifdef DEBUG_P3P
nsresult rv;
nsCOMPtr<nsIHTTPChannel> pHTTPChannel;
nsCOMPtr<nsIURI> pURI;
@ -248,19 +196,12 @@ nsP3PHTTPNotify::ModifyRequest( nsISupports *aContext ) {
rv = GetP3PService( );
if (NS_SUCCEEDED( rv ) && mP3PIsEnabled) {
// Make sure we have an HTTP channel
pHTTPChannel = do_QueryInterface( aContext,
&rv );
rv = aHttpChannel->GetURI( getter_AddRefs( pURI ) );
if (NS_SUCCEEDED( rv )) {
rv = pHTTPChannel->GetURI( getter_AddRefs( pURI ) );
if (NS_SUCCEEDED( rv )) {
if (!mP3PService->IsP3PRelatedURI( pURI )) {
P3P_PRINT_REQUEST_HEADERS( pHTTPChannel );
}
if (!mP3PService->IsP3PRelatedURI( pURI )) {
P3P_PRINT_REQUEST_HEADERS( pHTTPChannel );
}
}
}
@ -276,12 +217,10 @@ nsP3PHTTPNotify::ModifyRequest( nsISupports *aContext ) {
// Parms: 1. In The HTTPChannel object of the response
//
NS_IMETHODIMP
nsP3PHTTPNotify::AsyncExamineResponse( nsISupports *aContext ) {
nsP3PHTTPNotify::OnExamineResponse( nsIHttpChannel* aHttpChannel ) {
nsresult rv;
nsCOMPtr<nsIHTTPChannel> pHTTPChannel;
nsXPIDLCString xcsURISpec,
xcsStatus;
@ -292,8 +231,6 @@ nsP3PHTTPNotify::AsyncExamineResponse( nsISupports *aContext ) {
nsCOMPtr<nsIURI> pURI;
nsCOMPtr<nsIAtom> pRequestMethod;
nsAutoString sRequestMethod;
nsCOMPtr<nsIDocShellTreeItem> pDocShellTreeItem;
@ -303,131 +240,126 @@ nsP3PHTTPNotify::AsyncExamineResponse( nsISupports *aContext ) {
rv = GetP3PService( );
if (NS_SUCCEEDED( rv ) && mP3PIsEnabled) {
// Make sure we have an HTTP channel
pHTTPChannel = do_QueryInterface( aContext,
&rv );
rv = aHttpChannel->GetURI( getter_AddRefs( pURI ) );
if (NS_SUCCEEDED( rv )) {
rv = pHTTPChannel->GetURI( getter_AddRefs( pURI ) );
if (NS_SUCCEEDED( rv )) {
if (!mP3PService->IsP3PRelatedURI( pURI )) {
if (!mP3PService->IsP3PRelatedURI( pURI )) {
#ifdef DEBUG_P3P
{ P3P_PRINT_RESPONSE_HEADERS( pHTTPChannel );
}
{ P3P_PRINT_RESPONSE_HEADERS( aHttpChannel );
}
#endif
pURI->GetSpec( getter_Copies( xcsURISpec ) );
pHTTPChannel->GetResponseStatus(&uiStatus );
pHTTPChannel->GetResponseString( getter_Copies( xcsStatus ) );
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PHTTPNotify: AsyncExamineRequest, Receiving document %s - %i %s.\n", (const char *)xcsURISpec, uiStatus, (const char *)xcsStatus) );
pURI->GetSpec( getter_Copies( xcsURISpec ) );
aHttpChannel->GetResponseStatus(&uiStatus );
aHttpChannel->GetResponseStatusText( getter_Copies( xcsStatus ) );
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PHTTPNotify: AsyncExamineRequest, Receiving document %s - %i %s.\n", (const char *)xcsURISpec, uiStatus, xcsStatus.get()) );
// Process the request headers related to and important to P3P
ProcessRequestHeaders( pHTTPChannel );
// Process the request headers related to and important to P3P
ProcessRequestHeaders( aHttpChannel );
// Process the response headers related to and important to P3P
ProcessResponseHeaders( pHTTPChannel );
// Process the response headers related to and important to P3P
ProcessResponseHeaders( aHttpChannel );
if (((uiStatus / 100) != 1) && ((uiStatus / 100) != 3)) {
// Not an informational or redirection status
if (((uiStatus / 100) != 1) && ((uiStatus / 100) != 3)) {
// Not an informational or redirection status
// Look for the "content-type" response header
rv = pHTTPChannel->GetResponseHeader( mContentTypeHeader,
getter_Copies( xcsHeaderValue ) );
// Look for the "content-type" response header
rv = aHttpChannel->GetResponseHeader( P3P_HTTP_CONTENTTYPE_KEY,
getter_Copies( xcsHeaderValue ) );
if (NS_SUCCEEDED( rv )) {
PRBool bCheckPrivacy = PR_FALSE;
if (NS_SUCCEEDED( rv )) {
PRBool bCheckPrivacy = PR_FALSE;
if ((uiStatus / 100) == 2) {
// OK response, so "content-type" should be valid
if (xcsHeaderValue) {
nsCAutoString csHeaderValue((const char *)xcsHeaderValue );
if ((uiStatus / 100) == 2) {
// OK response, so "content-type" should be valid
if (xcsHeaderValue) {
nsCAutoString csHeaderValue((const char *)xcsHeaderValue );
if (!IsHTMLorXML( csHeaderValue )) {
// Not HTML or XML, so we don't have to wait for <LINK> tag detection
bCheckPrivacy = PR_TRUE;
}
}
else {
// No "content-type" header, check privacy
if (!IsHTMLorXML( csHeaderValue )) {
// Not HTML or XML, so we don't have to wait for <LINK> tag detection
bCheckPrivacy = PR_TRUE;
}
}
else {
// Not an OK response, so perform the check
// No "content-type" header, check privacy
bCheckPrivacy = PR_TRUE;
}
}
else {
// Not an OK response, so perform the check
bCheckPrivacy = PR_TRUE;
}
if (bCheckPrivacy) {
// Privacy Check to be performed now
if (bCheckPrivacy) {
// Privacy Check to be performed now
#ifdef DEBUG_P3P
{ printf( "P3P: Non HTML/XML or unknown content encountered, complete processing\n" );
}
{ printf( "P3P: Non HTML/XML or unknown content encountered, complete processing\n" );
}
#endif
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PHTTPNotify: AsyncExamineRequest, Non HTML/XML or unknown content encountered.\n") );
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PHTTPNotify: AsyncExamineRequest, Non HTML/XML or unknown content encountered.\n") );
// Obtain the request method used
rv = pHTTPChannel->GetRequestMethod( getter_AddRefs( pRequestMethod ) );
// Obtain the request method used
nsXPIDLCString requestMethod;
rv = aHttpChannel->GetRequestMethod( getter_Copies( requestMethod ) );
if (NS_SUCCEEDED( rv )) {
rv = pRequestMethod->ToString( sRequestMethod );
if (NS_SUCCEEDED( rv )) {
sRequestMethod.AssignWithConversion(requestMethod);
if (!sRequestMethod.IsEmpty()) {
// Get the DocShellTreeItem associated with the request
rv = GetDocShellTreeItem( aHttpChannel,
getter_AddRefs( pDocShellTreeItem ) );
if (NS_SUCCEEDED( rv )) {
// Get the DocShellTreeItem associated with the request
rv = GetDocShellTreeItem( pHTTPChannel,
getter_AddRefs( pDocShellTreeItem ) );
// Check the privacy
rv = mP3PService->CheckPrivacy( sRequestMethod,
pURI,
pDocShellTreeItem,
nsnull );
if (NS_SUCCEEDED( rv )) {
// Check the privacy
rv = mP3PService->CheckPrivacy( sRequestMethod,
pURI,
pDocShellTreeItem,
nsnull );
if (rv == P3P_PRIVACY_NOT_MET) {
// Delete set-cookie header and the cookie
if (rv == P3P_PRIVACY_NOT_MET) {
// Delete set-cookie header and the cookie
#ifdef DEBUG_P3P
{ printf( "P3P: Privacy not met, removing \"Set-Cookie\" header and cookie\n" );
}
{ printf( "P3P: Privacy not met, removing \"Set-Cookie\" header and cookie\n" );
}
#endif
rv = DeleteCookies( pHTTPChannel );
}
rv = DeleteCookies( aHttpChannel );
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: AsyncExamineResponse, pRequestMethod->ToString failed - %X.\n", rv) );
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: AsyncExamineResponse, pHTTPChannel->GetRequestMethod failed - %X.\n", rv) );
("P3PHTTPNotify: AsyncExamineResponse, AssignWithConversion failed - %X.\n", rv) );
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: AsyncExamineResponse, aHttpChannel->GetRequestMethod failed - %X.\n", rv) );
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: AsyncExamineResponse, pHTTPChannel->GetResponseHeader failed - %X.\n", rv) );
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: AsyncExamineResponse, aHttpChannel->GetResponseHeader failed - %X.\n", rv) );
}
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: AsyncExamineResponse, pHTTPChannel->GetURI failed - %X.\n", rv) );
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: AsyncExamineResponse, aHttpChannel->GetURI failed - %X.\n", rv) );
}
}
@ -448,7 +380,7 @@ nsP3PHTTPNotify::AsyncExamineResponse( nsISupports *aContext ) {
// Parms: 1. In The HTTPChannel object of the response
//
NS_METHOD_( void )
nsP3PHTTPNotify::ProcessRequestHeaders( nsIHTTPChannel *aHTTPChannel ) {
nsP3PHTTPNotify::ProcessRequestHeaders( nsIHttpChannel *aHTTPChannel ) {
nsresult rv;
@ -465,7 +397,7 @@ nsP3PHTTPNotify::ProcessRequestHeaders( nsIHTTPChannel *aHTTPChannel ) {
if (NS_SUCCEEDED( rv )) {
// Look for the "referer" request header
rv = aHTTPChannel->GetRequestHeader( mRefererHeader,
rv = aHTTPChannel->GetRequestHeader( P3P_HTTP_REFERER_KEY,
getter_Copies( xcsRefererValue ) );
if (NS_SUCCEEDED( rv )) {
@ -485,7 +417,7 @@ nsP3PHTTPNotify::ProcessRequestHeaders( nsIHTTPChannel *aHTTPChannel ) {
else if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: ProcessRequestHeaders, pHTTPChannel->GetRequestHeader \"Referer\" failed - %X.\n", rv) );
("P3PHTTPNotify: ProcessRequestHeaders, aHttpChannel->GetRequestHeader \"Referer\" failed - %X.\n", rv) );
}
}
@ -505,7 +437,7 @@ nsP3PHTTPNotify::ProcessRequestHeaders( nsIHTTPChannel *aHTTPChannel ) {
// Parms: 1. In The HTTPChannel object of the response
//
NS_METHOD_( void )
nsP3PHTTPNotify::ProcessResponseHeaders( nsIHTTPChannel *aHTTPChannel ) {
nsP3PHTTPNotify::ProcessResponseHeaders( nsIHttpChannel *aHTTPChannel ) {
nsresult rv;
@ -528,7 +460,7 @@ nsP3PHTTPNotify::ProcessResponseHeaders( nsIHTTPChannel *aHTTPChannel ) {
if (NS_SUCCEEDED( rv )) {
// Look for the "P3P" response header
rv = aHTTPChannel->GetResponseHeader( mP3PHeader,
rv = aHTTPChannel->GetResponseHeader( P3P_HTTPEXT_P3P_KEY,
getter_Copies( xcsP3PValue ) );
if (NS_SUCCEEDED( rv ) && xcsP3PValue) {
@ -551,7 +483,7 @@ nsP3PHTTPNotify::ProcessResponseHeaders( nsIHTTPChannel *aHTTPChannel ) {
if (NS_SUCCEEDED( rv )) {
// Look for the "set-cookie" response header
rv = aHTTPChannel->GetResponseHeader( mSetCookieHeader,
rv = aHTTPChannel->GetResponseHeader( P3P_HTTP_SETCOOKIE_KEY,
getter_Copies( xcsSetCookieValues ) );
if (NS_SUCCEEDED( rv ) && xcsSetCookieValues) {
@ -571,7 +503,7 @@ nsP3PHTTPNotify::ProcessResponseHeaders( nsIHTTPChannel *aHTTPChannel ) {
else if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PHTTPNotify: ProcessResponseHeaders, pHTTPChannel->GetResponseHeader \"Set-Cookie\" failed - %X.\n", rv) );
("P3PHTTPNotify: ProcessResponseHeaders, aHttpChannel->GetResponseHeader \"Set-Cookie\" failed - %X.\n", rv) );
}
}
@ -587,7 +519,7 @@ nsP3PHTTPNotify::ProcessResponseHeaders( nsIHTTPChannel *aHTTPChannel ) {
//
NS_METHOD
nsP3PHTTPNotify::ProcessP3PHeaders( nsCString& aP3PValues,
nsIHTTPChannel *aHTTPChannel ) {
nsIHttpChannel *aHTTPChannel ) {
nsresult rv;
@ -630,7 +562,7 @@ nsP3PHTTPNotify::ProcessP3PHeaders( nsCString& aP3PValues,
//
NS_METHOD
nsP3PHTTPNotify::ProcessIndividualP3PHeader( nsCString& aP3PValue,
nsIHTTPChannel *aHTTPChannel ) {
nsIHttpChannel *aHTTPChannel ) {
nsresult rv;
@ -739,7 +671,7 @@ nsP3PHTTPNotify::IsHTMLorXML( nsCString& aContentType ) {
// 2. Out The DocShellTreeItem object
//
NS_METHOD
nsP3PHTTPNotify::GetDocShellTreeItem( nsIHTTPChannel *aHTTPChannel,
nsP3PHTTPNotify::GetDocShellTreeItem( nsIHttpChannel *aHTTPChannel,
nsIDocShellTreeItem **aDocShellTreeItem ) {
nsresult rv;
@ -864,7 +796,7 @@ nsP3PHTTPNotify::GetDocShellTreeItem( nsIHTTPChannel *aHTTPChannel,
// Parms: 1. In The HTTPChannel object of the request
//
NS_METHOD
nsP3PHTTPNotify::DeleteCookies( nsIHTTPChannel *aHTTPChannel ) {
nsP3PHTTPNotify::DeleteCookies( nsIHttpChannel *aHTTPChannel ) {
nsresult rv;
@ -876,7 +808,7 @@ nsP3PHTTPNotify::DeleteCookies( nsIHTTPChannel *aHTTPChannel ) {
("P3PHTTPNotify: DeleteCookies, deleting \"Set-Cookie\" response header.\n") );
// Look for the "set-cookie" response header
rv = aHTTPChannel->GetResponseHeader( mSetCookieHeader,
rv = aHTTPChannel->GetResponseHeader( P3P_HTTP_SETCOOKIE_KEY,
getter_Copies( xcsSetCookieValues ) );
if (NS_SUCCEEDED( rv ) && xcsSetCookieValues) {
@ -885,11 +817,11 @@ nsP3PHTTPNotify::DeleteCookies( nsIHTTPChannel *aHTTPChannel ) {
#endif
// Clear the "set-cookie" response header
aHTTPChannel->SetResponseHeader( mSetCookieHeader,
aHTTPChannel->SetResponseHeader( P3P_HTTP_SETCOOKIE_KEY,
nsnull );
#ifdef DEBUG_P3P
{
aHTTPChannel->GetResponseHeader( mSetCookieHeader,
aHTTPChannel->GetResponseHeader( P3P_HTTP_SETCOOKIE_KEY,
getter_Copies( xcsSetCookieValues ) );
if (xcsSetCookieValues) {
printf( "P3P: Set-Cookie: %s\n", (const char *)xcsSetCookieValues );

View File

@ -32,19 +32,19 @@
#include "nsINetModuleMgr.h"
#include "nsIHTTPChannel.h"
#include "nsIHttpChannel.h"
#include "nsIDocShellTreeItem.h"
#include "nsIAtom.h"
class nsP3PHTTPNotify : public nsIHTTPNotify {
class nsP3PHTTPNotify : public nsIHttpNotify {
public:
// nsISupports
NS_DECL_ISUPPORTS
// nsIHTTPNotify methods
// nsIHttpNotify methods
NS_DECL_NSIHTTPNOTIFY
// nsP3PHTTPNotify methods
@ -54,20 +54,20 @@ public:
NS_METHOD Init( );
protected:
NS_METHOD_( void ) ProcessRequestHeaders( nsIHTTPChannel *aHTTPChannel );
NS_METHOD_( void ) ProcessRequestHeaders( nsIHttpChannel *aHTTPChannel );
NS_METHOD_( void ) ProcessResponseHeaders( nsIHTTPChannel *aHTTPChannel );
NS_METHOD_( void ) ProcessResponseHeaders( nsIHttpChannel *aHTTPChannel );
NS_METHOD ProcessP3PHeaders( nsCString& aP3PValues,
nsIHTTPChannel *aHTTPChannel );
nsIHttpChannel *aHTTPChannel );
NS_METHOD ProcessIndividualP3PHeader( nsCString& aP3PValue,
nsIHTTPChannel *aHTTPChannel );
nsIHttpChannel *aHTTPChannel );
NS_METHOD_( PRBool ) IsHTMLorXML( nsCString& aContentType );
NS_METHOD GetDocShellTreeItem( nsIHTTPChannel *aHTTPChannel,
NS_METHOD GetDocShellTreeItem( nsIHttpChannel *aHTTPChannel,
nsIDocShellTreeItem **aDocShellTreeItem );
NS_METHOD DeleteCookies( nsIHTTPChannel *aHTTPChannel );
NS_METHOD DeleteCookies( nsIHttpChannel *aHTTPChannel );
NS_METHOD GetP3PService( );
@ -77,15 +77,10 @@ protected:
PRBool mP3PIsEnabled; // An indicator as to whether the P3P Service is enabled
nsCOMPtr<nsINetModuleMgr> mNetModuleMgr; // The Network Module Manager
nsCOMPtr<nsIAtom> mP3PHeader, // Various request and response header types
mSetCookieHeader,
mContentTypeHeader,
mRefererHeader;
};
extern
NS_EXPORT NS_METHOD NS_NewP3PHTTPNotify( nsIHTTPNotify **aHTTPNotify );
NS_EXPORT NS_METHOD NS_NewP3PHTTPNotify( nsIHttpNotify **aHTTPNotify );
#endif /* nsP3PHTTPNotify_h___ */

View File

@ -237,7 +237,7 @@ nsP3PObserverHTML::Notify( PRUint32 aDocumentID,
&rv );
if (NS_SUCCEEDED( rv )) {
pDocument->GetDocumentURL( getter_AddRefs(pURI) );
pDocument->GetDocumentURL( &pURI );
if (pURI) {
rv = nsP3PObserverUtils::ExamineLINKTag( pURI,
@ -303,7 +303,7 @@ nsP3PObserverHTML::Notify( PRUint32 aDocumentID,
&rv );
if (NS_SUCCEEDED( rv )) {
pDocument->GetDocumentURL( getter_AddRefs(pURI) );
pDocument->GetDocumentURL( &pURI );
if (pURI) {
rv = nsP3PObserverUtils::ExamineLINKTag( pURI,

View File

@ -37,7 +37,7 @@
#include "nsCURILoader.h"
#include "nsIURILoader.h"
#include "nsILoadGroup.h"
#include "nsIHTTPChannel.h"
#include "nsIHttpChannel.h"
#include "nsISimpleEnumerator.h"
#include "nsString.h"
@ -309,12 +309,10 @@ nsP3PObserverLayout::GetRequestMethod( nsIDocShell *aDocShell,
nsCOMPtr<nsIRequest> pRequest;
nsCOMPtr<nsIHTTPChannel> pHTTPChannel;
nsCOMPtr<nsIHttpChannel> pHTTPChannel;
nsCOMPtr<nsIURI> pURI;
nsCOMPtr<nsIAtom> pRequestMethod;
// Get the load group associated with this DocShell
rv = mURILoader->GetLoadGroupForContext( aDocShell,
@ -345,16 +343,11 @@ nsP3PObserverLayout::GetRequestMethod( nsIDocShell *aDocShell,
if (bURIMatch) {
// They match, so get the request method
rv = pHTTPChannel->GetRequestMethod( getter_AddRefs( pRequestMethod ) );
nsXPIDLCString requestMethod;
rv = pHTTPChannel->GetRequestMethod( getter_Copies( requestMethod ) );
if (NS_SUCCEEDED( rv )) {
rv = pRequestMethod->ToString( aRequestMethod );
if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PObserverLayout: GetRequestMethod, pRequestMethod->ToString failed - %X.\n", rv) );
}
aRequestMethod.AssignWithConversion(requestMethod);
}
else {
PR_LOG( gP3PLogModule,

View File

@ -35,6 +35,7 @@
#include "nsIDocShell.h"
#include "nsIURI.h"
#include "nsIURILoader.h"
class nsP3PObserverLayout : public nsIObserver,

View File

@ -246,7 +246,7 @@ nsP3PObserverXML::Notify( PRUint32 aDocumentID,
&rv );
if (NS_SUCCEEDED( rv )) {
pDocument->GetDocumentURL( getter_AddRefs(pURI) );
pDocument->GetDocumentURL( &pURI );
if (pURI) {
rv = nsP3PObserverUtils::ExamineLINKTag( pURI,
@ -311,7 +311,7 @@ nsP3PObserverXML::Notify( PRUint32 aDocumentID,
&rv );
if (NS_SUCCEEDED( rv )) {
pDocument->GetDocumentURL( getter_AddRefs(pURI) );
pDocument->GetDocumentURL( &pURI );
if (pURI) {
rv = nsP3PObserverUtils::ExamineLINKTag( pURI,

View File

@ -43,7 +43,7 @@
#include "nsIGenericFactory.h"
#include "nsIHTTPProtocolHandler.h"
#include "nsIHttpProtocolHandler.h"
#include "nsLayoutCID.h"
#include "nsINameSpaceManager.h"
@ -2913,16 +2913,16 @@ nsP3PService::GetFormRequestMethod( nsIContent *aFormContent,
nsAutoString sName;
rv = aFormContent->GetAttributeCount( iAttributeCount );
rv = aFormContent->GetAttrCount( iAttributeCount );
if (NS_SUCCEEDED( rv )) {
for (iCount = 0, bAttributeFound = PR_FALSE;
NS_SUCCEEDED( rv ) && (iCount < iAttributeCount);
iCount++) {
rv = aFormContent->GetAttributeNameAt( iCount,
iNameSpaceID,
*getter_AddRefs( pName ),
*getter_AddRefs( pInclude ) );
rv = aFormContent->GetAttrNameAt( iCount,
iNameSpaceID,
*getter_AddRefs( pName ),
*getter_AddRefs( pInclude ) );
if (NS_SUCCEEDED( rv )) {
rv = pName->ToString( sName );
@ -2932,10 +2932,10 @@ nsP3PService::GetFormRequestMethod( nsIContent *aFormContent,
if (sName.EqualsIgnoreCase( "method" )) {
bAttributeFound = PR_TRUE;
rv = aFormContent->GetAttribute( iNameSpaceID,
pName,
*getter_AddRefs( pInclude ),
aURIMethod );
rv = aFormContent->GetAttr( iNameSpaceID,
pName,
*getter_AddRefs( pInclude ),
aURIMethod );
if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,

View File

@ -44,7 +44,7 @@
#include "nsIObserver.h"
#include "nsIHTTPChannel.h"
#include "nsIHttpChannel.h"
#include "nsIHttpNotify.h"
#include "nsDeque.h"
@ -200,7 +200,7 @@ protected:
nsSupportsHashtable mBrowserWindowBusyMap; // "Busy" DocShellTreeItem object to BrowserWindowData object mapping
nsCOMPtr<nsIHTTPNotify> mHTTPNotify; // The HTTP Notify Listener
nsCOMPtr<nsIHttpNotify> mHTTPNotify; // The HTTP Notify Listener
nsCOMPtr<nsIObserver> mObserverHTML; // The HTML Tag observer
nsCOMPtr<nsIObserver> mObserverXML; // The XML Tag observer
nsCOMPtr<nsIObserver> mObserverLayout; // The Layout observer

View File

@ -27,6 +27,7 @@
#include "nsP3PLogging.h"
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsIP3PUI.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptGlobalObjectOwner.h"

View File

@ -31,18 +31,18 @@
#include "nsIDOMElement.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMEvent.h"
#include "nsIChannel.h"
#include "nsIInputStream.h"
#include "nsIDOMParser.h"
#include "nsIHTTPChannel.h"
#include "nsIHttpChannel.h"
#include "nsLayoutCID.h"
#include "nsNetUtil.h"
#include "nsIHTTPHeader.h"
#include "nsIDocument.h"
@ -161,66 +161,6 @@ nsP3PXMLProcessor::Init( nsString& aURISpec ) {
}
}
if (NS_SUCCEEDED( rv )) {
// Create the "User-Agent" atom
mUserAgentHeader = NS_NewAtom( P3P_HTTP_USERAGENT_KEY );
if (!mUserAgentHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: Init, NS_NewAtom for \"User-Agent\" failed.\n") );
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED( rv )) {
// Create the "Referer" atom
mRefererHeader = NS_NewAtom( P3P_HTTP_REFERER_KEY );
if (!mRefererHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: Init, NS_NewAtom for \"Referer\" failed.\n") );
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED( rv )) {
// Create the "Cookie" atom
mCookieHeader = NS_NewAtom( P3P_HTTP_COOKIE_KEY );
if (!mCookieHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: Init, NS_NewAtom for \"Cookie\" failed.\n") );
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED( rv )) {
// Create the "Cache-Control" atom
mCacheControlHeader = NS_NewAtom( P3P_HTTP_CACHECONTROL_KEY );
if (!mCacheControlHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: Init, NS_NewAtom for \"CacheControl\" failed.\n") );
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED( rv )) {
// Create the "Pragma" atom
mPragmaHeader = NS_NewAtom( P3P_HTTP_PRAGMA_KEY );
if (!mPragmaHeader) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: Init, NS_NewAtom for \"Pragma\" failed.\n") );
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED( rv )) {
mP3PService->AddP3PRelatedURISpec( aURISpec );
mP3PRelatedURIAdded = PR_TRUE;
@ -411,55 +351,49 @@ nsP3PXMLProcessor::InlineRead( nsIDOMNode *aDOMNode,
return rv;
}
// P3P XML Processor: ModifyRequest
// P3P XML Processor: OnModifyRequest
//
// Function: Allows modification to the request headers before they are sent to the server.
//
// Parms: 1. In The HTTPChannel object of the request
//
NS_IMETHODIMP
nsP3PXMLProcessor::ModifyRequest( nsISupports *aContext ) {
nsP3PXMLProcessor::OnModifyRequest( nsIHttpChannel *aHttpChannel ) {
nsresult rv;
nsCOMPtr<nsIHTTPChannel> pHTTPChannel;
nsCOMPtr<nsIHttpChannel> pRequestHTTPChannel;
nsCOMPtr<nsIHTTPChannel> pRequestHTTPChannel;
nsCOMPtr<nsIChannel> channel;
rv = mXMLHttpRequest->GetChannel( getter_AddRefs( channel ) );
pRequestHTTPChannel = do_QueryInterface(channel);
pHTTPChannel = do_QueryInterface( aContext,
&rv );
if (NS_SUCCEEDED( rv )) {
rv = mXMLHttpRequest->GetChannel( getter_AddRefs( pRequestHTTPChannel ) );
if (NS_SUCCEEDED( rv ) && (pHTTPChannel == pRequestHTTPChannel)) {
if (NS_SUCCEEDED( rv ) && (aHttpChannel == pRequestHTTPChannel)) {
#ifdef DEBUG_P3P
{ printf( "P3P: Clearing \"Safe Zone\" headers and requesting \"no-cache\" for P3P request\n" );
}
{ printf( "P3P: Clearing \"Safe Zone\" headers and requesting \"no-cache\" for P3P request\n" );
}
#endif
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PXMLProcessor: ModifyRequest, clearing safe zone headers and requesting fresh copies for P3P URI request - %s.\n", (const char *)mcsURISpec) );
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PXMLProcessor: ModifyRequest, clearing safe zone headers and requesting fresh copies for P3P URI request - %s.\n", (const char *)mcsURISpec) );
// Clear certain request headers as part of the P3P safe zone
ClearSafeZoneHeaders( pHTTPChannel );
// Clear certain request headers as part of the P3P safe zone
ClearSafeZoneHeaders( aHttpChannel );
// Request a non-cached version of the P3P document
RequestFreshCopy( pHTTPChannel );
// Request a non-cached version of the P3P document
RequestFreshCopy( aHttpChannel );
#ifdef DEBUG_P3P
{ P3P_PRINT_REQUEST_HEADERS( pHTTPChannel );
}
{ P3P_PRINT_REQUEST_HEADERS( aHttpChannel );
}
#endif
}
else if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s ModifyRequest, mXMLHttpRequest->GetChannel failed - %X.\n", (const char *)mcsURISpec, rv) );
}
}
else if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s ModifyRequest, mXMLHttpRequest->GetChannel failed - %X.\n", (const char *)mcsURISpec, rv) );
}
return NS_OK;
}
@ -471,69 +405,65 @@ nsP3PXMLProcessor::ModifyRequest( nsISupports *aContext ) {
// Parms: 1. In The HTTPChannel object of the response
//
NS_METHOD
nsP3PXMLProcessor::AsyncExamineResponse( nsISupports *aContext ) {
nsP3PXMLProcessor::OnExamineResponse( nsIHttpChannel *aHttpChannel ) {
nsresult rv;
nsCOMPtr<nsIHTTPChannel> pHTTPChannel;
nsCOMPtr<nsIHTTPChannel> pRequestHTTPChannel;
nsCOMPtr<nsIHttpChannel> pRequestHTTPChannel;
PRUint32 uiResponseStatus,
uiResponseClass;
pHTTPChannel = do_QueryInterface( aContext,
&rv );
nsCOMPtr<nsIChannel> channel;
rv = mXMLHttpRequest->GetChannel( getter_AddRefs( channel ) );
pRequestHTTPChannel = do_QueryInterface(channel);
if (NS_SUCCEEDED( rv )) {
rv = mXMLHttpRequest->GetChannel( getter_AddRefs( pRequestHTTPChannel ) );
if (NS_SUCCEEDED( rv ) && (pHTTPChannel == pRequestHTTPChannel)) {
if (NS_SUCCEEDED( rv ) && (aHttpChannel == pRequestHTTPChannel)) {
#ifdef DEBUG_P3P
{ P3P_PRINT_RESPONSE_HEADERS( pHTTPChannel );
}
{ P3P_PRINT_RESPONSE_HEADERS( aHttpChannel );
}
#endif
rv = pHTTPChannel->GetResponseStatus(&uiResponseStatus );
rv = aHttpChannel->GetResponseStatus(&uiResponseStatus );
if (NS_SUCCEEDED( rv )) {
uiResponseClass = uiResponseStatus / 100;
if (NS_SUCCEEDED( rv )) {
uiResponseClass = uiResponseStatus / 100;
switch (uiResponseClass) {
case 3:
switch (uiResponseStatus) {
case 301:
case 302:
case 303:
case 307:
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PXMLProcessor: %s AsyncExamineResponse, request has been redirected.\n", (const char *)mcsURISpec) );
// XXX this is not the correct way to determine if a redirect occured --darin
switch (uiResponseClass) {
case 3:
switch (uiResponseStatus) {
case 301:
case 302:
case 303:
case 307:
PR_LOG( gP3PLogModule,
PR_LOG_NOTICE,
("P3PXMLProcessor: %s AsyncExamineResponse, request has been redirected.\n", (const char *)mcsURISpec) );
mRedirected = PR_TRUE;
break;
mRedirected = PR_TRUE;
break;
default:
break;
}
default:
break;
}
default:
break;
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s AsyncExamineResponse, pHTTPChannel-GetResponseStatus failed - %X.\n", (const char *)mcsURISpec, rv) );
default:
break;
}
}
else if (NS_FAILED( rv )) {
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s AsyncExamineResponse, mXMLHttpRequest->GetChannel failed - %X.\n", (const char *)mcsURISpec, rv) );
("P3PXMLProcessor: %s AsyncExamineResponse, aHttpChannel-GetResponseStatus failed - %X.\n", (const char *)mcsURISpec, rv) );
}
}
else if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s AsyncExamineResponse, mXMLHttpRequest->GetChannel failed - %X.\n", (const char *)mcsURISpec, rv) );
}
return NS_OK;
}
@ -1310,25 +1240,31 @@ nsP3PXMLProcessor::AddDOMEventListener( ) {
getter_AddRefs( mDOMEventListener ) );
if (NS_SUCCEEDED( rv )) {
// Add the load event listener
rv = mXMLHttpRequest->AddEventListener( "load",
mDOMEventListener );
nsCOMPtr<nsIDOMEventTarget> pDOMEventTarget(do_QueryInterface(mXMLHttpRequest,&rv));
if (NS_SUCCEEDED( rv )) {
rv = mXMLHttpRequest->AddEventListener( "error",
mDOMEventListener );
if(NS_SUCCEEDED(rv)) {
// Add the load event listener
rv = pDOMEventTarget->AddEventListener( NS_LITERAL_STRING("load"),
mDOMEventListener,
PR_FALSE );
if (NS_FAILED( rv )) {
if (NS_SUCCEEDED( rv )) {
rv = pDOMEventTarget->AddEventListener( NS_LITERAL_STRING("error"),
mDOMEventListener,
PR_FALSE );
if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s AddDOMEventListener, pDOMEventTarget->AddEventListener for errors failed - %X.\n", (const char *)mcsURISpec, rv) );
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s AddDOMEventListener, mXMLHttpRequest->AddEventListener for errors failed - %X.\n", (const char *)mcsURISpec, rv) );
("P3PXMLProcessor: %s AddDOMEventListener, pDOMEventTarget->AddEventListener for loads failed - %X.\n", (const char *)mcsURISpec, rv) );
}
}
else {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s AddDOMEventListener, mXMLHttpRequest->AddEventListener for loads failed - %X.\n", (const char *)mcsURISpec, rv) );
}
}
else {
PR_LOG( gP3PLogModule,
@ -1349,26 +1285,31 @@ NS_METHOD_( void )
nsP3PXMLProcessor::RemoveDOMEventListener( ) {
nsresult rv;
nsCOMPtr<nsIDOMEventTarget> pDOMEventTarget(do_QueryInterface(mXMLHttpRequest,&rv));
if(NS_SUCCEEDED(rv)) {
// Remove the load event listener
rv = pDOMEventTarget->RemoveEventListener( NS_LITERAL_STRING("load"),
mDOMEventListener,
PR_FALSE );
// Remove the load event listener
rv = mXMLHttpRequest->RemoveEventListener( "load",
mDOMEventListener );
if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s RemoveDOMEventListener, pDOMEventTarget->RemoveEventListener for loads failed - %X.\n", (const char *)mcsURISpec, rv) );
}
if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s RemoveDOMEventListener, mXMLHttpRequest->RemoveEventListener for loads failed - %X.\n", (const char *)mcsURISpec, rv) );
}
// Remove the error event listener
rv = pDOMEventTarget->RemoveEventListener( NS_LITERAL_STRING("error"),
mDOMEventListener,
PR_FALSE );
// Remove the error event listener
rv = mXMLHttpRequest->RemoveEventListener( "error",
mDOMEventListener );
if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s RemoveDOMEventListener, mXMLHttpRequest->RemoveEventListener for errors failed - %X.\n", (const char *)mcsURISpec, rv) );
if (NS_FAILED( rv )) {
PR_LOG( gP3PLogModule,
PR_LOG_ERROR,
("P3PXMLProcessor: %s RemoveDOMEventListener, pDOMEventTarget->RemoveEventListener for errors failed - %X.\n", (const char *)mcsURISpec, rv) );
}
}
mDOMEventListener = nsnull;
@ -1383,15 +1324,15 @@ nsP3PXMLProcessor::RemoveDOMEventListener( ) {
// Parms: 1. In The HTTPChannel object of the request
//
NS_METHOD_( void )
nsP3PXMLProcessor::ClearSafeZoneHeaders( nsIHTTPChannel *aHTTPChannel ) {
nsP3PXMLProcessor::ClearSafeZoneHeaders( nsIHttpChannel *aHTTPChannel ) {
aHTTPChannel->SetRequestHeader( mUserAgentHeader,
aHTTPChannel->SetRequestHeader( P3P_HTTP_USERAGENT_KEY,
nsnull );
aHTTPChannel->SetRequestHeader( mRefererHeader,
aHTTPChannel->SetRequestHeader( P3P_HTTP_REFERER_KEY,
nsnull );
aHTTPChannel->SetRequestHeader( mCookieHeader,
aHTTPChannel->SetRequestHeader( P3P_HTTP_COOKIE_KEY,
nsnull );
return;
@ -1405,12 +1346,12 @@ nsP3PXMLProcessor::ClearSafeZoneHeaders( nsIHTTPChannel *aHTTPChannel ) {
// Parms: 1. In The HTTPChannel object of the request
//
NS_METHOD_( void )
nsP3PXMLProcessor::RequestFreshCopy( nsIHTTPChannel *aHTTPChannel ) {
nsP3PXMLProcessor::RequestFreshCopy( nsIHttpChannel *aHTTPChannel ) {
aHTTPChannel->SetRequestHeader( mPragmaHeader,
aHTTPChannel->SetRequestHeader( P3P_HTTP_PRAGMA_KEY,
P3P_PRAGMA_NOCACHE );
aHTTPChannel->SetRequestHeader( mCacheControlHeader,
aHTTPChannel->SetRequestHeader( P3P_HTTP_CACHECONTROL_KEY,
P3P_CACHECONTROL_NOCACHE );
return;
@ -1685,13 +1626,13 @@ nsP3PXMLProcessorReadRequest::~nsP3PXMLProcessorReadRequest( ) {
// ****************************************************************************
// P3P XML Processor HTTP Notify: nsISupports
NS_IMPL_ISUPPORTS2( nsP3PXMLProcessorHTTPNotify, nsIHTTPNotify,
NS_IMPL_ISUPPORTS2( nsP3PXMLProcessorHTTPNotify, nsIHttpNotify,
nsINetNotify );
// P3P XML Processor HTTP Notify: Creation routine
NS_METHOD
NS_NewP3PXMLProcessorHTTPNotify( nsP3PXMLProcessor *aXMLProcessor,
nsIHTTPNotify **aXMLProcessorHTTPNotify ) {
nsIHttpNotify **aXMLProcessorHTTPNotify ) {
nsresult rv;
@ -1707,7 +1648,7 @@ NS_NewP3PXMLProcessorHTTPNotify( nsP3PXMLProcessor *aXMLProcessor,
if (pNewXMLProcessorHTTPNotify) {
NS_ADDREF( pNewXMLProcessorHTTPNotify );
rv = pNewXMLProcessorHTTPNotify->QueryInterface( NS_GET_IID( nsIHTTPNotify ),
rv = pNewXMLProcessorHTTPNotify->QueryInterface( NS_GET_IID( nsIHttpNotify ),
(void **)aXMLProcessorHTTPNotify );
NS_RELEASE( pNewXMLProcessorHTTPNotify );
@ -1737,23 +1678,23 @@ nsP3PXMLProcessorHTTPNotify::~nsP3PXMLProcessorHTTPNotify( ) {
// ****************************************************************************
// nsIHTTPNotify routines
// nsIHttpNotify routines
// ****************************************************************************
// P3P XML Processor HTTP Notify: ModifyRequest
// P3P XML Processor HTTP Notify: OnModifyRequest
NS_IMETHODIMP
nsP3PXMLProcessorHTTPNotify::ModifyRequest( nsISupports *aContext ) {
nsP3PXMLProcessorHTTPNotify::OnModifyRequest( nsIHttpChannel *aHttpChannel ) {
mXMLProcessor->ModifyRequest( aContext );
mXMLProcessor->OnModifyRequest( aHttpChannel );
return NS_OK;
}
// P3P XML Processor HTTP Notify: AsyncExamineResponse
// P3P XML Processor HTTP Notify: OnExamineResponse
NS_IMETHODIMP
nsP3PXMLProcessorHTTPNotify::AsyncExamineResponse( nsISupports *aContext ) {
nsP3PXMLProcessorHTTPNotify::OnExamineResponse( nsIHttpChannel *aHttpChannel ) {
mXMLProcessor->AsyncExamineResponse( aContext );
mXMLProcessor->OnExamineResponse( aHttpChannel );
return NS_OK;
}
@ -1819,7 +1760,7 @@ nsP3PXMLProcessorDOMEventListener::~nsP3PXMLProcessorDOMEventListener( ) {
// ****************************************************************************
// P3P XML Processor DOM Event Listener: HandleEvent
nsresult
NS_IMETHODIMP
nsP3PXMLProcessorDOMEventListener::HandleEvent( nsIDOMEvent *aEvent ) {
mXMLProcessor->HandleEvent( aEvent );

View File

@ -42,7 +42,7 @@
#include "nsINetModuleMgr.h"
#include "nsIURI.h"
#include "nsIHTTPChannel.h"
#include "nsIHttpChannel.h"
#include "nsISupportsArray.h"
@ -76,9 +76,9 @@ public:
nsIP3PXMLListener *aXMLListener,
nsISupports *aReaderData );
NS_METHOD ModifyRequest( nsISupports *aContext );
NS_METHOD OnModifyRequest( nsIHttpChannel *aHttpChannel );
NS_METHOD AsyncExamineResponse( nsISupports *aContext );
NS_METHOD OnExamineResponse( nsIHttpChannel *aHttpChannel );
NS_METHOD HandleEvent( nsIDOMEvent *aEvent );
@ -112,9 +112,9 @@ protected:
NS_METHOD_( void ) RemoveDOMEventListener( );
NS_METHOD_( void ) ClearSafeZoneHeaders( nsIHTTPChannel *aHTTPChannel );
NS_METHOD_( void ) ClearSafeZoneHeaders( nsIHttpChannel *aHTTPChannel );
NS_METHOD_( void ) RequestFreshCopy( nsIHTTPChannel *aHTTPChannel );
NS_METHOD_( void ) RequestFreshCopy( nsIHttpChannel *aHTTPChannel );
NS_METHOD_( void ) GetCacheRelatedHeaders( );
@ -136,12 +136,6 @@ protected:
nsCOMPtr<nsINetModuleMgr> mNetModuleMgr; // The Network Module Manager Service
nsCOMPtr<nsIAtom> mUserAgentHeader, // Various request and response header types
mRefererHeader,
mCookieHeader,
mCacheControlHeader,
mPragmaHeader;
nsString mDateValue, // The value of the "Date" header
mCacheControlValue, // The value of the "Cache-Control" header
mExpiresValue, // The value of the "Expires" header
@ -166,7 +160,7 @@ protected:
nsCOMPtr<nsIP3PCService> mP3PService; // The P3P Service
nsCOMPtr<nsIHTTPNotify> mHTTPNotify; // The HTTP Notify listener
nsCOMPtr<nsIHttpNotify> mHTTPNotify; // The HTTP Notify listener
nsCOMPtr<nsIDOMEventListener> mDOMEventListener; // The DOM Event listener
PRTime mExpirationTime; // The date/time when the document expires
@ -201,11 +195,11 @@ PRBool NotifyXMLProcessorReaders( nsISupports *aElement,
void *aData );
class nsP3PXMLProcessorHTTPNotify : public nsIHTTPNotify {
class nsP3PXMLProcessorHTTPNotify : public nsIHttpNotify {
// nsISupports
NS_DECL_ISUPPORTS
// nsIHTTPNotify methods
// nsIHttpNotify methods
NS_DECL_NSIHTTPNOTIFY
// nsP3PXMLProcessorReadRequest methods
@ -218,7 +212,7 @@ protected:
extern
NS_EXPORT NS_METHOD NS_NewP3PXMLProcessorHTTPNotify( nsP3PXMLProcessor *aXMLProcessor,
nsIHTTPNotify **aXMLProcessorHTTPNotify );
nsIHttpNotify **aXMLProcessorHTTPNotify );
class nsP3PXMLProcessorDOMEventListener : public nsIDOMEventListener {
@ -227,7 +221,7 @@ public:
NS_DECL_ISUPPORTS
// nsIDOMEventListener
nsresult HandleEvent( nsIDOMEvent *aEvent );
NS_IMETHOD HandleEvent( nsIDOMEvent *aEvent );
// nsP3PXMLProcessorReadRequest methods
nsP3PXMLProcessorDOMEventListener( nsP3PXMLProcessor *aXMLProcessor );