Bug 1450309 - Allow nSIContentPolicy to reject based on enterprise policy. r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D91487
This commit is contained in:
Michael Kaply 2020-10-03 00:02:19 +00:00
parent a9816b2cdb
commit 01ac66c721
3 changed files with 21 additions and 5 deletions

View File

@ -8431,8 +8431,13 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
&shouldLoad);
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
if (NS_SUCCEEDED(rv) && shouldLoad == nsIContentPolicy::REJECT_TYPE) {
return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
if (NS_SUCCEEDED(rv)) {
if (shouldLoad == nsIContentPolicy::REJECT_TYPE) {
return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
}
if (shouldLoad == nsIContentPolicy::REJECT_POLICY) {
return NS_ERROR_BLOCKED_BY_POLICY;
}
}
return NS_ERROR_CONTENT_BLOCKED;

View File

@ -468,6 +468,12 @@ interface nsIContentPolicy : nsISupports
*/
const short REJECT_OTHER = -4;
/**
* Returned from shouldLoad or shouldProcess if the load/process is forbiddden
* based on enterprise policy.
*/
const short REJECT_POLICY = -5;
/**
* Returned from shouldLoad or shouldProcess if the load or process request
* is not rejected.

View File

@ -588,11 +588,16 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
NS_SetRequestBlockingReasonIfNull(
aLoadInfo, nsILoadInfo::BLOCKING_REASON_CONTENT_POLICY_GENERAL);
if ((NS_SUCCEEDED(rv) && shouldLoad == nsIContentPolicy::REJECT_TYPE) &&
if (NS_SUCCEEDED(rv) &&
(contentPolicyType == nsIContentPolicy::TYPE_DOCUMENT ||
contentPolicyType == nsIContentPolicy::TYPE_SUBDOCUMENT)) {
// for docshell loads we might have to return SHOW_ALT.
return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
if (shouldLoad == nsIContentPolicy::REJECT_TYPE) {
// for docshell loads we might have to return SHOW_ALT.
return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
}
if (shouldLoad == nsIContentPolicy::REJECT_POLICY) {
return NS_ERROR_BLOCKED_BY_POLICY;
}
}
return NS_ERROR_CONTENT_BLOCKED;
}