From 78b23d6e7aab3249832e12ce725dde70c54d58ee Mon Sep 17 00:00:00 2001 From: Dimi Lee Date: Tue, 17 Dec 2013 10:32:29 +0800 Subject: [PATCH] Bug 939056 - B2G NFC: Enable/disable MOZ_NFC at runtime. r=bz --- dom/base/Navigator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 443deca78c45..403ae203b7df 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1808,6 +1808,12 @@ Navigator::HasFMRadioSupport(JSContext* /* unused */, JSObject* aGlobal) bool Navigator::HasNfcSupport(JSContext* /* unused */, JSObject* aGlobal) { + // Do not support NFC if NFC content helper does not exist. + nsCOMPtr contentHelper = do_GetService("@mozilla.org/nfc/content-helper;1"); + if (!contentHelper) { + return false; + } + nsCOMPtr win = GetWindowFromGlobal(aGlobal); return win && (CheckPermission(win, "nfc-read") || CheckPermission(win, "nfc-write"));