Bug 1447341 - stop querying prefs for fake protocols we use internally, r?hurley draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 17 Apr 2018 15:48:13 +0100
changeset 784349 3e207bbdc9d0ed8d6aa9606a89616fa1e76ea755
parent 784348 a2b76e9b7c1ac1195a1977ff928b66aa6955cab9
push id106899
push userbmo:gijskruitbosch+bugs@gmail.com
push dateWed, 18 Apr 2018 12:35:51 +0000
reviewershurley
bugs1447341
milestone61.0a1
Bug 1447341 - stop querying prefs for fake protocols we use internally, r?hurley MozReview-Commit-ID: EXUupEKlsSM
netwerk/base/nsIOService.cpp
netwerk/base/nsIOService.h
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -517,16 +517,22 @@ UsesExternalProtocolHandler(const char* 
         NS_LITERAL_CSTRING("chrome").Equals(aScheme) ||
         NS_LITERAL_CSTRING("resource").Equals(aScheme)) {
         // Don't allow file:, chrome: or resource: URIs to be handled with
         // nsExternalProtocolHandler, since internally we rely on being able to
         // use and read from these URIs.
         return false;
     }
 
+    for (unsigned int i = 0; i < NS_N(gForcedExternalSchemes); i++) {
+      if (!nsCRT::strcasecmp(gForcedExternalSchemes[i], aScheme)) {
+        return true;
+      }
+    }
+
     nsAutoCString pref("network.protocol-handler.external.");
     pref += aScheme;
 
     return Preferences::GetBool(pref.get(), false);
 }
 
 NS_IMETHODIMP
 nsIOService::GetProtocolHandler(const char* scheme, nsIProtocolHandler* *result)
--- a/netwerk/base/nsIOService.h
+++ b/netwerk/base/nsIOService.h
@@ -30,16 +30,19 @@
 // See Bug 552829
 #define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
 #define NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC "ipc:network:set-connectivity"
 
 static const char gScheme[][sizeof("moz-safe-about")] =
     {"chrome", "file", "http", "https", "jar", "data", "about", "moz-safe-about", "resource",
      "moz-extension", "page-icon", "blob"};
 
+static const char gForcedExternalSchemes[][sizeof("moz-nullprincipal")] =
+    {"place", "fake-favicon-uri", "favicon", "moz-nullprincipal"};
+
 class nsINetworkLinkService;
 class nsIPrefBranch;
 class nsIProtocolProxyService2;
 class nsIProxyInfo;
 class nsPISocketTransportService;
 
 namespace mozilla {
 namespace net {