Browse Source

Bug 1783623 fis about pages

Bill Gianopoulos 2 years ago
parent
commit
20b7557ad5
1 changed files with 274 additions and 0 deletions
  1. 274 0
      comm-central/patches/WIP-1783623-port1524687-suite.patch

+ 274 - 0
comm-central/patches/WIP-1783623-port1524687-suite.patch

@@ -169,3 +169,277 @@ deleted file mode 100644
 -  kSuiteContracts,
 -  kSuiteCategories
 -};
+diff --git a/suite/components/AboutRedirector.jsm b/suite/components/AboutRedirector.jsm
+new file mode 100644
+--- /dev/null
++++ b/suite/components/AboutRedirector.jsm
+@@ -0,0 +1,125 @@
++/* This Source Code Form is subject to the terms of the Mozilla Public
++ * License, v. 2.0. If a copy of the MPL was not distributed with this
++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
++
++var EXPORTED_SYMBOLS = ["AboutRedirector"];
++
++function AboutRedirector() {}
++AboutRedirector.prototype = {
++  QueryInterface: ChromeUtils.generateQI(["nsIAboutModule"]),
++
++  // Each entry in the map has the key as the part after the "about:" and the
++  // value as a record with url and flags entries. Note that each addition here
++  // should be coupled with a corresponding addition in mailComponents.manifest.
++  _redirMap: {
++    newserror: {
++      url: "chrome://messenger/content/newsError.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    rights: {
++      url: "chrome://messenger/content/aboutRights.xhtml",
++      flags:
++        Ci.nsIAboutModule.ALLOW_SCRIPT |
++        Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT,
++    },
++    support: {
++      url: "chrome://messenger/content/about-support/aboutSupport.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    preferences: {
++      url: "chrome://messenger/content/preferences/preferences.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    downloads: {
++      url: "chrome://messenger/content/downloads/aboutDownloads.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    policies: {
++      url: "chrome://messenger/content/policies/aboutPolicies.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    accountsettings: {
++      url: "chrome://messenger/content/AccountManager.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    accountsetup: {
++      url: "chrome://messenger/content/accountcreation/accountSetup.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    accountprovisioner: {
++      url: "chrome://messenger/content/newmailaccount/accountProvisioner.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    addressbook: {
++      url: "chrome://messenger/content/addressbook/aboutAddressBook.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    "3pane": {
++      url: "chrome://messenger/content/about3Pane.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    message: {
++      url: "chrome://messenger/content/aboutMessage.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    import: {
++      url: "chrome://messenger/content/aboutImport.xhtml",
++      flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
++    },
++    profiling: {
++      url:
++        "chrome://devtools/content/performance-new/aboutprofiling/index.xhtml",
++      flags:
++        Ci.nsIAboutModule.ALLOW_SCRIPT | Ci.nsIAboutModule.IS_SECURE_CHROME_UI,
++    },
++  },
++
++  /**
++   * Gets the module name from the given URI.
++   */
++  _getModuleName(aURI) {
++    // Strip out the first ? or #, and anything following it
++    let name = /[^?#]+/.exec(aURI.pathQueryRef)[0];
++    return name.toLowerCase();
++  },
++
++  getURIFlags(aURI) {
++    let name = this._getModuleName(aURI);
++    if (!(name in this._redirMap)) {
++      throw Components.Exception(`no about:${name}`, Cr.NS_ERROR_ILLEGAL_VALUE);
++    }
++    return this._redirMap[name].flags;
++  },
++
++  newChannel(aURI, aLoadInfo) {
++    let name = this._getModuleName(aURI);
++    if (!(name in this._redirMap)) {
++      throw Components.Exception(`no about:${name}`, Cr.NS_ERROR_ILLEGAL_VALUE);
++    }
++
++    let newURI = Services.io.newURI(this._redirMap[name].url);
++    let channel = Services.io.newChannelFromURIWithLoadInfo(newURI, aLoadInfo);
++    channel.originalURI = aURI;
++
++    if (
++      this._redirMap[name].flags &
++      Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT
++    ) {
++      let principal = Services.scriptSecurityManager.createContentPrincipal(
++        aURI,
++        {}
++      );
++      channel.owner = principal;
++    }
++
++    return channel;
++  },
++
++  getChromeURI(aURI) {
++    let name = this._getModuleName(aURI);
++    if (!(name in this._redirMap)) {
++      throw Components.Exception(`no about:${name}`, Cr.NS_ERROR_ILLEGAL_VALUE);
++    }
++    return Services.io.newURI(this._redirMap[name].url);
++  },
++};
+diff --git a/suite/components/components.conf b/suite/components/components.conf
+new file mode 100644
+--- /dev/null
++++ b/suite/components/components.conf
+@@ -0,0 +1,37 @@
++# HG changeset patch
++# User Bill Gianopoulos <wgianopoulos@gmail.com>
++# Date 1659988365 0
++Bug 1783623 - Convert suite binary components registration to components.conf.
++Port Bug 1524687 Part 11  to suite.
++
++diff --git a/suite/components/components.conf b/suite/components/components.conf
++new file mode 100644
++--- /dev/null
+++++ b/suite/components/components.conf
++@@ -0,0 +1,26 @@
+++# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+++# vim: set filetype=python:
+++# This Source Code Form is subject to the terms of the Mozilla Public
+++# License, v. 2.0. If a copy of the MPL was not distributed with this
+++# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+++
+++pages = [
+++    'blocked',
+++    'certerror',
+++    'data',
+++    'feeds',
+++    'life',
+++    'newserror',
+++    'privatebrowsing',
+++    'rights',
+++    'sessionrestore',
+++]
+++
+++Classes = [
+++    {
+++        'cid': '{d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}',
+++        'contract_ids': ['@mozilla.org/network/protocol/about;1?what=%s' % page
+++                         for page in pages],
+++        'constructor': 'AboutRedirector',
+++    },
+++]
+diff --git a/suite/components/nsAbout.js b/suite/components/nsAbout.js
+deleted file mode 100644
+--- a/suite/components/nsAbout.js
++++ /dev/null
+@@ -1,76 +0,0 @@
+-/* This Source Code Form is subject to the terms of the Mozilla Public
+- * License, v. 2.0. If a copy of the MPL was not distributed with this
+- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+-
+-var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+-
+-const SCRIPT = Ci.nsIAboutModule.ALLOW_SCRIPT;
+-const UNTRUSTED = Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
+-const HIDE = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT;
+-const INDEXEDDB = Ci.nsIAboutModule.ENABLE_INDEXED_DB;
+-
+-function About() { }
+-About.prototype = {
+-  Flags: SCRIPT,
+-  URI: "chrome://communicator/content/about.xhtml",
+-  blockedFlags: SCRIPT | UNTRUSTED | HIDE,
+-  blockedURI: "chrome://communicator/content/blockedSite.xhtml",
+-  certerrorFlags: SCRIPT | UNTRUSTED | HIDE,
+-  certerrorURI: "chrome://communicator/content/certError.xhtml",
+-  dataFlags: SCRIPT,
+-  dataURI: "chrome://communicator/content/dataman/dataman.xhtml",
+-  feedsFlags: SCRIPT | UNTRUSTED | HIDE,
+-  feedsURI: "chrome://communicator/content/feeds/subscribe.xhtml",
+-  lifeFlags: SCRIPT | UNTRUSTED | HIDE,
+-  lifeURI: "chrome://communicator/content/aboutLife.xhtml",
+-  newserrorFlags: SCRIPT | HIDE,
+-  newserrorURI: "chrome://messenger/content/newsError.xhtml",
+-  privatebrowsingFlags: SCRIPT,
+-  privatebrowsingURI: "chrome://communicator/content/aboutPrivateBrowsing.xhtml",
+-  rightsFlags: SCRIPT | UNTRUSTED,
+-  rightsURI: "chrome://branding/content/aboutRights.xhtml",
+-  sessionrestoreFlags: SCRIPT | HIDE,
+-  sessionrestoreURI: "chrome://communicator/content/aboutSessionRestore.xhtml",
+-  // synctabsFlags: SCRIPT,
+-  // synctabsURI: "chrome://communicator/content/aboutSyncTabs.xhtml",
+-
+-  classID: Components.ID("{d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}"),
+-  QueryInterface: ChromeUtils.generateQI([Ci.nsIAboutModule]),
+-
+-  getModule: function(aURI) {
+-    return aURI.pathQueryRef.replace(/-|\W.*$/g, "").toLowerCase();
+-  },
+-
+-  getURIFlags: function(aURI) {
+-    return this[this.getModule(aURI) + "Flags"];
+-  },
+-
+-  newChannel: function(aURI, aLoadInfo) {
+-    let module = this.getModule(aURI);
+-    let newURI = Services.io.newURI(this[module + "URI"]);
+-
+-    // We want a happy family which is always providing a loadInfo object.
+-    if (!aLoadInfo) {
+-      // Write out an error so that we have a stack and can fix the caller.
+-      Cu.reportError('aLoadInfo was not provided in nsAbout.newChannel!');
+-    }
+-
+-    let channel = aLoadInfo ?
+-                  Services.io.newChannelFromURIWithLoadInfo(newURI, aLoadInfo) :
+-                  Services.io.newChannelFromURI(newURI, null,
+-                                                Services.scriptSecurityManager.getSystemPrincipal(),
+-                                                null,
+-                                                Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
+-                                                Ci.nsIContentPolicy.TYPE_OTHER);
+-
+-    channel.originalURI = aURI;
+-    if (this[module + "Flags"] & UNTRUSTED) {
+-      let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
+-      channel.owner = principal;
+-    }
+-    return channel;
+-  },
+-};
+-
+-var NSGetFactory = XPCOMUtils.generateNSGetFactory([About]);
+diff --git a/suite/installer/package-manifest.in b/suite/installer/package-manifest.in
+--- a/suite/installer/package-manifest.in
++++ b/suite/installer/package-manifest.in
+@@ -166,17 +166,16 @@
+ @RESPATH@/components/SuiteSidebar.manifest
+ @RESPATH@/components/toolkitsearch.manifest
+ ; JavaScript components
+ @RESPATH@/components/cryptoComponents.manifest
+ @RESPATH@/components/FeedConverter.js
+ @RESPATH@/components/FeedWriter.js
+ @RESPATH@/components/jsconsole-clhandler.js
+ @RESPATH@/components/jsconsole-clhandler.manifest
+-@RESPATH@/components/nsAbout.js
+ @RESPATH@/components/nsBrowserContentHandler.js
+ @RESPATH@/components/nsComposerCmdLineHandler.js
+ @RESPATH@/components/nsComposerCmdLineHandler.manifest
+ @RESPATH@/components/nsGopherProtocolStubHandler.js
+ @RESPATH@/components/nsPlacesAutoComplete.js
+ @RESPATH@/components/nsPlacesAutoComplete.manifest
+ @RESPATH@/components/nsSessionStartup.js
+ @RESPATH@/components/nsSessionStartup.manifest