Closed Bug 1601420 Opened 4 years ago Closed 2 years ago

Implement `permissions.request` for GeckoView.

Categories

(GeckoView :: Extensions, enhancement, P1)

Unspecified
All
enhancement

Tracking

(firefox-esr91 wontfix, firefox98 wontfix, firefox99 wontfix, firefox100 wontfix, firefox101 wontfix, firefox102 fixed)

RESOLVED FIXED
102 Branch
Tracking Status
firefox-esr91 --- wontfix
firefox98 --- wontfix
firefox99 --- wontfix
firefox100 --- wontfix
firefox101 --- wontfix
firefox102 --- fixed

People

(Reporter: agi, Assigned: calu)

References

Details

(Whiteboard: [geckoview:m100] [geckoview:m101] [geckoview:m102])

Attachments

(1 file)

Design doc: https://docs.google.com/document/d/10Za-_ZqjrDpq-7qTOZ05k5IGkj8R2ttj5zB_3l8nX1Q/edit

This tracks implementing permissions.request from the doc.

Implementation detail: GeckoView would have to add an observer for the "webextension-optional-permission-prompt" notification sent from https://searchfox.org/mozilla-central/rev/6bb59b783b193f06d6744c5ccaac69a992e9ee7b/toolkit/components/extensions/parent/ext-permissions.js#84

On desktop, permission prompts need to be anchored to some tab, so there is some complicated logic to keep track of the right <browser> (via withPendingBrowser) (impl here) for anchoring the permission prompt to (ultimately used here). The implementation in GeckoView may be simpler if the permission prompt is browser-global rather than be anchored to a specific tab.

Another thing that isn't obvious from the snippets that I linked is that on desktop, the prompts implementation accounts for multiple prompts, by queueing permission requests in a tab-specific queue and showing one prompt at a time.

Summary: Implement `permission.request` for GeckoView. → Implement `permissions.request` for GeckoView.

The relevant Firefox for Android github issue: https://github.com/mozilla-mobile/fenix/issues/16912

Resetting priority to discuss again.

Severity: normal → --
Priority: P3 → --
Priority: -- → P3
Severity: -- → S3
Priority: P3 → P1
Whiteboard: [geckoview:m100]
Whiteboard: [geckoview:m100] → [geckoview:m100] [geckoview:m101]

Cathy, I'm assigning this bug to you because Agi says you're working on it.

Assignee: nobody → calu

FYI, also managing optional/additional permissions in Add-ons Manager is missing:
https://support.mozilla.org/en-US/kb/manage-optional-permissions-extensions

Bug:
https://github.com/mozilla-mobile/fenix/issues/24637

IMHO to increase (desktop/mobile) portability: I suggest just skipping unsupported permissions (e.g. nativeMessaging) (a disabled checkmark/switch) instead of a refusal for install.

FYI a published extension with permission "nativeMessaging" won't install on Android, with optional_permission nativeMessaging it does install at the moment on Firefox Android 98.

BTW that's confusing because with web-ext it does work with permission "nativeMessaging" as a temporary extension

FYI a published extension with permission "nativeMessaging" won't install on Android, with optional_permission nativeMessaging it does install at the moment on Firefox Android 98.

Is that really the case? I thought that I fixed that in bug 1739746.

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.

(In reply to Rob Wu [:robwu] from comment #7)

FYI a published extension with permission "nativeMessaging" won't install on Android, with optional_permission nativeMessaging it does install at the moment on Firefox Android 98.

Is that really the case? I thought that I fixed that in bug 1739746.

Yes I got that impression, but I didn't do a thorough research.

My extension File this for me V0.30 did work with web-ext, but didn't install in the end on Android:

"permissions": [
  "nativeMessaging",
  "activeTab",
  "downloads",
  "storage",
  "<all_urls>"
],

Also next version didn't work on Android (0.32):

  "permissions": ["storage", "activeTab"],
  "optional_permissions": ["downloads", "nativeMessaging", "<all_urls>"],

This did (0.34)

  "permissions": ["storage", "activeTab", "<all_urls>"],
  "optional_permissions": ["downloads", "nativeMessaging"],

But <all_urls> is not always needed, so preferable I offer it as an optional permission.

Cathy will continue working on this bug in GV 102.

permissions.request is needed for MV3.

Whiteboard: [geckoview:m100] [geckoview:m101] → [geckoview:m100] [geckoview:m101] [geckoview:m102]
Pushed by calu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a3b7a018c421
Implement permissions.request/optional web extension permissions for geckoview r=geckoview-reviewers,agi,robwu
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch

No need to uplift this new API to Beta 101.

Blocks: 1796184
See Also: → 1811563
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: