зеркало из https://github.com/mozilla/gecko-dev.git
Bug 959437 - Part 2: Add NotifySendFileStatus to Chrome process. r=allstars.chh
This commit is contained in:
Родитель
213e2bb4a5
Коммит
dc061fa45e
|
@ -59,7 +59,8 @@ const NFC_IPC_PEER_MSG_NAMES = [
|
|||
"NFC:RegisterPeerTarget",
|
||||
"NFC:UnregisterPeerTarget",
|
||||
"NFC:CheckP2PRegistration",
|
||||
"NFC:NotifyUserAcceptedP2P"
|
||||
"NFC:NotifyUserAcceptedP2P",
|
||||
"NFC:NotifySendFileStatus"
|
||||
];
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
||||
|
@ -309,10 +310,12 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Add extra permission check for below IPC Peer events:
|
||||
// 'NFC:CheckP2PRegistration' , 'NFC:NotifyUserAcceptedP2P'
|
||||
// Add extra permission check for below events:
|
||||
// 'NFC:CheckP2PRegistration' , 'NFC:NotifyUserAcceptedP2P',
|
||||
// 'NFC:NotifySendFileStatus'
|
||||
if ((msg.name == "NFC:CheckP2PRegistration") ||
|
||||
(msg.name == "NFC:NotifyUserAcceptedP2P")) {
|
||||
(msg.name == "NFC:NotifyUserAcceptedP2P") ||
|
||||
(msg.name == "NFC:NotifySendFileStatus")) {
|
||||
// ONLY privileged Content can send these events
|
||||
if (!msg.target.assertPermission("nfc-manager")) {
|
||||
debug("NFC message " + message.name +
|
||||
|
@ -356,6 +359,11 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||
// Notify the 'NFC_PEER_EVENT_READY' since user has acknowledged
|
||||
this.notifyPeerEvent(msg.json.appId, NFC.NFC_PEER_EVENT_READY);
|
||||
break;
|
||||
case "NFC:NotifySendFileStatus":
|
||||
// Upon receiving the status of sendFile operation, send the response
|
||||
// to appropriate content process.
|
||||
this.sendNfcResponseMessage(msg.name + "Response", msg.json);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
|
|
@ -52,7 +52,9 @@ const NFC_IPC_MSG_NAMES = [
|
|||
"NFC:ConnectResponse",
|
||||
"NFC:CloseResponse",
|
||||
"NFC:CheckP2PRegistrationResponse",
|
||||
"NFC:PeerEvent"
|
||||
"NFC:PeerEvent",
|
||||
"NFC:NotifySendFileStatusResponse",
|
||||
"NFC:SendFileResponse"
|
||||
];
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
|
@ -235,6 +237,19 @@ NfcContentHelper.prototype = {
|
|||
return request;
|
||||
},
|
||||
|
||||
notifySendFileStatus: function notifySendFileStatus(window, status,
|
||||
requestId) {
|
||||
if (window == null) {
|
||||
throw Components.Exception("Can't get window object",
|
||||
Cr.NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
cpmm.sendAsyncMessage("NFC:NotifySendFileStatus", {
|
||||
status: status,
|
||||
requestId: requestId
|
||||
});
|
||||
},
|
||||
|
||||
registerTargetForPeerEvent: function registerTargetForPeerEvent(window,
|
||||
appId, event, callback) {
|
||||
if (window == null) {
|
||||
|
@ -341,6 +356,7 @@ NfcContentHelper.prototype = {
|
|||
case "NFC:MakeReadOnlyNDEFResponse":
|
||||
case "NFC:GetDetailsNDEFResponse":
|
||||
case "NFC:CheckP2PRegistrationResponse":
|
||||
case "NFC:NotifySendFileStatusResponse":
|
||||
this.handleResponse(message.json);
|
||||
break;
|
||||
case "NFC:PeerEvent":
|
||||
|
|
|
@ -24,7 +24,7 @@ interface nsINfcPeerCallback : nsISupports
|
|||
in DOMString sessionToken);
|
||||
};
|
||||
|
||||
[scriptable, uuid(91c2760a-f41c-4174-ad68-614840d4e201)]
|
||||
[scriptable, uuid(70cac000-7e3c-11e3-baa7-0800200c9a66)]
|
||||
interface nsINfcContentHelper : nsISupports
|
||||
{
|
||||
const long NFC_EVENT_PEER_READY = 0x01;
|
||||
|
@ -118,4 +118,21 @@ interface nsINfcContentHelper : nsISupports
|
|||
* Application ID that is capable of handling NFC_EVENT_PEER_READY event
|
||||
*/
|
||||
void notifyUserAcceptedP2P(in nsIDOMWindow window, in unsigned long appId);
|
||||
|
||||
/**
|
||||
* Notify the status of sendFile operation to Chrome process
|
||||
*
|
||||
* @param window
|
||||
* Current window
|
||||
*
|
||||
* @param status
|
||||
* Status of sendFile operation
|
||||
* (GECKO_NFC_ERROR_SUCCESS, GECKO_NFC_ERROR_GENERIC_FAILURE)
|
||||
*
|
||||
* @param requestId
|
||||
* Request ID of SendFile DOM Request
|
||||
*/
|
||||
void notifySendFileStatus(in nsIDOMWindow window,
|
||||
in octet status,
|
||||
in DOMString requestId);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче