зеркало из https://github.com/mozilla/gecko-dev.git
Bug 786686 - B2G Contacts API must not access RadioInterfaceLayer in content process. r=anygregor
This commit is contained in:
Родитель
81b3d8e64e
Коммит
5ea0991b99
|
@ -23,10 +23,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
|||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageSender");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "mRIL", function () {
|
||||
return Cc["@mozilla.org/telephony/system-worker-manager;1"].getService(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIRadioInterfaceLayer);
|
||||
});
|
||||
|
||||
const nsIClassInfo = Ci.nsIClassInfo;
|
||||
const CONTACTPROPERTIES_CID = Components.ID("{f5181640-89e8-11e1-b0c4-0800200c9a66}");
|
||||
const nsIDOMContactProperties = Ci.nsIDOMContactProperties;
|
||||
|
@ -372,9 +368,10 @@ ContactManager.prototype = {
|
|||
let msg = aMessage.json;
|
||||
let contacts = msg.contacts;
|
||||
|
||||
let req;
|
||||
switch (aMessage.name) {
|
||||
case "Contacts:Find:Return:OK":
|
||||
let req = this.getRequest(msg.requestID);
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req) {
|
||||
let result = this._convertContactsArray(contacts);
|
||||
Services.DOMRequest.fireSuccess(req.request, result);
|
||||
|
@ -382,6 +379,20 @@ ContactManager.prototype = {
|
|||
if (DEBUG) debug("no request stored!" + msg.requestID);
|
||||
}
|
||||
break;
|
||||
case "Contacts:GetSimContacts:Return:OK":
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req) {
|
||||
let result = contacts.map(function(c) {
|
||||
let contact = new Contact();
|
||||
contact.init( { name: [c.alphaId], tel: [ { value: c.number } ] } );
|
||||
return contact;
|
||||
});
|
||||
if (DEBUG) debug("result: " + JSON.stringify(result));
|
||||
Services.DOMRequest.fireSuccess(req.request, result);
|
||||
} else {
|
||||
if (DEBUG) debug("no request stored!" + msg.requestID);
|
||||
}
|
||||
break;
|
||||
case "Contact:Save:Return:OK":
|
||||
case "Contacts:Clear:Return:OK":
|
||||
case "Contact:Remove:Return:OK":
|
||||
|
@ -542,21 +553,13 @@ ContactManager.prototype = {
|
|||
getSimContacts: function(aType) {
|
||||
let request;
|
||||
request = this.createRequest();
|
||||
let options = {type: aType};
|
||||
|
||||
let allowCallback = function() {
|
||||
let callback = function(aType, aContacts) {
|
||||
if (DEBUG) debug("got SIM contacts: " + aType + " " + JSON.stringify(aContacts));
|
||||
let result = aContacts.map(function(c) {
|
||||
var contact = new Contact();
|
||||
contact.init( { name: [c.alphaId], tel: [ { value: c.number } ] } );
|
||||
return contact;
|
||||
});
|
||||
if (DEBUG) debug("result: " + JSON.stringify(result));
|
||||
Services.DOMRequest.fireSuccess(request, result);
|
||||
};
|
||||
if (DEBUG) debug("getSimContacts " + aType);
|
||||
|
||||
mRIL.getICCContacts(aType, callback);
|
||||
cpmm.sendAsyncMessage("Contacts:GetSimContacts",
|
||||
{requestID: this.getRequestId({request: request, reason: "getSimContacts"}),
|
||||
options: options});
|
||||
}.bind(this);
|
||||
|
||||
let cancelCallback = function() {
|
||||
|
@ -575,6 +578,7 @@ ContactManager.prototype = {
|
|||
"Contacts:Clear:Return:OK", "Contacts:Clear:Return:KO",
|
||||
"Contact:Save:Return:OK", "Contact:Save:Return:KO",
|
||||
"Contact:Remove:Return:OK", "Contact:Remove:Return:KO",
|
||||
"Contacts:GetSimContacts:Return:OK",
|
||||
"PermissionPromptHelper:AskPermission:OK"]);
|
||||
},
|
||||
|
||||
|
|
|
@ -21,12 +21,18 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
|||
"@mozilla.org/parentprocessmessagemanager;1",
|
||||
"nsIMessageListenerManager");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "mRIL", function () {
|
||||
return Cc["@mozilla.org/telephony/system-worker-manager;1"].
|
||||
getService(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIRadioInterfaceLayer);
|
||||
});
|
||||
|
||||
let myGlobal = this;
|
||||
|
||||
let DOMContactManager = {
|
||||
init: function() {
|
||||
if (DEBUG) debug("Init");
|
||||
this._messages = ["Contacts:Find", "Contacts:Clear", "Contact:Save", "Contact:Remove"];
|
||||
this._messages = ["Contacts:Find", "Contacts:Clear", "Contact:Save", "Contact:Remove", "Contacts:GetSimContacts"];
|
||||
this._messages.forEach((function(msgName) {
|
||||
ppmm.addMessageListener(msgName, this);
|
||||
}).bind(this));
|
||||
|
@ -141,6 +147,14 @@ let DOMContactManager = {
|
|||
function() { mm.sendAsyncMessage("Contacts:Clear:Return:OK", { requestID: msg.requestID }); }.bind(this),
|
||||
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:Clear:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg }); }.bind(this)
|
||||
);
|
||||
break;
|
||||
case "Contacts:GetSimContacts":
|
||||
let callback = function(aType, aContacts) {
|
||||
if (DEBUG) debug("got SIM contacts: " + aType + " " + JSON.stringify(aContacts));
|
||||
mm.sendAsyncMessage("Contacts:GetSimContacts:Return:OK", {requestID: msg.requestID, contacts: aContacts});
|
||||
};
|
||||
mRIL.getICCContacts(msg.options.type, callback);
|
||||
break;
|
||||
default:
|
||||
if (DEBUG) debug("WRONG MESSAGE NAME: " + aMessage.name);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче