Bug 1141457 - Part 2: add isP2P for writeNDEF. r=dimi

From 35af6fe22fa075ecef92cd84e2ce22357c9c395f Mon Sep 17 00:00:00 2001
---
 dom/nfc/NfcContentHelper.js     | 5 +++--
 dom/nfc/gonk/Nfc.js             | 1 -
 dom/nfc/nsINfcContentHelper.idl | 5 ++++-
 dom/nfc/nsNfc.js                | 4 ++--
 4 files changed, 9 insertions(+), 6 deletions(-)
This commit is contained in:
Yoshi Huang 2015-03-10 16:49:08 +08:00
parent 9a3417e8f9
commit a24e6525de
4 changed files with 9 additions and 6 deletions

View File

@ -162,14 +162,15 @@ NfcContentHelper.prototype = {
});
},
writeNDEF: function writeNDEF(records, sessionToken, callback) {
writeNDEF: function writeNDEF(records, isP2P, sessionToken, callback) {
let requestId = callback.getCallbackId();
this._requestMap[requestId] = callback;
cpmm.sendAsyncMessage("NFC:WriteNDEF", {
requestId: requestId,
sessionToken: sessionToken,
records: records
records: records,
isP2P: isP2P
});
},

View File

@ -698,7 +698,6 @@ Nfc.prototype = {
this.sendToNfcService(NfcRequestType.READ_NDEF, message.data);
break;
case "NFC:WriteNDEF":
message.data.isP2P = SessionHelper.isP2PSession(message.data.sessionId);
this.sendToNfcService(NfcRequestType.WRITE_NDEF, message.data);
break;
case "NFC:MakeReadOnly":

View File

@ -119,7 +119,7 @@ interface nsINfcBrowserAPI : nsISupports
in boolean isFocus);
};
[scriptable, uuid(39e1b25b-5063-449e-b9e8-5514cdca9c3a)]
[scriptable, uuid(9cf841c9-0347-4564-99e5-18c0f74eca4d)]
interface nsINfcContentHelper : nsISupports
{
void init(in nsIDOMWindow window);
@ -142,6 +142,8 @@ interface nsINfcContentHelper : nsISupports
* @param records
* NDEF records to be written
*
* @param isP2P
* If this write is for P2P.
* @param sessionToken
* Current token
*
@ -149,6 +151,7 @@ interface nsINfcContentHelper : nsISupports
* Called when request is finished
*/
void writeNDEF(in nsIVariant records,
in boolean isP2P,
in DOMString sessionToken,
in nsINfcRequestCallback callback);

View File

@ -182,7 +182,7 @@ MozNFCTagImpl.prototype = {
}
let callback = new NfcCallback(this._window);
this._nfcContentHelper.writeNDEF(records, this.session, callback);
this._nfcContentHelper.writeNDEF(records, false, this.session, callback);
return callback.promise;
},
@ -281,7 +281,7 @@ MozNFCPeerImpl.prototype = {
// Just forward sendNDEF to writeNDEF
let callback = new NfcCallback(this._window);
this._nfcContentHelper.writeNDEF(records, this.session, callback);
this._nfcContentHelper.writeNDEF(records, true, this.session, callback);
return callback.promise;
},