Bug 1416066 - Add a new flag to nsIAboutModule to load URIs in privileged content processes if feature is enabled. draft
authorimjching <jlim@mozilla.com>
Tue, 03 Jul 2018 19:31:37 -0400
changeset 816200 0e2d733382abb40cd11a7a20e86ff874ec85a7ee
parent 816199 c3982c467554a582fa238bbd0e702f1c1b1fb0ce
child 816201 a2a9d156bf2ce952abb5ffafcfdd7f8eff0a4177
child 817032 7e14c3555dd1680062e6b91cc940aa69fcdce1f0
child 817367 f9e957a79a091aa8ff5b4e752b7dfeb6578c277c
child 817496 e4344669418b6b309eeee889ab220c8acfe014c6
push id115771
push userbmo:jlim@mozilla.com
push dateTue, 10 Jul 2018 17:44:26 +0000
bugs1416066
milestone63.0a1
Bug 1416066 - Add a new flag to nsIAboutModule to load URIs in privileged content processes if feature is enabled. We will apply the URI_CAN_LOAD_IN_PRIVILEGED_CHILD flag to Activity Stream about: pages instead of hardcoding the URLs in a Set. MozReview-Commit-ID: F6AGmsKs1SR
browser/components/about/AboutRedirector.cpp
netwerk/protocol/about/nsIAboutModule.idl
toolkit/modules/E10SUtils.jsm
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -23,16 +23,17 @@ NS_IMPL_ISUPPORTS(AboutRedirector, nsIAb
 
 bool AboutRedirector::sNewTabPageEnabled = false;
 bool AboutRedirector::sNewCertErrorPageEnabled = false;
 
 static const uint32_t ACTIVITY_STREAM_FLAGS =
   nsIAboutModule::ALLOW_SCRIPT |
   nsIAboutModule::ENABLE_INDEXED_DB |
   nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
+  nsIAboutModule::URI_CAN_LOAD_IN_PRIVILEGED_CHILD |
   nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT;
 
 struct RedirEntry {
   const char* id;
   const char* url;
   uint32_t flags;
 };
 
@@ -87,16 +88,17 @@ static const RedirEntry kRedirMap[] = {
   { "welcomeback", "chrome://browser/content/aboutWelcomeBack.xhtml",
     nsIAboutModule::ALLOW_SCRIPT |
     nsIAboutModule::HIDE_FROM_ABOUTABOUT },
   // Actual activity stream URL for home and newtab are set in channel creation
   { "home", "about:blank", ACTIVITY_STREAM_FLAGS },
   { "newtab", "about:blank", ACTIVITY_STREAM_FLAGS },
   { "welcome", "about:blank",
     nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
+    nsIAboutModule::URI_CAN_LOAD_IN_PRIVILEGED_CHILD |
     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
     nsIAboutModule::ALLOW_SCRIPT },
   { "library", "chrome://browser/content/aboutLibrary.xhtml",
     nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
   { "preferences", "chrome://browser/content/preferences/in-content/preferences.xul",
     nsIAboutModule::ALLOW_SCRIPT },
   { "downloads", "chrome://browser/content/downloads/contentAreaDownloadsView.xul",
--- a/netwerk/protocol/about/nsIAboutModule.idl
+++ b/netwerk/protocol/about/nsIAboutModule.idl
@@ -5,21 +5,21 @@
 
 #include "nsISupports.idl"
 
 interface nsIURI;
 interface nsIChannel;
 interface nsILoadInfo;
 
 [scriptable, uuid(c0c19db9-1b5a-4ac5-b656-ed6f8149fa48)]
-interface nsIAboutModule : nsISupports 
+interface nsIAboutModule : nsISupports
 {
 
     /**
-     * Constructs a new channel for the about protocol module. 
+     * Constructs a new channel for the about protocol module.
      *
      * @param aURI the uri of the new channel
      * @param aLoadInfo the loadinfo of the new channel
      */
     nsIChannel newChannel(in nsIURI aURI,
                           in nsILoadInfo aLoadInfo);
 
     /**
@@ -67,22 +67,29 @@ interface nsIAboutModule : nsISupports
 
     /**
      * A flag that indicates that this URI should be linkable from content.
      * Ignored unless URI_SAFE_FOR_UNTRUSTED_CONTENT is also specified.
      */
     const unsigned long MAKE_LINKABLE = (1 << 7);
 
     /**
+     * A flag that indicates that this URI can be loaded in the privileged
+     * content process if privileged content process is enabled. Ignored unless
+     * URI_MUST_LOAD_IN_CHILD is also specified.
+     */
+    const unsigned long URI_CAN_LOAD_IN_PRIVILEGED_CHILD = (1 << 8);
+
+    /**
      * A method to get the flags that apply to a given about: URI.  The URI
      * passed in is guaranteed to be one of the URIs that this module
      * registered to deal with.
      */
     unsigned long getURIFlags(in nsIURI aURI);
 };
 
 %{C++
 
-#define NS_ABOUT_MODULE_CONTRACTID        "@mozilla.org/network/protocol/about;1" 
-#define NS_ABOUT_MODULE_CONTRACTID_PREFIX NS_ABOUT_MODULE_CONTRACTID "?what=" 
+#define NS_ABOUT_MODULE_CONTRACTID        "@mozilla.org/network/protocol/about;1"
+#define NS_ABOUT_MODULE_CONTRACTID_PREFIX NS_ABOUT_MODULE_CONTRACTID "?what="
 #define NS_ABOUT_MODULE_CONTRACTID_LENGTH 49      // strlen(NS_ABOUT_MODULE_CONTRACTID_PREFIX)
 
 %}
--- a/toolkit/modules/E10SUtils.jsm
+++ b/toolkit/modules/E10SUtils.jsm
@@ -38,18 +38,16 @@ const WEB_REMOTE_TYPE = "web";
 const FILE_REMOTE_TYPE = "file";
 const EXTENSION_REMOTE_TYPE = "extension";
 const PRIVILEGED_REMOTE_TYPE = "privileged";
 
 // This must start with the WEB_REMOTE_TYPE above.
 const LARGE_ALLOCATION_REMOTE_TYPE = "webLargeAllocation";
 const DEFAULT_REMOTE_TYPE = WEB_REMOTE_TYPE;
 
-const ACTIVITY_STREAM_PAGES = new Set(["home", "newtab", "welcome"]);
-
 function validatedWebRemoteType(aPreferredRemoteType, aTargetUri, aCurrentUri) {
   // If the domain is whitelisted to allow it to use file:// URIs, then we have
   // to run it in a file content process, in case it uses file:// sub-resources.
   const sm = Services.scriptSecurityManager;
   if (sm.inFileURIWhitelist(aTargetUri)) {
     return FILE_REMOTE_TYPE;
   }
 
@@ -154,19 +152,18 @@ var E10SUtils = {
         // If the module doesn't exist then an error page will be loading, that
         // should be ok to load in any process
         if (!module) {
           return aPreferredRemoteType;
         }
 
         let flags = module.getURIFlags(aURI);
         if (flags & Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD) {
-          // Load Activity Stream in a separate process.
-          if (useSeparatePrivilegedContentProcess &&
-              ACTIVITY_STREAM_PAGES.has(aURI.filePath)) {
+          if ((flags & Ci.nsIAboutModule.URI_CAN_LOAD_IN_PRIVILEGED_CHILD) &&
+              useSeparatePrivilegedContentProcess) {
             return PRIVILEGED_REMOTE_TYPE;
           }
           return DEFAULT_REMOTE_TYPE;
         }
 
         // If the about page can load in parent or child, it should be safe to
         // load in any remote type.
         if (flags & Ci.nsIAboutModule.URI_CAN_LOAD_IN_CHILD) {