Merge pull request #4343 from brendandahl/ff-cleanup

Use only one resource url for moz central build.
This commit is contained in:
Yury Delendik 2014-03-04 20:29:27 -06:00
commit 192f09cd69
6 changed files with 27 additions and 40 deletions

View File

@ -111,13 +111,13 @@ function startup(aData, aReason) {
// Load the component and register it.
pdfStreamConverterUrl = aData.resourceURI.spec +
'components/PdfStreamConverter.js';
'content/PdfStreamConverter.jsm';
Cu.import(pdfStreamConverterUrl);
pdfStreamConverterFactory.register(PdfStreamConverter);
if (registerOverlayPreview) {
pdfRedirectorUrl = aData.resourceURI.spec +
'components/PdfRedirector.js';
'content/PdfRedirector.jsm';
Cu.import(pdfRedirectorUrl);
pdfRedirectorFactory.register(PdfRedirector);

View File

@ -1,2 +1 @@
resource pdf.js content/
resource pdf.js.components components/

View File

@ -34,8 +34,8 @@ const PDF_CONTENT_TYPE = 'application/pdf';
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://pdf.js.components/PdfStreamConverter.js');
Cu.import('resource://pdf.js.components/PdfRedirector.js');
Cu.import('resource://pdf.js/PdfStreamConverter.jsm');
Cu.import('resource://pdf.js/PdfRedirector.jsm');
let Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
@ -61,39 +61,25 @@ function getIntPref(aPref, aDefaultValue) {
}
}
// Factory that registers/unregisters a constructor as a component.
// Register/unregister a constructor as a factory.
function Factory() {}
Factory.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
_targetConstructor: null,
register: function register(targetConstructor) {
this._targetConstructor = targetConstructor;
var proto = targetConstructor.prototype;
this._classID = proto.classID;
var factory = XPCOMUtils._getFactory(targetConstructor);
this._factory = factory;
var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(proto.classID, proto.classDescription,
proto.contractID, this);
proto.contractID, factory);
},
unregister: function unregister() {
var proto = this._targetConstructor.prototype;
var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(proto.classID, this);
this._targetConstructor = null;
},
// nsIFactory
createInstance: function createInstance(aOuter, iid) {
if (aOuter !== null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return (new (this._targetConstructor)).QueryInterface(iid);
},
// nsIFactory
lockFactory: function lockFactory(lock) {
// No longer used as of gecko 1.7.
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
registrar.unregisterFactory(this._classID, this._factory);
this._factory = null;
}
};

View File

@ -131,5 +131,3 @@ PdfRedirector.prototype = {
// Do nothing
}
};
var NSGetFactory = XPCOMUtils.generateNSGetFactory([PdfRedirector]);

View File

@ -959,5 +959,3 @@ PdfStreamConverter.prototype = {
delete this.binaryStream;
}
};
var NSGetFactory = XPCOMUtils.generateNSGetFactory([PdfStreamConverter]);

22
make.js
View File

@ -448,7 +448,6 @@ target.firefox = function() {
'*.svg',
'*.png',
'*.manifest',
'components',
'locale',
'../../LICENSE'],
FIREFOX_EXTENSION_FILES =
@ -457,7 +456,6 @@ target.firefox = function() {
'chrome.manifest',
'icon.png',
'icon64.png',
'components',
'content',
'locale',
'LICENSE'],
@ -480,6 +478,12 @@ target.firefox = function() {
cp(FIREFOX_CONTENT_DIR + 'PdfJsTelemetry-addon.jsm',
FIREFOX_BUILD_CONTENT_DIR + 'PdfJsTelemetry.jsm');
cp(FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm',
FIREFOX_BUILD_CONTENT_DIR);
cp(FIREFOX_CONTENT_DIR + 'PdfRedirector.jsm',
FIREFOX_BUILD_CONTENT_DIR);
// Copy extension files
cd(FIREFOX_EXTENSION_DIR);
cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + FIREFOX_BUILD_DIR);
@ -520,11 +524,11 @@ target.firefox = function() {
FIREFOX_BUILD_DIR + '/update.rdf');
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, FIREFOX_STREAM_CONVERTER_ID,
FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX,
FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false',
FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
// Update localized metadata
var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc');
@ -591,6 +595,8 @@ target.mozcentral = function() {
cp(FIREFOX_CONTENT_DIR + 'PdfJs.jsm', MOZCENTRAL_CONTENT_DIR);
cp(FIREFOX_CONTENT_DIR + 'PdfJsTelemetry.jsm', MOZCENTRAL_CONTENT_DIR);
cp(FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm', MOZCENTRAL_CONTENT_DIR);
cp(FIREFOX_CONTENT_DIR + 'PdfRedirector.jsm', MOZCENTRAL_CONTENT_DIR);
// Copy extension files
cd('extensions/firefox');
@ -645,11 +651,11 @@ target.mozcentral = function() {
MOZCENTRAL_EXTENSION_DIR + 'README.mozilla');
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, MOZCENTRAL_STREAM_CONVERTER_ID,
MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX,
MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true',
MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
// Copy test files
mkdir('-p', MOZCENTRAL_TEST_DIR);