2012-12-14 17:32:30 -08:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
|
|
|
this.EXPORTED_SYMBOLS = [
|
|
|
|
"PermissionsTable",
|
|
|
|
"PermissionsReverseTable",
|
|
|
|
"expandPermissions",
|
|
|
|
"appendAccessToPermName",
|
2014-08-27 21:01:29 -07:00
|
|
|
"isExplicitInPermissionsTable",
|
|
|
|
"AllPossiblePermissions"
|
2012-12-14 17:32:30 -08:00
|
|
|
];
|
|
|
|
|
|
|
|
// Permission access flags
|
|
|
|
const READONLY = "readonly";
|
|
|
|
const CREATEONLY = "createonly";
|
|
|
|
const READCREATE = "readcreate";
|
|
|
|
const READWRITE = "readwrite";
|
|
|
|
|
|
|
|
const UNKNOWN_ACTION = Ci.nsIPermissionManager.UNKNOWN_ACTION;
|
|
|
|
const ALLOW_ACTION = Ci.nsIPermissionManager.ALLOW_ACTION;
|
|
|
|
const DENY_ACTION = Ci.nsIPermissionManager.DENY_ACTION;
|
|
|
|
const PROMPT_ACTION = Ci.nsIPermissionManager.PROMPT_ACTION;
|
|
|
|
|
|
|
|
// Permissions Matrix: https://docs.google.com/spreadsheet/ccc?key=0Akyz_Bqjgf5pdENVekxYRjBTX0dCXzItMnRyUU1RQ0E#gid=0
|
|
|
|
|
|
|
|
// Permissions that are implicit:
|
|
|
|
// battery-status, network-information, vibration,
|
|
|
|
// device-capabilities
|
|
|
|
|
|
|
|
this.PermissionsTable = { geolocation: {
|
|
|
|
app: PROMPT_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
2013-01-08 07:20:15 -08:00
|
|
|
certified: PROMPT_ACTION
|
2012-12-14 17:32:30 -08:00
|
|
|
},
|
2014-08-28 17:25:01 -07:00
|
|
|
"geolocation-noprompt": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
substitute: ["geolocation"]
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
camera: {
|
|
|
|
app: DENY_ACTION,
|
2014-04-01 21:08:42 -07:00
|
|
|
privileged: PROMPT_ACTION,
|
2012-12-14 17:32:30 -08:00
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
alarms: {
|
|
|
|
app: ALLOW_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"tcp-socket": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2014-05-27 22:56:23 -07:00
|
|
|
},
|
|
|
|
"udp-socket": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2012-12-14 17:32:30 -08:00
|
|
|
},
|
|
|
|
"network-events": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
contacts: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read", "write", "create"]
|
|
|
|
},
|
|
|
|
"device-storage:apps": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read"]
|
|
|
|
},
|
2013-08-23 07:59:03 -07:00
|
|
|
"device-storage:crashes": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read"]
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
"device-storage:pictures": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read", "write", "create"]
|
|
|
|
},
|
|
|
|
"device-storage:videos": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read", "write", "create"]
|
|
|
|
},
|
|
|
|
"device-storage:music": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read", "write", "create"]
|
|
|
|
},
|
|
|
|
"device-storage:sdcard": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read", "write", "create"]
|
|
|
|
},
|
|
|
|
sms: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
telephony: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
browser: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2015-07-16 00:56:00 -07:00
|
|
|
"browser:universalxss": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
bluetooth: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
mobileconnection: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-05-02 18:37:51 -07:00
|
|
|
mobilenetwork: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
power: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-03-28 20:49:41 -07:00
|
|
|
push: {
|
|
|
|
app: ALLOW_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
settings: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read", "write"],
|
2014-08-27 21:01:29 -07:00
|
|
|
additional: ["indexedDB-chrome-settings", "settings-api"]
|
2012-12-14 17:32:30 -08:00
|
|
|
},
|
2014-08-27 21:01:29 -07:00
|
|
|
// This exists purely for tests, no app
|
|
|
|
// should ever use it. It can only be
|
|
|
|
// handed out by SpecialPowers.
|
|
|
|
"settings-clear": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: DENY_ACTION,
|
|
|
|
additional: ["indexedDB-chrome-settings", "settings-api"]
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
permissions: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-07-31 21:04:59 -07:00
|
|
|
phonenumberservice: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
fmradio: {
|
2013-03-12 05:54:56 -07:00
|
|
|
app: DENY_ACTION,
|
2012-12-14 17:32:30 -08:00
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
attention: {
|
|
|
|
app: DENY_ACTION,
|
2014-07-08 03:10:24 -07:00
|
|
|
privileged: DENY_ACTION,
|
2012-12-14 17:32:30 -08:00
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2015-01-09 00:55:18 -08:00
|
|
|
"global-clickthrough-overlay": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2014-07-08 03:10:24 -07:00
|
|
|
"moz-attention": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
substitute: ["attention"]
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
"webapps-manage": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2014-11-02 11:04:08 -08:00
|
|
|
},
|
|
|
|
"homescreen-webapps-manage": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2012-12-14 17:32:30 -08:00
|
|
|
},
|
|
|
|
"backgroundservice": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"desktop-notification": {
|
|
|
|
app: ALLOW_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"networkstats-manage": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2014-03-09 20:54:15 -07:00
|
|
|
"resourcestats-manage": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
"wifi-manage": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"systemXHR": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"voicemail": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"idle": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"time": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"embed-apps": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2014-08-19 07:14:08 -07:00
|
|
|
"embed-widgets": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
"background-sensors": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
cellbroadcast: {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"audio-channel-normal": {
|
|
|
|
app: ALLOW_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"audio-channel-content": {
|
|
|
|
app: ALLOW_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"audio-channel-notification": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"audio-channel-alarm": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-03-15 21:01:50 -07:00
|
|
|
},
|
|
|
|
"audio-channel-system": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2012-12-14 17:32:30 -08:00
|
|
|
},
|
|
|
|
"audio-channel-telephony": {
|
|
|
|
app: DENY_ACTION,
|
2014-07-08 03:10:24 -07:00
|
|
|
privileged: DENY_ACTION,
|
2012-12-14 17:32:30 -08:00
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2014-07-08 03:10:24 -07:00
|
|
|
"moz-audio-channel-telephony": {
|
2012-12-14 17:32:30 -08:00
|
|
|
app: DENY_ACTION,
|
2014-05-19 02:10:00 -07:00
|
|
|
privileged: ALLOW_ACTION,
|
2014-07-08 03:10:24 -07:00
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
substitute: ["audio-channel-telephony"]
|
|
|
|
},
|
|
|
|
"audio-channel-ringer": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
2012-12-14 17:32:30 -08:00
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2014-07-08 03:10:24 -07:00
|
|
|
"moz-audio-channel-ringer": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
substitute: ["audio-channel-ringer"]
|
|
|
|
},
|
2012-12-14 17:32:30 -08:00
|
|
|
"audio-channel-publicnotification": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"open-remote-window": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-11-01 06:01:14 -07:00
|
|
|
"input": {
|
2013-02-15 12:35:18 -08:00
|
|
|
app: DENY_ACTION,
|
2013-09-13 11:29:26 -07:00
|
|
|
privileged: ALLOW_ACTION,
|
2013-02-15 12:35:18 -08:00
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-11-01 06:01:14 -07:00
|
|
|
"input-manage": {
|
2013-09-23 06:40:59 -07:00
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-08-05 00:21:07 -07:00
|
|
|
"wappush": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-09-15 23:39:03 -07:00
|
|
|
"audio-capture": {
|
|
|
|
app: PROMPT_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
2014-06-06 21:12:45 -07:00
|
|
|
certified: ALLOW_ACTION
|
2013-09-15 23:39:03 -07:00
|
|
|
},
|
2015-01-05 17:54:22 -08:00
|
|
|
"audio-capture:3gpp": {
|
2015-08-21 10:00:54 -07:00
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"nfc": {
|
|
|
|
app: DENY_ACTION,
|
2014-11-25 20:16:18 -08:00
|
|
|
privileged: ALLOW_ACTION,
|
2014-11-05 19:12:38 -08:00
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"nfc-share": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2013-11-04 17:17:05 -08:00
|
|
|
},
|
|
|
|
"nfc-manager": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2014-08-27 05:41:00 -07:00
|
|
|
"nfc-hci-events": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-11-24 15:50:03 -08:00
|
|
|
"speaker-control": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2013-11-27 23:18:08 -08:00
|
|
|
"downloads": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2014-02-09 12:34:40 -08:00
|
|
|
"video-capture": {
|
|
|
|
app: PROMPT_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
2014-06-06 21:12:45 -07:00
|
|
|
certified: ALLOW_ACTION
|
2014-02-09 12:34:40 -08:00
|
|
|
},
|
2014-05-11 19:05:03 -07:00
|
|
|
"feature-detection": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2014-06-26 16:18:19 -07:00
|
|
|
"mobileid": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
|
|
|
certified: PROMPT_ACTION
|
2014-07-08 02:45:00 -07:00
|
|
|
},
|
|
|
|
// This permission doesn't actually grant access to
|
|
|
|
// anything. It exists only to check the correctness
|
|
|
|
// of web prompt composed permissions in tests.
|
|
|
|
"test-permission": {
|
|
|
|
app: PROMPT_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read", "write", "create"]
|
2014-07-11 07:13:32 -07:00
|
|
|
},
|
|
|
|
"firefox-accounts": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
|
|
|
"moz-firefox-accounts": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: PROMPT_ACTION,
|
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
substitute: ["firefox-accounts"]
|
2015-08-21 10:00:54 -07:00
|
|
|
},
|
2014-08-28 17:20:27 -07:00
|
|
|
"themeable": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2014-08-27 21:01:30 -07:00
|
|
|
},
|
|
|
|
"settings:wallpaper.image": {
|
|
|
|
app: DENY_ACTION,
|
2015-01-15 14:56:11 -08:00
|
|
|
privileged: ALLOW_ACTION,
|
2014-08-27 21:01:30 -07:00
|
|
|
certified: ALLOW_ACTION,
|
|
|
|
access: ["read", "write"],
|
|
|
|
additional: ["settings-api"]
|
2014-09-21 00:06:00 -07:00
|
|
|
},
|
|
|
|
"engineering-mode": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2014-08-21 02:15:18 -07:00
|
|
|
},
|
|
|
|
"tv": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2014-11-02 23:05:43 -08:00
|
|
|
},
|
|
|
|
"before-after-keyboard-event": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2014-11-14 13:55:24 -08:00
|
|
|
},
|
|
|
|
"presentation-device-manage": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-01-30 15:27:09 -08:00
|
|
|
},
|
|
|
|
"requestsync-manager": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-02-11 00:35:00 -08:00
|
|
|
},
|
|
|
|
"secureelement-manage": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-04-08 00:07:00 -07:00
|
|
|
},
|
|
|
|
"inputport": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-06-30 11:27:57 -07:00
|
|
|
},
|
|
|
|
"external-app": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-07-12 19:06:00 -07:00
|
|
|
},
|
|
|
|
"system-update": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-03-19 00:48:28 -07:00
|
|
|
},
|
|
|
|
"presentation": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2015-08-04 05:13:53 -07:00
|
|
|
"open-hidden-window": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
|
|
|
},
|
2015-08-20 04:07:54 -07:00
|
|
|
"moz-extremely-unstable-and-will-change-webcomponents": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
trusted: DENY_ACTION,
|
|
|
|
privileged: ALLOW_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-08-26 00:11:00 -07:00
|
|
|
},
|
|
|
|
"killswitch": {
|
|
|
|
app: DENY_ACTION,
|
|
|
|
trusted: DENY_ACTION,
|
|
|
|
privileged: DENY_ACTION,
|
|
|
|
certified: ALLOW_ACTION
|
2015-08-20 04:07:54 -07:00
|
|
|
}
|
2012-12-14 17:32:30 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Append access modes to the permission name as suffixes.
|
|
|
|
* e.g. permission name 'contacts' with ['read', 'write'] =
|
|
|
|
* ['contacts-read', contacts-write']
|
|
|
|
* @param string aPermName
|
|
|
|
* @param array aAccess
|
|
|
|
* @returns array containing access-appended permission names.
|
|
|
|
**/
|
|
|
|
this.appendAccessToPermName = function appendAccessToPermName(aPermName, aAccess) {
|
|
|
|
if (aAccess.length == 0) {
|
|
|
|
return [aPermName];
|
|
|
|
}
|
|
|
|
return aAccess.map(function(aMode) {
|
|
|
|
return aPermName + "-" + aMode;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expand an access string into multiple permission names,
|
|
|
|
* e.g: permission name 'contacts' with 'readwrite' =
|
|
|
|
* ['contacts-read', 'contacts-create', 'contacts-write']
|
|
|
|
* @param string aPermName
|
|
|
|
* @param string aAccess (optional)
|
|
|
|
* @returns array containing expanded permission names.
|
|
|
|
**/
|
|
|
|
this.expandPermissions = function expandPermissions(aPermName, aAccess) {
|
|
|
|
if (!PermissionsTable[aPermName]) {
|
2013-04-05 16:38:08 -07:00
|
|
|
let errorMsg =
|
2012-12-14 17:32:30 -08:00
|
|
|
"PermissionsTable.jsm: expandPermissions: Unknown Permission: " + aPermName;
|
|
|
|
Cu.reportError(errorMsg);
|
|
|
|
dump(errorMsg);
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
const tableEntry = PermissionsTable[aPermName];
|
|
|
|
|
|
|
|
if (tableEntry.substitute && tableEntry.additional) {
|
2013-04-05 16:38:08 -07:00
|
|
|
let errorMsg =
|
2012-12-14 17:32:30 -08:00
|
|
|
"PermissionsTable.jsm: expandPermissions: Can't handle both 'substitute' " +
|
|
|
|
"and 'additional' entries for permission: " + aPermName;
|
|
|
|
Cu.reportError(errorMsg);
|
|
|
|
dump(errorMsg);
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aAccess && tableEntry.access ||
|
|
|
|
aAccess && !tableEntry.access) {
|
2013-04-05 16:38:08 -07:00
|
|
|
let errorMsg =
|
|
|
|
"PermissionsTable.jsm: expandPermissions: Invalid access for permission " +
|
|
|
|
aPermName + ": " + aAccess + "\n";
|
2012-12-14 17:32:30 -08:00
|
|
|
Cu.reportError(errorMsg);
|
|
|
|
dump(errorMsg);
|
2013-04-05 16:38:08 -07:00
|
|
|
return [];
|
2012-12-14 17:32:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
let expandedPermNames = [];
|
|
|
|
|
|
|
|
if (tableEntry.access && aAccess) {
|
|
|
|
let requestedSuffixes = [];
|
|
|
|
switch (aAccess) {
|
|
|
|
case READONLY:
|
|
|
|
requestedSuffixes.push("read");
|
|
|
|
break;
|
|
|
|
case CREATEONLY:
|
|
|
|
requestedSuffixes.push("create");
|
|
|
|
break;
|
|
|
|
case READCREATE:
|
|
|
|
requestedSuffixes.push("read", "create");
|
|
|
|
break;
|
|
|
|
case READWRITE:
|
|
|
|
requestedSuffixes.push("read", "create", "write");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
let permArr = appendAccessToPermName(aPermName, requestedSuffixes);
|
|
|
|
|
|
|
|
// Add the same suffix to each of the additions.
|
|
|
|
if (tableEntry.additional) {
|
|
|
|
for each (let additional in tableEntry.additional) {
|
|
|
|
permArr = permArr.concat(appendAccessToPermName(additional, requestedSuffixes));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only add the suffixed version if the suffix exists in the table.
|
|
|
|
for (let idx in permArr) {
|
|
|
|
let suffix = requestedSuffixes[idx % requestedSuffixes.length];
|
|
|
|
if (tableEntry.access.indexOf(suffix) != -1) {
|
|
|
|
expandedPermNames.push(permArr[idx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (tableEntry.substitute) {
|
|
|
|
expandedPermNames = expandedPermNames.concat(tableEntry.substitute);
|
|
|
|
} else {
|
|
|
|
expandedPermNames.push(aPermName);
|
|
|
|
// Include each of the additions exactly as they appear in the table.
|
|
|
|
if (tableEntry.additional) {
|
|
|
|
expandedPermNames = expandedPermNames.concat(tableEntry.additional);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return expandedPermNames;
|
|
|
|
};
|
|
|
|
|
2014-08-27 21:01:29 -07:00
|
|
|
this.PermissionsReverseTable = {};
|
|
|
|
this.AllPossiblePermissions = [];
|
|
|
|
|
|
|
|
(function () {
|
2012-12-14 17:32:30 -08:00
|
|
|
// PermissionsTable as it is works well for direct searches, but not
|
|
|
|
// so well for reverse ones (that is, if I get something like
|
|
|
|
// device-storage:music-read or indexedDB-chrome-settings-read how
|
|
|
|
// do I know which permission it really is? Hence this table is
|
|
|
|
// born. The idea is that
|
|
|
|
// reverseTable[device-storage:music-read] should return
|
|
|
|
// device-storage:music
|
2014-08-27 21:01:29 -07:00
|
|
|
//
|
|
|
|
// We also need a list of all the possible permissions for things like the
|
|
|
|
// settingsmanager, so construct that while we're at it.
|
2012-12-14 17:32:30 -08:00
|
|
|
for (let permName in PermissionsTable) {
|
2014-08-28 17:25:01 -07:00
|
|
|
let permAliases = [];
|
2012-12-14 17:32:30 -08:00
|
|
|
if (PermissionsTable[permName].access) {
|
|
|
|
permAliases = expandPermissions(permName, "readwrite");
|
2014-08-28 17:25:01 -07:00
|
|
|
} else if (!PermissionsTable[permName].substitute) {
|
2012-12-14 17:32:30 -08:00
|
|
|
permAliases = expandPermissions(permName);
|
|
|
|
}
|
|
|
|
for (let i = 0; i < permAliases.length; i++) {
|
2014-08-27 21:01:29 -07:00
|
|
|
PermissionsReverseTable[permAliases[i]] = permName;
|
|
|
|
AllPossiblePermissions.push(permAliases[i]);
|
2012-12-14 17:32:30 -08:00
|
|
|
}
|
|
|
|
}
|
2014-08-27 21:01:29 -07:00
|
|
|
AllPossiblePermissions =
|
2014-11-28 00:44:12 -08:00
|
|
|
AllPossiblePermissions.concat(["indexedDB", "offline-app", "pin-app"]);
|
2012-12-14 17:32:30 -08:00
|
|
|
})();
|
|
|
|
|
2015-01-31 11:10:50 -08:00
|
|
|
this.isExplicitInPermissionsTable = function(aPermName, aIntStatus, aAppKind) {
|
2012-12-14 17:32:30 -08:00
|
|
|
|
|
|
|
// Check to see if the 'webapp' is app/privileged/certified.
|
|
|
|
let appStatus;
|
|
|
|
switch (aIntStatus) {
|
|
|
|
case Ci.nsIPrincipal.APP_STATUS_CERTIFIED:
|
|
|
|
appStatus = "certified";
|
|
|
|
break;
|
|
|
|
case Ci.nsIPrincipal.APP_STATUS_PRIVILEGED:
|
|
|
|
appStatus = "privileged";
|
|
|
|
break;
|
|
|
|
default: // If it isn't certified or privileged, it's app
|
2015-08-21 10:00:54 -07:00
|
|
|
appStatus = "app";
|
2012-12-14 17:32:30 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
let realPerm = PermissionsReverseTable[aPermName];
|
|
|
|
|
|
|
|
if (realPerm) {
|
2013-04-05 16:38:08 -07:00
|
|
|
return (PermissionsTable[realPerm][appStatus] ==
|
2012-12-14 17:32:30 -08:00
|
|
|
Ci.nsIPermissionManager.PROMPT_ACTION);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|