diff --git a/dom/nfc/nsNfc.js b/dom/nfc/nsNfc.js index 8cf28137450..55f865d796d 100644 --- a/dom/nfc/nsNfc.js +++ b/dom/nfc/nsNfc.js @@ -138,8 +138,12 @@ MozNFCPeer.prototype = { */ function mozNfc() { debug("In mozNfc Constructor"); - this._nfcContentHelper = Cc["@mozilla.org/nfc/content-helper;1"] - .getService(Ci.nsINfcContentHelper); + try { + this._nfcContentHelper = Cc["@mozilla.org/nfc/content-helper;1"] + .getService(Ci.nsINfcContentHelper); + } catch(e) { + debug("No NFC support.") + } } mozNfc.prototype = { _nfcContentHelper: null, diff --git a/dom/system/gonk/Nfc.js b/dom/system/gonk/Nfc.js index 67152fc4d7a..c2a489ef426 100644 --- a/dom/system/gonk/Nfc.js +++ b/dom/system/gonk/Nfc.js @@ -25,6 +25,9 @@ Cu.import("resource://gre/modules/Services.jsm"); let NFC = {}; Cu.import("resource://gre/modules/nfc_consts.js", NFC); +Cu.import("resource://gre/modules/systemlibs.js"); +const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true"; + // set to true in nfc_consts.js to see debug messages let DEBUG = NFC.DEBUG_NFC; @@ -627,4 +630,6 @@ Nfc.prototype = { } }; -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Nfc]); +if (NFC_ENABLED) { + this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Nfc]); +} diff --git a/dom/system/gonk/NfcContentHelper.js b/dom/system/gonk/NfcContentHelper.js index 623206212fd..2ed5b17670a 100644 --- a/dom/system/gonk/NfcContentHelper.js +++ b/dom/system/gonk/NfcContentHelper.js @@ -26,6 +26,9 @@ Cu.import("resource://gre/modules/DOMRequestHelper.jsm"); let NFC = {}; Cu.import("resource://gre/modules/nfc_consts.js", NFC); +Cu.import("resource://gre/modules/systemlibs.js"); +const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true"; + // set to true to in nfc_consts.js to see debug messages let DEBUG = NFC.DEBUG_CONTENT_HELPER; @@ -384,4 +387,6 @@ NfcContentHelper.prototype = { }, }; -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NfcContentHelper]); +if (NFC_ENABLED) { + this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NfcContentHelper]); +}