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:
@@ -6508,6 +6508,7 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
||||
// Bug 1629201 is filed for having much clearer decision making around
|
||||
// which cases need error events.
|
||||
bool fireFrameErrorEvent = (aStatus == NS_ERROR_CONTENT_BLOCKED_SHOW_ALT ||
|
||||
aStatus == NS_ERROR_BLOCKED_BY_POLICY ||
|
||||
aStatus == NS_ERROR_CONTENT_BLOCKED);
|
||||
UnblockEmbedderLoadEventForFailure(fireFrameErrorEvent);
|
||||
|
||||
@@ -8426,8 +8427,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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user