mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1126653 - don't send nfc-manager-tech-lost if the foreground has received ontag/peerfound. r=dimi
This commit is contained in:
parent
21112546e2
commit
a04b632dab
@ -292,6 +292,12 @@ NfcContentHelper.prototype = {
|
||||
records: encodedRecords});
|
||||
},
|
||||
|
||||
callDefaultLostHandler: function callDefaultLostHandler(sessionToken, isP2P) {
|
||||
cpmm.sendAsyncMessage("NFC:CallDefaultLostHandler",
|
||||
{sessionToken: sessionToken,
|
||||
isP2P: isP2P});
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
observe: function observe(subject, topic, data) {
|
||||
if (topic == "xpcom-shutdown") {
|
||||
|
@ -58,7 +58,8 @@ const NFC_IPC_MSG_ENTRIES = [
|
||||
{ permission: null,
|
||||
messages: ["NFC:AddEventListener",
|
||||
"NFC:QueryInfo",
|
||||
"NFC:CallDefaultFoundHandler"] },
|
||||
"NFC:CallDefaultFoundHandler",
|
||||
"NFC:CallDefaultLostHandler"] },
|
||||
|
||||
{ permission: "nfc",
|
||||
messages: ["NFC:ReadNDEF",
|
||||
@ -245,6 +246,11 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
||||
gSystemMessenger.broadcastMessage("nfc-manager-tech-discovered", sysMsg);
|
||||
},
|
||||
|
||||
callDefaultLostHandler: function callDefaultLostHandler(message) {
|
||||
// message.isP2P is not used.
|
||||
gSystemMessenger.broadcastMessage("nfc-manager-tech-lost", message.sessionToken);
|
||||
},
|
||||
|
||||
onTagFound: function onTagFound(message) {
|
||||
let target = this.eventListeners[this.focusApp] ||
|
||||
this.eventListeners[NFC.SYSTEM_APP_ID];
|
||||
@ -348,6 +354,9 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
||||
case "NFC:CallDefaultFoundHandler":
|
||||
this.callDefaultFoundHandler(message.data);
|
||||
return null;
|
||||
case "NFC:CallDefaultLostHandler":
|
||||
this.callDefaultLostHandler(message.data);
|
||||
return null;
|
||||
default:
|
||||
return this.nfc.receiveMessage(message);
|
||||
}
|
||||
@ -546,10 +555,6 @@ Nfc.prototype = {
|
||||
}
|
||||
|
||||
SessionHelper.unregisterSession(message.sessionId);
|
||||
// Do not expose the actual session to the content
|
||||
delete message.sessionId;
|
||||
|
||||
gSystemMessenger.broadcastMessage("nfc-manager-tech-lost", message);
|
||||
break;
|
||||
case "HCIEventTransactionNotification":
|
||||
this.notifyHCIEventTransaction(message);
|
||||
|
@ -119,7 +119,7 @@ interface nsINfcBrowserAPI : nsISupports
|
||||
in boolean isFocus);
|
||||
};
|
||||
|
||||
[scriptable, uuid(b35f4bf5-e1b8-45f4-b5d3-2ae9b6d5871e)]
|
||||
[scriptable, uuid(39e1b25b-5063-449e-b9e8-5514cdca9c3a)]
|
||||
interface nsINfcContentHelper : nsISupports
|
||||
{
|
||||
void init(in nsIDOMWindow window);
|
||||
@ -301,4 +301,17 @@ interface nsINfcContentHelper : nsISupports
|
||||
void callDefaultFoundHandler(in DOMString sessionToken,
|
||||
in boolean isP2P,
|
||||
in nsIVariant records);
|
||||
|
||||
/**
|
||||
* Notify parent process to call the default taglost or peerlost event
|
||||
* handler.
|
||||
*
|
||||
* @param sessionToken
|
||||
* Session token of this event.
|
||||
* @param isP2P
|
||||
* Is this a P2P Session.
|
||||
*/
|
||||
void callDefaultLostHandler(in DOMString sessionToken,
|
||||
in boolean isP2P);
|
||||
|
||||
};
|
||||
|
@ -493,18 +493,24 @@ MozNFCImpl.prototype = {
|
||||
},
|
||||
|
||||
notifyTagLost: function notifyTagLost(sessionToken) {
|
||||
if (!this.handleTagLost(sessionToken)) {
|
||||
this._nfcContentHelper.callDefaultLostHandler(sessionToken, false);
|
||||
}
|
||||
},
|
||||
|
||||
handleTagLost: function handleTagLost(sessionToken) {
|
||||
if (this.hasDeadWrapper()) {
|
||||
dump("this._window or this.__DOM_IMPL__ is a dead wrapper.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.checkPermissions(["nfc"])) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.nfcTag) {
|
||||
debug("No NFCTag object existing.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
this.nfcTag.notifyLost();
|
||||
@ -513,6 +519,8 @@ MozNFCImpl.prototype = {
|
||||
debug("fire ontaglost " + sessionToken);
|
||||
let event = new this._window.Event("taglost");
|
||||
this.__DOM_IMPL__.dispatchEvent(event);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
notifyPeerFound: function notifyPeerFound(sessionToken, isPeerReady) {
|
||||
@ -578,18 +586,24 @@ MozNFCImpl.prototype = {
|
||||
},
|
||||
|
||||
notifyPeerLost: function notifyPeerLost(sessionToken) {
|
||||
if (!this.handlePeerLost(sessionToken)) {
|
||||
this._nfcContentHelper.callDefaultLostHandler(sessionToken, true);
|
||||
}
|
||||
},
|
||||
|
||||
handlePeerLost: function handlePeerLost(sessionToken) {
|
||||
if (this.hasDeadWrapper()) {
|
||||
dump("this._window or this.__DOM_IMPL__ is a dead wrapper.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.checkPermissions(["nfc", "nfc-share"])) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.nfcPeer) {
|
||||
debug("No NFCPeer object existing.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
this.nfcPeer.notifyLost();
|
||||
@ -598,6 +612,8 @@ MozNFCImpl.prototype = {
|
||||
debug("fire onpeerlost");
|
||||
let event = new this._window.Event("peerlost");
|
||||
this.__DOM_IMPL__.dispatchEvent(event);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
notifyRFStateChanged: function notifyRFStateChanged(rfState) {
|
||||
|
Loading…
Reference in New Issue
Block a user