Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug 828214 - Allow to modify explicit permissions for certified apps #7442

Merged
merged 1 commit into from

2 participants

@bakulf

No description provided.

@mounirlamouri mounirlamouri merged commit 7dd7e8f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 9, 2013
This page is out of date. Refresh to see the latest.
View
1  apps/settings/index.html
@@ -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
61 apps/settings/js/apps.js
@@ -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);
View
8 apps/settings/js/hiddenapps.js
@@ -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"
+]
Something went wrong with that request. Please try again.