Bug 939056 - B2G NFC: Enable/disable MOZ_NFC at runtime. r=bz

This commit is contained in:
Dimi Lee 2013-12-17 10:32:29 +08:00
Родитель 3a2a73567c
Коммит 78b23d6e7a
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -1808,6 +1808,12 @@ Navigator::HasFMRadioSupport(JSContext* /* unused */, JSObject* aGlobal)
bool bool
Navigator::HasNfcSupport(JSContext* /* unused */, JSObject* aGlobal) 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); nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && (CheckPermission(win, "nfc-read") || return win && (CheckPermission(win, "nfc-read") ||
CheckPermission(win, "nfc-write")); CheckPermission(win, "nfc-write"));