Permalink
Browse files

Bug 828214 - Allow to modify explicit permissions for certified apps

  • Loading branch information...
1 parent cb602f5 commit c1ffec61161c66bd8df63d046be83ef9c7a2b1d1 @bakulf bakulf committed Jan 9, 2013
Showing with 62 additions and 8 deletions.
  1. +1 −0 apps/settings/index.html
  2. +53 −8 apps/settings/js/apps.js
  3. +8 −0 apps/settings/js/hiddenapps.js
View
@@ -1589,6 +1589,7 @@ <h1 data-l10n-id="appPermissions">
<ul>
</ul>
+ <script type="application/javascript" src="js/hiddenapps.js"></script>
<script type="application/javascript" src="js/apps.js"></script>
-->
</section>
View
@@ -36,13 +36,49 @@ var ApplicationsList = {
var table = xhr.response;
this._permissionsTable = table;
- // then load the apps
- this.loadApps();
+ this.initExplicitPermissionsTable();
}
}).bind(this);
xhr.send();
},
+ initExplicitPermissionsTable: function al_initExplicitPermissionsTable() {
+ var self = this;
+
+ var table = this._permissionsTable;
+ table.explicitCertifiedPermissions = [];
+
+ var mozPerms = navigator.mozPermissionSettings;
+
+ // we need _any_ certified app in order to build the
+ // explicitCertifiedPermissions list so we use the Settings app itself.
+ window.navigator.mozApps.getSelf().onsuccess = function getSelfCB(evt) {
+ var app = evt.target.result;
+
+ table.plainPermissions.forEach(function permIterator(perm) {
+ var isExplicit = mozPerms.isExplicit(perm, app.manifestURL,
+ app.origin, false);
+ if (isExplicit) {
+ table.explicitCertifiedPermissions.push(perm);
+ }
+ });
+
+ table.composedPermissions.forEach(function permIterator(perm) {
+ table.accessModes.some(function modeIterator(mode) {
+ var composedPerm = perm + '-' + mode;
+ var isExplicit = mozPerms.isExplicit(composedPerm, app.manifestURL,
+ app.origin, false);
+ if (isExplicit) {
+ table.explicitCertifiedPermissions.push(composedPerm);
+ }
+ });
+ });
+
+ // then load the apps
+ self.loadApps();
+ };
+ },
+
handleEvent: function al_handleEvent(evt) {
if (evt.target == this.uninstallButton) {
this.uninstall();
@@ -58,17 +94,29 @@ var ApplicationsList = {
loadApps: function al_loadApps() {
var self = this;
+ var table = this._permissionsTable;
+ var mozPerms = navigator.mozPermissionSettings;
navigator.mozApps.mgmt.getAll().onsuccess = function mozAppGotAll(evt) {
var apps = evt.target.result;
apps.forEach(function(app) {
- // Ignore certified apps
+ if (HIDDEN_APPS.indexOf(app.manifestURL) != -1)
+ return;
+
var manifest = app.manifest ? app.manifest : app.updateManifest;
- if (manifest.type == 'certified')
+ if (manifest.type != 'certified') {
+ self._apps.push(app);
return;
+ }
- self._apps.push(app);
+ var display = table.explicitCertifiedPermissions.some(function iterator(perm) {
+ return mozPerms.get(perm, app.manifestURL, app.origin, false) != 'unknown';
+ });
+
+ if (display) {
+ self._apps.push(app);
+ }
});
self._sortApps();
@@ -212,9 +260,6 @@ var ApplicationsList = {
},
_shouldDisplayPerm: function al_shouldDisplayPerm(app, perm, value) {
- // We display permissions declared in the manifest
- // and any other granted permission.
- var manifest = app.manifest ? app.manifest : app.updateManifest;
var mozPerms = navigator.mozPermissionSettings;
var isExplicit = mozPerms.isExplicit(perm, app.manifestURL,
app.origin, false);
@@ -0,0 +1,8 @@
+var HIDDEN_APPS = [
+ "app://homescreen.gaiamobile.org/manifest.webapp",
+ "app://keyboard.gaiamobile.org/manifest.webapp",
+ "app://wallpaper.gaiamobile.org/manifest.webapp",
+ "app://bluetooth.gaiamobile.org/manifest.webapp",
+ "app://system.gaiamobile.org/manifest.webapp",
+ "app://pdfjs.gaiamobile.org/manifest.webapp"
+]

0 comments on commit c1ffec6

Please sign in to comment.