@ -14,6 +14,9 @@
@@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License .
* /
/* jshint esnext:true */
/ * g l o b a l s C o m p o n e n t s , S e r v i c e s , X P C O M U t i l s , N e t U t i l , P r i v a t e B r o w s i n g U t i l s ,
dump * /
'use strict' ;
@ -24,7 +27,7 @@ const Ci = Components.interfaces;
@@ -24,7 +27,7 @@ const Ci = Components.interfaces;
const Cr = Components . results ;
const Cu = Components . utils ;
// True only if this is the version of pdf.js that is included with firefox.
const MOZ _CENTRAL = PDFJSSCRIPT _MOZ _CENTRAL ;
const MOZ _CENTRAL = JSON . parse ( 'PDFJSSCRIPT_MOZ_CENTRAL' ) ;
const PDFJS _EVENT _ID = 'pdf.js.message' ;
const PDF _CONTENT _TYPE = 'application/pdf' ;
const PREF _PREFIX = 'PDFJSSCRIPT_PREF_PREFIX' ;
@ -38,7 +41,7 @@ Cu.import('resource://gre/modules/NetUtil.jsm');
@@ -38,7 +41,7 @@ Cu.import('resource://gre/modules/NetUtil.jsm');
XPCOMUtils . defineLazyModuleGetter ( this , 'PrivateBrowsingUtils' ,
'resource://gre/modules/PrivateBrowsingUtils.jsm' ) ;
let Svc = { } ;
var Svc = { } ;
XPCOMUtils . defineLazyServiceGetter ( Svc , 'mime' ,
'@mozilla.org/mime;1' ,
'nsIMIMEService' ) ;
@ -68,7 +71,7 @@ function getIntPref(pref, def) {
@@ -68,7 +71,7 @@ function getIntPref(pref, def) {
}
function setStringPref ( pref , value ) {
let str = Cc [ '@mozilla.org/supports-string;1' ]
var str = Cc [ '@mozilla.org/supports-string;1' ]
. createInstance ( Ci . nsISupportsString ) ;
str . data = value ;
Services . prefs . setComplexValue ( pref , Ci . nsISupportsString , str ) ;
@ -85,7 +88,7 @@ function getStringPref(pref, def) {
@@ -85,7 +88,7 @@ function getStringPref(pref, def) {
function log ( aMsg ) {
if ( ! getBoolPref ( PREF _PREFIX + '.pdfBugEnabled' , false ) )
return ;
let msg = 'PdfStreamConverter.js: ' + ( aMsg . join ? aMsg . join ( '' ) : aMsg ) ;
var msg = 'PdfStreamConverter.js: ' + ( aMsg . join ? aMsg . join ( '' ) : aMsg ) ;
Services . console . logStringMessage ( msg ) ;
dump ( msg + '\n' ) ;
}
@ -107,7 +110,7 @@ function isEnabled() {
@@ -107,7 +110,7 @@ function isEnabled() {
// selected in the Application preferences.
var handlerInfo = Svc . mime
. getFromTypeAndExtension ( 'application/pdf' , 'pdf' ) ;
return handlerInfo . alwaysAskBeforeHandling == false &&
return ! handlerInfo . alwaysAskBeforeHandling &&
handlerInfo . preferredAction == Ci . nsIHandlerInfo . handleInternally ;
}
// Always returns true for the extension since enabling/disabling is handled
@ -189,6 +192,9 @@ PdfDataListener.prototype = {
@@ -189,6 +192,9 @@ PdfDataListener.prototype = {
}
} ,
onprogress : function ( ) { } ,
get oncomplete ( ) {
return this . oncompleteCallback ;
} ,
set oncomplete ( value ) {
this . oncompleteCallback = value ;
if ( this . isDataReady ) {
@ -209,7 +215,7 @@ function ChromeActions(domWindow, dataListener, contentDispositionFilename) {
@@ -209,7 +215,7 @@ function ChromeActions(domWindow, dataListener, contentDispositionFilename) {
ChromeActions . prototype = {
isInPrivateBrowsing : function ( ) {
let docIsPrivate ;
var docIsPrivate , privateBrowsing ;
try {
docIsPrivate = PrivateBrowsingUtils . isWindowPrivate ( this . domWindow ) ;
} catch ( x ) {
@ -218,7 +224,7 @@ ChromeActions.prototype = {
@@ -218,7 +224,7 @@ ChromeActions.prototype = {
if ( typeof docIsPrivate === 'undefined' ) {
// per-window Private Browsing is not supported, trying global service
try {
let privateBrowsing = Cc [ '@mozilla.org/privatebrowsing;1' ]
privateBrowsing = Cc [ '@mozilla.org/privatebrowsing;1' ]
. getService ( Ci . nsIPrivateBrowsingService ) ;
docIsPrivate = privateBrowsing . privateBrowsingEnabled ;
} catch ( x ) {
@ -245,8 +251,8 @@ ChromeActions.prototype = {
@@ -245,8 +251,8 @@ ChromeActions.prototype = {
var frontWindow = Cc [ '@mozilla.org/embedcomp/window-watcher;1' ] .
getService ( Ci . nsIWindowWatcher ) . activeWindow ;
let docIsPrivate = this . isInPrivateBrowsing ( ) ;
let netChannel = NetUtil . newChannel ( blobUri ) ;
var docIsPrivate = this . isInPrivateBrowsing ( ) ;
var netChannel = NetUtil . newChannel ( blobUri ) ;
if ( 'nsIPrivateBrowsingChannel' in Ci &&
netChannel instanceof Ci . nsIPrivateBrowsingChannel ) {
netChannel . setPrivate ( docIsPrivate ) ;
@ -259,7 +265,7 @@ ChromeActions.prototype = {
@@ -259,7 +265,7 @@ ChromeActions.prototype = {
}
// Create a nsIInputStreamChannel so we can set the url on the channel
// so the filename will be correct.
let channel = Cc [ '@mozilla.org/network/input-stream-channel;1' ] .
var channel = Cc [ '@mozilla.org/network/input-stream-channel;1' ] .
createInstance ( Ci . nsIInputStreamChannel ) ;
channel . QueryInterface ( Ci . nsIChannel ) ;
channel . contentDisposition = Ci . nsIChannel . DISPOSITION _ATTACHMENT ;
@ -472,7 +478,7 @@ RequestListener.prototype.receive = function(event) {
@@ -472,7 +478,7 @@ RequestListener.prototype.receive = function(event) {
var listener = doc . createEvent ( 'HTMLEvents' ) ;
listener . initEvent ( 'pdf.js.response' , true , false ) ;
return message . dispatchEvent ( listener ) ;
}
} ;
}
actions [ action ] . call ( this . actions , data , response ) ;
}
@ -623,9 +629,9 @@ PdfStreamConverter.prototype = {
@@ -623,9 +629,9 @@ PdfStreamConverter.prototype = {
var domWindow = getDOMWindow ( channel ) ;
// Double check the url is still the correct one.
if ( domWindow . document . documentURIObject . equals ( aRequest . URI ) ) {
let actions = new ChromeActions ( domWindow , dataListener ,
var actions = new ChromeActions ( domWindow , dataListener ,
contentDispositionFilename ) ;
let requestListener = new RequestListener ( actions ) ;
var requestListener = new RequestListener ( actions ) ;
domWindow . addEventListener ( PDFJS _EVENT _ID , function ( event ) {
requestListener . receive ( event ) ;
} , false , true ) ;