aboutPage.js (1178B)
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 5 "use strict"; 6 7 /* global ExtensionAPI, XPCOMUtils, Services */ 8 9 XPCOMUtils.defineLazyServiceGetter( 10 this, 11 "resProto", 12 "@mozilla.org/network/protocol;1?name=resource", 13 Ci.nsISubstitutingProtocolHandler 14 ); 15 16 const ResourceSubstitution = "webcompat"; 17 const ProcessScriptURL = "resource://webcompat/aboutPageProcessScript.js"; 18 const ContractID = "@mozilla.org/network/protocol/about;1?what=compat"; 19 20 this.aboutPage = class extends ExtensionAPI { 21 onStartup() { 22 const { rootURI } = this.extension; 23 24 resProto.setSubstitution( 25 ResourceSubstitution, 26 Services.io.newURI("about-compat/", null, rootURI) 27 ); 28 29 if (!(ContractID in Cc)) { 30 Services.ppmm.loadProcessScript(ProcessScriptURL, true); 31 this.processScriptRegistered = true; 32 } 33 } 34 35 onShutdown() { 36 resProto.setSubstitution(ResourceSubstitution, null); 37 38 if (this.processScriptRegistered) { 39 Services.ppmm.removeDelayedProcessScript(ProcessScriptURL); 40 } 41 } 42 };