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 783634 437e50f72d5a9afd99cd2207867c9062cc7c4c0a
parent 783633 19e274628b12dd295c33ff87aa12b49e74c835bd
push id106746
push userbmo:gijskruitbosch+bugs@gmail.com
push dateTue, 17 Apr 2018 15:04:52 +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(gDefaultSchemes); i++) {
+      if (!nsCRT::strcasecmp(gDefaultSchemes[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 gDefaultSchemes[][sizeof("moz-nullprincipal")] =
+    {"place", "fake-favicon-uri", "favicon", "moz-nullprincipal"};
+
 class nsINetworkLinkService;
 class nsIPrefBranch;
 class nsIProtocolProxyService2;
 class nsIProxyInfo;
 class nsPISocketTransportService;
 
 namespace mozilla {
 namespace net {