зеркало из https://github.com/mozilla/gecko-dev.git
Bug 976402 - Part 1 - Do not register target if the sessionTokens do not match. r=allstars.chh
This commit is contained in:
Родитель
42f55c3cf4
Коммит
1a20585dbd
|
@ -366,10 +366,14 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||
|
||||
switch (msg.name) {
|
||||
case "NFC:SetSessionToken":
|
||||
if (msg.json.sessionToken !== this.nfc.sessionTokenMap[this.nfc._currentSessionId]) {
|
||||
debug("Received invalid Session Token: " + msg.json.sessionToken + " - Do not register this target");
|
||||
return NFC.NFC_ERROR_BAD_SESSION_ID;
|
||||
}
|
||||
this._registerMessageTarget(this.nfc.sessionTokenMap[this.nfc._currentSessionId], msg.target);
|
||||
debug("Registering target for this SessionToken : " +
|
||||
this.nfc.sessionTokenMap[this.nfc._currentSessionId]);
|
||||
return null;
|
||||
return NFC.NFC_SUCCESS;
|
||||
case "NFC:RegisterPeerTarget":
|
||||
this.registerPeerTarget(msg);
|
||||
return null;
|
||||
|
|
|
@ -118,12 +118,13 @@ NfcContentHelper.prototype = {
|
|||
if (sessionToken == null) {
|
||||
throw Components.Exception("No session token!",
|
||||
Cr.NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// Report session to Nfc.js only.
|
||||
cpmm.sendAsyncMessage("NFC:SetSessionToken", {
|
||||
sessionToken: sessionToken,
|
||||
let val = cpmm.sendSyncMessage("NFC:SetSessionToken", {
|
||||
sessionToken: sessionToken
|
||||
});
|
||||
return (val[0] === NFC.NFC_SUCCESS);
|
||||
},
|
||||
|
||||
// NFCTag interface
|
||||
|
|
|
@ -24,13 +24,13 @@ interface nsINfcPeerCallback : nsISupports
|
|||
in DOMString sessionToken);
|
||||
};
|
||||
|
||||
[scriptable, uuid(10b2eb1b-3fe0-4c98-9c67-9e4c2274cd78)]
|
||||
[scriptable, uuid(26e8123f-ba00-4708-ac77-d1902457168c)]
|
||||
interface nsINfcContentHelper : nsISupports
|
||||
{
|
||||
const long NFC_EVENT_PEER_READY = 0x01;
|
||||
const long NFC_EVENT_PEER_LOST = 0x02;
|
||||
|
||||
void setSessionToken(in DOMString sessionToken);
|
||||
boolean setSessionToken(in DOMString sessionToken);
|
||||
|
||||
nsIDOMDOMRequest getDetailsNDEF(in nsIDOMWindow window, in DOMString sessionToken);
|
||||
nsIDOMDOMRequest readNDEF(in nsIDOMWindow window, in DOMString sessionToken);
|
||||
|
|
Загрузка…
Ссылка в новой задаче