Bug 861905 - Contacts API: Shortcut permission check in the child. r=mounir

This commit is contained in:
Gregor Wagner 2013-04-17 07:51:51 -04:00
Родитель d6381883a6
Коммит c94f5db02e
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -20,6 +20,10 @@ XPCOMUtils.defineLazyGetter(Services, "DOMRequest", function() {
return Cc["@mozilla.org/dom/dom-request-service;1"].getService(Ci.nsIDOMRequestService); return Cc["@mozilla.org/dom/dom-request-service;1"].getService(Ci.nsIDOMRequestService);
}); });
XPCOMUtils.defineLazyServiceGetter(this, "pm",
"@mozilla.org/permissionmanager;1",
"nsIPermissionManager");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm", XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1", "@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender"); "nsIMessageSender");
@ -559,6 +563,15 @@ ContactManager.prototype = {
access = "unknown"; access = "unknown";
} }
// Shortcut for ALLOW_ACTION so we avoid a parent roundtrip
let type = "contacts-" + access;
let permValue =
pm.testExactPermissionFromPrincipal(this._window.document.nodePrincipal, type);
if (permValue == Ci.nsIPermissionManager.ALLOW_ACTION) {
aAllowCallback();
return;
}
let requestID = this.getRequestId({ let requestID = this.getRequestId({
request: aRequest, request: aRequest,
allow: function() { allow: function() {