|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
|
|
|
|
|
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ |
|
|
|
/* Copyright 2012 Mozilla Foundation |
|
|
|
/* Copyright 2012 Mozilla Foundation |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
@ -12,6 +14,8 @@ |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* limitations under the License. |
|
|
|
* limitations under the License. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
/* jshint esnext:true */ |
|
|
|
|
|
|
|
/* globals Components, Services, XPCOMUtils */ |
|
|
|
|
|
|
|
|
|
|
|
'use strict'; |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
@ -33,23 +37,25 @@ let PdfjsContentUtils = { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
get isRemote() { |
|
|
|
get isRemote() { |
|
|
|
return Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT; |
|
|
|
return (Services.appinfo.processType === |
|
|
|
|
|
|
|
Services.appinfo.PROCESS_TYPE_CONTENT); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
init: function () { |
|
|
|
init: function () { |
|
|
|
// 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"].getService(Ci.nsISyncMessageSender); |
|
|
|
this._mm = Cc['@mozilla.org/childprocessmessagemanager;1']. |
|
|
|
this._mm.addMessageListener("PDFJS:Child:refreshSettings", this); |
|
|
|
getService(Ci.nsISyncMessageSender); |
|
|
|
Services.obs.addObserver(this, "quit-application", false); |
|
|
|
this._mm.addMessageListener('PDFJS:Child:refreshSettings', this); |
|
|
|
|
|
|
|
Services.obs.addObserver(this, 'quit-application', false); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
uninit: function () { |
|
|
|
uninit: function () { |
|
|
|
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; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -61,34 +67,34 @@ let PdfjsContentUtils = { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
clearUserPref: function (aPrefName) { |
|
|
|
clearUserPref: function (aPrefName) { |
|
|
|
this._mm.sendSyncMessage("PDFJS:Parent:clearUserPref", { |
|
|
|
this._mm.sendSyncMessage('PDFJS:Parent:clearUserPref', { |
|
|
|
name: aPrefName |
|
|
|
name: aPrefName |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setIntPref: function (aPrefName, aPrefValue) { |
|
|
|
setIntPref: function (aPrefName, aPrefValue) { |
|
|
|
this._mm.sendSyncMessage("PDFJS:Parent:setIntPref", { |
|
|
|
this._mm.sendSyncMessage('PDFJS:Parent:setIntPref', { |
|
|
|
name: aPrefName, |
|
|
|
name: aPrefName, |
|
|
|
value: aPrefValue |
|
|
|
value: aPrefValue |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setBoolPref: function (aPrefName, aPrefValue) { |
|
|
|
setBoolPref: function (aPrefName, aPrefValue) { |
|
|
|
this._mm.sendSyncMessage("PDFJS:Parent:setBoolPref", { |
|
|
|
this._mm.sendSyncMessage('PDFJS:Parent:setBoolPref', { |
|
|
|
name: aPrefName, |
|
|
|
name: aPrefName, |
|
|
|
value: aPrefValue |
|
|
|
value: aPrefValue |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setCharPref: function (aPrefName, aPrefValue) { |
|
|
|
setCharPref: function (aPrefName, aPrefValue) { |
|
|
|
this._mm.sendSyncMessage("PDFJS:Parent:setCharPref", { |
|
|
|
this._mm.sendSyncMessage('PDFJS:Parent:setCharPref', { |
|
|
|
name: aPrefName, |
|
|
|
name: aPrefName, |
|
|
|
value: aPrefValue |
|
|
|
value: aPrefValue |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setStringPref: function (aPrefName, aPrefValue) { |
|
|
|
setStringPref: function (aPrefName, aPrefValue) { |
|
|
|
this._mm.sendSyncMessage("PDFJS:Parent:setStringPref", { |
|
|
|
this._mm.sendSyncMessage('PDFJS:Parent:setStringPref', { |
|
|
|
name: aPrefName, |
|
|
|
name: aPrefName, |
|
|
|
value: aPrefValue |
|
|
|
value: aPrefValue |
|
|
|
}); |
|
|
|
}); |
|
|
@ -99,7 +105,7 @@ let PdfjsContentUtils = { |
|
|
|
* handler app settings only available in the parent process. |
|
|
|
* handler app settings only available in the parent process. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
isDefaultHandlerApp: function () { |
|
|
|
isDefaultHandlerApp: function () { |
|
|
|
return this._mm.sendSyncMessage("PDFJS:Parent:isDefaultHandlerApp")[0]; |
|
|
|
return this._mm.sendSyncMessage('PDFJS:Parent:isDefaultHandlerApp')[0]; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -112,7 +118,7 @@ let 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: accessKey |
|
|
|
accessKey: accessKey |
|
|
@ -126,17 +132,18 @@ let PdfjsContentUtils = { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
observe: function(aSubject, aTopic, aData) { |
|
|
|
observe: function(aSubject, aTopic, aData) { |
|
|
|
if (aTopic == "quit-application") { |
|
|
|
if (aTopic === 'quit-application') { |
|
|
|
this.uninit(); |
|
|
|
this.uninit(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
receiveMessage: function (aMsg) { |
|
|
|
receiveMessage: function (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 == Services.appinfo.PROCESS_TYPE_CONTENT) { |
|
|
|
if (Services.appinfo.processType === |
|
|
|
let jsm = "resource://pdf.js/PdfJs.jsm"; |
|
|
|
Services.appinfo.PROCESS_TYPE_CONTENT) { |
|
|
|
|
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
@ -159,12 +166,14 @@ let PdfjsContentUtils = { |
|
|
|
// send over a small container for the object we want.
|
|
|
|
// send over a small container for the object we want.
|
|
|
|
let suitcase = { |
|
|
|
let suitcase = { |
|
|
|
_window: null, |
|
|
|
_window: null, |
|
|
|
setChromeWindow: function (aObj) { this._window = aObj; } |
|
|
|
setChromeWindow: function (aObj) { |
|
|
|
|
|
|
|
this._window = aObj; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!winmm.sendSyncMessage("PDFJS:Parent:getChromeWindow", {}, |
|
|
|
}; |
|
|
|
|
|
|
|
if (!winmm.sendSyncMessage('PDFJS:Parent:getChromeWindow', {}, |
|
|
|
{ suitcase: suitcase })[0]) { |
|
|
|
{ suitcase: suitcase })[0]) { |
|
|
|
Cu.reportError("A request for a CPOW wrapped chrome window " + |
|
|
|
Cu.reportError('A request for a CPOW wrapped chrome window ' + |
|
|
|
"failed for unknown reasons."); |
|
|
|
'failed for unknown reasons.'); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return suitcase._window; |
|
|
|
return suitcase._window; |
|
|
@ -179,12 +188,14 @@ let PdfjsContentUtils = { |
|
|
|
.getInterface(Ci.nsIContentFrameMessageManager); |
|
|
|
.getInterface(Ci.nsIContentFrameMessageManager); |
|
|
|
let suitcase = { |
|
|
|
let suitcase = { |
|
|
|
_findbar: null, |
|
|
|
_findbar: null, |
|
|
|
setFindBar: function (aObj) { this._findbar = aObj; } |
|
|
|
setFindBar: function (aObj) { |
|
|
|
|
|
|
|
this._findbar = aObj; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!winmm.sendSyncMessage("PDFJS:Parent:getFindBar", {}, |
|
|
|
}; |
|
|
|
|
|
|
|
if (!winmm.sendSyncMessage('PDFJS:Parent:getFindBar', {}, |
|
|
|
{ suitcase: suitcase })[0]) { |
|
|
|
{ suitcase: suitcase })[0]) { |
|
|
|
Cu.reportError("A request for a CPOW wrapped findbar " + |
|
|
|
Cu.reportError('A request for a CPOW wrapped findbar ' + |
|
|
|
"failed for unknown reasons."); |
|
|
|
'failed for unknown reasons.'); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return suitcase._findbar; |
|
|
|
return suitcase._findbar; |
|
|
|