Bug 1463748 - Fork and pref-off the new error pages r=johannh draft
authortrisha <tgupta@mozilla.com>
Tue, 12 Jun 2018 17:51:37 -0700
changeset 807425 c931afe480ca2c946aeba4aa7ac14c670c49a73e
parent 807031 0344af5522398276a98629b66df90cca6f395245
child 808635 22593ab96742e5e6a91ef193adda4b555b3ecc7e
child 809097 324a04739d41560bf29e40a6d0ccff2ac73259bc
push id113102
push userbmo:guptatrisha97@gmail.com
push dateThu, 14 Jun 2018 16:15:30 +0000
reviewersjohannh
bugs1463748
milestone62.0a1
Bug 1463748 - Fork and pref-off the new error pages r=johannh MozReview-Commit-ID: KVw4omdhuaS
browser/app/profile/firefox.js
browser/base/content/aboutNetError-new.xhtml
browser/base/jar.mn
browser/components/about/AboutRedirector.cpp
browser/components/about/AboutRedirector.h
browser/installer/allowed-dupes.mn
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -978,16 +978,19 @@ pref("app.feedback.baseURL", "https://in
 #endif
 
 // base URL for web-based marketing pages
 pref("app.productInfo.baseURL", "https://www.mozilla.org/firefox/features/");
 
 // Name of alternate about: page for certificate errors (when undefined, defaults to about:neterror)
 pref("security.alternate_certificate_error_page", "certerror");
 
+// Indicates if new certificate error page (enabled) or not
+pref("browser.security.newcerterrorpage.enabled", false);
+
 // Whether to start the private browsing mode at application startup
 pref("browser.privatebrowsing.autostart", false);
 
 // Don't try to alter this pref, it'll be reset the next time you use the
 // bookmarking dialog
 pref("browser.bookmarks.editDialog.firstEditField", "namePicker");
 
 pref("dom.ipc.plugins.flash.disable-protected-mode", false);
copy from browser/base/content/aboutNetError.xhtml
copy to browser/base/content/aboutNetError-new.xhtml
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -15,16 +15,17 @@ browser.jar:
         content/browser/aboutRobots.css               (content/aboutRobots.css)
 
         content/browser/illustrations/error-connection-failure.svg (content/illustrations/error-connection-failure.svg)
         content/browser/illustrations/error-server-not-found.svg (content/illustrations/error-server-not-found.svg)
         content/browser/illustrations/error-malformed-url.svg (content/illustrations/error-malformed-url.svg)
         content/browser/illustrations/under-construction.svg (content/illustrations/under-construction.svg)
         content/browser/aboutNetError.xhtml            (content/aboutNetError.xhtml)
         content/browser/aboutNetError.js               (content/aboutNetError.js)
+        content/browser/aboutNetError-new.xhtml        (content/aboutNetError-new.xhtml)
         content/browser/aboutRobots-icon.png          (content/aboutRobots-icon.png)
         content/browser/aboutRobots-widget-left.png   (content/aboutRobots-widget-left.png)
         content/browser/aboutTabCrashed.css           (content/aboutTabCrashed.css)
         content/browser/aboutTabCrashed.js            (content/aboutTabCrashed.js)
         content/browser/aboutTabCrashed.xhtml         (content/aboutTabCrashed.xhtml)
 *       content/browser/browser.css                   (content/browser.css)
         content/browser/browser.js                    (content/browser.js)
 *       content/browser/browser.xul                   (content/browser.xul)
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -17,16 +17,17 @@
 #include "nsServiceManagerUtils.h"
 
 namespace mozilla {
 namespace browser {
 
 NS_IMPL_ISUPPORTS(AboutRedirector, nsIAboutModule)
 
 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_SAFE_FOR_UNTRUSTED_CONTENT;
 
 struct RedirEntry {
@@ -142,31 +143,43 @@ AboutRedirector::NewChannel(nsIURI* aURI
 
   static bool sNTPEnabledCacheInited = false;
   if (!sNTPEnabledCacheInited) {
     Preferences::AddBoolVarCache(&AboutRedirector::sNewTabPageEnabled,
                                  "browser.newtabpage.enabled");
     sNTPEnabledCacheInited = true;
   }
 
+  static bool sNCEPEnabledCacheInited = false;
+  if (!sNCEPEnabledCacheInited) {
+    Preferences::AddBoolVarCache(&AboutRedirector::sNewCertErrorPageEnabled,
+                                 "browser.security.newcerterrorpage.enabled");
+    sNCEPEnabledCacheInited = true;
+  }
+
   for (auto & redir : kRedirMap) {
     if (!strcmp(path.get(), redir.id)) {
       nsAutoCString url;
 
       // Let the aboutNewTabService decide where to redirect for about:home and
       // enabled about:newtab. Disabledx about:newtab page uses fallback.
       if (path.EqualsLiteral("home") ||
           (sNewTabPageEnabled && path.EqualsLiteral("newtab")) ||
           path.EqualsLiteral("welcome")) {
         nsCOMPtr<nsIAboutNewTabService> aboutNewTabService =
           do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv);
         NS_ENSURE_SUCCESS(rv, rv);
         rv = aboutNewTabService->GetDefaultURL(url);
         NS_ENSURE_SUCCESS(rv, rv);
       }
+
+      if (sNewCertErrorPageEnabled && path.EqualsLiteral("certerror")) {
+        url.AssignASCII("chrome://browser/content/aboutNetError-new.xhtml");
+      }
+
       // fall back to the specified url in the map
       if (url.IsEmpty()) {
         url.AssignASCII(redir.url);
       }
 
       nsCOMPtr<nsIChannel> tempChannel;
       nsCOMPtr<nsIURI> tempURI;
       rv = NS_NewURI(getter_AddRefs(tempURI), url);
--- a/browser/components/about/AboutRedirector.h
+++ b/browser/components/about/AboutRedirector.h
@@ -22,14 +22,15 @@ public:
   static nsresult
     Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
 protected:
   virtual ~AboutRedirector() {}
 
 private:
   static bool sNewTabPageEnabled;
+  static bool sNewCertErrorPageEnabled;
 };
 
 } // namespace browser
 } // namespace mozilla
 
 #endif // AboutRedirector_h__
--- a/browser/installer/allowed-dupes.mn
+++ b/browser/installer/allowed-dupes.mn
@@ -148,8 +148,11 @@ browser/features/formautofill@mozilla.or
 browser/chrome/browser/res/payments/formautofill/editAddress.xhtml
 browser/features/formautofill@mozilla.org/chrome/content/editCreditCard.xhtml
 browser/chrome/browser/res/payments/formautofill/editCreditCard.xhtml
 browser/features/formautofill@mozilla.org/chrome/content/autofillEditForms.js
 browser/chrome/browser/res/payments/formautofill/autofillEditForms.js
 # Bug 1451050 - Remote settings empty dumps (will be populated with data eventually)
 browser/defaults/settings/pinning/pins.json
 browser/defaults/settings/main/tippytop.json
+# Bug 1463748 - Fork and pref-off the new error pages
+browser/chrome/browser/content/browser/aboutNetError-new.xhtml
+browser/chrome/browser/content/browser/aboutNetError.xhtml