mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1103732 - remove getNFCPeer. r=smaug, dimi
This commit is contained in:
parent
a95c871e12
commit
40186f9184
@ -131,21 +131,6 @@ NfcContentHelper.prototype = {
|
||||
return encodedRecords;
|
||||
},
|
||||
|
||||
// NFC interface:
|
||||
checkSessionToken: function checkSessionToken(sessionToken, isP2P) {
|
||||
if (sessionToken == null) {
|
||||
throw Components.Exception("No session token!",
|
||||
Cr.NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
// Report session to Nfc.js only.
|
||||
let val = cpmm.sendSyncMessage("NFC:CheckSessionToken", {
|
||||
sessionToken: sessionToken,
|
||||
isP2P: isP2P
|
||||
});
|
||||
return (val[0] === NFC.NFC_GECKO_SUCCESS);
|
||||
},
|
||||
|
||||
// NFCTag interface
|
||||
readNDEF: function readNDEF(sessionToken, callback) {
|
||||
let requestId = callback.getCallbackId();
|
||||
|
@ -54,12 +54,8 @@ const NFC_CONTRACTID = "@mozilla.org/nfc;1";
|
||||
const NFC_CID =
|
||||
Components.ID("{2ff24790-5e74-11e1-b86c-0800200c9a66}");
|
||||
|
||||
const NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES = [
|
||||
"NFC:AddEventListener"
|
||||
];
|
||||
|
||||
const NFC_IPC_MSG_NAMES = [
|
||||
"NFC:CheckSessionToken",
|
||||
"NFC:AddEventListener",
|
||||
"NFC:QueryInfo"
|
||||
];
|
||||
|
||||
@ -131,10 +127,6 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
||||
_registerMessageListeners: function _registerMessageListeners() {
|
||||
ppmm.addMessageListener("child-process-shutdown", this);
|
||||
|
||||
for (let message of NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES) {
|
||||
ppmm.addMessageListener(message, this);
|
||||
}
|
||||
|
||||
for (let message of NFC_IPC_MSG_NAMES) {
|
||||
ppmm.addMessageListener(message, this);
|
||||
}
|
||||
@ -155,10 +147,6 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
||||
_unregisterMessageListeners: function _unregisterMessageListeners() {
|
||||
ppmm.removeMessageListener("child-process-shutdown", this);
|
||||
|
||||
for (let message of NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES) {
|
||||
ppmm.removeMessageListener(message, this);
|
||||
}
|
||||
|
||||
for (let message of NFC_IPC_MSG_NAMES) {
|
||||
ppmm.removeMessageListener(message, this);
|
||||
}
|
||||
@ -290,8 +278,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (NFC_IPC_MSG_NAMES.indexOf(message.name) != -1 ||
|
||||
NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES.indexOf(message.name) != -1 ) {
|
||||
if (NFC_IPC_MSG_NAMES.indexOf(message.name) != -1) {
|
||||
// Do nothing.
|
||||
} else if (NFC_IPC_NFC_PERM_MSG_NAMES.indexOf(message.name) != -1) {
|
||||
if (!message.target.assertPermission("nfc")) {
|
||||
@ -320,11 +307,6 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
||||
case "NFC:AddEventListener":
|
||||
this.addEventListener(message.target);
|
||||
return null;
|
||||
case "NFC:CheckSessionToken":
|
||||
let sessionToken = message.data.sessionToken;
|
||||
return SessionHelper.isValidToken(sessionToken, message.data.isP2P) ?
|
||||
NFC.NFC_GECKO_SUCCESS :
|
||||
NFC.NFC_GECKO_ERROR_BAD_SESSION_TOKEN;
|
||||
case "NFC:RegisterPeerReadyTarget":
|
||||
this.registerPeerReadyTarget(message.target, message.data.appId);
|
||||
return null;
|
||||
@ -341,7 +323,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
||||
// Upon receiving the status of sendFile operation, send the response
|
||||
// to appropriate content process.
|
||||
message.data.type = "NotifySendFileStatusResponse";
|
||||
if (message.data.status !== NFC.NFC_SUCCESS) {
|
||||
if (message.data.status) {
|
||||
message.data.errorMsg =
|
||||
this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_SEND_FILE_FAILED);
|
||||
}
|
||||
@ -421,17 +403,6 @@ let SessionHelper = {
|
||||
|
||||
isP2PSession: function isP2PSession(id) {
|
||||
return (this.tokenMap[id] != null) && this.tokenMap[id].isP2P;
|
||||
},
|
||||
|
||||
isValidToken: function isValidToken(token, isP2P) {
|
||||
for (let id in this.tokenMap) {
|
||||
if ((this.tokenMap[id].token == token) &&
|
||||
(this.tokenMap[id].isP2P == isP2P)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -511,8 +482,7 @@ Nfc.prototype = {
|
||||
},
|
||||
|
||||
getErrorMessage: function getErrorMessage(errorCode) {
|
||||
return NFC.NFC_ERROR_MSG[errorCode] ||
|
||||
NFC.NFC_ERROR_MSG[NFC.NFC_GECKO_ERROR_GENERIC_FAILURE];
|
||||
return NFC.NFC_ERROR_MSG[errorCode];
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -23,17 +23,12 @@ this.DEBUG_CONTENT_HELPER = DEBUG_ALL || false;
|
||||
this.DEBUG_NFC = DEBUG_ALL || false;
|
||||
|
||||
// Gecko specific error codes
|
||||
this.NFC_GECKO_SUCCESS = 0;
|
||||
this.NFC_GECKO_ERROR_GENERIC_FAILURE = 1;
|
||||
this.NFC_GECKO_ERROR_P2P_REG_INVALID = 2;
|
||||
this.NFC_GECKO_ERROR_SEND_FILE_FAILED = 3;
|
||||
this.NFC_GECKO_ERROR_BAD_SESSION_TOKEN = 4;
|
||||
this.NFC_GECKO_ERROR_P2P_REG_INVALID = 1;
|
||||
this.NFC_GECKO_ERROR_SEND_FILE_FAILED = 2;
|
||||
|
||||
this.NFC_ERROR_MSG = {};
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_GENERIC_FAILURE] = "NfcGenericFailureError";
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_P2P_REG_INVALID] = "NfcP2PRegistrationInvalid";
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_SEND_FILE_FAILED] = "NfcSendFileFailed";
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_BAD_SESSION_TOKEN] = "NfcBadSessionToken";
|
||||
|
||||
this.NFC_RF_STATE_IDLE = "idle";
|
||||
this.NFC_RF_STATE_LISTEN = "listen";
|
||||
|
@ -87,13 +87,11 @@ interface nsINfcRequestCallback : nsISupports
|
||||
void notifyError(in DOMString errorMsg);
|
||||
};
|
||||
|
||||
[scriptable, uuid(bcf214de-885b-43e6-9e53-9b7d880e1633)]
|
||||
[scriptable, uuid(c5fdf956-735e-45d3-aa25-3a871bd3e2f8)]
|
||||
interface nsINfcContentHelper : nsISupports
|
||||
{
|
||||
void init(in nsIDOMWindow window);
|
||||
|
||||
boolean checkSessionToken(in DOMString sessionToken, in boolean isP2P);
|
||||
|
||||
/**
|
||||
* Read current NDEF data on the tag.
|
||||
*
|
||||
|
@ -332,23 +332,6 @@ MozNFCImpl.prototype = {
|
||||
return callback.promise;
|
||||
},
|
||||
|
||||
_createNFCPeer: function _createNFCPeer(sessionToken) {
|
||||
let peer = new MozNFCPeerImpl(this._window, sessionToken);
|
||||
return this._window.MozNFCPeer._create(this._window, peer);
|
||||
},
|
||||
|
||||
getNFCPeer: function getNFCPeer(sessionToken) {
|
||||
if (!sessionToken || !this._nfcContentHelper.checkSessionToken(sessionToken, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!this.nfcPeer || this.nfcPeer.session != sessionToken) {
|
||||
this.nfcPeer = this._createNFCPeer(sessionToken);
|
||||
}
|
||||
|
||||
return this.nfcPeer;
|
||||
},
|
||||
|
||||
defineEventHandlerGetterSetter: function defineEventHandlerGetterSetter(name) {
|
||||
Object.defineProperty(this, name, {
|
||||
get: function get() {
|
||||
@ -469,7 +452,8 @@ MozNFCImpl.prototype = {
|
||||
this.eventService.addSystemEventListener(this._window, "visibilitychange",
|
||||
this, /* useCapture */false);
|
||||
|
||||
this.nfcPeer = this._createNFCPeer(sessionToken);
|
||||
let peerImpl = new MozNFCPeerImpl(this._window, sessionToken);
|
||||
this.nfcPeer = this._window.MozNFCPeer._create(this._window, peerImpl)
|
||||
let eventData = { "peer": this.nfcPeer };
|
||||
let type = (isPeerReady) ? "peerready" : "peerfound";
|
||||
|
||||
|
@ -28,12 +28,6 @@ enum NfcErrorMessage {
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface MozNFCManager {
|
||||
/**
|
||||
* Returns MozNFCPeer object or null in case of invalid sessionToken
|
||||
*/
|
||||
[CheckPermissions="nfc-manager"]
|
||||
MozNFCPeer? getNFCPeer(DOMString sessionToken);
|
||||
|
||||
/**
|
||||
* API to check if the given application's manifest
|
||||
* URL is registered with the Chrome Process or not.
|
||||
|
Loading…
Reference in New Issue
Block a user