Fix code style in extensions/firefox/content/PdfjsChromeUtils.jsm

This commit is contained in:
Jonas Jenwald 2014-09-18 02:10:03 +02:00
parent 9ed3e1e545
commit 3370b18e0b

View File

@ -14,7 +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.
*/ */
/*globals DEFAULT_PREFERENCES */ /* jshint esnext:true */
/* globals Components, Services, XPCOMUtils, DEFAULT_PREFERENCES */
'use strict'; 'use strict';
@ -52,39 +53,42 @@ let PdfjsChromeUtils = {
init: function () { init: function () {
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"].getService(Ci.nsIMessageBroadcaster); this._ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1'].
this._ppmm.addMessageListener("PDFJS:Parent:clearUserPref", this); getService(Ci.nsIMessageBroadcaster);
this._ppmm.addMessageListener("PDFJS:Parent:setIntPref", this); this._ppmm.addMessageListener('PDFJS:Parent:clearUserPref', this);
this._ppmm.addMessageListener("PDFJS:Parent:setBoolPref", this); this._ppmm.addMessageListener('PDFJS:Parent:setIntPref', this);
this._ppmm.addMessageListener("PDFJS:Parent:setCharPref", this); this._ppmm.addMessageListener('PDFJS:Parent:setBoolPref', this);
this._ppmm.addMessageListener("PDFJS:Parent:setStringPref", this); this._ppmm.addMessageListener('PDFJS:Parent:setCharPref', this);
this._ppmm.addMessageListener("PDFJS:Parent:isDefaultHandlerApp", this); this._ppmm.addMessageListener('PDFJS:Parent:setStringPref', 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"].getService(Ci.nsIMessageListenerManager); this._mmg = Cc['@mozilla.org/globalmessagemanager;1'].
this._mmg.addMessageListener("PDFJS:Parent:getChromeWindow", this); getService(Ci.nsIMessageListenerManager);
this._mmg.addMessageListener("PDFJS:Parent:getFindBar", this); this._mmg.addMessageListener('PDFJS:Parent:getChromeWindow', this);
this._mmg.addMessageListener("PDFJS:Parent:displayWarning", this); this._mmg.addMessageListener('PDFJS:Parent:getFindBar', this);
this._mmg.addMessageListener('PDFJS:Parent:displayWarning', this);
// observer to handle shutdown // observer to handle shutdown
Services.obs.addObserver(this, "quit-application", false); Services.obs.addObserver(this, 'quit-application', false);
} }
}, },
uninit: function () { uninit: function () {
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); this._ppmm.removeMessageListener('PDFJS:Parent:isDefaultHandlerApp',
this);
this._mmg.removeMessageListener("PDFJS:Parent:getChromeWindow", this); this._mmg.removeMessageListener('PDFJS:Parent:getChromeWindow', this);
this._mmg.removeMessageListener("PDFJS:Parent:getFindBar", this); this._mmg.removeMessageListener('PDFJS:Parent:getFindBar', this);
this._mmg.removeMessageListener("PDFJS:Parent:displayWarning", this); this._mmg.removeMessageListener('PDFJS:Parent:displayWarning', this);
Services.obs.removeObserver(this, "quit-application", false); Services.obs.removeObserver(this, 'quit-application', false);
this._mmg = null; this._mmg = null;
this._ppmm = null; this._ppmm = null;
@ -98,14 +102,14 @@ let PdfjsChromeUtils = {
* the module's registration. * the module's registration.
*/ */
notifyChildOfSettingsChange: function () { notifyChildOfSettingsChange: function () {
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_DEFAULT && if (Services.appinfo.processType ===
this._ppmm) { Services.appinfo.PROCESS_TYPE_DEFAULT && this._ppmm) {
// XXX kinda bad, we want to get the parent process mm associated // XXX kinda bad, we want to get the parent process mm associated
// with the content process. _ppmm is currently the global process // with the content process. _ppmm is currently the global process
// 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', {});
} }
}, },
@ -114,38 +118,38 @@ let PdfjsChromeUtils = {
*/ */
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: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;
// CPOW getters // CPOW getters
case "PDFJS:Parent:getChromeWindow": case 'PDFJS:Parent:getChromeWindow':
return this._getChromeWindow(aMsg); return this._getChromeWindow(aMsg);
case "PDFJS:Parent:getFindBar": case 'PDFJS:Parent:getFindBar':
return this._getFindBar(aMsg); return this._getFindBar(aMsg);
} }
}, },
@ -178,8 +182,8 @@ let PdfjsChromeUtils = {
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 + '" ' +
msg += "can't be accessed from content. See PdfjsChromeUtils." 'can\'t be accessed from content. See PdfjsChromeUtils.';
throw new Error(msg); throw new Error(msg);
} }
}, },
@ -219,8 +223,8 @@ let PdfjsChromeUtils = {
*/ */
isDefaultHandlerApp: function () { isDefaultHandlerApp: function () {
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);
}, },
/* /*
@ -285,13 +289,13 @@ function PdfjsFindbarWrapper(aBrowser) {
} }
//#endif //#endif
this._findbar = tabbrowser.getFindBar(tab); this._findbar = tabbrowser.getFindBar(tab);
}; }
PdfjsFindbarWrapper.prototype = { PdfjsFindbarWrapper.prototype = {
__exposedProps__: { __exposedProps__: {
addEventListener: "r", addEventListener: 'r',
removeEventListener: "r", removeEventListener: 'r',
updateControlState: "r", updateControlState: 'r',
}, },
_findbar: null, _findbar: null,
@ -300,7 +304,8 @@ PdfjsFindbarWrapper.prototype = {
}, },
addEventListener: function (aType, aListener, aUseCapture, aWantsUntrusted) { addEventListener: function (aType, aListener, aUseCapture, aWantsUntrusted) {
this._findbar.addEventListener(aType, aListener, aUseCapture, aWantsUntrusted); this._findbar.addEventListener(aType, aListener, aUseCapture,
aWantsUntrusted);
}, },
removeEventListener: function (aType, aListener, aUseCapture) { removeEventListener: function (aType, aListener, aUseCapture) {
@ -310,11 +315,11 @@ PdfjsFindbarWrapper.prototype = {
function PdfjsWindowWrapper(aBrowser) { function PdfjsWindowWrapper(aBrowser) {
this._window = aBrowser.ownerDocument.defaultView; this._window = aBrowser.ownerDocument.defaultView;
}; }
PdfjsWindowWrapper.prototype = { PdfjsWindowWrapper.prototype = {
__exposedProps__: { __exposedProps__: {
valueOf: "r", valueOf: 'r',
}, },
_window: null, _window: null,
@ -322,4 +327,3 @@ PdfjsWindowWrapper.prototype = {
return this._window.valueOf(); return this._window.valueOf();
} }
}; };