Bug 939056 - B2G NFC: Enable/disable MOZ_NFC at runtime. r=bz, a=1.3+
authorDimi Lee <dlee@mozilla.com>
Tue, 17 Dec 2013 10:32:29 +0800
changeset 175353 63d2929a55edefcb9861dc837c2d748ddd299057
parent 175352 f04923b7a3812160aa2fa1f5b0a9db8d4668ebf1
child 175354 d913ebd1569f8288bae4e1eea304127188a181f2
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, 1
bugs939056
milestone28.0a2
Bug 939056 - B2G NFC: Enable/disable MOZ_NFC at runtime. r=bz, a=1.3+
dom/base/Navigator.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1801,16 +1801,22 @@ Navigator::HasFMRadioSupport(JSContext* 
 }
 #endif // MOZ_B2G_FM
 
 #ifdef MOZ_NFC
 /* static */
 bool
 Navigator::HasNfcSupport(JSContext* /* unused */, JSObject* aGlobal)
 {
+  // Do not support NFC if NFC content helper does not exist.
+  nsCOMPtr<nsISupports> contentHelper = do_GetService("@mozilla.org/nfc/content-helper;1");
+  if (!contentHelper) {
+    return false;
+  }
+
   nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
   return win && (CheckPermission(win, "nfc-read") ||
                  CheckPermission(win, "nfc-write"));
 }
 #endif // MOZ_NFC
 
 
 #ifdef MOZ_TIME_MANAGER