[Firefox addon] Enforce double quotes, using ESLint, to avoid linting errors in mozilla-central (issue 7957)
Given that this patch causes a lot of churn in the addon code, I wouldn't really mind if we ultimately decide against doing this and just add a rule exception in mozilla-central instead.[1] --- [1] Note that I used the ESLint `--fix` option, hence writing this commit message actually took longer time than the creation of the patch :-)
This commit is contained in:
		
							parent
							
								
									e0a92a7f48
								
							
						
					
					
						commit
						a5d5b970af
					
				| @ -17,6 +17,7 @@ | |||||||
|     }], |     }], | ||||||
| 
 | 
 | ||||||
|     // Stylistic Issues |     // Stylistic Issues | ||||||
|  |     "quotes": ["error", "double"], | ||||||
|     "space-before-function-paren": ["error", "never"], |     "space-before-function-paren": ["error", "never"], | ||||||
| 
 | 
 | ||||||
|     // ECMAScript 6 |     // ECMAScript 6 | ||||||
|  | |||||||
							
								
								
									
										54
									
								
								extensions/firefox/bootstrap.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										54
									
								
								extensions/firefox/bootstrap.js
									
									
									
									
										vendored
									
									
								
							| @ -15,10 +15,10 @@ | |||||||
| /* globals Components, Services, dump, XPCOMUtils, PdfStreamConverter, | /* globals Components, Services, dump, XPCOMUtils, PdfStreamConverter, | ||||||
|            APP_SHUTDOWN, PdfjsChromeUtils, PdfjsContentUtils */ |            APP_SHUTDOWN, PdfjsChromeUtils, PdfjsContentUtils */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const RESOURCE_NAME = 'pdf.js'; | const RESOURCE_NAME = "pdf.js"; | ||||||
| const EXT_PREFIX = 'extensions.uriloader@pdf.js'; | const EXT_PREFIX = "extensions.uriloader@pdf.js"; | ||||||
| 
 | 
 | ||||||
| const Cc = Components.classes; | const Cc = Components.classes; | ||||||
| const Ci = Components.interfaces; | const Ci = Components.interfaces; | ||||||
| @ -26,8 +26,8 @@ const Cm = Components.manager; | |||||||
| const Cu = Components.utils; | const Cu = Components.utils; | ||||||
| const Cr = Components.results; | const Cr = Components.results; | ||||||
| 
 | 
 | ||||||
| Cu.import('resource://gre/modules/XPCOMUtils.jsm'); | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||||||
| Cu.import('resource://gre/modules/Services.jsm'); | Cu.import("resource://gre/modules/Services.jsm"); | ||||||
| 
 | 
 | ||||||
| function getBoolPref(pref, def) { | function getBoolPref(pref, def) { | ||||||
|   try { |   try { | ||||||
| @ -38,31 +38,31 @@ function getBoolPref(pref, def) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function log(str) { | function log(str) { | ||||||
|   if (!getBoolPref(EXT_PREFIX + '.pdfBugEnabled', false)) { |   if (!getBoolPref(EXT_PREFIX + ".pdfBugEnabled", false)) { | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|   dump(str + '\n'); |   dump(str + "\n"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function initializeDefaultPreferences() { | function initializeDefaultPreferences() { | ||||||
|   var DEFAULT_PREFERENCES = |   var DEFAULT_PREFERENCES = | ||||||
| //#include ../../web/default_preferences.json
 | //#include ../../web/default_preferences.json
 | ||||||
| //#if false
 | //#if false
 | ||||||
|     'end of DEFAULT_PREFERENCES'; |     "end of DEFAULT_PREFERENCES"; | ||||||
| //#endif
 | //#endif
 | ||||||
| 
 | 
 | ||||||
|   var defaultBranch = Services.prefs.getDefaultBranch(EXT_PREFIX + '.'); |   var defaultBranch = Services.prefs.getDefaultBranch(EXT_PREFIX + "."); | ||||||
|   var defaultValue; |   var defaultValue; | ||||||
|   for (var key in DEFAULT_PREFERENCES) { |   for (var key in DEFAULT_PREFERENCES) { | ||||||
|     defaultValue = DEFAULT_PREFERENCES[key]; |     defaultValue = DEFAULT_PREFERENCES[key]; | ||||||
|     switch (typeof defaultValue) { |     switch (typeof defaultValue) { | ||||||
|       case 'boolean': |       case "boolean": | ||||||
|         defaultBranch.setBoolPref(key, defaultValue); |         defaultBranch.setBoolPref(key, defaultValue); | ||||||
|         break; |         break; | ||||||
|       case 'number': |       case "number": | ||||||
|         defaultBranch.setIntPref(key, defaultValue); |         defaultBranch.setIntPref(key, defaultValue); | ||||||
|         break; |         break; | ||||||
|       case 'string': |       case "string": | ||||||
|         defaultBranch.setCharPref(key, defaultValue); |         defaultBranch.setCharPref(key, defaultValue); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
| @ -126,27 +126,27 @@ var e10sEnabled = false; | |||||||
| function startup(aData, aReason) { | function startup(aData, aReason) { | ||||||
|   // Setup the resource url.
 |   // Setup the resource url.
 | ||||||
|   var ioService = Services.io; |   var ioService = Services.io; | ||||||
|   var resProt = ioService.getProtocolHandler('resource') |   var resProt = ioService.getProtocolHandler("resource") | ||||||
|                   .QueryInterface(Ci.nsIResProtocolHandler); |                   .QueryInterface(Ci.nsIResProtocolHandler); | ||||||
|   var aliasURI = ioService.newURI('content/', 'UTF-8', aData.resourceURI); |   var aliasURI = ioService.newURI("content/", "UTF-8", aData.resourceURI); | ||||||
|   resProt.setSubstitution(RESOURCE_NAME, aliasURI); |   resProt.setSubstitution(RESOURCE_NAME, aliasURI); | ||||||
| 
 | 
 | ||||||
|   pdfBaseUrl = aData.resourceURI.spec; |   pdfBaseUrl = aData.resourceURI.spec; | ||||||
| 
 | 
 | ||||||
|   Cu.import(pdfBaseUrl + 'content/PdfjsChromeUtils.jsm'); |   Cu.import(pdfBaseUrl + "content/PdfjsChromeUtils.jsm"); | ||||||
|   PdfjsChromeUtils.init(); |   PdfjsChromeUtils.init(); | ||||||
|   Cu.import(pdfBaseUrl + 'content/PdfjsContentUtils.jsm'); |   Cu.import(pdfBaseUrl + "content/PdfjsContentUtils.jsm"); | ||||||
|   PdfjsContentUtils.init(); |   PdfjsContentUtils.init(); | ||||||
| 
 | 
 | ||||||
|   // Load the component and register it.
 |   // Load the component and register it.
 | ||||||
|   var pdfStreamConverterUrl = pdfBaseUrl + 'content/PdfStreamConverter.jsm'; |   var pdfStreamConverterUrl = pdfBaseUrl + "content/PdfStreamConverter.jsm"; | ||||||
|   Cu.import(pdfStreamConverterUrl); |   Cu.import(pdfStreamConverterUrl); | ||||||
|   pdfStreamConverterFactory.register(PdfStreamConverter); |   pdfStreamConverterFactory.register(PdfStreamConverter); | ||||||
| 
 | 
 | ||||||
|   try { |   try { | ||||||
|     let globalMM = Cc['@mozilla.org/globalmessagemanager;1'] |     let globalMM = Cc["@mozilla.org/globalmessagemanager;1"] | ||||||
|                      .getService(Ci.nsIFrameScriptLoader); |                      .getService(Ci.nsIFrameScriptLoader); | ||||||
|     globalMM.loadFrameScript('chrome://pdf.js/content/content.js', true); |     globalMM.loadFrameScript("chrome://pdf.js/content/content.js", true); | ||||||
|     e10sEnabled = true; |     e10sEnabled = true; | ||||||
|   } catch (ex) { |   } catch (ex) { | ||||||
|   } |   } | ||||||
| @ -160,32 +160,32 @@ function shutdown(aData, aReason) { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (e10sEnabled) { |   if (e10sEnabled) { | ||||||
|     let globalMM = Cc['@mozilla.org/globalmessagemanager;1'] |     let globalMM = Cc["@mozilla.org/globalmessagemanager;1"] | ||||||
|                      .getService(Ci.nsIMessageBroadcaster); |                      .getService(Ci.nsIMessageBroadcaster); | ||||||
|     globalMM.broadcastAsyncMessage('PDFJS:Child:shutdown'); |     globalMM.broadcastAsyncMessage("PDFJS:Child:shutdown"); | ||||||
|     globalMM.removeDelayedFrameScript('chrome://pdf.js/content/content.js'); |     globalMM.removeDelayedFrameScript("chrome://pdf.js/content/content.js"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   var ioService = Services.io; |   var ioService = Services.io; | ||||||
|   var resProt = ioService.getProtocolHandler('resource') |   var resProt = ioService.getProtocolHandler("resource") | ||||||
|                   .QueryInterface(Ci.nsIResProtocolHandler); |                   .QueryInterface(Ci.nsIResProtocolHandler); | ||||||
|   // Remove the resource url.
 |   // Remove the resource url.
 | ||||||
|   resProt.setSubstitution(RESOURCE_NAME, null); |   resProt.setSubstitution(RESOURCE_NAME, null); | ||||||
|   // Remove the contract/component.
 |   // Remove the contract/component.
 | ||||||
|   pdfStreamConverterFactory.unregister(); |   pdfStreamConverterFactory.unregister(); | ||||||
|   // Unload the converter
 |   // Unload the converter
 | ||||||
|   var pdfStreamConverterUrl = pdfBaseUrl + 'content/PdfStreamConverter.jsm'; |   var pdfStreamConverterUrl = pdfBaseUrl + "content/PdfStreamConverter.jsm"; | ||||||
|   Cu.unload(pdfStreamConverterUrl); |   Cu.unload(pdfStreamConverterUrl); | ||||||
| 
 | 
 | ||||||
|   PdfjsContentUtils.uninit(); |   PdfjsContentUtils.uninit(); | ||||||
|   Cu.unload(pdfBaseUrl + 'content/PdfjsContentUtils.jsm'); |   Cu.unload(pdfBaseUrl + "content/PdfjsContentUtils.jsm"); | ||||||
|   PdfjsChromeUtils.uninit(); |   PdfjsChromeUtils.uninit(); | ||||||
|   Cu.unload(pdfBaseUrl + 'content/PdfjsChromeUtils.jsm'); |   Cu.unload(pdfBaseUrl + "content/PdfjsChromeUtils.jsm"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function install(aData, aReason) { | function install(aData, aReason) { | ||||||
|   // TODO remove after some time -- cleanup of unused preferences
 |   // TODO remove after some time -- cleanup of unused preferences
 | ||||||
|   Services.prefs.clearUserPref(EXT_PREFIX + '.database'); |   Services.prefs.clearUserPref(EXT_PREFIX + ".database"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function uninstall(aData, aReason) { | function uninstall(aData, aReason) { | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
| /* globals Components, Services, XPCOMUtils, PdfjsContentUtils, | /* globals Components, Services, XPCOMUtils, PdfjsContentUtils, | ||||||
|            PdfjsContentUtils, PdfStreamConverter, addMessageListener */ |            PdfjsContentUtils, PdfStreamConverter, addMessageListener */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| (function contentScriptClosure() { | (function contentScriptClosure() { | ||||||
|   // we need to use closure here -- we are running in the global context
 |   // we need to use closure here -- we are running in the global context
 | ||||||
| @ -26,8 +26,8 @@ | |||||||
|   const Cu = Components.utils; |   const Cu = Components.utils; | ||||||
|   const Cr = Components.results; |   const Cr = Components.results; | ||||||
| 
 | 
 | ||||||
|   Cu.import('resource://gre/modules/XPCOMUtils.jsm'); |   Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||||||
|   Cu.import('resource://gre/modules/Services.jsm'); |   Cu.import("resource://gre/modules/Services.jsm"); | ||||||
| 
 | 
 | ||||||
|   var isRemote = Services.appinfo.processType === |   var isRemote = Services.appinfo.processType === | ||||||
|     Services.appinfo.PROCESS_TYPE_CONTENT; |     Services.appinfo.PROCESS_TYPE_CONTENT; | ||||||
| @ -73,10 +73,10 @@ | |||||||
|   var pdfStreamConverterFactory = new Factory(); |   var pdfStreamConverterFactory = new Factory(); | ||||||
| 
 | 
 | ||||||
|   function startup() { |   function startup() { | ||||||
|     Cu.import('resource://pdf.js/PdfjsContentUtils.jsm'); |     Cu.import("resource://pdf.js/PdfjsContentUtils.jsm"); | ||||||
|     PdfjsContentUtils.init(); |     PdfjsContentUtils.init(); | ||||||
| 
 | 
 | ||||||
|     Cu.import('resource://pdf.js/PdfStreamConverter.jsm'); |     Cu.import("resource://pdf.js/PdfStreamConverter.jsm"); | ||||||
|     pdfStreamConverterFactory.register(PdfStreamConverter); |     pdfStreamConverterFactory.register(PdfStreamConverter); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -84,16 +84,16 @@ | |||||||
|     // Remove the contract/component.
 |     // Remove the contract/component.
 | ||||||
|     pdfStreamConverterFactory.unregister(); |     pdfStreamConverterFactory.unregister(); | ||||||
|     // Unload the converter
 |     // Unload the converter
 | ||||||
|     Cu.unload('resource://pdf.js/PdfStreamConverter.jsm'); |     Cu.unload("resource://pdf.js/PdfStreamConverter.jsm"); | ||||||
| 
 | 
 | ||||||
|     PdfjsContentUtils.uninit(); |     PdfjsContentUtils.uninit(); | ||||||
|     Cu.unload('resource://pdf.js/PdfjsContentUtils.jsm'); |     Cu.unload("resource://pdf.js/PdfjsContentUtils.jsm"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (isRemote) { |   if (isRemote) { | ||||||
|     startup(); |     startup(); | ||||||
| 
 | 
 | ||||||
|     addMessageListener('PDFJS:Child:shutdown', function() { |     addMessageListener("PDFJS:Child:shutdown", function() { | ||||||
|       shutdown(); |       shutdown(); | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -14,12 +14,12 @@ | |||||||
|  */ |  */ | ||||||
| /* eslint max-len: ["error", 100] */ | /* eslint max-len: ["error", 100] */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| // Don't remove this file!
 | // Don't remove this file!
 | ||||||
| // FF15+ expects `PdfJs` module to be present at `resource://pdf.js/PdfJs.jsm`,
 | // FF15+ expects `PdfJs` module to be present at `resource://pdf.js/PdfJs.jsm`,
 | ||||||
| // see https://dxr.mozilla.org/mozilla-central/source/browser/components/nsBrowserGlue.js
 | // see https://dxr.mozilla.org/mozilla-central/source/browser/components/nsBrowserGlue.js
 | ||||||
| var EXPORTED_SYMBOLS = ['PdfJs']; | var EXPORTED_SYMBOLS = ["PdfJs"]; | ||||||
| 
 | 
 | ||||||
| var PdfJs = { | var PdfJs = { | ||||||
|   init: function PdfJs_init() {} |   init: function PdfJs_init() {} | ||||||
|  | |||||||
| @ -15,9 +15,9 @@ | |||||||
| /* globals Components, Services, XPCOMUtils, PdfjsChromeUtils, | /* globals Components, Services, XPCOMUtils, PdfjsChromeUtils, | ||||||
|            PdfjsContentUtils, PdfStreamConverter */ |            PdfjsContentUtils, PdfStreamConverter */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| var EXPORTED_SYMBOLS = ['PdfJs']; | var EXPORTED_SYMBOLS = ["PdfJs"]; | ||||||
| 
 | 
 | ||||||
| const Cc = Components.classes; | const Cc = Components.classes; | ||||||
| const Ci = Components.interfaces; | const Ci = Components.interfaces; | ||||||
| @ -25,32 +25,32 @@ const Cr = Components.results; | |||||||
| const Cm = Components.manager; | const Cm = Components.manager; | ||||||
| const Cu = Components.utils; | const Cu = Components.utils; | ||||||
| 
 | 
 | ||||||
| const PREF_PREFIX = 'pdfjs'; | const PREF_PREFIX = "pdfjs"; | ||||||
| const PREF_DISABLED = PREF_PREFIX + '.disabled'; | const PREF_DISABLED = PREF_PREFIX + ".disabled"; | ||||||
| const PREF_MIGRATION_VERSION = PREF_PREFIX + '.migrationVersion'; | const PREF_MIGRATION_VERSION = PREF_PREFIX + ".migrationVersion"; | ||||||
| const PREF_PREVIOUS_ACTION = PREF_PREFIX + '.previousHandler.preferredAction'; | const PREF_PREVIOUS_ACTION = PREF_PREFIX + ".previousHandler.preferredAction"; | ||||||
| const PREF_PREVIOUS_ASK = PREF_PREFIX + | const PREF_PREVIOUS_ASK = PREF_PREFIX + | ||||||
|                           '.previousHandler.alwaysAskBeforeHandling'; |                           ".previousHandler.alwaysAskBeforeHandling"; | ||||||
| const PREF_DISABLED_PLUGIN_TYPES = 'plugin.disable_full_page_plugin_for_types'; | const PREF_DISABLED_PLUGIN_TYPES = "plugin.disable_full_page_plugin_for_types"; | ||||||
| const TOPIC_PDFJS_HANDLER_CHANGED = 'pdfjs:handlerChanged'; | const TOPIC_PDFJS_HANDLER_CHANGED = "pdfjs:handlerChanged"; | ||||||
| const TOPIC_PLUGINS_LIST_UPDATED = 'plugins-list-updated'; | const TOPIC_PLUGINS_LIST_UPDATED = "plugins-list-updated"; | ||||||
| const TOPIC_PLUGIN_INFO_UPDATED = 'plugin-info-updated'; | const TOPIC_PLUGIN_INFO_UPDATED = "plugin-info-updated"; | ||||||
| const PDF_CONTENT_TYPE = 'application/pdf'; | const PDF_CONTENT_TYPE = "application/pdf"; | ||||||
| 
 | 
 | ||||||
| Cu.import('resource://gre/modules/XPCOMUtils.jsm'); | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||||||
| Cu.import('resource://gre/modules/Services.jsm'); | Cu.import("resource://gre/modules/Services.jsm"); | ||||||
| 
 | 
 | ||||||
| var Svc = {}; | var Svc = {}; | ||||||
| XPCOMUtils.defineLazyServiceGetter(Svc, 'mime', | XPCOMUtils.defineLazyServiceGetter(Svc, "mime", | ||||||
|                                    '@mozilla.org/mime;1', |                                    "@mozilla.org/mime;1", | ||||||
|                                    'nsIMIMEService'); |                                    "nsIMIMEService"); | ||||||
| XPCOMUtils.defineLazyServiceGetter(Svc, 'pluginHost', | XPCOMUtils.defineLazyServiceGetter(Svc, "pluginHost", | ||||||
|                                    '@mozilla.org/plugin/host;1', |                                    "@mozilla.org/plugin/host;1", | ||||||
|                                    'nsIPluginHost'); |                                    "nsIPluginHost"); | ||||||
| XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsChromeUtils', | XPCOMUtils.defineLazyModuleGetter(this, "PdfjsChromeUtils", | ||||||
|                                   'resource://pdf.js/PdfjsChromeUtils.jsm'); |                                   "resource://pdf.js/PdfjsChromeUtils.jsm"); | ||||||
| XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsContentUtils', | XPCOMUtils.defineLazyModuleGetter(this, "PdfjsContentUtils", | ||||||
|                                   'resource://pdf.js/PdfjsContentUtils.jsm'); |                                   "resource://pdf.js/PdfjsContentUtils.jsm"); | ||||||
| 
 | 
 | ||||||
| function getBoolPref(aPref, aDefaultValue) { | function getBoolPref(aPref, aDefaultValue) { | ||||||
|   try { |   try { | ||||||
| @ -79,21 +79,21 @@ function initializeDefaultPreferences() { | |||||||
|   var DEFAULT_PREFERENCES = |   var DEFAULT_PREFERENCES = | ||||||
| //#include ../../../web/default_preferences.json
 | //#include ../../../web/default_preferences.json
 | ||||||
| //#if false
 | //#if false
 | ||||||
|     'end of DEFAULT_PREFERENCES'; |     "end of DEFAULT_PREFERENCES"; | ||||||
| //#endif
 | //#endif
 | ||||||
| 
 | 
 | ||||||
|   var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.'); |   var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + "."); | ||||||
|   var defaultValue; |   var defaultValue; | ||||||
|   for (var key in DEFAULT_PREFERENCES) { |   for (var key in DEFAULT_PREFERENCES) { | ||||||
|     defaultValue = DEFAULT_PREFERENCES[key]; |     defaultValue = DEFAULT_PREFERENCES[key]; | ||||||
|     switch (typeof defaultValue) { |     switch (typeof defaultValue) { | ||||||
|       case 'boolean': |       case "boolean": | ||||||
|         defaultBranch.setBoolPref(key, defaultValue); |         defaultBranch.setBoolPref(key, defaultValue); | ||||||
|         break; |         break; | ||||||
|       case 'number': |       case "number": | ||||||
|         defaultBranch.setIntPref(key, defaultValue); |         defaultBranch.setIntPref(key, defaultValue); | ||||||
|         break; |         break; | ||||||
|       case 'string': |       case "string": | ||||||
|         defaultBranch.setCharPref(key, defaultValue); |         defaultBranch.setCharPref(key, defaultValue); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
| @ -139,8 +139,8 @@ var PdfJs = { | |||||||
|   init: function init(remote) { |   init: function init(remote) { | ||||||
|     if (Services.appinfo.processType !== |     if (Services.appinfo.processType !== | ||||||
|         Services.appinfo.PROCESS_TYPE_DEFAULT) { |         Services.appinfo.PROCESS_TYPE_DEFAULT) { | ||||||
|       throw new Error('PdfJs.init should only get called ' + |       throw new Error("PdfJs.init should only get called " + | ||||||
|                       'in the parent process.'); |                       "in the parent process."); | ||||||
|     } |     } | ||||||
|     PdfjsChromeUtils.init(); |     PdfjsChromeUtils.init(); | ||||||
|     if (!remote) { |     if (!remote) { | ||||||
| @ -203,13 +203,13 @@ var PdfJs = { | |||||||
|     } |     } | ||||||
|     if (currentVersion < 2) { |     if (currentVersion < 2) { | ||||||
|       // cleaning up of unused database preference (see #3994)
 |       // cleaning up of unused database preference (see #3994)
 | ||||||
|       Services.prefs.clearUserPref(PREF_PREFIX + '.database'); |       Services.prefs.clearUserPref(PREF_PREFIX + ".database"); | ||||||
|     } |     } | ||||||
|     Services.prefs.setIntPref(PREF_MIGRATION_VERSION, VERSION); |     Services.prefs.setIntPref(PREF_MIGRATION_VERSION, VERSION); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   _becomeHandler: function _becomeHandler() { |   _becomeHandler: function _becomeHandler() { | ||||||
|     let handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf'); |     let handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, "pdf"); | ||||||
|     let prefs = Services.prefs; |     let prefs = Services.prefs; | ||||||
|     if (handlerInfo.preferredAction !== Ci.nsIHandlerInfo.handleInternally && |     if (handlerInfo.preferredAction !== Ci.nsIHandlerInfo.handleInternally && | ||||||
|         handlerInfo.preferredAction !== false) { |         handlerInfo.preferredAction !== false) { | ||||||
| @ -220,7 +220,7 @@ var PdfJs = { | |||||||
|       prefs.setBoolPref(PREF_PREVIOUS_ASK, handlerInfo.alwaysAskBeforeHandling); |       prefs.setBoolPref(PREF_PREVIOUS_ASK, handlerInfo.alwaysAskBeforeHandling); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     let handlerService = Cc['@mozilla.org/uriloader/handler-service;1']. |     let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"]. | ||||||
|                          getService(Ci.nsIHandlerService); |                          getService(Ci.nsIHandlerService); | ||||||
| 
 | 
 | ||||||
|     // Change and save mime handler settings.
 |     // Change and save mime handler settings.
 | ||||||
| @ -229,24 +229,24 @@ var PdfJs = { | |||||||
|     handlerService.store(handlerInfo); |     handlerService.store(handlerInfo); | ||||||
| 
 | 
 | ||||||
|     // Also disable any plugins for pdfs.
 |     // Also disable any plugins for pdfs.
 | ||||||
|     var stringTypes = ''; |     var stringTypes = ""; | ||||||
|     var types = []; |     var types = []; | ||||||
|     if (prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) { |     if (prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) { | ||||||
|       stringTypes = prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES); |       stringTypes = prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES); | ||||||
|     } |     } | ||||||
|     if (stringTypes !== '') { |     if (stringTypes !== "") { | ||||||
|       types = stringTypes.split(','); |       types = stringTypes.split(","); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (types.indexOf(PDF_CONTENT_TYPE) === -1) { |     if (types.indexOf(PDF_CONTENT_TYPE) === -1) { | ||||||
|       types.push(PDF_CONTENT_TYPE); |       types.push(PDF_CONTENT_TYPE); | ||||||
|     } |     } | ||||||
|     prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(',')); |     prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(",")); | ||||||
| 
 | 
 | ||||||
|     // Update the category manager in case the plugins are already loaded.
 |     // Update the category manager in case the plugins are already loaded.
 | ||||||
|     let categoryManager = Cc['@mozilla.org/categorymanager;1']; |     let categoryManager = Cc["@mozilla.org/categorymanager;1"]; | ||||||
|     categoryManager.getService(Ci.nsICategoryManager). |     categoryManager.getService(Ci.nsICategoryManager). | ||||||
|                     deleteCategoryEntry('Gecko-Content-Viewers', |                     deleteCategoryEntry("Gecko-Content-Viewers", | ||||||
|                                         PDF_CONTENT_TYPE, |                                         PDF_CONTENT_TYPE, | ||||||
|                                         false); |                                         false); | ||||||
|   }, |   }, | ||||||
| @ -256,7 +256,7 @@ var PdfJs = { | |||||||
|     this.updateRegistration(); |     this.updateRegistration(); | ||||||
|     if (Services.appinfo.processType === |     if (Services.appinfo.processType === | ||||||
|         Services.appinfo.PROCESS_TYPE_DEFAULT) { |         Services.appinfo.PROCESS_TYPE_DEFAULT) { | ||||||
|       let jsm = 'resource://pdf.js/PdfjsChromeUtils.jsm'; |       let jsm = "resource://pdf.js/PdfjsChromeUtils.jsm"; | ||||||
|       let PdfjsChromeUtils = Components.utils.import(jsm, {}).PdfjsChromeUtils; |       let PdfjsChromeUtils = Components.utils.import(jsm, {}).PdfjsChromeUtils; | ||||||
|       PdfjsChromeUtils.notifyChildOfSettingsChange(); |       PdfjsChromeUtils.notifyChildOfSettingsChange(); | ||||||
|     } |     } | ||||||
| @ -281,7 +281,7 @@ var PdfJs = { | |||||||
|     // Check if we have disabled plugin handling of 'application/pdf' in prefs
 |     // Check if we have disabled plugin handling of 'application/pdf' in prefs
 | ||||||
|     if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) { |     if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) { | ||||||
|       let disabledPluginTypes = |       let disabledPluginTypes = | ||||||
|         Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(','); |         Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(","); | ||||||
|       if (disabledPluginTypes.indexOf(PDF_CONTENT_TYPE) >= 0) { |       if (disabledPluginTypes.indexOf(PDF_CONTENT_TYPE) >= 0) { | ||||||
|         return true; |         return true; | ||||||
|       } |       } | ||||||
| @ -290,7 +290,7 @@ var PdfJs = { | |||||||
|     // Check if there is an enabled pdf plugin.
 |     // Check if there is an enabled pdf plugin.
 | ||||||
|     // Note: this check is performed last because getPluginTags() triggers
 |     // Note: this check is performed last because getPluginTags() triggers
 | ||||||
|     // costly plugin list initialization (bug 881575)
 |     // costly plugin list initialization (bug 881575)
 | ||||||
|     let tags = Cc['@mozilla.org/plugin/host;1']. |     let tags = Cc["@mozilla.org/plugin/host;1"]. | ||||||
|                   getService(Ci.nsIPluginHost). |                   getService(Ci.nsIPluginHost). | ||||||
|                   getPluginTags(); |                   getPluginTags(); | ||||||
|     let enabledPluginFound = tags.some(function(tag) { |     let enabledPluginFound = tags.some(function(tag) { | ||||||
| @ -312,7 +312,7 @@ var PdfJs = { | |||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|     this._pdfStreamConverterFactory = new Factory(); |     this._pdfStreamConverterFactory = new Factory(); | ||||||
|     Cu.import('resource://pdf.js/PdfStreamConverter.jsm'); |     Cu.import("resource://pdf.js/PdfStreamConverter.jsm"); | ||||||
|     this._pdfStreamConverterFactory.register(PdfStreamConverter); |     this._pdfStreamConverterFactory.register(PdfStreamConverter); | ||||||
| 
 | 
 | ||||||
|     this._registered = true; |     this._registered = true; | ||||||
| @ -323,7 +323,7 @@ var PdfJs = { | |||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|     this._pdfStreamConverterFactory.unregister(); |     this._pdfStreamConverterFactory.unregister(); | ||||||
|     Cu.unload('resource://pdf.js/PdfStreamConverter.jsm'); |     Cu.unload("resource://pdf.js/PdfStreamConverter.jsm"); | ||||||
|     delete this._pdfStreamConverterFactory; |     delete this._pdfStreamConverterFactory; | ||||||
| 
 | 
 | ||||||
|     this._registered = false; |     this._registered = false; | ||||||
|  | |||||||
| @ -14,14 +14,14 @@ | |||||||
|  */ |  */ | ||||||
| /* globals Components, Services */ | /* globals Components, Services */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| Components.utils.import('resource://gre/modules/Services.jsm'); | Components.utils.import("resource://gre/modules/Services.jsm"); | ||||||
| 
 | 
 | ||||||
| var EXPORTED_SYMBOLS = ['NetworkManager']; | var EXPORTED_SYMBOLS = ["NetworkManager"]; | ||||||
| 
 | 
 | ||||||
| function log(aMsg) { | function log(aMsg) { | ||||||
|   var msg = 'PdfJsNetwork.jsm: ' + (aMsg.join ? aMsg.join('') : aMsg); |   var msg = "PdfJsNetwork.jsm: " + (aMsg.join ? aMsg.join("") : aMsg); | ||||||
|   Services.console.logStringMessage(msg); |   Services.console.logStringMessage(msg); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -32,7 +32,7 @@ var NetworkManager = (function NetworkManagerClosure() { | |||||||
| 
 | 
 | ||||||
|   function getArrayBuffer(xhr) { |   function getArrayBuffer(xhr) { | ||||||
|     var data = xhr.response; |     var data = xhr.response; | ||||||
|     if (typeof data !== 'string') { |     if (typeof data !== "string") { | ||||||
|       return data; |       return data; | ||||||
|     } |     } | ||||||
|     var length = data.length; |     var length = data.length; | ||||||
| @ -82,18 +82,18 @@ var NetworkManager = (function NetworkManagerClosure() { | |||||||
|         xhr, |         xhr, | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       xhr.open('GET', this.url); |       xhr.open("GET", this.url); | ||||||
|       xhr.withCredentials = this.withCredentials; |       xhr.withCredentials = this.withCredentials; | ||||||
|       for (var property in this.httpHeaders) { |       for (var property in this.httpHeaders) { | ||||||
|         var value = this.httpHeaders[property]; |         var value = this.httpHeaders[property]; | ||||||
|         if (typeof value === 'undefined') { |         if (typeof value === "undefined") { | ||||||
|           continue; |           continue; | ||||||
|         } |         } | ||||||
|         xhr.setRequestHeader(property, value); |         xhr.setRequestHeader(property, value); | ||||||
|       } |       } | ||||||
|       if (this.isHttp && 'begin' in args && 'end' in args) { |       if (this.isHttp && "begin" in args && "end" in args) { | ||||||
|         var rangeStr = args.begin + '-' + (args.end - 1); |         var rangeStr = args.begin + "-" + (args.end - 1); | ||||||
|         xhr.setRequestHeader('Range', 'bytes=' + rangeStr); |         xhr.setRequestHeader("Range", "bytes=" + rangeStr); | ||||||
|         pendingRequest.expectedStatus = 206; |         pendingRequest.expectedStatus = 206; | ||||||
|       } else { |       } else { | ||||||
|         pendingRequest.expectedStatus = 200; |         pendingRequest.expectedStatus = 200; | ||||||
| @ -101,11 +101,11 @@ var NetworkManager = (function NetworkManagerClosure() { | |||||||
| 
 | 
 | ||||||
|       var useMozChunkedLoading = !!args.onProgressiveData; |       var useMozChunkedLoading = !!args.onProgressiveData; | ||||||
|       if (useMozChunkedLoading) { |       if (useMozChunkedLoading) { | ||||||
|         xhr.responseType = 'moz-chunked-arraybuffer'; |         xhr.responseType = "moz-chunked-arraybuffer"; | ||||||
|         pendingRequest.onProgressiveData = args.onProgressiveData; |         pendingRequest.onProgressiveData = args.onProgressiveData; | ||||||
|         pendingRequest.mozChunked = true; |         pendingRequest.mozChunked = true; | ||||||
|       } else { |       } else { | ||||||
|         xhr.responseType = 'arraybuffer'; |         xhr.responseType = "arraybuffer"; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (args.onError) { |       if (args.onError) { | ||||||
| @ -197,7 +197,7 @@ var NetworkManager = (function NetworkManagerClosure() { | |||||||
| 
 | 
 | ||||||
|       var chunk = getArrayBuffer(xhr); |       var chunk = getArrayBuffer(xhr); | ||||||
|       if (xhrStatus === PARTIAL_CONTENT_RESPONSE) { |       if (xhrStatus === PARTIAL_CONTENT_RESPONSE) { | ||||||
|         var rangeHeader = xhr.getResponseHeader('Content-Range'); |         var rangeHeader = xhr.getResponseHeader("Content-Range"); | ||||||
|         var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader); |         var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader); | ||||||
|         var begin = parseInt(matches[1], 10); |         var begin = parseInt(matches[1], 10); | ||||||
|         pendingRequest.onDone({ |         pendingRequest.onDone({ | ||||||
|  | |||||||
| @ -15,74 +15,74 @@ | |||||||
| /* eslint max-len: ["error", 120] */ | /* eslint max-len: ["error", 120] */ | ||||||
| /* globals Components, Services */ | /* globals Components, Services */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| this.EXPORTED_SYMBOLS = ['PdfJsTelemetry']; | this.EXPORTED_SYMBOLS = ["PdfJsTelemetry"]; | ||||||
| 
 | 
 | ||||||
| const Cu = Components.utils; | const Cu = Components.utils; | ||||||
| Cu.import('resource://gre/modules/Services.jsm'); | Cu.import("resource://gre/modules/Services.jsm"); | ||||||
| 
 | 
 | ||||||
| const ADDON_ID = 'uriloader@pdf.js'; | const ADDON_ID = "uriloader@pdf.js"; | ||||||
| 
 | 
 | ||||||
| var Telemetry = Services.telemetry; | var Telemetry = Services.telemetry; | ||||||
| var registerAddonHistogram = Telemetry.registerAddonHistogram; | var registerAddonHistogram = Telemetry.registerAddonHistogram; | ||||||
| 
 | 
 | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_USED', Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_USED", Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_FALLBACK_SHOWN', Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_FALLBACK_SHOWN", Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_DOCUMENT_VERSION', Telemetry.HISTOGRAM_LINEAR, 1, 10, 11); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_DOCUMENT_VERSION", Telemetry.HISTOGRAM_LINEAR, 1, 10, 11); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_DOCUMENT_GENERATOR', Telemetry.HISTOGRAM_LINEAR, 1, 25, 26); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_DOCUMENT_GENERATOR", Telemetry.HISTOGRAM_LINEAR, 1, 25, 26); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_DOCUMENT_SIZE_KB', Telemetry.HISTOGRAM_EXPONENTIAL, 2, 64 * 1024, 20); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_DOCUMENT_SIZE_KB", Telemetry.HISTOGRAM_EXPONENTIAL, 2, 64 * 1024, 20); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_EMBED', Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_EMBED", Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_FONT_TYPES', Telemetry.HISTOGRAM_LINEAR, 1, 19, 20); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_FONT_TYPES", Telemetry.HISTOGRAM_LINEAR, 1, 19, 20); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_FORM', Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_FORM", Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_PRINT', Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_PRINT", Telemetry.HISTOGRAM_BOOLEAN, 1, 2, 3); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_STREAM_TYPES', Telemetry.HISTOGRAM_LINEAR, 1, 19, 20); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_STREAM_TYPES", Telemetry.HISTOGRAM_LINEAR, 1, 19, 20); | ||||||
| registerAddonHistogram(ADDON_ID, 'PDF_VIEWER_TIME_TO_VIEW_MS', Telemetry.HISTOGRAM_EXPONENTIAL, 1, 10000, 50); | registerAddonHistogram(ADDON_ID, "PDF_VIEWER_TIME_TO_VIEW_MS", Telemetry.HISTOGRAM_EXPONENTIAL, 1, 10000, 50); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| this.PdfJsTelemetry = { | this.PdfJsTelemetry = { | ||||||
|   onViewerIsUsed() { |   onViewerIsUsed() { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_USED'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_USED"); | ||||||
|     histogram.add(true); |     histogram.add(true); | ||||||
|   }, |   }, | ||||||
|   onFallback() { |   onFallback() { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_FALLBACK_SHOWN'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_FALLBACK_SHOWN"); | ||||||
|     histogram.add(true); |     histogram.add(true); | ||||||
|   }, |   }, | ||||||
|   onDocumentSize(size) { |   onDocumentSize(size) { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_DOCUMENT_SIZE_KB'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_DOCUMENT_SIZE_KB"); | ||||||
|     histogram.add(size / 1024); |     histogram.add(size / 1024); | ||||||
|   }, |   }, | ||||||
|   onDocumentVersion(versionId) { |   onDocumentVersion(versionId) { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_DOCUMENT_VERSION'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_DOCUMENT_VERSION"); | ||||||
|     histogram.add(versionId); |     histogram.add(versionId); | ||||||
|   }, |   }, | ||||||
|   onDocumentGenerator(generatorId) { |   onDocumentGenerator(generatorId) { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_DOCUMENT_GENERATOR'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_DOCUMENT_GENERATOR"); | ||||||
|     histogram.add(generatorId); |     histogram.add(generatorId); | ||||||
|   }, |   }, | ||||||
|   onEmbed(isObject) { |   onEmbed(isObject) { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_EMBED'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_EMBED"); | ||||||
|     histogram.add(isObject); |     histogram.add(isObject); | ||||||
|   }, |   }, | ||||||
|   onFontType(fontTypeId) { |   onFontType(fontTypeId) { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_FONT_TYPES'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_FONT_TYPES"); | ||||||
|     histogram.add(fontTypeId); |     histogram.add(fontTypeId); | ||||||
|   }, |   }, | ||||||
|   onForm(isAcroform) { |   onForm(isAcroform) { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_FORM'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_FORM"); | ||||||
|     histogram.add(isAcroform); |     histogram.add(isAcroform); | ||||||
|   }, |   }, | ||||||
|   onPrint() { |   onPrint() { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_PRINT'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_PRINT"); | ||||||
|     histogram.add(true); |     histogram.add(true); | ||||||
|   }, |   }, | ||||||
|   onStreamType(streamTypeId) { |   onStreamType(streamTypeId) { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_STREAM_TYPES'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_STREAM_TYPES"); | ||||||
|     histogram.add(streamTypeId); |     histogram.add(streamTypeId); | ||||||
|   }, |   }, | ||||||
|   onTimeToView(ms) { |   onTimeToView(ms) { | ||||||
|     let histogram = Telemetry.getAddonHistogram(ADDON_ID, 'PDF_VIEWER_TIME_TO_VIEW_MS'); |     let histogram = Telemetry.getAddonHistogram(ADDON_ID, "PDF_VIEWER_TIME_TO_VIEW_MS"); | ||||||
|     histogram.add(ms); |     histogram.add(ms); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -15,56 +15,56 @@ | |||||||
| /* eslint max-len: ["error", 100] */ | /* eslint max-len: ["error", 100] */ | ||||||
| /* globals Components, Services */ | /* globals Components, Services */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| this.EXPORTED_SYMBOLS = ['PdfJsTelemetry']; | this.EXPORTED_SYMBOLS = ["PdfJsTelemetry"]; | ||||||
| 
 | 
 | ||||||
| const Cu = Components.utils; | const Cu = Components.utils; | ||||||
| Cu.import('resource://gre/modules/Services.jsm'); | Cu.import("resource://gre/modules/Services.jsm"); | ||||||
| 
 | 
 | ||||||
| this.PdfJsTelemetry = { | this.PdfJsTelemetry = { | ||||||
|   onViewerIsUsed() { |   onViewerIsUsed() { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_USED'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_USED"); | ||||||
|     histogram.add(true); |     histogram.add(true); | ||||||
|   }, |   }, | ||||||
|   onFallback() { |   onFallback() { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FALLBACK_SHOWN'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_FALLBACK_SHOWN"); | ||||||
|     histogram.add(true); |     histogram.add(true); | ||||||
|   }, |   }, | ||||||
|   onDocumentSize(size) { |   onDocumentSize(size) { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_SIZE_KB'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_DOCUMENT_SIZE_KB"); | ||||||
|     histogram.add(size / 1024); |     histogram.add(size / 1024); | ||||||
|   }, |   }, | ||||||
|   onDocumentVersion(versionId) { |   onDocumentVersion(versionId) { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_VERSION'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_DOCUMENT_VERSION"); | ||||||
|     histogram.add(versionId); |     histogram.add(versionId); | ||||||
|   }, |   }, | ||||||
|   onDocumentGenerator(generatorId) { |   onDocumentGenerator(generatorId) { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_GENERATOR'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_DOCUMENT_GENERATOR"); | ||||||
|     histogram.add(generatorId); |     histogram.add(generatorId); | ||||||
|   }, |   }, | ||||||
|   onEmbed(isObject) { |   onEmbed(isObject) { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_EMBED'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_EMBED"); | ||||||
|     histogram.add(isObject); |     histogram.add(isObject); | ||||||
|   }, |   }, | ||||||
|   onFontType(fontTypeId) { |   onFontType(fontTypeId) { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FONT_TYPES'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_FONT_TYPES"); | ||||||
|     histogram.add(fontTypeId); |     histogram.add(fontTypeId); | ||||||
|   }, |   }, | ||||||
|   onForm(isAcroform) { |   onForm(isAcroform) { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FORM'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_FORM"); | ||||||
|     histogram.add(isAcroform); |     histogram.add(isAcroform); | ||||||
|   }, |   }, | ||||||
|   onPrint() { |   onPrint() { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_PRINT'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_PRINT"); | ||||||
|     histogram.add(true); |     histogram.add(true); | ||||||
|   }, |   }, | ||||||
|   onStreamType(streamTypeId) { |   onStreamType(streamTypeId) { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_STREAM_TYPES'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_STREAM_TYPES"); | ||||||
|     histogram.add(streamTypeId); |     histogram.add(streamTypeId); | ||||||
|   }, |   }, | ||||||
|   onTimeToView(ms) { |   onTimeToView(ms) { | ||||||
|     let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_TIME_TO_VIEW_MS'); |     let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_TIME_TO_VIEW_MS"); | ||||||
|     histogram.add(ms); |     histogram.add(ms); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -15,43 +15,43 @@ | |||||||
| /* globals Components, Services, XPCOMUtils, NetUtil, PrivateBrowsingUtils, | /* globals Components, Services, XPCOMUtils, NetUtil, PrivateBrowsingUtils, | ||||||
|            dump, NetworkManager, PdfJsTelemetry, PdfjsContentUtils */ |            dump, NetworkManager, PdfJsTelemetry, PdfjsContentUtils */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| var EXPORTED_SYMBOLS = ['PdfStreamConverter']; | var EXPORTED_SYMBOLS = ["PdfStreamConverter"]; | ||||||
| 
 | 
 | ||||||
| const Cc = Components.classes; | const Cc = Components.classes; | ||||||
| const Ci = Components.interfaces; | const Ci = Components.interfaces; | ||||||
| const Cr = Components.results; | const Cr = Components.results; | ||||||
| const Cu = Components.utils; | const Cu = Components.utils; | ||||||
| // True only if this is the version of pdf.js that is included with firefox.
 | // True only if this is the version of pdf.js that is included with firefox.
 | ||||||
| const MOZ_CENTRAL = JSON.parse('PDFJSSCRIPT_MOZ_CENTRAL'); | const MOZ_CENTRAL = JSON.parse("PDFJSSCRIPT_MOZ_CENTRAL"); | ||||||
| const PDFJS_EVENT_ID = 'pdf.js.message'; | const PDFJS_EVENT_ID = "pdf.js.message"; | ||||||
| const PDF_CONTENT_TYPE = 'application/pdf'; | const PDF_CONTENT_TYPE = "application/pdf"; | ||||||
| const PREF_PREFIX = 'PDFJSSCRIPT_PREF_PREFIX'; | const PREF_PREFIX = "PDFJSSCRIPT_PREF_PREFIX"; | ||||||
| const PDF_VIEWER_WEB_PAGE = 'resource://pdf.js/web/viewer.html'; | const PDF_VIEWER_WEB_PAGE = "resource://pdf.js/web/viewer.html"; | ||||||
| const MAX_NUMBER_OF_PREFS = 50; | const MAX_NUMBER_OF_PREFS = 50; | ||||||
| const MAX_STRING_PREF_LENGTH = 128; | const MAX_STRING_PREF_LENGTH = 128; | ||||||
| 
 | 
 | ||||||
| Cu.import('resource://gre/modules/XPCOMUtils.jsm'); | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||||||
| Cu.import('resource://gre/modules/Services.jsm'); | Cu.import("resource://gre/modules/Services.jsm"); | ||||||
| Cu.import('resource://gre/modules/NetUtil.jsm'); | Cu.import("resource://gre/modules/NetUtil.jsm"); | ||||||
| 
 | 
 | ||||||
| XPCOMUtils.defineLazyModuleGetter(this, 'NetworkManager', | XPCOMUtils.defineLazyModuleGetter(this, "NetworkManager", | ||||||
|   'resource://pdf.js/PdfJsNetwork.jsm'); |   "resource://pdf.js/PdfJsNetwork.jsm"); | ||||||
| 
 | 
 | ||||||
| XPCOMUtils.defineLazyModuleGetter(this, 'PrivateBrowsingUtils', | XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", | ||||||
|   'resource://gre/modules/PrivateBrowsingUtils.jsm'); |   "resource://gre/modules/PrivateBrowsingUtils.jsm"); | ||||||
| 
 | 
 | ||||||
| XPCOMUtils.defineLazyModuleGetter(this, 'PdfJsTelemetry', | XPCOMUtils.defineLazyModuleGetter(this, "PdfJsTelemetry", | ||||||
|   'resource://pdf.js/PdfJsTelemetry.jsm'); |   "resource://pdf.js/PdfJsTelemetry.jsm"); | ||||||
| 
 | 
 | ||||||
| XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsContentUtils', | XPCOMUtils.defineLazyModuleGetter(this, "PdfjsContentUtils", | ||||||
|   'resource://pdf.js/PdfjsContentUtils.jsm'); |   "resource://pdf.js/PdfjsContentUtils.jsm"); | ||||||
| 
 | 
 | ||||||
| var Svc = {}; | var Svc = {}; | ||||||
| XPCOMUtils.defineLazyServiceGetter(Svc, 'mime', | XPCOMUtils.defineLazyServiceGetter(Svc, "mime", | ||||||
|                                    '@mozilla.org/mime;1', |                                    "@mozilla.org/mime;1", | ||||||
|                                    'nsIMIMEService'); |                                    "nsIMIMEService"); | ||||||
| 
 | 
 | ||||||
| function getContainingBrowser(domWindow) { | function getContainingBrowser(domWindow) { | ||||||
|   return domWindow.QueryInterface(Ci.nsIInterfaceRequestor) |   return domWindow.QueryInterface(Ci.nsIInterfaceRequestor) | ||||||
| @ -62,7 +62,7 @@ function getContainingBrowser(domWindow) { | |||||||
| 
 | 
 | ||||||
| function getFindBar(domWindow) { | function getFindBar(domWindow) { | ||||||
|   if (PdfjsContentUtils.isRemote) { |   if (PdfjsContentUtils.isRemote) { | ||||||
|     throw new Error('FindBar is not accessible from the content process.'); |     throw new Error("FindBar is not accessible from the content process."); | ||||||
|   } |   } | ||||||
|   try { |   try { | ||||||
|     var browser = getContainingBrowser(domWindow); |     var browser = getContainingBrowser(domWindow); | ||||||
| @ -101,12 +101,12 @@ function getStringPref(pref, def) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function log(aMsg) { | function log(aMsg) { | ||||||
|   if (!getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false)) { |   if (!getBoolPref(PREF_PREFIX + ".pdfBugEnabled", false)) { | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|   var msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg); |   var msg = "PdfStreamConverter.js: " + (aMsg.join ? aMsg.join("") : aMsg); | ||||||
|   Services.console.logStringMessage(msg); |   Services.console.logStringMessage(msg); | ||||||
|   dump(msg + '\n'); |   dump(msg + "\n"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getDOMWindow(aChannel) { | function getDOMWindow(aChannel) { | ||||||
| @ -118,16 +118,16 @@ function getDOMWindow(aChannel) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getLocalizedStrings(path) { | function getLocalizedStrings(path) { | ||||||
|   var stringBundle = Cc['@mozilla.org/intl/stringbundle;1']. |   var stringBundle = Cc["@mozilla.org/intl/stringbundle;1"]. | ||||||
|       getService(Ci.nsIStringBundleService). |       getService(Ci.nsIStringBundleService). | ||||||
|       createBundle('chrome://pdf.js/locale/' + path); |       createBundle("chrome://pdf.js/locale/" + path); | ||||||
| 
 | 
 | ||||||
|   var map = {}; |   var map = {}; | ||||||
|   var enumerator = stringBundle.getSimpleEnumeration(); |   var enumerator = stringBundle.getSimpleEnumeration(); | ||||||
|   while (enumerator.hasMoreElements()) { |   while (enumerator.hasMoreElements()) { | ||||||
|     var string = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement); |     var string = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement); | ||||||
|     var key = string.key, property = 'textContent'; |     var key = string.key, property = "textContent"; | ||||||
|     var i = key.lastIndexOf('.'); |     var i = key.lastIndexOf("."); | ||||||
|     if (i >= 0) { |     if (i >= 0) { | ||||||
|       property = key.substring(i + 1); |       property = key.substring(i + 1); | ||||||
|       key = key.substring(0, i); |       key = key.substring(0, i); | ||||||
| @ -140,7 +140,7 @@ function getLocalizedStrings(path) { | |||||||
|   return map; |   return map; | ||||||
| } | } | ||||||
| function getLocalizedString(strings, id, property) { | function getLocalizedString(strings, id, property) { | ||||||
|   property = property || 'textContent'; |   property = property || "textContent"; | ||||||
|   if (id in strings) { |   if (id in strings) { | ||||||
|     return strings[id][property]; |     return strings[id][property]; | ||||||
|   } |   } | ||||||
| @ -233,13 +233,13 @@ class ChromeActions { | |||||||
|     // the original url.
 |     // the original url.
 | ||||||
|     var originalUri = NetUtil.newURI(originalUrl); |     var originalUri = NetUtil.newURI(originalUrl); | ||||||
|     var filename = data.filename; |     var filename = data.filename; | ||||||
|     if (typeof filename !== 'string' || |     if (typeof filename !== "string" || | ||||||
|         (!/\.pdf$/i.test(filename) && !data.isAttachment)) { |         (!/\.pdf$/i.test(filename) && !data.isAttachment)) { | ||||||
|       filename = 'document.pdf'; |       filename = "document.pdf"; | ||||||
|     } |     } | ||||||
|     var blobUri = NetUtil.newURI(blobUrl); |     var blobUri = NetUtil.newURI(blobUrl); | ||||||
|     var extHelperAppSvc = |     var extHelperAppSvc = | ||||||
|           Cc['@mozilla.org/uriloader/external-helper-app-service;1']. |           Cc["@mozilla.org/uriloader/external-helper-app-service;1"]. | ||||||
|              getService(Ci.nsIExternalHelperAppService); |              getService(Ci.nsIExternalHelperAppService); | ||||||
| 
 | 
 | ||||||
|     var docIsPrivate = this.isInPrivateBrowsing(); |     var docIsPrivate = this.isInPrivateBrowsing(); | ||||||
| @ -247,7 +247,7 @@ class ChromeActions { | |||||||
|       uri: blobUri, |       uri: blobUri, | ||||||
|       loadUsingSystemPrincipal: true, |       loadUsingSystemPrincipal: true, | ||||||
|     }); |     }); | ||||||
|     if ('nsIPrivateBrowsingChannel' in Ci && |     if ("nsIPrivateBrowsingChannel" in Ci && | ||||||
|         netChannel instanceof Ci.nsIPrivateBrowsingChannel) { |         netChannel instanceof Ci.nsIPrivateBrowsingChannel) { | ||||||
|       netChannel.setPrivate(docIsPrivate); |       netChannel.setPrivate(docIsPrivate); | ||||||
|     } |     } | ||||||
| @ -260,7 +260,7 @@ class ChromeActions { | |||||||
|       } |       } | ||||||
|       // Create a nsIInputStreamChannel so we can set the url on the channel
 |       // Create a nsIInputStreamChannel so we can set the url on the channel
 | ||||||
|       // so the filename will be correct.
 |       // so the filename will be correct.
 | ||||||
|       var channel = Cc['@mozilla.org/network/input-stream-channel;1']. |       var channel = Cc["@mozilla.org/network/input-stream-channel;1"]. | ||||||
|                        createInstance(Ci.nsIInputStreamChannel); |                        createInstance(Ci.nsIInputStreamChannel); | ||||||
|       channel.QueryInterface(Ci.nsIChannel); |       channel.QueryInterface(Ci.nsIChannel); | ||||||
|       try { |       try { | ||||||
| @ -275,7 +275,7 @@ class ChromeActions { | |||||||
|       channel.setURI(originalUri); |       channel.setURI(originalUri); | ||||||
|       channel.loadInfo = netChannel.loadInfo; |       channel.loadInfo = netChannel.loadInfo; | ||||||
|       channel.contentStream = aInputStream; |       channel.contentStream = aInputStream; | ||||||
|       if ('nsIPrivateBrowsingChannel' in Ci && |       if ("nsIPrivateBrowsingChannel" in Ci && | ||||||
|           channel instanceof Ci.nsIPrivateBrowsingChannel) { |           channel instanceof Ci.nsIPrivateBrowsingChannel) { | ||||||
|         channel.setPrivate(docIsPrivate); |         channel.setPrivate(docIsPrivate); | ||||||
|       } |       } | ||||||
| @ -288,8 +288,8 @@ class ChromeActions { | |||||||
|                                 .getInterface(Ci.nsIWebNavigation) |                                 .getInterface(Ci.nsIWebNavigation) | ||||||
|                                 .QueryInterface(Ci.nsILoadContext); |                                 .QueryInterface(Ci.nsILoadContext); | ||||||
|           this.extListener = extHelperAppSvc.doContent( |           this.extListener = extHelperAppSvc.doContent( | ||||||
|             (data.isAttachment ? 'application/octet-stream' : |             (data.isAttachment ? "application/octet-stream" : | ||||||
|                                  'application/pdf'), |                                  "application/pdf"), | ||||||
|             aRequest, loadContext, false); |             aRequest, loadContext, false); | ||||||
|           this.extListener.onStartRequest(aRequest, aContext); |           this.extListener.onStartRequest(aRequest, aContext); | ||||||
|         }, |         }, | ||||||
| @ -313,20 +313,20 @@ class ChromeActions { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   getLocale() { |   getLocale() { | ||||||
|     return getStringPref('general.useragent.locale', 'en-US'); |     return getStringPref("general.useragent.locale", "en-US"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   getStrings(data) { |   getStrings(data) { | ||||||
|     try { |     try { | ||||||
|       // Lazy initialization of localizedStrings
 |       // Lazy initialization of localizedStrings
 | ||||||
|       if (!('localizedStrings' in this)) { |       if (!("localizedStrings" in this)) { | ||||||
|         this.localizedStrings = getLocalizedStrings('viewer.properties'); |         this.localizedStrings = getLocalizedStrings("viewer.properties"); | ||||||
|       } |       } | ||||||
|       var result = this.localizedStrings[data]; |       var result = this.localizedStrings[data]; | ||||||
|       return JSON.stringify(result || null); |       return JSON.stringify(result || null); | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|       log('Unable to retrieve localized strings: ' + e); |       log("Unable to retrieve localized strings: " + e); | ||||||
|       return 'null'; |       return "null"; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -343,52 +343,52 @@ class ChromeActions { | |||||||
| 
 | 
 | ||||||
|     // ... or when the new find events code exists.
 |     // ... or when the new find events code exists.
 | ||||||
|     var findBar = getFindBar(this.domWindow); |     var findBar = getFindBar(this.domWindow); | ||||||
|     return !!findBar && ('updateControlState' in findBar); |     return !!findBar && ("updateControlState" in findBar); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   supportsDocumentFonts() { |   supportsDocumentFonts() { | ||||||
|     var prefBrowser = getIntPref('browser.display.use_document_fonts', 1); |     var prefBrowser = getIntPref("browser.display.use_document_fonts", 1); | ||||||
|     var prefGfx = getBoolPref('gfx.downloadable_fonts.enabled', true); |     var prefGfx = getBoolPref("gfx.downloadable_fonts.enabled", true); | ||||||
|     return (!!prefBrowser && prefGfx); |     return (!!prefBrowser && prefGfx); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   supportsDocumentColors() { |   supportsDocumentColors() { | ||||||
|     return getIntPref('browser.display.document_color_use', 0) !== 2; |     return getIntPref("browser.display.document_color_use", 0) !== 2; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   supportedMouseWheelZoomModifierKeys() { |   supportedMouseWheelZoomModifierKeys() { | ||||||
|     return { |     return { | ||||||
|       ctrlKey: getIntPref('mousewheel.with_control.action', 3) === 3, |       ctrlKey: getIntPref("mousewheel.with_control.action", 3) === 3, | ||||||
|       metaKey: getIntPref('mousewheel.with_meta.action', 1) === 3, |       metaKey: getIntPref("mousewheel.with_meta.action", 1) === 3, | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   reportTelemetry(data) { |   reportTelemetry(data) { | ||||||
|     var probeInfo = JSON.parse(data); |     var probeInfo = JSON.parse(data); | ||||||
|     switch (probeInfo.type) { |     switch (probeInfo.type) { | ||||||
|       case 'documentInfo': |       case "documentInfo": | ||||||
|         if (!this.telemetryState.documentInfo) { |         if (!this.telemetryState.documentInfo) { | ||||||
|           PdfJsTelemetry.onDocumentVersion(probeInfo.version | 0); |           PdfJsTelemetry.onDocumentVersion(probeInfo.version | 0); | ||||||
|           PdfJsTelemetry.onDocumentGenerator(probeInfo.generator | 0); |           PdfJsTelemetry.onDocumentGenerator(probeInfo.generator | 0); | ||||||
|           if (probeInfo.formType) { |           if (probeInfo.formType) { | ||||||
|             PdfJsTelemetry.onForm(probeInfo.formType === 'acroform'); |             PdfJsTelemetry.onForm(probeInfo.formType === "acroform"); | ||||||
|           } |           } | ||||||
|           this.telemetryState.documentInfo = true; |           this.telemetryState.documentInfo = true; | ||||||
|         } |         } | ||||||
|         break; |         break; | ||||||
|       case 'pageInfo': |       case "pageInfo": | ||||||
|         if (!this.telemetryState.firstPageInfo) { |         if (!this.telemetryState.firstPageInfo) { | ||||||
|           var duration = Date.now() - this.telemetryState.startAt; |           var duration = Date.now() - this.telemetryState.startAt; | ||||||
|           PdfJsTelemetry.onTimeToView(duration); |           PdfJsTelemetry.onTimeToView(duration); | ||||||
|           this.telemetryState.firstPageInfo = true; |           this.telemetryState.firstPageInfo = true; | ||||||
|         } |         } | ||||||
|         break; |         break; | ||||||
|       case 'documentStats': |       case "documentStats": | ||||||
|         // documentStats can be called several times for one documents.
 |         // documentStats can be called several times for one documents.
 | ||||||
|         // if stream/font types are reported, trying not to submit the same
 |         // if stream/font types are reported, trying not to submit the same
 | ||||||
|         // enumeration value multiple times.
 |         // enumeration value multiple times.
 | ||||||
|         var documentStats = probeInfo.stats; |         var documentStats = probeInfo.stats; | ||||||
|         if (!documentStats || typeof documentStats !== 'object') { |         if (!documentStats || typeof documentStats !== "object") { | ||||||
|           break; |           break; | ||||||
|         } |         } | ||||||
|         var i, streamTypes = documentStats.streamTypes; |         var i, streamTypes = documentStats.streamTypes; | ||||||
| @ -414,7 +414,7 @@ class ChromeActions { | |||||||
|           } |           } | ||||||
|         } |         } | ||||||
|         break; |         break; | ||||||
|       case 'print': |       case "print": | ||||||
|         PdfJsTelemetry.onPrint(); |         PdfJsTelemetry.onPrint(); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
| @ -428,29 +428,29 @@ class ChromeActions { | |||||||
|     var featureId = args.featureId; |     var featureId = args.featureId; | ||||||
| 
 | 
 | ||||||
|     var domWindow = this.domWindow; |     var domWindow = this.domWindow; | ||||||
|     var strings = getLocalizedStrings('chrome.properties'); |     var strings = getLocalizedStrings("chrome.properties"); | ||||||
|     var message; |     var message; | ||||||
|     if (featureId === 'forms') { |     if (featureId === "forms") { | ||||||
|       message = getLocalizedString(strings, 'unsupported_feature_forms'); |       message = getLocalizedString(strings, "unsupported_feature_forms"); | ||||||
|     } else { |     } else { | ||||||
|       message = getLocalizedString(strings, 'unsupported_feature'); |       message = getLocalizedString(strings, "unsupported_feature"); | ||||||
|     } |     } | ||||||
|     PdfJsTelemetry.onFallback(); |     PdfJsTelemetry.onFallback(); | ||||||
|     PdfjsContentUtils.displayWarning(domWindow, message, |     PdfjsContentUtils.displayWarning(domWindow, message, | ||||||
|       getLocalizedString(strings, 'open_with_different_viewer'), |       getLocalizedString(strings, "open_with_different_viewer"), | ||||||
|       getLocalizedString(strings, 'open_with_different_viewer', 'accessKey')); |       getLocalizedString(strings, "open_with_different_viewer", "accessKey")); | ||||||
| 
 | 
 | ||||||
|     let winmm = domWindow.QueryInterface(Ci.nsIInterfaceRequestor) |     let winmm = domWindow.QueryInterface(Ci.nsIInterfaceRequestor) | ||||||
|                          .getInterface(Ci.nsIDocShell) |                          .getInterface(Ci.nsIDocShell) | ||||||
|                          .QueryInterface(Ci.nsIInterfaceRequestor) |                          .QueryInterface(Ci.nsIInterfaceRequestor) | ||||||
|                          .getInterface(Ci.nsIContentFrameMessageManager); |                          .getInterface(Ci.nsIContentFrameMessageManager); | ||||||
| 
 | 
 | ||||||
|     winmm.addMessageListener('PDFJS:Child:fallbackDownload', |     winmm.addMessageListener("PDFJS:Child:fallbackDownload", | ||||||
|       function fallbackDownload(msg) { |       function fallbackDownload(msg) { | ||||||
|         let data = msg.data; |         let data = msg.data; | ||||||
|         sendResponse(data.download); |         sendResponse(data.download); | ||||||
| 
 | 
 | ||||||
|         winmm.removeMessageListener('PDFJS:Child:fallbackDownload', |         winmm.removeMessageListener("PDFJS:Child:fallbackDownload", | ||||||
|                                     fallbackDownload); |                                     fallbackDownload); | ||||||
|       }); |       }); | ||||||
|   } |   } | ||||||
| @ -463,8 +463,8 @@ class ChromeActions { | |||||||
|     var result = data.result; |     var result = data.result; | ||||||
|     var findPrevious = data.findPrevious; |     var findPrevious = data.findPrevious; | ||||||
|     var findPreviousType = typeof findPrevious; |     var findPreviousType = typeof findPrevious; | ||||||
|     if ((typeof result !== 'number' || result < 0 || result > 3) || |     if ((typeof result !== "number" || result < 0 || result > 3) || | ||||||
|         (findPreviousType !== 'undefined' && findPreviousType !== 'boolean')) { |         (findPreviousType !== "undefined" && findPreviousType !== "boolean")) { | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -473,34 +473,34 @@ class ChromeActions { | |||||||
|                               .QueryInterface(Ci.nsIInterfaceRequestor) |                               .QueryInterface(Ci.nsIInterfaceRequestor) | ||||||
|                               .getInterface(Ci.nsIContentFrameMessageManager); |                               .getInterface(Ci.nsIContentFrameMessageManager); | ||||||
| 
 | 
 | ||||||
|     winmm.sendAsyncMessage('PDFJS:Parent:updateControlState', data); |     winmm.sendAsyncMessage("PDFJS:Parent:updateControlState", data); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   setPreferences(prefs, sendResponse) { |   setPreferences(prefs, sendResponse) { | ||||||
|     var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.'); |     var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + "."); | ||||||
|     var numberOfPrefs = 0; |     var numberOfPrefs = 0; | ||||||
|     var prefValue, prefName; |     var prefValue, prefName; | ||||||
|     for (var key in prefs) { |     for (var key in prefs) { | ||||||
|       if (++numberOfPrefs > MAX_NUMBER_OF_PREFS) { |       if (++numberOfPrefs > MAX_NUMBER_OF_PREFS) { | ||||||
|         log('setPreferences - Exceeded the maximum number of preferences ' + |         log("setPreferences - Exceeded the maximum number of preferences " + | ||||||
|             'that is allowed to be set at once.'); |             "that is allowed to be set at once."); | ||||||
|         break; |         break; | ||||||
|       } else if (!defaultBranch.getPrefType(key)) { |       } else if (!defaultBranch.getPrefType(key)) { | ||||||
|         continue; |         continue; | ||||||
|       } |       } | ||||||
|       prefValue = prefs[key]; |       prefValue = prefs[key]; | ||||||
|       prefName = (PREF_PREFIX + '.' + key); |       prefName = (PREF_PREFIX + "." + key); | ||||||
|       switch (typeof prefValue) { |       switch (typeof prefValue) { | ||||||
|         case 'boolean': |         case "boolean": | ||||||
|           PdfjsContentUtils.setBoolPref(prefName, prefValue); |           PdfjsContentUtils.setBoolPref(prefName, prefValue); | ||||||
|           break; |           break; | ||||||
|         case 'number': |         case "number": | ||||||
|           PdfjsContentUtils.setIntPref(prefName, prefValue); |           PdfjsContentUtils.setIntPref(prefName, prefValue); | ||||||
|           break; |           break; | ||||||
|         case 'string': |         case "string": | ||||||
|           if (prefValue.length > MAX_STRING_PREF_LENGTH) { |           if (prefValue.length > MAX_STRING_PREF_LENGTH) { | ||||||
|             log('setPreferences - Exceeded the maximum allowed length ' + |             log("setPreferences - Exceeded the maximum allowed length " + | ||||||
|                 'for a string preference.'); |                 "for a string preference."); | ||||||
|           } else { |           } else { | ||||||
|             PdfjsContentUtils.setStringPref(prefName, prefValue); |             PdfjsContentUtils.setStringPref(prefName, prefValue); | ||||||
|           } |           } | ||||||
| @ -513,27 +513,27 @@ class ChromeActions { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   getPreferences(prefs, sendResponse) { |   getPreferences(prefs, sendResponse) { | ||||||
|     var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.'); |     var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + "."); | ||||||
|     var currentPrefs = {}, numberOfPrefs = 0; |     var currentPrefs = {}, numberOfPrefs = 0; | ||||||
|     var prefValue, prefName; |     var prefValue, prefName; | ||||||
|     for (var key in prefs) { |     for (var key in prefs) { | ||||||
|       if (++numberOfPrefs > MAX_NUMBER_OF_PREFS) { |       if (++numberOfPrefs > MAX_NUMBER_OF_PREFS) { | ||||||
|         log('getPreferences - Exceeded the maximum number of preferences ' + |         log("getPreferences - Exceeded the maximum number of preferences " + | ||||||
|             'that is allowed to be fetched at once.'); |             "that is allowed to be fetched at once."); | ||||||
|         break; |         break; | ||||||
|       } else if (!defaultBranch.getPrefType(key)) { |       } else if (!defaultBranch.getPrefType(key)) { | ||||||
|         continue; |         continue; | ||||||
|       } |       } | ||||||
|       prefValue = prefs[key]; |       prefValue = prefs[key]; | ||||||
|       prefName = (PREF_PREFIX + '.' + key); |       prefName = (PREF_PREFIX + "." + key); | ||||||
|       switch (typeof prefValue) { |       switch (typeof prefValue) { | ||||||
|         case 'boolean': |         case "boolean": | ||||||
|           currentPrefs[key] = getBoolPref(prefName, prefValue); |           currentPrefs[key] = getBoolPref(prefName, prefValue); | ||||||
|           break; |           break; | ||||||
|         case 'number': |         case "number": | ||||||
|           currentPrefs[key] = getIntPref(prefName, prefValue); |           currentPrefs[key] = getIntPref(prefName, prefValue); | ||||||
|           break; |           break; | ||||||
|         case 'string': |         case "string": | ||||||
|           currentPrefs[key] = getStringPref(prefName, prefValue); |           currentPrefs[key] = getStringPref(prefName, prefValue); | ||||||
|           break; |           break; | ||||||
|       } |       } | ||||||
| @ -566,7 +566,7 @@ class RangedChromeActions extends ChromeActions { | |||||||
|     var httpHeaderVisitor = { |     var httpHeaderVisitor = { | ||||||
|       headers: {}, |       headers: {}, | ||||||
|       visitHeader(aHeader, aValue) { |       visitHeader(aHeader, aValue) { | ||||||
|         if (aHeader === 'Range') { |         if (aHeader === "Range") { | ||||||
|           // When loading the PDF from cache, firefox seems to set the Range
 |           // When loading the PDF from cache, firefox seems to set the Range
 | ||||||
|           // request header to fetch only the unfetched portions of the file
 |           // request header to fetch only the unfetched portions of the file
 | ||||||
|           // (e.g. 'Range: bytes=1024-'). However, we want to set this header
 |           // (e.g. 'Range: bytes=1024-'). However, we want to set this header
 | ||||||
| @ -584,7 +584,7 @@ class RangedChromeActions extends ChromeActions { | |||||||
|     var xhr_onreadystatechange = function xhr_onreadystatechange() { |     var xhr_onreadystatechange = function xhr_onreadystatechange() { | ||||||
|       if (this.readyState === 1) { // LOADING
 |       if (this.readyState === 1) { // LOADING
 | ||||||
|         var netChannel = this.channel; |         var netChannel = this.channel; | ||||||
|         if ('nsIPrivateBrowsingChannel' in Ci && |         if ("nsIPrivateBrowsingChannel" in Ci && | ||||||
|             netChannel instanceof Ci.nsIPrivateBrowsingChannel) { |             netChannel instanceof Ci.nsIPrivateBrowsingChannel) { | ||||||
|           var docIsPrivate = self.isInPrivateBrowsing(); |           var docIsPrivate = self.isInPrivateBrowsing(); | ||||||
|           netChannel.setPrivate(docIsPrivate); |           netChannel.setPrivate(docIsPrivate); | ||||||
| @ -593,9 +593,9 @@ class RangedChromeActions extends ChromeActions { | |||||||
|     }; |     }; | ||||||
|     var getXhr = function getXhr() { |     var getXhr = function getXhr() { | ||||||
|       const XMLHttpRequest = Components.Constructor( |       const XMLHttpRequest = Components.Constructor( | ||||||
|           '@mozilla.org/xmlextras/xmlhttprequest;1'); |           "@mozilla.org/xmlextras/xmlhttprequest;1"); | ||||||
|       var xhr = new XMLHttpRequest(); |       var xhr = new XMLHttpRequest(); | ||||||
|       xhr.addEventListener('readystatechange', xhr_onreadystatechange); |       xhr.addEventListener("readystatechange", xhr_onreadystatechange); | ||||||
|       return xhr; |       return xhr; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| @ -606,7 +606,7 @@ class RangedChromeActions extends ChromeActions { | |||||||
| 
 | 
 | ||||||
|     // If we are in range request mode, this means we manually issued xhr
 |     // If we are in range request mode, this means we manually issued xhr
 | ||||||
|     // requests, which we need to abort when we leave the page
 |     // requests, which we need to abort when we leave the page
 | ||||||
|     domWindow.addEventListener('unload', function unload(e) { |     domWindow.addEventListener("unload", function unload(e) { | ||||||
|       domWindow.removeEventListener(e.type, unload); |       domWindow.removeEventListener(e.type, unload); | ||||||
|       self.abortLoading(); |       self.abortLoading(); | ||||||
|     }); |     }); | ||||||
| @ -624,11 +624,11 @@ class RangedChromeActions extends ChromeActions { | |||||||
| 
 | 
 | ||||||
|       this.dataListener.onprogress = (loaded, total) => { |       this.dataListener.onprogress = (loaded, total) => { | ||||||
|         this.domWindow.postMessage({ |         this.domWindow.postMessage({ | ||||||
|           pdfjsLoadAction: 'progressiveRead', |           pdfjsLoadAction: "progressiveRead", | ||||||
|           loaded, |           loaded, | ||||||
|           total, |           total, | ||||||
|           chunk: this.dataListener.readData(), |           chunk: this.dataListener.readData(), | ||||||
|         }, '*'); |         }, "*"); | ||||||
|       }; |       }; | ||||||
|       this.dataListener.oncomplete = () => { |       this.dataListener.oncomplete = () => { | ||||||
|         this.dataListener = null; |         this.dataListener = null; | ||||||
| @ -636,13 +636,13 @@ class RangedChromeActions extends ChromeActions { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     this.domWindow.postMessage({ |     this.domWindow.postMessage({ | ||||||
|       pdfjsLoadAction: 'supportsRangedLoading', |       pdfjsLoadAction: "supportsRangedLoading", | ||||||
|       rangeEnabled: this.rangeEnabled, |       rangeEnabled: this.rangeEnabled, | ||||||
|       streamingEnabled: this.streamingEnabled, |       streamingEnabled: this.streamingEnabled, | ||||||
|       pdfUrl: this.pdfUrl, |       pdfUrl: this.pdfUrl, | ||||||
|       length: this.contentLength, |       length: this.contentLength, | ||||||
|       data, |       data, | ||||||
|     }, '*'); |     }, "*"); | ||||||
| 
 | 
 | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
| @ -661,16 +661,16 @@ class RangedChromeActions extends ChromeActions { | |||||||
|     this.networkManager.requestRange(begin, end, { |     this.networkManager.requestRange(begin, end, { | ||||||
|       onDone: function RangedChromeActions_onDone(aArgs) { |       onDone: function RangedChromeActions_onDone(aArgs) { | ||||||
|         domWindow.postMessage({ |         domWindow.postMessage({ | ||||||
|           pdfjsLoadAction: 'range', |           pdfjsLoadAction: "range", | ||||||
|           begin: aArgs.begin, |           begin: aArgs.begin, | ||||||
|           chunk: aArgs.chunk, |           chunk: aArgs.chunk, | ||||||
|         }, '*'); |         }, "*"); | ||||||
|       }, |       }, | ||||||
|       onProgress: function RangedChromeActions_onProgress(evt) { |       onProgress: function RangedChromeActions_onProgress(evt) { | ||||||
|         domWindow.postMessage({ |         domWindow.postMessage({ | ||||||
|           pdfjsLoadAction: 'rangeProgress', |           pdfjsLoadAction: "rangeProgress", | ||||||
|           loaded: evt.loaded, |           loaded: evt.loaded, | ||||||
|         }, '*'); |         }, "*"); | ||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
| @ -703,18 +703,18 @@ class StandardChromeActions extends ChromeActions { | |||||||
| 
 | 
 | ||||||
|     this.dataListener.onprogress = (loaded, total) => { |     this.dataListener.onprogress = (loaded, total) => { | ||||||
|       this.domWindow.postMessage({ |       this.domWindow.postMessage({ | ||||||
|         pdfjsLoadAction: 'progress', |         pdfjsLoadAction: "progress", | ||||||
|         loaded, |         loaded, | ||||||
|         total, |         total, | ||||||
|       }, '*'); |       }, "*"); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     this.dataListener.oncomplete = (data, errorCode) => { |     this.dataListener.oncomplete = (data, errorCode) => { | ||||||
|       this.domWindow.postMessage({ |       this.domWindow.postMessage({ | ||||||
|         pdfjsLoadAction: 'complete', |         pdfjsLoadAction: "complete", | ||||||
|         data, |         data, | ||||||
|         errorCode, |         errorCode, | ||||||
|       }, '*'); |       }, "*"); | ||||||
| 
 | 
 | ||||||
|       this.dataListener = null; |       this.dataListener = null; | ||||||
|       this.originalRequest = null; |       this.originalRequest = null; | ||||||
| @ -749,7 +749,7 @@ class RequestListener { | |||||||
|     var sync = event.detail.sync; |     var sync = event.detail.sync; | ||||||
|     var actions = this.actions; |     var actions = this.actions; | ||||||
|     if (!(action in actions)) { |     if (!(action in actions)) { | ||||||
|       log('Unknown action: ' + action); |       log("Unknown action: " + action); | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|     var response; |     var response; | ||||||
| @ -763,9 +763,9 @@ class RequestListener { | |||||||
|       } else { |       } else { | ||||||
|         response = function sendResponse(aResponse) { |         response = function sendResponse(aResponse) { | ||||||
|           try { |           try { | ||||||
|             var listener = doc.createEvent('CustomEvent'); |             var listener = doc.createEvent("CustomEvent"); | ||||||
|             let detail = Cu.cloneInto({ response: aResponse }, doc.defaultView); |             let detail = Cu.cloneInto({ response: aResponse }, doc.defaultView); | ||||||
|             listener.initCustomEvent('pdf.js.response', true, false, detail); |             listener.initCustomEvent("pdf.js.response", true, false, detail); | ||||||
|             return message.dispatchEvent(listener); |             return message.dispatchEvent(listener); | ||||||
|           } catch (e) { |           } catch (e) { | ||||||
|             // doc is no longer accessible because the requestor is already
 |             // doc is no longer accessible because the requestor is already
 | ||||||
| @ -797,14 +797,14 @@ class FindEventManager { | |||||||
|       this.unbind(); |       this.unbind(); | ||||||
|       this.contentWindow.removeEventListener(e.type, unload); |       this.contentWindow.removeEventListener(e.type, unload); | ||||||
|     }.bind(this); |     }.bind(this); | ||||||
|     this.contentWindow.addEventListener('unload', unload); |     this.contentWindow.addEventListener("unload", unload); | ||||||
| 
 | 
 | ||||||
|     // We cannot directly attach listeners to for the find events
 |     // We cannot directly attach listeners to for the find events
 | ||||||
|     // since the FindBar is in the parent process. Instead we're
 |     // since the FindBar is in the parent process. Instead we're
 | ||||||
|     // asking the PdfjsChromeUtils to do it for us and forward
 |     // asking the PdfjsChromeUtils to do it for us and forward
 | ||||||
|     // all the find events to us.
 |     // all the find events to us.
 | ||||||
|     this.winmm.sendAsyncMessage('PDFJS:Parent:addEventListener'); |     this.winmm.sendAsyncMessage("PDFJS:Parent:addEventListener"); | ||||||
|     this.winmm.addMessageListener('PDFJS:Child:handleEvent', this); |     this.winmm.addMessageListener("PDFJS:Child:handleEvent", this); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   receiveMessage(msg) { |   receiveMessage(msg) { | ||||||
| @ -813,13 +813,13 @@ class FindEventManager { | |||||||
|     var contentWindow = this.contentWindow; |     var contentWindow = this.contentWindow; | ||||||
| 
 | 
 | ||||||
|     detail = Cu.cloneInto(detail, contentWindow); |     detail = Cu.cloneInto(detail, contentWindow); | ||||||
|     var forward = contentWindow.document.createEvent('CustomEvent'); |     var forward = contentWindow.document.createEvent("CustomEvent"); | ||||||
|     forward.initCustomEvent(type, true, true, detail); |     forward.initCustomEvent(type, true, true, detail); | ||||||
|     contentWindow.dispatchEvent(forward); |     contentWindow.dispatchEvent(forward); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   unbind() { |   unbind() { | ||||||
|     this.winmm.sendAsyncMessage('PDFJS:Parent:removeEventListener'); |     this.winmm.sendAsyncMessage("PDFJS:Parent:removeEventListener"); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -829,12 +829,12 @@ function PdfStreamConverter() { | |||||||
| PdfStreamConverter.prototype = { | PdfStreamConverter.prototype = { | ||||||
| 
 | 
 | ||||||
|   // properties required for XPCOM registration:
 |   // properties required for XPCOM registration:
 | ||||||
|   classID: Components.ID('{PDFJSSCRIPT_STREAM_CONVERTER_ID}'), |   classID: Components.ID("{PDFJSSCRIPT_STREAM_CONVERTER_ID}"), | ||||||
|   classDescription: 'pdf.js Component', |   classDescription: "pdf.js Component", | ||||||
|   contractID: '@mozilla.org/streamconv;1?from=application/pdf&to=*/*', |   contractID: "@mozilla.org/streamconv;1?from=application/pdf&to=*/*", | ||||||
| 
 | 
 | ||||||
|   classID2: Components.ID('{PDFJSSCRIPT_STREAM_CONVERTER2_ID}'), |   classID2: Components.ID("{PDFJSSCRIPT_STREAM_CONVERTER2_ID}"), | ||||||
|   contractID2: '@mozilla.org/streamconv;1?from=application/pdf&to=text/html', |   contractID2: "@mozilla.org/streamconv;1?from=application/pdf&to=text/html", | ||||||
| 
 | 
 | ||||||
|   QueryInterface: XPCOMUtils.generateQI([ |   QueryInterface: XPCOMUtils.generateQI([ | ||||||
|       Ci.nsISupports, |       Ci.nsISupports, | ||||||
| @ -894,29 +894,29 @@ PdfStreamConverter.prototype = { | |||||||
|     var rangeRequest = false; |     var rangeRequest = false; | ||||||
|     var streamRequest = false; |     var streamRequest = false; | ||||||
|     if (isHttpRequest) { |     if (isHttpRequest) { | ||||||
|       var contentEncoding = 'identity'; |       var contentEncoding = "identity"; | ||||||
|       try { |       try { | ||||||
|         contentEncoding = aRequest.getResponseHeader('Content-Encoding'); |         contentEncoding = aRequest.getResponseHeader("Content-Encoding"); | ||||||
|       } catch (e) {} |       } catch (e) {} | ||||||
| 
 | 
 | ||||||
|       var acceptRanges; |       var acceptRanges; | ||||||
|       try { |       try { | ||||||
|         acceptRanges = aRequest.getResponseHeader('Accept-Ranges'); |         acceptRanges = aRequest.getResponseHeader("Accept-Ranges"); | ||||||
|       } catch (e) {} |       } catch (e) {} | ||||||
| 
 | 
 | ||||||
|       var hash = aRequest.URI.ref; |       var hash = aRequest.URI.ref; | ||||||
|       var isPDFBugEnabled = getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false); |       var isPDFBugEnabled = getBoolPref(PREF_PREFIX + ".pdfBugEnabled", false); | ||||||
|       rangeRequest = contentEncoding === 'identity' && |       rangeRequest = contentEncoding === "identity" && | ||||||
|                      acceptRanges === 'bytes' && |                      acceptRanges === "bytes" && | ||||||
|                      aRequest.contentLength >= 0 && |                      aRequest.contentLength >= 0 && | ||||||
|                      !getBoolPref(PREF_PREFIX + '.disableRange', false) && |                      !getBoolPref(PREF_PREFIX + ".disableRange", false) && | ||||||
|                      (!isPDFBugEnabled || |                      (!isPDFBugEnabled || | ||||||
|                       hash.toLowerCase().indexOf('disablerange=true') < 0); |                       hash.toLowerCase().indexOf("disablerange=true") < 0); | ||||||
|       streamRequest = contentEncoding === 'identity' && |       streamRequest = contentEncoding === "identity" && | ||||||
|                       aRequest.contentLength >= 0 && |                       aRequest.contentLength >= 0 && | ||||||
|                       !getBoolPref(PREF_PREFIX + '.disableStream', false) && |                       !getBoolPref(PREF_PREFIX + ".disableStream", false) && | ||||||
|                       (!isPDFBugEnabled || |                       (!isPDFBugEnabled || | ||||||
|                        hash.toLowerCase().indexOf('disablestream=true') < 0); |                        hash.toLowerCase().indexOf("disablestream=true") < 0); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     aRequest.QueryInterface(Ci.nsIChannel); |     aRequest.QueryInterface(Ci.nsIChannel); | ||||||
| @ -929,15 +929,15 @@ PdfStreamConverter.prototype = { | |||||||
|     } catch (e) {} |     } catch (e) {} | ||||||
| 
 | 
 | ||||||
|     // Change the content type so we don't get stuck in a loop.
 |     // Change the content type so we don't get stuck in a loop.
 | ||||||
|     aRequest.setProperty('contentType', aRequest.contentType); |     aRequest.setProperty("contentType", aRequest.contentType); | ||||||
|     aRequest.contentType = 'text/html'; |     aRequest.contentType = "text/html"; | ||||||
|     if (isHttpRequest) { |     if (isHttpRequest) { | ||||||
|       // We trust PDF viewer, using no CSP
 |       // We trust PDF viewer, using no CSP
 | ||||||
|       aRequest.setResponseHeader('Content-Security-Policy', '', false); |       aRequest.setResponseHeader("Content-Security-Policy", "", false); | ||||||
|       aRequest.setResponseHeader('Content-Security-Policy-Report-Only', '', |       aRequest.setResponseHeader("Content-Security-Policy-Report-Only", "", | ||||||
|                                  false); |                                  false); | ||||||
|       // The viewer does not need to handle HTTP Refresh header.
 |       // The viewer does not need to handle HTTP Refresh header.
 | ||||||
|       aRequest.setResponseHeader('Refresh', '', false); |       aRequest.setResponseHeader("Refresh", "", false); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     PdfJsTelemetry.onViewerIsUsed(); |     PdfJsTelemetry.onViewerIsUsed(); | ||||||
| @ -946,7 +946,7 @@ PdfStreamConverter.prototype = { | |||||||
|     // Creating storage for PDF data
 |     // Creating storage for PDF data
 | ||||||
|     var contentLength = aRequest.contentLength; |     var contentLength = aRequest.contentLength; | ||||||
|     this.dataListener = new PdfDataListener(contentLength); |     this.dataListener = new PdfDataListener(contentLength); | ||||||
|     this.binaryStream = Cc['@mozilla.org/binaryinputstream;1'] |     this.binaryStream = Cc["@mozilla.org/binaryinputstream;1"] | ||||||
|                         .createInstance(Ci.nsIBinaryInputStream); |                         .createInstance(Ci.nsIBinaryInputStream); | ||||||
| 
 | 
 | ||||||
|     // Create a new channel that is viewer loaded as a resource.
 |     // Create a new channel that is viewer loaded as a resource.
 | ||||||
| @ -993,8 +993,8 @@ PdfStreamConverter.prototype = { | |||||||
|         listener.onStopRequest(aRequest, aContext, statusCode); |         listener.onStopRequest(aRequest, aContext, statusCode); | ||||||
| 
 | 
 | ||||||
|         if (domWindow.frameElement) { |         if (domWindow.frameElement) { | ||||||
|           var isObjectEmbed = domWindow.frameElement.tagName !== 'IFRAME' || |           var isObjectEmbed = domWindow.frameElement.tagName !== "IFRAME" || | ||||||
|             domWindow.frameElement.className === 'previewPluginContentFrame'; |             domWindow.frameElement.className === "previewPluginContentFrame"; | ||||||
|           PdfJsTelemetry.onEmbed(isObjectEmbed); |           PdfJsTelemetry.onEmbed(isObjectEmbed); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
| @ -1008,7 +1008,7 @@ PdfStreamConverter.prototype = { | |||||||
|     // We can use the resource principal when data is fetched by the chrome,
 |     // We can use the resource principal when data is fetched by the chrome,
 | ||||||
|     // e.g. useful for NoScript. Make make sure we reuse the origin attributes
 |     // e.g. useful for NoScript. Make make sure we reuse the origin attributes
 | ||||||
|     // from the request channel to keep isolation consistent.
 |     // from the request channel to keep isolation consistent.
 | ||||||
|     var ssm = Cc['@mozilla.org/scriptsecuritymanager;1'] |     var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] | ||||||
|                 .getService(Ci.nsIScriptSecurityManager); |                 .getService(Ci.nsIScriptSecurityManager); | ||||||
|     var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE); |     var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE); | ||||||
|     var resourcePrincipal = |     var resourcePrincipal = | ||||||
|  | |||||||
| @ -14,30 +14,30 @@ | |||||||
|  */ |  */ | ||||||
| /* globals Components, Services, XPCOMUtils */ | /* globals Components, Services, XPCOMUtils */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| var EXPORTED_SYMBOLS = ['PdfjsChromeUtils']; | var EXPORTED_SYMBOLS = ["PdfjsChromeUtils"]; | ||||||
| 
 | 
 | ||||||
| const Cc = Components.classes; | const Cc = Components.classes; | ||||||
| const Ci = Components.interfaces; | const Ci = Components.interfaces; | ||||||
| const Cr = Components.results; | const Cr = Components.results; | ||||||
| const Cu = Components.utils; | const Cu = Components.utils; | ||||||
| 
 | 
 | ||||||
| const PREF_PREFIX = 'PDFJSSCRIPT_PREF_PREFIX'; | const PREF_PREFIX = "PDFJSSCRIPT_PREF_PREFIX"; | ||||||
| const PDF_CONTENT_TYPE = 'application/pdf'; | const PDF_CONTENT_TYPE = "application/pdf"; | ||||||
| 
 | 
 | ||||||
| Cu.import('resource://gre/modules/XPCOMUtils.jsm'); | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||||||
| Cu.import('resource://gre/modules/Services.jsm'); | Cu.import("resource://gre/modules/Services.jsm"); | ||||||
| 
 | 
 | ||||||
| var Svc = {}; | var Svc = {}; | ||||||
| XPCOMUtils.defineLazyServiceGetter(Svc, 'mime', | XPCOMUtils.defineLazyServiceGetter(Svc, "mime", | ||||||
|                                    '@mozilla.org/mime;1', |                                    "@mozilla.org/mime;1", | ||||||
|                                    'nsIMIMEService'); |                                    "nsIMIMEService"); | ||||||
| 
 | 
 | ||||||
| var DEFAULT_PREFERENCES = | var DEFAULT_PREFERENCES = | ||||||
| //#include ../../../web/default_preferences.json
 | //#include ../../../web/default_preferences.json
 | ||||||
| //#if false
 | //#if false
 | ||||||
|   'end of DEFAULT_PREFERENCES'; |   "end of DEFAULT_PREFERENCES"; | ||||||
| //#endif
 | //#endif
 | ||||||
| 
 | 
 | ||||||
| var PdfjsChromeUtils = { | var PdfjsChromeUtils = { | ||||||
| @ -55,46 +55,46 @@ var PdfjsChromeUtils = { | |||||||
|     this._browsers = new WeakSet(); |     this._browsers = new WeakSet(); | ||||||
|     if (!this._ppmm) { |     if (!this._ppmm) { | ||||||
|       // global parent process message manager (PPMM)
 |       // global parent process message manager (PPMM)
 | ||||||
|       this._ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1']. |       this._ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]. | ||||||
|         getService(Ci.nsIMessageBroadcaster); |         getService(Ci.nsIMessageBroadcaster); | ||||||
|       this._ppmm.addMessageListener('PDFJS:Parent:clearUserPref', this); |       this._ppmm.addMessageListener("PDFJS:Parent:clearUserPref", this); | ||||||
|       this._ppmm.addMessageListener('PDFJS:Parent:setIntPref', this); |       this._ppmm.addMessageListener("PDFJS:Parent:setIntPref", this); | ||||||
|       this._ppmm.addMessageListener('PDFJS:Parent:setBoolPref', this); |       this._ppmm.addMessageListener("PDFJS:Parent:setBoolPref", this); | ||||||
|       this._ppmm.addMessageListener('PDFJS:Parent:setCharPref', this); |       this._ppmm.addMessageListener("PDFJS:Parent:setCharPref", this); | ||||||
|       this._ppmm.addMessageListener('PDFJS:Parent:setStringPref', this); |       this._ppmm.addMessageListener("PDFJS:Parent:setStringPref", this); | ||||||
|       this._ppmm.addMessageListener('PDFJS:Parent:isDefaultHandlerApp', this); |       this._ppmm.addMessageListener("PDFJS:Parent:isDefaultHandlerApp", this); | ||||||
| 
 | 
 | ||||||
|       // global dom message manager (MMg)
 |       // global dom message manager (MMg)
 | ||||||
|       this._mmg = Cc['@mozilla.org/globalmessagemanager;1']. |       this._mmg = Cc["@mozilla.org/globalmessagemanager;1"]. | ||||||
|         getService(Ci.nsIMessageListenerManager); |         getService(Ci.nsIMessageListenerManager); | ||||||
|       this._mmg.addMessageListener('PDFJS:Parent:displayWarning', this); |       this._mmg.addMessageListener("PDFJS:Parent:displayWarning", this); | ||||||
| 
 | 
 | ||||||
|       this._mmg.addMessageListener('PDFJS:Parent:addEventListener', this); |       this._mmg.addMessageListener("PDFJS:Parent:addEventListener", this); | ||||||
|       this._mmg.addMessageListener('PDFJS:Parent:removeEventListener', this); |       this._mmg.addMessageListener("PDFJS:Parent:removeEventListener", this); | ||||||
|       this._mmg.addMessageListener('PDFJS:Parent:updateControlState', this); |       this._mmg.addMessageListener("PDFJS:Parent:updateControlState", this); | ||||||
| 
 | 
 | ||||||
|       // observer to handle shutdown
 |       // observer to handle shutdown
 | ||||||
|       Services.obs.addObserver(this, 'quit-application', false); |       Services.obs.addObserver(this, "quit-application", false); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   uninit() { |   uninit() { | ||||||
|     if (this._ppmm) { |     if (this._ppmm) { | ||||||
|       this._ppmm.removeMessageListener('PDFJS:Parent:clearUserPref', this); |       this._ppmm.removeMessageListener("PDFJS:Parent:clearUserPref", this); | ||||||
|       this._ppmm.removeMessageListener('PDFJS:Parent:setIntPref', this); |       this._ppmm.removeMessageListener("PDFJS:Parent:setIntPref", this); | ||||||
|       this._ppmm.removeMessageListener('PDFJS:Parent:setBoolPref', this); |       this._ppmm.removeMessageListener("PDFJS:Parent:setBoolPref", this); | ||||||
|       this._ppmm.removeMessageListener('PDFJS:Parent:setCharPref', this); |       this._ppmm.removeMessageListener("PDFJS:Parent:setCharPref", this); | ||||||
|       this._ppmm.removeMessageListener('PDFJS:Parent:setStringPref', this); |       this._ppmm.removeMessageListener("PDFJS:Parent:setStringPref", this); | ||||||
|       this._ppmm.removeMessageListener('PDFJS:Parent:isDefaultHandlerApp', |       this._ppmm.removeMessageListener("PDFJS:Parent:isDefaultHandlerApp", | ||||||
|                                        this); |                                        this); | ||||||
| 
 | 
 | ||||||
|       this._mmg.removeMessageListener('PDFJS:Parent:displayWarning', this); |       this._mmg.removeMessageListener("PDFJS:Parent:displayWarning", this); | ||||||
| 
 | 
 | ||||||
|       this._mmg.removeMessageListener('PDFJS:Parent:addEventListener', this); |       this._mmg.removeMessageListener("PDFJS:Parent:addEventListener", this); | ||||||
|       this._mmg.removeMessageListener('PDFJS:Parent:removeEventListener', this); |       this._mmg.removeMessageListener("PDFJS:Parent:removeEventListener", this); | ||||||
|       this._mmg.removeMessageListener('PDFJS:Parent:updateControlState', this); |       this._mmg.removeMessageListener("PDFJS:Parent:updateControlState", this); | ||||||
| 
 | 
 | ||||||
|       Services.obs.removeObserver(this, 'quit-application'); |       Services.obs.removeObserver(this, "quit-application"); | ||||||
| 
 | 
 | ||||||
|       this._mmg = null; |       this._mmg = null; | ||||||
|       this._ppmm = null; |       this._ppmm = null; | ||||||
| @ -115,7 +115,7 @@ var PdfjsChromeUtils = { | |||||||
|       // manager, which means this is going to fire to every child process
 |       // manager, which means this is going to fire to every child process
 | ||||||
|       // we have open. Unfortunately I can't find a way to get at that
 |       // we have open. Unfortunately I can't find a way to get at that
 | ||||||
|       // process specific mm from js.
 |       // process specific mm from js.
 | ||||||
|       this._ppmm.broadcastAsyncMessage('PDFJS:Child:refreshSettings', {}); |       this._ppmm.broadcastAsyncMessage("PDFJS:Child:refreshSettings", {}); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
| @ -124,40 +124,40 @@ var PdfjsChromeUtils = { | |||||||
|    */ |    */ | ||||||
| 
 | 
 | ||||||
|   observe(aSubject, aTopic, aData) { |   observe(aSubject, aTopic, aData) { | ||||||
|     if (aTopic === 'quit-application') { |     if (aTopic === "quit-application") { | ||||||
|       this.uninit(); |       this.uninit(); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   receiveMessage(aMsg) { |   receiveMessage(aMsg) { | ||||||
|     switch (aMsg.name) { |     switch (aMsg.name) { | ||||||
|       case 'PDFJS:Parent:clearUserPref': |       case "PDFJS:Parent:clearUserPref": | ||||||
|         this._clearUserPref(aMsg.data.name); |         this._clearUserPref(aMsg.data.name); | ||||||
|         break; |         break; | ||||||
|       case 'PDFJS:Parent:setIntPref': |       case "PDFJS:Parent:setIntPref": | ||||||
|         this._setIntPref(aMsg.data.name, aMsg.data.value); |         this._setIntPref(aMsg.data.name, aMsg.data.value); | ||||||
|         break; |         break; | ||||||
|       case 'PDFJS:Parent:setBoolPref': |       case "PDFJS:Parent:setBoolPref": | ||||||
|         this._setBoolPref(aMsg.data.name, aMsg.data.value); |         this._setBoolPref(aMsg.data.name, aMsg.data.value); | ||||||
|         break; |         break; | ||||||
|       case 'PDFJS:Parent:setCharPref': |       case "PDFJS:Parent:setCharPref": | ||||||
|         this._setCharPref(aMsg.data.name, aMsg.data.value); |         this._setCharPref(aMsg.data.name, aMsg.data.value); | ||||||
|         break; |         break; | ||||||
|       case 'PDFJS:Parent:setStringPref': |       case "PDFJS:Parent:setStringPref": | ||||||
|         this._setStringPref(aMsg.data.name, aMsg.data.value); |         this._setStringPref(aMsg.data.name, aMsg.data.value); | ||||||
|         break; |         break; | ||||||
|       case 'PDFJS:Parent:isDefaultHandlerApp': |       case "PDFJS:Parent:isDefaultHandlerApp": | ||||||
|         return this.isDefaultHandlerApp(); |         return this.isDefaultHandlerApp(); | ||||||
|       case 'PDFJS:Parent:displayWarning': |       case "PDFJS:Parent:displayWarning": | ||||||
|         this._displayWarning(aMsg); |         this._displayWarning(aMsg); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|       case 'PDFJS:Parent:updateControlState': |       case "PDFJS:Parent:updateControlState": | ||||||
|         return this._updateControlState(aMsg); |         return this._updateControlState(aMsg); | ||||||
|       case 'PDFJS:Parent:addEventListener': |       case "PDFJS:Parent:addEventListener": | ||||||
|         return this._addEventListener(aMsg); |         return this._addEventListener(aMsg); | ||||||
|       case 'PDFJS:Parent:removeEventListener': |       case "PDFJS:Parent:removeEventListener": | ||||||
|         return this._removeEventListener(aMsg); |         return this._removeEventListener(aMsg); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| @ -192,25 +192,25 @@ var PdfjsChromeUtils = { | |||||||
| 
 | 
 | ||||||
|     let browser = aEvent.currentTarget.browser; |     let browser = aEvent.currentTarget.browser; | ||||||
|     if (!this._browsers.has(browser)) { |     if (!this._browsers.has(browser)) { | ||||||
|       throw new Error('FindEventManager was not bound ' + |       throw new Error("FindEventManager was not bound " + | ||||||
|                       'for the current browser.'); |                       "for the current browser."); | ||||||
|     } |     } | ||||||
|     // Only forward the events if the current browser is a registered browser.
 |     // Only forward the events if the current browser is a registered browser.
 | ||||||
|     let mm = browser.messageManager; |     let mm = browser.messageManager; | ||||||
|     mm.sendAsyncMessage('PDFJS:Child:handleEvent', { type, detail, }); |     mm.sendAsyncMessage("PDFJS:Child:handleEvent", { type, detail, }); | ||||||
|     aEvent.preventDefault(); |     aEvent.preventDefault(); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   _types: ['find', |   _types: ["find", | ||||||
|            'findagain', |            "findagain", | ||||||
|            'findhighlightallchange', |            "findhighlightallchange", | ||||||
|            'findcasesensitivitychange'], |            "findcasesensitivitychange"], | ||||||
| 
 | 
 | ||||||
|   _addEventListener(aMsg) { |   _addEventListener(aMsg) { | ||||||
|     let browser = aMsg.target; |     let browser = aMsg.target; | ||||||
|     if (this._browsers.has(browser)) { |     if (this._browsers.has(browser)) { | ||||||
|       throw new Error('FindEventManager was bound 2nd time ' + |       throw new Error("FindEventManager was bound 2nd time " + | ||||||
|                       'without unbinding it first.'); |                       "without unbinding it first."); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Since this jsm is global, we need to store all the browsers
 |     // Since this jsm is global, we need to store all the browsers
 | ||||||
| @ -228,7 +228,7 @@ var PdfjsChromeUtils = { | |||||||
|   _removeEventListener(aMsg) { |   _removeEventListener(aMsg) { | ||||||
|     let browser = aMsg.target; |     let browser = aMsg.target; | ||||||
|     if (!this._browsers.has(browser)) { |     if (!this._browsers.has(browser)) { | ||||||
|       throw new Error('FindEventManager was unbound without binding it first.'); |       throw new Error("FindEventManager was unbound without binding it first."); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     this._browsers.delete(browser); |     this._browsers.delete(browser); | ||||||
| @ -242,11 +242,11 @@ var PdfjsChromeUtils = { | |||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   _ensurePreferenceAllowed(aPrefName) { |   _ensurePreferenceAllowed(aPrefName) { | ||||||
|     let unPrefixedName = aPrefName.split(PREF_PREFIX + '.'); |     let unPrefixedName = aPrefName.split(PREF_PREFIX + "."); | ||||||
|     if (unPrefixedName[0] !== '' || |     if (unPrefixedName[0] !== "" || | ||||||
|         this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) { |         this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) { | ||||||
|       let msg = '"' + aPrefName + '" ' + |       let msg = "\"" + aPrefName + "\" " + | ||||||
|                 'can\'t be accessed from content. See PdfjsChromeUtils.'; |                 "can't be accessed from content. See PdfjsChromeUtils."; | ||||||
|       throw new Error(msg); |       throw new Error(msg); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| @ -273,7 +273,7 @@ var PdfjsChromeUtils = { | |||||||
| 
 | 
 | ||||||
|   _setStringPref(aPrefName, aPrefValue) { |   _setStringPref(aPrefName, aPrefValue) { | ||||||
|     this._ensurePreferenceAllowed(aPrefName); |     this._ensurePreferenceAllowed(aPrefName); | ||||||
|     let str = Cc['@mozilla.org/supports-string;1'] |     let str = Cc["@mozilla.org/supports-string;1"] | ||||||
|                 .createInstance(Ci.nsISupportsString); |                 .createInstance(Ci.nsISupportsString); | ||||||
|     str.data = aPrefValue; |     str.data = aPrefValue; | ||||||
|     Services.prefs.setComplexValue(aPrefName, Ci.nsISupportsString, str); |     Services.prefs.setComplexValue(aPrefName, Ci.nsISupportsString, str); | ||||||
| @ -285,7 +285,7 @@ var PdfjsChromeUtils = { | |||||||
|    * parent. |    * parent. | ||||||
|    */ |    */ | ||||||
|   isDefaultHandlerApp() { |   isDefaultHandlerApp() { | ||||||
|     var handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf'); |     var handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, "pdf"); | ||||||
|     return (!handlerInfo.alwaysAskBeforeHandling && |     return (!handlerInfo.alwaysAskBeforeHandling && | ||||||
|             handlerInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally); |             handlerInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally); | ||||||
|   }, |   }, | ||||||
| @ -307,7 +307,7 @@ var PdfjsChromeUtils = { | |||||||
|     let messageSent = false; |     let messageSent = false; | ||||||
|     function sendMessage(download) { |     function sendMessage(download) { | ||||||
|       let mm = browser.messageManager; |       let mm = browser.messageManager; | ||||||
|       mm.sendAsyncMessage('PDFJS:Child:fallbackDownload', { download, }); |       mm.sendAsyncMessage("PDFJS:Child:fallbackDownload", { download, }); | ||||||
|     } |     } | ||||||
|     let buttons = [{ |     let buttons = [{ | ||||||
|       label: data.label, |       label: data.label, | ||||||
| @ -317,13 +317,13 @@ var PdfjsChromeUtils = { | |||||||
|         sendMessage(true); |         sendMessage(true); | ||||||
|       } |       } | ||||||
|     }]; |     }]; | ||||||
|     notificationBox.appendNotification(data.message, 'pdfjs-fallback', null, |     notificationBox.appendNotification(data.message, "pdfjs-fallback", null, | ||||||
|                                        notificationBox.PRIORITY_INFO_LOW, |                                        notificationBox.PRIORITY_INFO_LOW, | ||||||
|                                        buttons, |                                        buttons, | ||||||
|                                        function eventsCallback(eventType) { |                                        function eventsCallback(eventType) { | ||||||
|       // Currently there is only one event "removed" but if there are any other
 |       // Currently there is only one event "removed" but if there are any other
 | ||||||
|       // added in the future we still only care about removed at the moment.
 |       // added in the future we still only care about removed at the moment.
 | ||||||
|       if (eventType !== 'removed') { |       if (eventType !== "removed") { | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|       // Don't send a response again if we already responded when the button was
 |       // Don't send a response again if we already responded when the button was
 | ||||||
|  | |||||||
| @ -14,17 +14,17 @@ | |||||||
|  */ |  */ | ||||||
| /* globals Components, Services, XPCOMUtils */ | /* globals Components, Services, XPCOMUtils */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| var EXPORTED_SYMBOLS = ['PdfjsContentUtils']; | var EXPORTED_SYMBOLS = ["PdfjsContentUtils"]; | ||||||
| 
 | 
 | ||||||
| const Cc = Components.classes; | const Cc = Components.classes; | ||||||
| const Ci = Components.interfaces; | const Ci = Components.interfaces; | ||||||
| const Cr = Components.results; | const Cr = Components.results; | ||||||
| const Cu = Components.utils; | const Cu = Components.utils; | ||||||
| 
 | 
 | ||||||
| Cu.import('resource://gre/modules/XPCOMUtils.jsm'); | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||||||
| Cu.import('resource://gre/modules/Services.jsm'); | Cu.import("resource://gre/modules/Services.jsm"); | ||||||
| 
 | 
 | ||||||
| var PdfjsContentUtils = { | var PdfjsContentUtils = { | ||||||
|   _mm: null, |   _mm: null, | ||||||
| @ -42,17 +42,17 @@ var PdfjsContentUtils = { | |||||||
|     // child *process* mm, or when loaded into the parent for in-content
 |     // child *process* mm, or when loaded into the parent for in-content
 | ||||||
|     // support the psuedo child process mm 'child PPMM'.
 |     // support the psuedo child process mm 'child PPMM'.
 | ||||||
|     if (!this._mm) { |     if (!this._mm) { | ||||||
|       this._mm = Cc['@mozilla.org/childprocessmessagemanager;1']. |       this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"]. | ||||||
|         getService(Ci.nsISyncMessageSender); |         getService(Ci.nsISyncMessageSender); | ||||||
|       this._mm.addMessageListener('PDFJS:Child:refreshSettings', this); |       this._mm.addMessageListener("PDFJS:Child:refreshSettings", this); | ||||||
|       Services.obs.addObserver(this, 'quit-application', false); |       Services.obs.addObserver(this, "quit-application", false); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   uninit() { |   uninit() { | ||||||
|     if (this._mm) { |     if (this._mm) { | ||||||
|       this._mm.removeMessageListener('PDFJS:Child:refreshSettings', this); |       this._mm.removeMessageListener("PDFJS:Child:refreshSettings", this); | ||||||
|       Services.obs.removeObserver(this, 'quit-application'); |       Services.obs.removeObserver(this, "quit-application"); | ||||||
|     } |     } | ||||||
|     this._mm = null; |     this._mm = null; | ||||||
|   }, |   }, | ||||||
| @ -64,34 +64,34 @@ var PdfjsContentUtils = { | |||||||
|    */ |    */ | ||||||
| 
 | 
 | ||||||
|   clearUserPref(aPrefName) { |   clearUserPref(aPrefName) { | ||||||
|     this._mm.sendSyncMessage('PDFJS:Parent:clearUserPref', { |     this._mm.sendSyncMessage("PDFJS:Parent:clearUserPref", { | ||||||
|       name: aPrefName |       name: aPrefName | ||||||
|     }); |     }); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   setIntPref(aPrefName, aPrefValue) { |   setIntPref(aPrefName, aPrefValue) { | ||||||
|     this._mm.sendSyncMessage('PDFJS:Parent:setIntPref', { |     this._mm.sendSyncMessage("PDFJS:Parent:setIntPref", { | ||||||
|       name: aPrefName, |       name: aPrefName, | ||||||
|       value: aPrefValue |       value: aPrefValue | ||||||
|     }); |     }); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   setBoolPref(aPrefName, aPrefValue) { |   setBoolPref(aPrefName, aPrefValue) { | ||||||
|     this._mm.sendSyncMessage('PDFJS:Parent:setBoolPref', { |     this._mm.sendSyncMessage("PDFJS:Parent:setBoolPref", { | ||||||
|       name: aPrefName, |       name: aPrefName, | ||||||
|       value: aPrefValue |       value: aPrefValue | ||||||
|     }); |     }); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   setCharPref(aPrefName, aPrefValue) { |   setCharPref(aPrefName, aPrefValue) { | ||||||
|     this._mm.sendSyncMessage('PDFJS:Parent:setCharPref', { |     this._mm.sendSyncMessage("PDFJS:Parent:setCharPref", { | ||||||
|       name: aPrefName, |       name: aPrefName, | ||||||
|       value: aPrefValue |       value: aPrefValue | ||||||
|     }); |     }); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   setStringPref(aPrefName, aPrefValue) { |   setStringPref(aPrefName, aPrefValue) { | ||||||
|     this._mm.sendSyncMessage('PDFJS:Parent:setStringPref', { |     this._mm.sendSyncMessage("PDFJS:Parent:setStringPref", { | ||||||
|       name: aPrefName, |       name: aPrefName, | ||||||
|       value: aPrefValue |       value: aPrefValue | ||||||
|     }); |     }); | ||||||
| @ -102,7 +102,7 @@ var PdfjsContentUtils = { | |||||||
|    * handler app settings only available in the parent process. |    * handler app settings only available in the parent process. | ||||||
|    */ |    */ | ||||||
|   isDefaultHandlerApp() { |   isDefaultHandlerApp() { | ||||||
|     return this._mm.sendSyncMessage('PDFJS:Parent:isDefaultHandlerApp')[0]; |     return this._mm.sendSyncMessage("PDFJS:Parent:isDefaultHandlerApp")[0]; | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   /* |   /* | ||||||
| @ -115,7 +115,7 @@ var PdfjsContentUtils = { | |||||||
|                        .getInterface(Ci.nsIDocShell) |                        .getInterface(Ci.nsIDocShell) | ||||||
|                        .QueryInterface(Ci.nsIInterfaceRequestor) |                        .QueryInterface(Ci.nsIInterfaceRequestor) | ||||||
|                        .getInterface(Ci.nsIContentFrameMessageManager); |                        .getInterface(Ci.nsIContentFrameMessageManager); | ||||||
|     winmm.sendAsyncMessage('PDFJS:Parent:displayWarning', { |     winmm.sendAsyncMessage("PDFJS:Parent:displayWarning", { | ||||||
|       message: aMessage, |       message: aMessage, | ||||||
|       label: aLabel, |       label: aLabel, | ||||||
|       accessKey: aAccessKey, |       accessKey: aAccessKey, | ||||||
| @ -127,18 +127,18 @@ var PdfjsContentUtils = { | |||||||
|    */ |    */ | ||||||
| 
 | 
 | ||||||
|   observe(aSubject, aTopic, aData) { |   observe(aSubject, aTopic, aData) { | ||||||
|     if (aTopic === 'quit-application') { |     if (aTopic === "quit-application") { | ||||||
|       this.uninit(); |       this.uninit(); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   receiveMessage(aMsg) { |   receiveMessage(aMsg) { | ||||||
|     switch (aMsg.name) { |     switch (aMsg.name) { | ||||||
|       case 'PDFJS:Child:refreshSettings': |       case "PDFJS:Child:refreshSettings": | ||||||
|         // Only react to this if we are remote.
 |         // Only react to this if we are remote.
 | ||||||
|         if (Services.appinfo.processType === |         if (Services.appinfo.processType === | ||||||
|             Services.appinfo.PROCESS_TYPE_CONTENT) { |             Services.appinfo.PROCESS_TYPE_CONTENT) { | ||||||
|           let jsm = 'resource://pdf.js/PdfJs.jsm'; |           let jsm = "resource://pdf.js/PdfJs.jsm"; | ||||||
|           let pdfjs = Components.utils.import(jsm, {}).PdfJs; |           let pdfjs = Components.utils.import(jsm, {}).PdfJs; | ||||||
|           pdfjs.updateRegistration(); |           pdfjs.updateRegistration(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -14,16 +14,16 @@ | |||||||
| */ | */ | ||||||
| /* globals Components, PdfjsContentUtils, PdfJs, Services */ | /* globals Components, PdfjsContentUtils, PdfJs, Services */ | ||||||
| 
 | 
 | ||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| /* | /* | ||||||
|  * pdfjschildbootstrap.js loads into the content process to take care of |  * pdfjschildbootstrap.js loads into the content process to take care of | ||||||
|  * initializing our built-in version of pdfjs when running remote. |  * initializing our built-in version of pdfjs when running remote. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| Components.utils.import('resource://gre/modules/Services.jsm'); | Components.utils.import("resource://gre/modules/Services.jsm"); | ||||||
| Components.utils.import('resource://pdf.js/PdfJs.jsm'); | Components.utils.import("resource://pdf.js/PdfJs.jsm"); | ||||||
| Components.utils.import('resource://pdf.js/PdfjsContentUtils.jsm'); | Components.utils.import("resource://pdf.js/PdfjsContentUtils.jsm"); | ||||||
| 
 | 
 | ||||||
| // init content utils shim pdfjs will use to access privileged apis.
 | // init content utils shim pdfjs will use to access privileged apis.
 | ||||||
| PdfjsContentUtils.init(); | PdfjsContentUtils.init(); | ||||||
|  | |||||||
| @ -1,17 +1,17 @@ | |||||||
| 'use strict'; | "use strict"; | ||||||
| 
 | 
 | ||||||
| // Small subset of the webL10n API by Fabien Cazenave for pdf.js extension.
 | // Small subset of the webL10n API by Fabien Cazenave for pdf.js extension.
 | ||||||
| (function(window) { | (function(window) { | ||||||
|   var gLanguage = ''; |   var gLanguage = ""; | ||||||
|   var gExternalLocalizerServices = null; |   var gExternalLocalizerServices = null; | ||||||
|   var gReadyState = 'loading'; |   var gReadyState = "loading"; | ||||||
| 
 | 
 | ||||||
|   // fetch an l10n objects
 |   // fetch an l10n objects
 | ||||||
|   function getL10nData(key) { |   function getL10nData(key) { | ||||||
|     var response = gExternalLocalizerServices.getStrings(key); |     var response = gExternalLocalizerServices.getStrings(key); | ||||||
|     var data = JSON.parse(response); |     var data = JSON.parse(response); | ||||||
|     if (!data) { |     if (!data) { | ||||||
|       console.warn('[l10n] #' + key + ' missing for [' + gLanguage + ']'); |       console.warn("[l10n] #" + key + " missing for [" + gLanguage + "]"); | ||||||
|     } |     } | ||||||
|     return data; |     return data; | ||||||
|   } |   } | ||||||
| @ -22,25 +22,25 @@ | |||||||
|       return text; |       return text; | ||||||
|     } |     } | ||||||
|     return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function(all, name) { |     return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function(all, name) { | ||||||
|       return (name in args ? args[name] : '{{' + name + '}}'); |       return (name in args ? args[name] : "{{" + name + "}}"); | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // translate a string
 |   // translate a string
 | ||||||
|   function translateString(key, args, fallback) { |   function translateString(key, args, fallback) { | ||||||
|     var i = key.lastIndexOf('.'); |     var i = key.lastIndexOf("."); | ||||||
|     var name, property; |     var name, property; | ||||||
|     if (i >= 0) { |     if (i >= 0) { | ||||||
|       name = key.substring(0, i); |       name = key.substring(0, i); | ||||||
|       property = key.substring(i + 1); |       property = key.substring(i + 1); | ||||||
|     } else { |     } else { | ||||||
|       name = key; |       name = key; | ||||||
|       property = 'textContent'; |       property = "textContent"; | ||||||
|     } |     } | ||||||
|     var data = getL10nData(name); |     var data = getL10nData(name); | ||||||
|     var value = (data && data[property]) || fallback; |     var value = (data && data[property]) || fallback; | ||||||
|     if (!value) { |     if (!value) { | ||||||
|       return '{{' + key + '}}'; |       return "{{" + key + "}}"; | ||||||
|     } |     } | ||||||
|     return substArguments(value, args); |     return substArguments(value, args); | ||||||
|   } |   } | ||||||
| @ -65,7 +65,7 @@ | |||||||
|       try { |       try { | ||||||
|         args = JSON.parse(element.dataset.l10nArgs); |         args = JSON.parse(element.dataset.l10nArgs); | ||||||
|       } catch (e) { |       } catch (e) { | ||||||
|         console.warn('[l10n] could not parse arguments for #' + key + ''); |         console.warn("[l10n] could not parse arguments for #" + key + ""); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -79,10 +79,10 @@ | |||||||
| 
 | 
 | ||||||
|   // translate an HTML subtree
 |   // translate an HTML subtree
 | ||||||
|   function translateFragment(element) { |   function translateFragment(element) { | ||||||
|     element = element || document.querySelector('html'); |     element = element || document.querySelector("html"); | ||||||
| 
 | 
 | ||||||
|     // check all translatable children (= w/ a `data-l10n-id' attribute)
 |     // check all translatable children (= w/ a `data-l10n-id' attribute)
 | ||||||
|     var children = element.querySelectorAll('*[data-l10n-id]'); |     var children = element.querySelectorAll("*[data-l10n-id]"); | ||||||
|     var elementCount = children.length; |     var elementCount = children.length; | ||||||
|     for (var i = 0; i < elementCount; i++) { |     for (var i = 0; i < elementCount; i++) { | ||||||
|       translateElement(children[i]); |       translateElement(children[i]); | ||||||
| @ -99,16 +99,16 @@ | |||||||
| 
 | 
 | ||||||
|     translateFragment(); |     translateFragment(); | ||||||
| 
 | 
 | ||||||
|     gReadyState = 'complete'; |     gReadyState = "complete"; | ||||||
| 
 | 
 | ||||||
|     // fire a 'localized' DOM event
 |     // fire a 'localized' DOM event
 | ||||||
|     var evtObject = document.createEvent('Event'); |     var evtObject = document.createEvent("Event"); | ||||||
|     evtObject.initEvent('localized', false, false); |     evtObject.initEvent("localized", false, false); | ||||||
|     evtObject.language = gLanguage; |     evtObject.language = gLanguage; | ||||||
|     window.dispatchEvent(evtObject); |     window.dispatchEvent(evtObject); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   window.addEventListener('DOMContentLoaded', function() { |   window.addEventListener("DOMContentLoaded", function() { | ||||||
|     if (gExternalLocalizerServices) { |     if (gExternalLocalizerServices) { | ||||||
|       translateDocument(); |       translateDocument(); | ||||||
|     } |     } | ||||||
| @ -129,12 +129,12 @@ | |||||||
|     getDirection() { |     getDirection() { | ||||||
|       // http://www.w3.org/International/questions/qa-scripts
 |       // http://www.w3.org/International/questions/qa-scripts
 | ||||||
|       // Arabic, Hebrew, Farsi, Pashto, Urdu
 |       // Arabic, Hebrew, Farsi, Pashto, Urdu
 | ||||||
|       var rtlList = ['ar', 'he', 'fa', 'ps', 'ur']; |       var rtlList = ["ar", "he", "fa", "ps", "ur"]; | ||||||
| 
 | 
 | ||||||
|       // use the short language code for "full" codes like 'ar-sa' (issue 5440)
 |       // use the short language code for "full" codes like 'ar-sa' (issue 5440)
 | ||||||
|       var shortCode = gLanguage.split('-')[0]; |       var shortCode = gLanguage.split("-")[0]; | ||||||
| 
 | 
 | ||||||
|       return (rtlList.indexOf(shortCode) >= 0) ? 'rtl' : 'ltr'; |       return (rtlList.indexOf(shortCode) >= 0) ? "rtl" : "ltr"; | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     getReadyState() { |     getReadyState() { | ||||||
| @ -145,8 +145,8 @@ | |||||||
|       gExternalLocalizerServices = externalLocalizerServices; |       gExternalLocalizerServices = externalLocalizerServices; | ||||||
| 
 | 
 | ||||||
|       // ... in case if we missed DOMContentLoaded above.
 |       // ... in case if we missed DOMContentLoaded above.
 | ||||||
|       if (window.document.readyState === 'interactive' || |       if (window.document.readyState === "interactive" || | ||||||
|           window.document.readyState === 'complete') { |           window.document.readyState === "complete") { | ||||||
|         translateDocument(); |         translateDocument(); | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user