gecko-dev/mobile
Cathy Lu 3b90b13153 Bug 1601420 - Implement permissions.request/optional web extension permissions for geckoview r=geckoview-reviewers,agi,robwu
The general idea is that when extensions are installed at startup, they request permissions needed. Some examples of permissions might be access to downloads or bookmarks. This patch implements the ability to request permissions after install during runtime. A common optional permission is geolocation. The app won't request the user's location until needed.

GeckoView will provide a delegate to apps called onOptionalPrompt that provides the extension and the permissions the extension is requesting. They can then query the user to accept or reject the permission. The delegate works by listening to the browser API browser.permissions.request. Any browser API will be linked to a corresponding file and function such as ext-permissions.js::request() in this example. request() notifies observers of the topic webextension-optional-permission-prompt. ExtensionPromptObserver listens to that topic and dispatches an event GeckoView:WebExtension:OptionalPrompt. The geckoview web extension controller listens on that event and pass the extension and permissions to the skeleton delegate functions, that will get implemented by the app.

To verify this works, the test case WebExtensionTest.kt installs an extension through the package xpi. The package is created on build from moz.build to contain the extension's manifest.json and necessary scripts. Once the extension package is installed, we load the html script in the package that states when the page is clicked, trigger the browser API browser.permissions.request. The click is simulated with synthesizeTap. This request is then observed by listeners like mentioned in the previous paragraph. We verify in our skeleton delegate that the permissions provided match the ones requested.

Differential Revision: https://phabricator.services.mozilla.com/D143925
2022-05-02 19:45:39 +00:00
..
android Bug 1601420 - Implement permissions.request/optional web extension permissions for geckoview r=geckoview-reviewers,agi,robwu 2022-05-02 19:45:39 +00:00
locales Bug 1733497 - Remove region.properties. r=geckoview-reviewers,m_kato,flod 2022-01-13 21:18:30 +00:00
.eslintrc.js