Browse Source

Merge pull request #8467 from mozilla/bug1353029

Bug 1353029 - Pass PdfJs.enabled into child on change.
Brendan Dahl 8 years ago committed by GitHub
parent
commit
edd7d89fe5
  1. 16
      extensions/firefox/content/PdfJs.jsm
  2. 5
      extensions/firefox/content/PdfjsChromeUtils.jsm
  3. 20
      extensions/firefox/content/PdfjsContentUtils.jsm

16
extensions/firefox/content/PdfJs.jsm

@ -67,8 +67,9 @@ function getIntPref(aPref, aDefaultValue) { @@ -67,8 +67,9 @@ function getIntPref(aPref, aDefaultValue) {
}
function isDefaultHandler() {
if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) {
return PdfjsContentUtils.isDefaultHandlerApp();
if (Services.appinfo.processType !== Services.appinfo.PROCESS_TYPE_DEFAULT) {
throw new Error("isDefaultHandler should only get called in the parent " +
"process.");
}
return PdfjsChromeUtils.isDefaultHandlerApp();
}
@ -251,13 +252,16 @@ var PdfJs = { @@ -251,13 +252,16 @@ var PdfJs = {
// nsIObserver
observe: function observe(aSubject, aTopic, aData) {
this.updateRegistration();
if (Services.appinfo.processType ===
if (Services.appinfo.processType !==
Services.appinfo.PROCESS_TYPE_DEFAULT) {
throw new Error("Only the parent process should be observing PDF " +
"handler changes.");
}
this.updateRegistration();
let jsm = "resource://pdf.js/PdfjsChromeUtils.jsm";
let PdfjsChromeUtils = Components.utils.import(jsm, {}).PdfjsChromeUtils;
PdfjsChromeUtils.notifyChildOfSettingsChange();
}
PdfjsChromeUtils.notifyChildOfSettingsChange(this.enabled);
},
/**

5
extensions/firefox/content/PdfjsChromeUtils.jsm

@ -117,7 +117,7 @@ var PdfjsChromeUtils = { @@ -117,7 +117,7 @@ var PdfjsChromeUtils = {
* instruct the child to refresh its configuration and (possibly)
* the module's registration.
*/
notifyChildOfSettingsChange() {
notifyChildOfSettingsChange(enabled) {
if (Services.appinfo.processType ===
Services.appinfo.PROCESS_TYPE_DEFAULT && this._ppmm) {
// XXX kinda bad, we want to get the parent process mm associated
@ -125,7 +125,8 @@ var PdfjsChromeUtils = { @@ -125,7 +125,8 @@ var PdfjsChromeUtils = {
// 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
// process specific mm from js.
this._ppmm.broadcastAsyncMessage("PDFJS:Child:refreshSettings", {});
this._ppmm.broadcastAsyncMessage("PDFJS:Child:updateSettings",
{ enabled, });
}
},

20
extensions/firefox/content/PdfjsContentUtils.jsm

@ -43,7 +43,7 @@ var PdfjsContentUtils = { @@ -43,7 +43,7 @@ var PdfjsContentUtils = {
if (!this._mm) {
this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"].
getService(Ci.nsISyncMessageSender);
this._mm.addMessageListener("PDFJS:Child:refreshSettings", this);
this._mm.addMessageListener("PDFJS:Child:updateSettings", this);
//#if !MOZCENTRAL
// The signature of `Services.obs.addObserver` changed in Firefox 55,
@ -62,7 +62,7 @@ var PdfjsContentUtils = { @@ -62,7 +62,7 @@ var PdfjsContentUtils = {
uninit() {
if (this._mm) {
this._mm.removeMessageListener("PDFJS:Child:refreshSettings", this);
this._mm.removeMessageListener("PDFJS:Child:updateSettings", this);
Services.obs.removeObserver(this, "quit-application");
}
this._mm = null;
@ -108,14 +108,6 @@ var PdfjsContentUtils = { @@ -108,14 +108,6 @@ var PdfjsContentUtils = {
});
},
/*
* Forwards default app query to the parent where we check various
* handler app settings only available in the parent process.
*/
isDefaultHandlerApp() {
return this._mm.sendSyncMessage("PDFJS:Parent:isDefaultHandlerApp")[0];
},
/*
* Request the display of a notification warning in the associated window
* when the renderer isn't sure a pdf displayed correctly.
@ -145,13 +137,17 @@ var PdfjsContentUtils = { @@ -145,13 +137,17 @@ var PdfjsContentUtils = {
receiveMessage(aMsg) {
switch (aMsg.name) {
case "PDFJS:Child:refreshSettings":
case "PDFJS:Child:updateSettings":
// Only react to this if we are remote.
if (Services.appinfo.processType ===
Services.appinfo.PROCESS_TYPE_CONTENT) {
let jsm = "resource://pdf.js/PdfJs.jsm";
let pdfjs = Components.utils.import(jsm, {}).PdfJs;
pdfjs.updateRegistration();
if (aMsg.data.enabled) {
pdfjs.ensureRegistered();
} else {
pdfjs.ensureUnregistered();
}
}
break;
}

Loading…
Cancel
Save