diff --git a/Makefile b/Makefile index 0666dfe2c..62565670a 100644 --- a/Makefile +++ b/Makefile @@ -226,6 +226,7 @@ FIREFOX_CONTENT_DIR := $(EXTENSION_SRC)/firefox/$(CONTENT_DIR)/ FIREFOX_EXTENSION_FILES_TO_COPY = \ *.js \ *.rdf \ + *.png \ install.rdf.in \ README.mozilla \ components \ @@ -234,12 +235,16 @@ FIREFOX_EXTENSION_FILES_TO_COPY = \ FIREFOX_EXTENSION_FILES = \ bootstrap.js \ install.rdf \ + icon.png \ + icon64.png \ components \ content \ LICENSE \ $(NULL) FIREFOX_MC_EXTENSION_FILES = \ bootstrap.js \ + icon.png \ + icon64.png \ components \ content \ LICENSE \ diff --git a/extensions/firefox/bootstrap.js b/extensions/firefox/bootstrap.js index 627fc7a89..d03812bcb 100644 --- a/extensions/firefox/bootstrap.js +++ b/extensions/firefox/bootstrap.js @@ -10,10 +10,14 @@ let Cc = Components.classes; let Ci = Components.interfaces; let Cm = Components.manager; let Cu = Components.utils; +let application = Cc['@mozilla.org/fuel/application;1'] + .getService(Ci.fuelIApplication); Cu.import('resource://gre/modules/Services.jsm'); function log(str) { + if (!application.prefs.getValue(EXT_PREFIX + '.pdfBugEnabled', false)) + return; dump(str + '\n'); } @@ -60,12 +64,7 @@ function startup(aData, aReason) { var ioService = Services.io; var resProt = ioService.getProtocolHandler('resource') .QueryInterface(Ci.nsIResProtocolHandler); - var aliasFile = Cc['@mozilla.org/file/local;1'] - .createInstance(Ci.nsILocalFile); - var componentPath = aData.installPath.clone(); - componentPath.append('content'); - aliasFile.initWithPath(componentPath.path); - var aliasURI = ioService.newFileURI(aliasFile); + var aliasURI = ioService.newURI('content/', 'UTF-8', aData.resourceURI); resProt.setSubstitution(RESOURCE_NAME, aliasURI); // Load the component and register it. @@ -73,12 +72,9 @@ function startup(aData, aReason) { 'components/PdfStreamConverter.js'; Cu.import(pdfStreamConverterUrl); Factory.register(PdfStreamConverter); - Services.prefs.setBoolPref('extensions.pdf.js.active', true); } function shutdown(aData, aReason) { - if (Services.prefs.getBoolPref('extensions.pdf.js.active')) - Services.prefs.setBoolPref('extensions.pdf.js.active', false); if (aReason == APP_SHUTDOWN) return; var ioService = Services.io; @@ -89,18 +85,14 @@ function shutdown(aData, aReason) { // Remove the contract/component. Factory.unregister(); // Unload the converter - if (pdfStreamConverterUrl) { - Cu.unload(pdfStreamConverterUrl); - pdfStreamConverterUrl = null; - } + Cu.unload(pdfStreamConverterUrl); + pdfStreamConverterUrl = null; } function install(aData, aReason) { - Services.prefs.setBoolPref('extensions.pdf.js.active', false); } function uninstall(aData, aReason) { - Services.prefs.clearUserPref('extensions.pdf.js.active'); application.prefs.setValue(EXT_PREFIX + '.database', '{}'); } diff --git a/extensions/firefox/components/PdfStreamConverter.js b/extensions/firefox/components/PdfStreamConverter.js index 8aeb4a0c9..9375a2690 100644 --- a/extensions/firefox/components/PdfStreamConverter.js +++ b/extensions/firefox/components/PdfStreamConverter.js @@ -17,7 +17,15 @@ const MAX_DATABASE_LENGTH = 4096; Cu.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import('resource://gre/modules/Services.jsm'); +let application = Cc['@mozilla.org/fuel/application;1'] + .getService(Ci.fuelIApplication); +let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1'] + .getService(Ci.nsIPrivateBrowsingService); +let inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled; + function log(aMsg) { + if (!application.prefs.getValue(EXT_PREFIX + '.pdfBugEnabled', false)) + return; let msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg); Services.console.logStringMessage(msg); dump(msg + '\n'); @@ -40,11 +48,6 @@ function topWindow(win) { .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindow); } -let application = Cc['@mozilla.org/fuel/application;1'] - .getService(Ci.fuelIApplication); -let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1'] - .getService(Ci.nsIPrivateBrowsingService); -let inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled; // All the priviledged actions. function ChromeActions() { @@ -125,9 +128,6 @@ PdfStreamConverter.prototype = { // nsIStreamConverter::asyncConvertData asyncConvertData: function(aFromType, aToType, aListener, aCtxt) { - if (!Services.prefs.getBoolPref('extensions.pdf.js.active')) - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - // Ignoring HTTP POST requests -- pdf.js has to repeat the request. var skipConversion = false; try { diff --git a/extensions/firefox/icon.png b/extensions/firefox/icon.png new file mode 100644 index 000000000..64763756e Binary files /dev/null and b/extensions/firefox/icon.png differ diff --git a/extensions/firefox/icon64.png b/extensions/firefox/icon64.png new file mode 100644 index 000000000..0131bbb5c Binary files /dev/null and b/extensions/firefox/icon64.png differ diff --git a/extensions/firefox/install.rdf b/extensions/firefox/install.rdf index 14938b669..0a0d813b2 100644 --- a/extensions/firefox/install.rdf +++ b/extensions/firefox/install.rdf @@ -5,9 +5,8 @@ uriloader@pdf.js - pdf.js + PDF Viewer PDFJSSCRIPT_VERSION - chrome://pdf.js/skin/logo.png {ec8030f7-c20a-464f-9b0e-13a3a9e97384} @@ -16,9 +15,8 @@ true - true - Mozilla Labs - pdf.js uri loader + Mozilla + Uses HTML5 to display PDF files directly in Firefox. https://github.com/mozilla/pdf.js/ 2 diff --git a/extensions/firefox/install.rdf.in b/extensions/firefox/install.rdf.in index dc2893c69..3f8f87cda 100644 --- a/extensions/firefox/install.rdf.in +++ b/extensions/firefox/install.rdf.in @@ -7,22 +7,20 @@ uriloader@pdf.js - pdf.js + PDF Viewer PDFJSSCRIPT_VERSION - chrome://pdf.js/skin/logo.png {ec8030f7-c20a-464f-9b0e-13a3a9e97384} @FIREFOX_VERSION@ @FIREFOX_VERSION@ - true + true true - true - Mozilla Labs - pdf.js uri loader - https://github.com/mozilla/pdf.js/ + Mozilla + Uses HTML5 to display PDF files directly in Firefox. + http://support.mozilla.org/kb/using-mozilla-pdf-viewer 2 diff --git a/make.js b/make.js index f2e499f8a..33771aeb7 100755 --- a/make.js +++ b/make.js @@ -220,6 +220,7 @@ target.firefox = function() { FIREFOX_EXTENSION_FILES_TO_COPY = ['*.js', '*.rdf', + '*.png', 'install.rdf.in', 'README.mozilla', 'components', @@ -227,11 +228,15 @@ target.firefox = function() { FIREFOX_EXTENSION_FILES = ['bootstrap.js', 'install.rdf', + 'icon.png', + 'icon64.png', 'components', 'content', 'LICENSE']; FIREFOX_MC_EXTENSION_FILES = ['bootstrap.js', + 'icon.png', + 'icon64.png', 'components', 'content', 'LICENSE'];