DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (dcc6d7a0dc00)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

 /* Copyright © 2013 Deutsche Telekom, Inc. */

enum NfcErrorMessage {
  "",
  "IOError",
  "Timeout",
  "Busy",
  "ErrorConnect",
  "ErrorDisconnect",
  "ErrorRead",
  "ErrorWrite",
  "InvalidParameter",
  "InsufficientResource",
  "ErrorSocketCreation",
  "FailEnableDiscovery",
  "FailDisableDiscovery",
  "NotInitialize",
  "InitializeFail",
  "DeinitializeFail",
  "NotSupport",
  "FailEnableLowPowerMode",
  "FailDisableLowPowerMode"
};

[NoInterfaceObject]
interface MozNFCManager {
  /**
   * API to check if the given application's manifest
   * URL is registered with the Chrome Process or not.
   *
   * Returns success if given manifestUrl is registered for 'onpeerready',
   * otherwise error
   */
  [CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
  Promise<boolean> checkP2PRegistration(DOMString manifestUrl);

  /**
   * Notify that user has accepted to share nfc message on P2P UI
   */
  [CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
  void notifyUserAcceptedP2P(DOMString manifestUrl);

  /**
   * Notify the status of sendFile operation
   */
  [CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
  void notifySendFileStatus(octet status, DOMString requestId);

  /**
   * Power on the NFC hardware and start polling for NFC tags or devices.
   */
  [CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
  Promise<void> startPoll();

  /**
   * Stop polling for NFC tags or devices. i.e. enter low power mode.
   */
  [CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
  Promise<void> stopPoll();

  /**
   * Power off the NFC hardware.
   */
  [CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
  Promise<void> powerOff();
};

[JSImplementation="@mozilla.org/nfc/manager;1",
 NavigatorProperty="mozNfc",
 Func="Navigator::HasNFCSupport",
 CheckAnyPermissions="nfc nfc-share",
 AvailableIn="PrivilegedApps",
 UnsafeInPrerendering]
interface MozNFC : EventTarget {
  /**
   * Indicate if NFC is enabled.
   */
  readonly attribute boolean enabled;

  /**
   * This event will be fired when another NFCPeer is detected, and user confirms
   * to share data to the NFCPeer object by calling mozNFC.notifyUserAcceptedP2P.
   * The event will be type of NFCPeerEvent.
   */
  [CheckAnyPermissions="nfc-share", AvailableIn=CertifiedApps]
  attribute EventHandler onpeerready;

  /**
   * This event will be fired when a NFCPeer is detected. The application has to
   * be running on the foreground (decided by System app) to receive this event.
   *
   * The default action of this event is to dispatch the event in System app
   * again, and System app will run the default UX behavior (like vibration).
   * So if the application would like to cancel the event, the application
   * should call event.preventDefault() or return false in this event handler.
   */
  attribute EventHandler onpeerfound;

  /**
   * This event will be fired when NFCPeer, earlier detected in onpeerready
   * or onpeerfound, moves out of range, or if the application has been switched
   * to the background (decided by System app).
   */
  attribute EventHandler onpeerlost;

  /**
   * This event will be fired when a NFCTag is detected. The application has to
   * be running on the foreground (decided by System app) to receive this event.
   *
   * The default action of this event is to dispatch the event in System app
   * again, and System app will run the default UX behavior (like vibration) and
   * launch MozActivity to handle the content of the tag. (For example, System
   * app will launch Browser if the tag contains URL). So if the application
   * would like to cancel the event, i.e. in the above example, the application
   * would process the URL by itself without launching Browser, the application
   * should call event.preventDefault() or return false in this event handler.
   */
  attribute EventHandler ontagfound;

  /**
   * This event will be fired if the tag detected in ontagfound has been
   * removed, or if the application has been switched to the background (decided
   * by System app).
   */
  attribute EventHandler ontaglost;
};

// Mozilla Only
partial interface MozNFC {
  [ChromeOnly]
  void eventListenerWasAdded(DOMString aType);
  [ChromeOnly]
  void eventListenerWasRemoved(DOMString aType);
};

MozNFC implements MozNFCManager;