diff --git a/content/base/src/nsCSPService.cpp b/content/base/src/nsCSPService.cpp index c757831ef0d4..3e2ee9b30537 100644 --- a/content/base/src/nsCSPService.cpp +++ b/content/base/src/nsCSPService.cpp @@ -55,7 +55,7 @@ #include "nsChannelProperties.h" /* Keeps track of whether or not CSP is enabled */ -static PRBool gCSPEnabled = PR_TRUE; +PRBool CSPService::sCSPEnabled = PR_TRUE; #ifdef PR_LOGGING static PRLogModuleInfo* gCspPRLog; @@ -63,7 +63,7 @@ static PRLogModuleInfo* gCspPRLog; CSPService::CSPService() { - nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &gCSPEnabled); + nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &sCSPEnabled); #ifdef PR_LOGGING if (!gCspPRLog) @@ -102,7 +102,7 @@ CSPService::ShouldLoad(PRUint32 aContentType, *aDecision = nsIContentPolicy::ACCEPT; // No need to continue processing if CSP is disabled - if (!gCSPEnabled) + if (!sCSPEnabled) return NS_OK; // find the principal of the document that initiated this request and see @@ -160,7 +160,7 @@ CSPService::ShouldProcess(PRUint32 aContentType, *aDecision = nsIContentPolicy::ACCEPT; // No need to continue processing if CSP is disabled - if (!gCSPEnabled) + if (!sCSPEnabled) return NS_OK; // find the nsDocument that initiated this request and see if it has a diff --git a/content/base/src/nsCSPService.h b/content/base/src/nsCSPService.h index 73dd2209b238..15052f05358e 100644 --- a/content/base/src/nsCSPService.h +++ b/content/base/src/nsCSPService.h @@ -52,7 +52,8 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSICONTENTPOLICY NS_DECL_NSICHANNELEVENTSINK - + CSPService(); virtual ~CSPService(); + static PRBool sCSPEnabled; }; diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 28ad6d28cb0e..d6f0e5f092c5 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -195,6 +195,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID); // FOR CSP (autogenerated by xpidl) #include "nsIContentSecurityPolicy.h" +#include "nsCSPService.h" #include "nsHTMLStyleSheet.h" #include "nsHTMLCSSStyleSheet.h" @@ -202,9 +203,6 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID); using namespace mozilla::dom; -/* Keeps track of whether or not CSP is enabled */ -static PRBool gCSPEnabled = PR_TRUE; - #ifdef PR_LOGGING static PRLogModuleInfo* gDocumentLeakPRLog; static PRLogModuleInfo* gCspPRLog; @@ -1409,8 +1407,6 @@ nsDocument::nsDocument(const char* aContentType) gCspPRLog = PR_NewLogModule("CSP"); #endif - nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &gCSPEnabled); - // Start out mLastStyleSheetSet as null, per spec SetDOMStringToNull(mLastStyleSheetSet); } @@ -2175,7 +2171,7 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, nsresult nsDocument::InitCSP() { - if (gCSPEnabled) { + if (CSPService::sCSPEnabled) { nsAutoString cspHeaderValue; nsAutoString cspROHeaderValue;