dom/webidl/MozNFC.webidl
author George Wright <george@mozilla.com>
Fri, 08 Apr 2016 13:33:27 -0400
changeset 317655 8d87452bfc44bf502e2a1a172db91f88e5284782
parent 272410 4dd71c32a6cb0e4dbf10350bf65d63bda844cb3b
child 332349 20a6fd076505809220e031dd594e03029459a664
permissions -rw-r--r--
Revert "Bug 1261416 - Rename firefox-plugin-container back to plugin-container to satisfy Flash's protected mode checks, and ensure that we launch the correct binary r=ted" because of widespread breakage due to whitelisted executable names in third parties This reverts commit 2d44e8ffaf63a32292f8e5b8fdd1485d0a462afc.

/* 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;