Bug 1163196 - Part 1: Remove instances of #ifdef PR_LOGGING in dom/security. r=froydnj

PR_LOGGING is now always defined, we can remove #ifdefs checking for it.
This commit is contained in:
Eric Rahm 2015-05-11 14:22:03 -07:00
parent bbd234182a
commit f9e1913937
4 changed files with 0 additions and 44 deletions

View File

@ -42,7 +42,6 @@
using namespace mozilla;
#if defined(PR_LOGGING)
static PRLogModuleInfo *
GetCspContextLog()
{
@ -51,7 +50,6 @@ GetCspContextLog()
gCspContextPRLog = PR_NewLogModule("CSPContext");
return gCspContextPRLog;
}
#endif
#define CSPCONTEXTLOG(args) PR_LOG(GetCspContextLog(), 4, args)
@ -107,13 +105,11 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
nsISupports* aExtra,
int16_t* outDecision)
{
#ifdef PR_LOGGING
{
nsAutoCString spec;
aContentLocation->GetSpec(spec);
CSPCONTEXTLOG(("nsCSPContext::ShouldLoad, aContentLocation: %s", spec.get()));
}
#endif
nsresult rv = NS_OK;
@ -197,13 +193,11 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
mShouldLoadCache.Put(cacheKey, *outDecision);
}
#ifdef PR_LOGGING
{
nsAutoCString spec;
aContentLocation->GetSpec(spec);
CSPCONTEXTLOG(("nsCSPContext::ShouldLoad, decision: %s, aContentLocation: %s", *outDecision ? "load" : "deny", spec.get()));
}
#endif
return NS_OK;
}
@ -1113,13 +1107,11 @@ nsCSPContext::PermitsAncestry(nsIDocShell* aDocShell, bool* outPermitsAncestry)
// there was one.
uriClone->SetUserPass(EmptyCString());
#ifdef PR_LOGGING
{
nsAutoCString spec;
uriClone->GetSpec(spec);
CSPCONTEXTLOG(("nsCSPContext::PermitsAncestry, found ancestor: %s", spec.get()));
}
#endif
ancestorsArray.AppendElement(uriClone);
}
@ -1135,13 +1127,11 @@ nsCSPContext::PermitsAncestry(nsIDocShell* aDocShell, bool* outPermitsAncestry)
// restriction not placed on subresource loads.
for (uint32_t a = 0; a < ancestorsArray.Length(); a++) {
#ifdef PR_LOGGING
{
nsAutoCString spec;
ancestorsArray[a]->GetSpec(spec);
CSPCONTEXTLOG(("nsCSPContext::PermitsAncestry, checking ancestor: %s", spec.get()));
}
#endif
// omit the ancestor URI in violation reports if cross-origin as per spec
// (it is a violation of the same-origin policy).
bool okToSendAncestor = NS_SecurityCompareURIs(ancestorsArray[a], mSelfURI, true);
@ -1184,7 +1174,6 @@ nsCSPContext::Permits(nsIURI* aURI,
true, // send violation reports
true); // send blocked URI in violation reports
#ifdef PR_LOGGING
{
nsAutoCString spec;
aURI->GetSpec(spec);
@ -1192,7 +1181,6 @@ nsCSPContext::Permits(nsIURI* aURI,
spec.get(), aDir,
*outPermits ? "allow" : "deny"));
}
#endif
return NS_OK;
}

View File

@ -19,7 +19,6 @@
using namespace mozilla;
#if defined(PR_LOGGING)
static PRLogModuleInfo*
GetCspParserLog()
{
@ -28,7 +27,6 @@ GetCspParserLog()
gCspParserPRLog = PR_NewLogModule("CSPParser");
return gCspParserPRLog;
}
#endif
#define CSPPARSERLOG(args) PR_LOG(GetCspParserLog(), 4, args)
@ -1080,7 +1078,6 @@ nsCSPParser::parseContentSecurityPolicy(const nsAString& aPolicyString,
bool aReportOnly,
uint64_t aInnerWindowID)
{
#ifdef PR_LOGGING
{
CSPPARSERLOG(("nsCSPParser::parseContentSecurityPolicy, policy: %s",
NS_ConvertUTF16toUTF8(aPolicyString).get()));
@ -1090,7 +1087,6 @@ nsCSPParser::parseContentSecurityPolicy(const nsAString& aPolicyString,
CSPPARSERLOG(("nsCSPParser::parseContentSecurityPolicy, reportOnly: %s",
(aReportOnly ? "true" : "false")));
}
#endif
NS_ASSERTION(aSelfURI, "Can not parseContentSecurityPolicy without aSelfURI");
@ -1128,14 +1124,12 @@ nsCSPParser::parseContentSecurityPolicy(const nsAString& aPolicyString,
return nullptr;
}
#ifdef PR_LOGGING
{
nsString parsedPolicy;
policy->toString(parsedPolicy);
CSPPARSERLOG(("nsCSPParser::parseContentSecurityPolicy, parsedPolicy: %s",
NS_ConvertUTF16toUTF8(parsedPolicy).get()));
}
#endif
return policy;
}

View File

@ -27,18 +27,14 @@ using namespace mozilla;
/* Keeps track of whether or not CSP is enabled */
bool CSPService::sCSPEnabled = true;
#ifdef PR_LOGGING
static PRLogModuleInfo* gCspPRLog;
#endif
CSPService::CSPService()
{
Preferences::AddBoolVarCache(&sCSPEnabled, "security.csp.enable");
#ifdef PR_LOGGING
if (!gCspPRLog)
gCspPRLog = PR_NewLogModule("CSP");
#endif
}
CSPService::~CSPService()
@ -113,14 +109,12 @@ CSPService::ShouldLoad(uint32_t aContentType,
return NS_ERROR_FAILURE;
}
#ifdef PR_LOGGING
{
nsAutoCString location;
aContentLocation->GetSpec(location);
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
("CSPService::ShouldLoad called for %s", location.get()));
}
#endif
// default decision, CSP can revise it if there's a policy to enforce
*aDecision = nsIContentPolicy::ACCEPT;
@ -210,7 +204,6 @@ CSPService::ShouldLoad(uint32_t aContentType,
principal->GetCsp(getter_AddRefs(csp));
if (csp) {
#ifdef PR_LOGGING
{
uint32_t numPolicies = 0;
nsresult rv = csp->GetPolicyCount(&numPolicies);
@ -224,7 +217,6 @@ CSPService::ShouldLoad(uint32_t aContentType,
}
}
}
#endif
// obtain the enforcement decision
// (don't pass aExtra, we use that slot for redirects)
csp->ShouldLoad(aContentType,
@ -236,14 +228,12 @@ CSPService::ShouldLoad(uint32_t aContentType,
aDecision);
}
}
#ifdef PR_LOGGING
else {
nsAutoCString uriSpec;
aContentLocation->GetSpec(uriSpec);
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
("COULD NOT get nsINode for location: %s", uriSpec.get()));
}
#endif
return NS_OK;
}
@ -326,7 +316,6 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
originalUri, // aMimeTypeGuess
&aDecision);
#ifdef PR_LOGGING
if (newUri) {
nsAutoCString newUriSpec("None");
newUri->GetSpec(newUriSpec);
@ -342,7 +331,6 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
("CSPService::AsyncOnChannelRedirect CANCELLING request."));
}
#endif
// if ShouldLoad doesn't accept the load, cancel the request
if (!NS_CP_ACCEPTED(aDecision)) {

View File

@ -14,7 +14,6 @@
#include "nsNetUtil.h"
#include "nsReadableUtils.h"
#if defined(PR_LOGGING)
static PRLogModuleInfo*
GetCspUtilsLog()
{
@ -23,7 +22,6 @@ GetCspUtilsLog()
gCspUtilsPRLog = PR_NewLogModule("CSPUtils");
return gCspUtilsPRLog;
}
#endif
#define CSPUTILSLOG(args) PR_LOG(GetCspUtilsLog(), 4, args)
@ -269,13 +267,11 @@ nsCSPBaseSrc::~nsCSPBaseSrc()
bool
nsCSPBaseSrc::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
{
#ifdef PR_LOGGING
{
nsAutoCString spec;
aUri->GetSpec(spec);
CSPUTILSLOG(("nsCSPBaseSrc::permits, aUri: %s", spec.get()));
}
#endif
return false;
}
@ -306,13 +302,11 @@ nsCSPSchemeSrc::~nsCSPSchemeSrc()
bool
nsCSPSchemeSrc::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
{
#ifdef PR_LOGGING
{
nsAutoCString spec;
aUri->GetSpec(spec);
CSPUTILSLOG(("nsCSPSchemeSrc::permits, aUri: %s", spec.get()));
}
#endif
NS_ASSERTION((!mScheme.EqualsASCII("")), "scheme can not be the empty string");
nsAutoCString scheme;
@ -344,13 +338,11 @@ nsCSPHostSrc::~nsCSPHostSrc()
bool
nsCSPHostSrc::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
{
#ifdef PR_LOGGING
{
nsAutoCString spec;
aUri->GetSpec(spec);
CSPUTILSLOG(("nsCSPHostSrc::permits, aUri: %s", spec.get()));
}
#endif
// we are following the enforcement rules from the spec, see:
// http://www.w3.org/TR/CSP11/#match-source-expression
@ -596,14 +588,12 @@ nsCSPNonceSrc::~nsCSPNonceSrc()
bool
nsCSPNonceSrc::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
{
#ifdef PR_LOGGING
{
nsAutoCString spec;
aUri->GetSpec(spec);
CSPUTILSLOG(("nsCSPNonceSrc::permits, aUri: %s, aNonce: %s",
spec.get(), NS_ConvertUTF16toUTF8(aNonce).get()));
}
#endif
return mNonce.Equals(aNonce);
}
@ -726,13 +716,11 @@ nsCSPDirective::~nsCSPDirective()
bool
nsCSPDirective::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
{
#ifdef PR_LOGGING
{
nsAutoCString spec;
aUri->GetSpec(spec);
CSPUTILSLOG(("nsCSPDirective::permits, aUri: %s", spec.get()));
}
#endif
for (uint32_t i = 0; i < mSrcs.Length(); i++) {
if (mSrcs[i]->permits(aUri, aNonce, aWasRedirected)) {
@ -838,14 +826,12 @@ nsCSPPolicy::permits(CSPDirective aDir,
bool aSpecific,
nsAString& outViolatedDirective) const
{
#ifdef PR_LOGGING
{
nsAutoCString spec;
aUri->GetSpec(spec);
CSPUTILSLOG(("nsCSPPolicy::permits, aUri: %s, aDir: %d, aSpecific: %s",
spec.get(), aDir, aSpecific ? "true" : "false"));
}
#endif
NS_ASSERTION(aUri, "permits needs an uri to perform the check!");