Upstream the changes from: Bug 1431533 - Add ChromeUtils helpers for lazy module import
Please see: - https://bugzilla.mozilla.org/show_bug.cgi?id=1431533 - https://hg.mozilla.org/mozilla-central/rev/e6a7b5e11ba8 - https://groups.google.com/forum/#!topic/mozilla.dev.platform/xQaTdsrbd-g
This commit is contained in:
parent
08b2e25ac1
commit
4db49b6613
10
extensions/firefox/bootstrap.js
vendored
10
extensions/firefox/bootstrap.js
vendored
@ -26,8 +26,8 @@ const Cm = Components.manager;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function initializeDefaultPreferences() {
|
||||
/* eslint-disable semi */
|
||||
@ -120,14 +120,14 @@ function startup(aData, aReason) {
|
||||
|
||||
pdfBaseUrl = aData.resourceURI.spec;
|
||||
|
||||
Cu.import(pdfBaseUrl + "content/PdfjsChromeUtils.jsm");
|
||||
ChromeUtils.import(pdfBaseUrl + "content/PdfjsChromeUtils.jsm");
|
||||
PdfjsChromeUtils.init();
|
||||
Cu.import(pdfBaseUrl + "content/PdfjsContentUtils.jsm");
|
||||
ChromeUtils.import(pdfBaseUrl + "content/PdfjsContentUtils.jsm");
|
||||
PdfjsContentUtils.init();
|
||||
|
||||
// Load the component and register it.
|
||||
var pdfStreamConverterUrl = pdfBaseUrl + "content/PdfStreamConverter.jsm";
|
||||
Cu.import(pdfStreamConverterUrl);
|
||||
ChromeUtils.import(pdfStreamConverterUrl);
|
||||
pdfStreamConverterFactory.register(PdfStreamConverter);
|
||||
|
||||
try {
|
||||
|
@ -25,8 +25,8 @@
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var isRemote = Services.appinfo.processType ===
|
||||
Services.appinfo.PROCESS_TYPE_CONTENT;
|
||||
@ -72,10 +72,10 @@
|
||||
var pdfStreamConverterFactory = new Factory();
|
||||
|
||||
function startup() {
|
||||
Cu.import("resource://pdf.js/PdfjsContentUtils.jsm");
|
||||
ChromeUtils.import("resource://pdf.js/PdfjsContentUtils.jsm");
|
||||
PdfjsContentUtils.init();
|
||||
|
||||
Cu.import("resource://pdf.js/PdfStreamConverter.jsm");
|
||||
ChromeUtils.import("resource://pdf.js/PdfStreamConverter.jsm");
|
||||
pdfStreamConverterFactory.register(PdfStreamConverter);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ const TOPIC_PLUGINS_LIST_UPDATED = "plugins-list-updated";
|
||||
const TOPIC_PLUGIN_INFO_UPDATED = "plugin-info-updated";
|
||||
const PDF_CONTENT_TYPE = "application/pdf";
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var Svc = {};
|
||||
XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
|
||||
@ -49,9 +49,9 @@ XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
|
||||
XPCOMUtils.defineLazyServiceGetter(Svc, "pluginHost",
|
||||
"@mozilla.org/plugin/host;1",
|
||||
"nsIPluginHost");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PdfjsChromeUtils",
|
||||
ChromeUtils.defineModuleGetter(this, "PdfjsChromeUtils",
|
||||
"resource://pdf.js/PdfjsChromeUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PdfjsContentUtils",
|
||||
ChromeUtils.defineModuleGetter(this, "PdfjsContentUtils",
|
||||
"resource://pdf.js/PdfjsContentUtils.jsm");
|
||||
|
||||
function getBoolPref(aPref, aDefaultValue) {
|
||||
@ -314,7 +314,7 @@ var PdfJs = {
|
||||
|
||||
this.updateRegistration();
|
||||
let jsm = "resource://pdf.js/PdfjsChromeUtils.jsm";
|
||||
let PdfjsChromeUtils = Components.utils.import(jsm, {}).PdfjsChromeUtils;
|
||||
let PdfjsChromeUtils = ChromeUtils.import(jsm, {}).PdfjsChromeUtils;
|
||||
PdfjsChromeUtils.notifyChildOfSettingsChange(this.enabled);
|
||||
},
|
||||
|
||||
@ -342,7 +342,7 @@ var PdfJs = {
|
||||
return;
|
||||
}
|
||||
this._pdfStreamConverterFactory = new Factory();
|
||||
Cu.import("resource://pdf.js/PdfStreamConverter.jsm");
|
||||
ChromeUtils.import("resource://pdf.js/PdfStreamConverter.jsm");
|
||||
this._pdfStreamConverterFactory.register(PdfStreamConverter);
|
||||
|
||||
this._registered = true;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var EXPORTED_SYMBOLS = ["NetworkManager"];
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
this.EXPORTED_SYMBOLS = ["PdfJsTelemetry"];
|
||||
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
this.PdfJsTelemetry = {
|
||||
onViewerIsUsed() {
|
||||
|
@ -29,22 +29,22 @@ const PDF_VIEWER_WEB_PAGE = "resource://pdf.js/web/viewer.html";
|
||||
const MAX_NUMBER_OF_PREFS = 50;
|
||||
const MAX_STRING_PREF_LENGTH = 128;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||
ChromeUtils.defineModuleGetter(this, "NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NetworkManager",
|
||||
ChromeUtils.defineModuleGetter(this, "NetworkManager",
|
||||
"resource://pdf.js/PdfJsNetwork.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PdfJsTelemetry",
|
||||
ChromeUtils.defineModuleGetter(this, "PdfJsTelemetry",
|
||||
"resource://pdf.js/PdfJsTelemetry.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PdfjsContentUtils",
|
||||
ChromeUtils.defineModuleGetter(this, "PdfjsContentUtils",
|
||||
"resource://pdf.js/PdfjsContentUtils.jsm");
|
||||
|
||||
var Svc = {};
|
||||
|
@ -25,8 +25,8 @@ const Cu = Components.utils;
|
||||
const PREF_PREFIX = "PDFJSSCRIPT_PREF_PREFIX";
|
||||
const PDF_CONTENT_TYPE = "application/pdf";
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var Svc = {};
|
||||
XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
|
||||
|
@ -22,8 +22,8 @@ const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var PdfjsContentUtils = {
|
||||
_mm: null,
|
||||
@ -131,7 +131,7 @@ var PdfjsContentUtils = {
|
||||
if (Services.appinfo.processType ===
|
||||
Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
let jsm = "resource://pdf.js/PdfJs.jsm";
|
||||
let pdfjs = Components.utils.import(jsm, {}).PdfJs;
|
||||
let pdfjs = ChromeUtils.import(jsm, {}).PdfJs;
|
||||
if (aMsg.data.enabled) {
|
||||
pdfjs.ensureRegistered();
|
||||
} else {
|
||||
|
@ -21,8 +21,8 @@
|
||||
* running remote. It will only be run when PdfJs.enable is true.
|
||||
*/
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://pdf.js/PdfJs.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://pdf.js/PdfJs.jsm");
|
||||
|
||||
if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
// register various pdfjs factories that hook us into content loading.
|
||||
|
@ -20,7 +20,7 @@
|
||||
* initializing our built-in version of pdfjs when running remote.
|
||||
*/
|
||||
|
||||
Components.utils.import("resource://pdf.js/PdfjsContentUtils.jsm");
|
||||
ChromeUtils.import("resource://pdf.js/PdfjsContentUtils.jsm");
|
||||
|
||||
// init content utils shim pdfjs will use to access privileged apis.
|
||||
PdfjsContentUtils.init();
|
||||
|
Loading…
Reference in New Issue
Block a user