From 0b5330781c367fcbc997947adbf2bdcdf71f61bc Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Thu, 2 Jul 2015 12:59:17 -0500 Subject: [PATCH] Bug 1179262 - Remove PlayPreview registration from PDF Viewer. --- extensions/firefox/bootstrap.js | 9 ++++++++ extensions/firefox/content/PdfJs.jsm | 22 ++++++++----------- .../firefox/content/PdfStreamConverter.jsm | 3 +++ make.js | 8 ++++++- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/extensions/firefox/bootstrap.js b/extensions/firefox/bootstrap.js index 93f8711cc..6d7f68d74 100644 --- a/extensions/firefox/bootstrap.js +++ b/extensions/firefox/bootstrap.js @@ -85,12 +85,21 @@ Factory.prototype = { var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar); registrar.registerFactory(proto.classID, proto.classDescription, proto.contractID, this); + + if (proto.classID2) { + this._classID2 = proto.classID2; + registrar.registerFactory(proto.classID2, proto.classDescription, + proto.contractID2, this); + } }, unregister: function unregister() { var proto = this._targetConstructor.prototype; var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar); registrar.unregisterFactory(proto.classID, this); + if (this._classID2) { + registrar.unregisterFactory(this._classID2, this); + } this._targetConstructor = null; }, diff --git a/extensions/firefox/content/PdfJs.jsm b/extensions/firefox/content/PdfJs.jsm index 82cc5c283..2503eeccf 100644 --- a/extensions/firefox/content/PdfJs.jsm +++ b/extensions/firefox/content/PdfJs.jsm @@ -112,11 +112,20 @@ Factory.prototype = { var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar); registrar.registerFactory(proto.classID, proto.classDescription, proto.contractID, factory); + + if (proto.classID2) { + this._classID2 = proto.classID2; + registrar.registerFactory(proto.classID2, proto.classDescription, + proto.contractID2, factory); + } }, unregister: function unregister() { var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar); registrar.unregisterFactory(this._classID, this._factory); + if (this._classID2) { + registrar.unregisterFactory(this._classID2, this._factory); + } this._factory = null; } }; @@ -305,13 +314,6 @@ let PdfJs = { Cu.import('resource://pdf.js/PdfStreamConverter.jsm'); this._pdfStreamConverterFactory.register(PdfStreamConverter); - this._pdfRedirectorFactory = new Factory(); - Cu.import('resource://pdf.js/PdfRedirector.jsm'); - this._pdfRedirectorFactory.register(PdfRedirector); - - Svc.pluginHost.registerPlayPreviewMimeType(PDF_CONTENT_TYPE, true, - 'data:application/x-moz-playpreview-pdfjs;,'); - this._registered = true; }, @@ -323,12 +325,6 @@ let PdfJs = { Cu.unload('resource://pdf.js/PdfStreamConverter.jsm'); delete this._pdfStreamConverterFactory; - this._pdfRedirectorFactory.unregister(); - Cu.unload('resource://pdf.js/PdfRedirector.jsm'); - delete this._pdfRedirectorFactory; - - Svc.pluginHost.unregisterPlayPreviewMimeType(PDF_CONTENT_TYPE); - this._registered = false; } }; diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm index 61e0c16c3..584bd6f0f 100644 --- a/extensions/firefox/content/PdfStreamConverter.jsm +++ b/extensions/firefox/content/PdfStreamConverter.jsm @@ -868,6 +868,9 @@ PdfStreamConverter.prototype = { classDescription: 'pdf.js Component', contractID: '@mozilla.org/streamconv;1?from=application/pdf&to=*/*', + classID2: Components.ID('{PDFJSSCRIPT_STREAM_CONVERTER2_ID}'), + contractID2: '@mozilla.org/streamconv;1?from=application/pdf&to=text/html', + QueryInterface: XPCOMUtils.generateQI([ Ci.nsISupports, Ci.nsIStreamConverter, diff --git a/make.js b/make.js index 036961466..d82db2e17 100644 --- a/make.js +++ b/make.js @@ -62,7 +62,9 @@ var ROOT_DIR = __dirname + '/', // absolute path to project's root MOZCENTRAL_PREF_PREFIX = 'pdfjs', FIREFOX_PREF_PREFIX = 'extensions.uriloader@pdf.js', MOZCENTRAL_STREAM_CONVERTER_ID = 'd0c5195d-e798-49d4-b1d3-9324328b2291', - FIREFOX_STREAM_CONVERTER_ID = '6457a96b-2d68-439a-bcfa-44465fbcdbb1'; + FIREFOX_STREAM_CONVERTER_ID = '6457a96b-2d68-439a-bcfa-44465fbcdbb1', + MOZCENTRAL_STREAM_CONVERTER2_ID = 'd0c5195d-e798-49d4-b1d3-9324328b2292', + FIREFOX_STREAM_CONVERTER2_ID = '6457a96b-2d68-439a-bcfa-44465fbcdbb2'; var DEFINES = { PRODUCTION: true, @@ -833,6 +835,8 @@ target.firefox = function() { sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, FIREFOX_STREAM_CONVERTER_ID, FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm'); + sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER2_ID/, FIREFOX_STREAM_CONVERTER2_ID, + FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm'); sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX, FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm'); sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false', @@ -966,6 +970,8 @@ target.mozcentral = function() { sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, MOZCENTRAL_STREAM_CONVERTER_ID, MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm'); + sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER2_ID/, MOZCENTRAL_STREAM_CONVERTER2_ID, + MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm'); sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX, MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm'); sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true',