mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1109458 - Let privilege App know if NFC is enabled or not. r=smaug, dimi
This commit is contained in:
parent
6a07e31ef6
commit
b15507d889
@ -397,7 +397,7 @@ Nfc.prototype = {
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsINfcGonkEventListener]),
|
||||
|
||||
rfState: null,
|
||||
rfState: NFC.NFC_RF_STATE_IDLE,
|
||||
|
||||
nfcService: null,
|
||||
|
||||
|
@ -246,6 +246,13 @@ MozNFCPeerImpl.prototype = {
|
||||
Ci.nsIDOMGlobalPropertyInitializer]),
|
||||
};
|
||||
|
||||
// Should be mapped to the RFState defined in WebIDL.
|
||||
let RFState = {
|
||||
IDLE: "idle",
|
||||
LISTEN: "listen",
|
||||
DISCOVERY: "discovery"
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of navigator NFC object.
|
||||
*/
|
||||
@ -270,13 +277,6 @@ MozNFCImpl.prototype = {
|
||||
nfcTag: null,
|
||||
eventService: null,
|
||||
|
||||
// Should be mapped to the RFState defined in WebIDL.
|
||||
rfState: {
|
||||
IDLE: "idle",
|
||||
LISTEN: "listen",
|
||||
DISCOVERY: "discovery"
|
||||
},
|
||||
|
||||
init: function init(aWindow) {
|
||||
debug("MozNFCImpl init called");
|
||||
this._window = aWindow;
|
||||
@ -316,22 +316,26 @@ MozNFCImpl.prototype = {
|
||||
|
||||
startPoll: function startPoll() {
|
||||
let callback = new NfcCallback(this._window);
|
||||
this._nfcContentHelper.changeRFState(this.rfState.DISCOVERY, callback);
|
||||
this._nfcContentHelper.changeRFState(RFState.DISCOVERY, callback);
|
||||
return callback.promise;
|
||||
},
|
||||
|
||||
stopPoll: function stopPoll() {
|
||||
let callback = new NfcCallback(this._window);
|
||||
this._nfcContentHelper.changeRFState(this.rfState.LISTEN, callback);
|
||||
this._nfcContentHelper.changeRFState(RFState.LISTEN, callback);
|
||||
return callback.promise;
|
||||
},
|
||||
|
||||
powerOff: function powerOff() {
|
||||
let callback = new NfcCallback(this._window);
|
||||
this._nfcContentHelper.changeRFState(this.rfState.IDLE, callback);
|
||||
this._nfcContentHelper.changeRFState(RFState.IDLE, callback);
|
||||
return callback.promise;
|
||||
},
|
||||
|
||||
get enabled() {
|
||||
return this._rfState != RFState.IDLE;
|
||||
},
|
||||
|
||||
defineEventHandlerGetterSetter: function defineEventHandlerGetterSetter(name) {
|
||||
Object.defineProperty(this, name, {
|
||||
get: function get() {
|
||||
|
@ -75,6 +75,11 @@ interface MozNFCManager {
|
||||
CheckPermissions="nfc nfc-share",
|
||||
AvailableIn="PrivilegedApps"]
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user