Bug 1470324 - Don't load enterprise policies in the content during startup. r=kmag
authorFelipe Gomes <felipc@gmail.com>
Fri, 27 Jul 2018 14:50:55 -0300
changeset 428796 dc4aad741068a627c27f6f03e42b5de428a36fbc
parent 428795 aa1a4841b26ab99c37599b22d92bf06dae8dfab8
child 428797 e042233ec1ba1a407ff258f635154759528aac84
push id67007
push userfelipc@gmail.com
push dateFri, 27 Jul 2018 17:59:24 +0000
treeherderautoland@a5bc7fb873cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1470324
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
netwerk/protocol/about/nsAboutProtocolHandler.cpp
toolkit/xre/nsXREDirProvider.cpp
--- 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.");