Bug 948850 - B2G NFC: to add onpeerready causes app to be killed. r=khuey
authorYoshi Huang <allstars.chh@mozilla.com>
Mon, 13 Jan 2014 17:33:12 +0800
changeset 163494 818236db09b4ac2f08ececd9adf410c6e628a3f1
parent 163493 3231b0081ff24bd6bab173747e6d33fa3367e6c0
child 163495 559465ad3fd8b32535adec33ae5802d5b9116f9c
push idunknown
push userunknown
push dateunknown
reviewerskhuey
bugs948850
milestone29.0a1
Bug 948850 - B2G NFC: to add onpeerready causes app to be killed. r=khuey
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/webidl/MozNfc.webidl
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1810,19 +1810,26 @@ Navigator::HasNfcSupport(JSContext* /* u
   if (!contentHelper) {
     return false;
   }
 
   nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
   return win && (CheckPermission(win, "nfc-read") ||
                  CheckPermission(win, "nfc-write"));
 }
+
+/* static */
+bool
+Navigator::HasNfcPeerSupport(JSContext* /* unused */, JSObject* aGlobal)
+{
+  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
+  return win && CheckPermission(win, "nfc-write");
+}
 #endif // MOZ_NFC
 
-
 #ifdef MOZ_TIME_MANAGER
 /* static */
 bool
 Navigator::HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
   return win && CheckPermission(win, "time");
 }
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -268,16 +268,17 @@ public:
 #ifdef MOZ_B2G_BT
   static bool HasBluetoothSupport(JSContext* /* unused */, JSObject* aGlobal);
 #endif // MOZ_B2G_BT
 #ifdef MOZ_B2G_FM
   static bool HasFMRadioSupport(JSContext* /* unused */, JSObject* aGlobal);
 #endif // MOZ_B2G_FM
 #ifdef MOZ_NFC
   static bool HasNfcSupport(JSContext* /* unused */, JSObject* aGlobal);
+  static bool HasNfcPeerSupport(JSContext* /* unused */, JSObject* aGlobal);
 #endif // MOZ_NFC
 #ifdef MOZ_TIME_MANAGER
   static bool HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal);
 #endif // MOZ_TIME_MANAGER
 #ifdef MOZ_MEDIA_NAVIGATOR
   static bool HasUserMediaSupport(JSContext* /* unused */,
                                   JSObject* /* unused */);
 #endif // MOZ_MEDIA_NAVIGATOR
--- a/dom/webidl/MozNfc.webidl
+++ b/dom/webidl/MozNfc.webidl
@@ -18,15 +18,17 @@ interface MozNfc : EventTarget {
     * Returns success if given manifestUrl is registered for 'onpeerready',
     * otherwise error
     *
     * Users of this API should have valid permissions 'nfc-manager'
     * and 'nfc-write'
     */
    DOMRequest checkP2PRegistration(DOMString manifestUrl);
 
+   [Func="Navigator::HasNfcPeerSupport"]
    attribute EventHandler onpeerready;
+   [Func="Navigator::HasNfcPeerSupport"]
    attribute EventHandler onpeerlost;
    [ChromeOnly]
    void eventListenerWasAdded(DOMString aType);
    [ChromeOnly]
    void eventListenerWasRemoved(DOMString aType);
 };