1/* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4"use strict"; 5 6const { XPCOMUtils } = ChromeUtils.import( 7 "resource://gre/modules/XPCOMUtils.jsm" 8); 9const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); 10const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm"); 11 12function MozProtocolHandler() { 13 XPCOMUtils.defineLazyPreferenceGetter( 14 this, 15 "urlToLoad", 16 "toolkit.mozprotocol.url", 17 "https://www.mozilla.org/about/manifesto/" 18 ); 19} 20 21MozProtocolHandler.prototype = { 22 scheme: "moz", 23 defaultPort: -1, 24 protocolFlags: Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD, 25 26 newChannel(uri, loadInfo) { 27 const kCanada = "https://www.mozilla.org/contact/communities/canada/"; 28 let realURL = NetUtil.newURI( 29 uri && uri.spec == "moz://eh" ? kCanada : this.urlToLoad 30 ); 31 let channel = Services.io.newChannelFromURIWithLoadInfo(realURL, loadInfo); 32 loadInfo.resultPrincipalURI = realURL; 33 return channel; 34 }, 35 36 QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolHandler]), 37}; 38 39var EXPORTED_SYMBOLS = ["MozProtocolHandler"]; 40