зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1043136 - Only prompt for certain permissions when action is unknown. r=mfinkle
This commit is contained in:
Родитель
4d1e4fdf93
Коммит
644fa28b7a
|
@ -14,6 +14,12 @@ const kEntities = { "geolocation": "geolocation",
|
|||
"desktop-notification": "desktopNotification",
|
||||
"contacts": "contacts" };
|
||||
|
||||
// For these types, prompt for permission if action is unknown.
|
||||
const PROMPT_FOR_UNKNOWN = [
|
||||
"desktop-notification",
|
||||
"geolocation",
|
||||
];
|
||||
|
||||
function ContentPermissionPrompt() {}
|
||||
|
||||
ContentPermissionPrompt.prototype = {
|
||||
|
@ -21,18 +27,19 @@ ContentPermissionPrompt.prototype = {
|
|||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionPrompt]),
|
||||
|
||||
handleExistingPermission: function handleExistingPermission(request, type, isApp) {
|
||||
handleExistingPermission: function handleExistingPermission(request, type, denyUnknown) {
|
||||
let result = Services.perms.testExactPermissionFromPrincipal(request.principal, type);
|
||||
if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
|
||||
request.allow();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (result == Ci.nsIPermissionManager.DENY_ACTION) {
|
||||
request.cancel();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isApp && (result == Ci.nsIPermissionManager.UNKNOWN_ACTION && !!kEntities[type])) {
|
||||
if (denyUnknown && result == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
|
||||
request.cancel();
|
||||
return true;
|
||||
}
|
||||
|
@ -73,7 +80,8 @@ ContentPermissionPrompt.prototype = {
|
|||
// Returns true if the request was handled
|
||||
let access = (perm.access && perm.access !== "unused") ?
|
||||
(perm.type + "-" + perm.access) : perm.type;
|
||||
if (this.handleExistingPermission(request, access, isApp))
|
||||
if (this.handleExistingPermission(request, access,
|
||||
/* denyUnknown */ isApp || PROMPT_FOR_UNKNOWN.indexOf(perm.type) < 0))
|
||||
return;
|
||||
|
||||
let chromeWin = this.getChromeForRequest(request);
|
||||
|
|
Загрузка…
Ссылка в новой задаче