Bug 1470324 - Don't load enterprise policies in the content during startup. r=kmag
With this patch, EnterprisePoliciesContent.js will only be loaded whenever a check for isAllowed happens in content.
This patch also adds shortcuts to make sure that checks for about:blank, about:neterror and about:certerror are skipped
MozReview-Commit-ID: AdMrolJqouN
--- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp
+++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp
@@ -180,17 +180,22 @@ nsAboutProtocolHandler::NewChannel2(nsIU
nsresult rv2 = NS_GetAboutModuleName(uri, path);
if (NS_SUCCEEDED(rv2)) {
if (path.EqualsLiteral("srcdoc")) {
// about:srcdoc is meant to be unresolvable, yet is included in the
// about lookup tables so that it can pass security checks when used in
// a srcdoc iframe. To ensure that it stays unresolvable, we pretend
// that it doesn't exist.
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
- } else {
+ } else if (!path.EqualsLiteral("blank") &&
+ !path.EqualsLiteral("neterror") &&
+ !path.EqualsLiteral("home") &&
+ !path.EqualsLiteral("welcome") &&
+ !path.EqualsLiteral("newtab") &&
+ !path.EqualsLiteral("certerror")) {
nsCOMPtr<nsIEnterprisePolicies> policyManager =
do_GetService("@mozilla.org/browser/enterprisepolicies;1", &rv2);
if (NS_SUCCEEDED(rv2)) {
nsAutoCString normalizedURL;
normalizedURL.AssignLiteral("about:");
normalizedURL.Append(path);
rv2 = policyManager->IsAllowed(normalizedURL, &aboutPageAllowed);
if (NS_FAILED(rv2)) {
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -973,20 +973,23 @@ nsXREDirProvider::DoStartup()
appStartup->RestartInSafeMode(nsIAppStartup::eForceQuit);
return NS_OK;
}
}
static const char16_t kStartup[] = {'s','t','a','r','t','u','p','\0'};
obsSvc->NotifyObservers(nullptr, "profile-do-change", kStartup);
- // Initialize the Enterprise Policies service
- nsCOMPtr<nsIObserver> policies(do_GetService("@mozilla.org/browser/enterprisepolicies;1"));
- if (policies) {
- policies->Observe(nullptr, "policies-startup", nullptr);
+ // Initialize the Enterprise Policies service in the parent process
+ // In the content process it's loaded on demand when needed
+ if (XRE_IsParentProcess()) {
+ nsCOMPtr<nsIObserver> policies(do_GetService("@mozilla.org/browser/enterprisepolicies;1"));
+ if (policies) {
+ policies->Observe(nullptr, "policies-startup", nullptr);
+ }
}
// Init the Extension Manager
nsCOMPtr<nsIObserver> em = do_GetService("@mozilla.org/addons/integration;1");
if (em) {
em->Observe(nullptr, "addons-startup", nullptr);
} else {
NS_WARNING("Failed to create Addons Manager.");