Bug 837351 - Log blocked mixed content to the Error and Web Consoles. r=smaug

This commit is contained in:
Garrett Robinson 2013-04-22 18:08:18 -07:00
parent e1712a3ad0
commit 6c7617d947
5 changed files with 27 additions and 1 deletions

View File

@ -795,6 +795,7 @@ public:
eBRAND_PROPERTIES,
eCOMMON_DIALOG_PROPERTIES,
eMATHML_PROPERTIES,
eSECURITY_PROPERTIES,
PropertiesFile_COUNT
};
static nsresult ReportToConsole(uint32_t aErrorFlags,

View File

@ -3224,7 +3224,8 @@ static const char gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT][56] = {
"chrome://global/locale/svg/svg.properties",
"chrome://branding/locale/brand.properties",
"chrome://global/locale/commonDialogs.properties",
"chrome://global/locale/mathml/mathml.properties"
"chrome://global/locale/mathml/mathml.properties",
"chrome://global/locale/security/security.properties"
};
/* static */ nsresult

View File

@ -25,6 +25,7 @@
#include "nsIDocumentLoader.h"
#include "nsIWebNavigation.h"
#include "nsLoadGroup.h"
#include "nsIScriptError.h"
#include "prlog.h"
@ -146,6 +147,24 @@ nsMixedContentBlocker::~nsMixedContentBlocker()
NS_IMPL_ISUPPORTS1(nsMixedContentBlocker, nsIContentPolicy)
void
LogBlockingMixedContent(MixedContentTypes classification,
nsIURI* aContentLocation,
nsIDocument* aRootDoc)
{
nsAutoCString locationSpec;
aContentLocation->GetSpec(locationSpec);
NS_ConvertUTF8toUTF16 locationSpecUTF16(locationSpec);
const PRUnichar* strings[] = { locationSpecUTF16.get() };
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
"Mixed Content Blocker",
aRootDoc,
nsContentUtils::eSECURITY_PROPERTIES,
classification == eMixedDisplay ? "BlockMixedDisplayContent" : "BlockMixedActiveContent",
strings, ArrayLength(strings));
}
NS_IMETHODIMP
nsMixedContentBlocker::ShouldLoad(uint32_t aContentType,
nsIURI* aContentLocation,
@ -441,6 +460,7 @@ nsMixedContentBlocker::ShouldLoad(uint32_t aContentType,
}
} else {
*aDecision = nsIContentPolicy::REJECT_REQUEST;
LogBlockingMixedContent(classification, aContentLocation, rootDoc);
if (!rootDoc->GetHasMixedDisplayContentBlocked() && NS_SUCCEEDED(stateRV)) {
eventSink->OnSecurityChange(aRequestingContext, (State | nsIWebProgressListener::STATE_BLOCKED_MIXED_DISPLAY_CONTENT));
}
@ -481,6 +501,7 @@ nsMixedContentBlocker::ShouldLoad(uint32_t aContentType,
} else {
//User has not overriden the pref by Disabling protection. Reject the request and update the security state.
*aDecision = nsIContentPolicy::REJECT_REQUEST;
LogBlockingMixedContent(classification, aContentLocation, rootDoc);
// See if the pref will change here. If it will, only then do we need to call OnSecurityChange() to update the UI.
if (rootDoc->GetHasMixedActiveContentBlocked()) {
return NS_OK;

View File

@ -0,0 +1,2 @@
BlockMixedDisplayContent = Blocked loading mixed display content "%1$S"
BlockMixedActiveContent = Blocked loading mixed active content "%1$S"

View File

@ -27,6 +27,7 @@
locale/@AB_CD@/global/layout/HtmlForm.properties (%chrome/layout/HtmlForm.properties)
locale/@AB_CD@/global/security/caps.properties (%chrome/security/caps.properties)
locale/@AB_CD@/global/security/csp.properties (%chrome/security/csp.properties)
locale/@AB_CD@/global/security/security.properties (%chrome/security/security.properties)
locale/@AB_CD@/global/xml/prettyprint.dtd (%chrome/xml/prettyprint.dtd)
locale/@AB_CD@/global-platform/win/accessible.properties (%chrome/accessibility/win/accessible.properties)
locale/@AB_CD@/global-platform/mac/accessible.properties (%chrome/accessibility/mac/accessible.properties)