mozilla/r2d2b2g — pull request #186 by digitarald (2012-12-06 16:57:14+00:00)
Title: Feature desktop permissions

## Problem
Firefox Desktop provides the best developer tools. Privileged APIs can't be accessed, so developers have to test on mobile devices at one point, where tools are limited by remote-capability.
Developers need to be able to test privileged APIs using Desktop Firefox.

## Customers
Gaia and FxOS developers

## Solution
Adding an app in Firefox OS Simulator installs the app in B2G Desktop and additionally adds the correct permissions to Firefox (P1).
The app installed in B2G Desktop should also get the requested APIs (P2).

## Implementation
**For Desktop**: Override *PermissionSettings* [3] in FxOS Simulator, so *PermissionsInstaller.installPermissions* [1] calls our *PermissionSettings.addPermission*, which will call *nsIPermissionManager.add* [4] instead of *~.addFromPrincipal*.
**For Simulator**: Use Webapps API [2] from the *shell.js* (command line or reading to files read on B2G Desktop launch)

References:
[1]: http://mxr.mozilla.org/mozilla-central/source/dom/apps/src/PermissionsInstaller.jsm
[2]: http://mxr.mozilla.org/mozilla-central/source/dom/apps/src/Webapps.jsm#1196
[3]: http://mxr.mozilla.org/mozilla-central/source/dom/permission/PermissionSettings.jsm
[4]: http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIPermissionManager.idl

From https://etherpad.mozilla.org/fxoss-desktop-permissions