[DNR] Support declarativeNetRequest and declarativeNetRequestWithHostAccess as an optional permission
Categories
(WebExtensions :: Request Handling, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: robwu, Unassigned)
References
(Blocks 2 open bugs)
Details
(Whiteboard: [addons-jira])
The declarativeNetRequest
and declarativeNetRequestWithHostAccess
permission can currently only be declared in permissions
, not in optional_permissions
. It would be useful if extensions can declare declarativeNetRequest
as an optional permission (because it has a permission warning).
From the implementation POV, them being non-optional means that the implementation can assume the permission/feature to either be available to the extension or be permanently unavailable. That is relied upon at e.g. https://searchfox.org/mozilla-central/rev/ad732108b073742d7324f998c085f459674a6846/toolkit/components/extensions/ExtensionDNR.sys.mjs#2285-2290.
If we make these permissions optional, we should:
- initialize the DNR engine for the extension if that has not happened yet (i.e. load saved static/dynamic rules)
- unregister and unload the DNR rules if all permissions have been revoked (i.e. unregister the RuleManager and its session/dynamic/static rules from ExtensionDNR), and possibly even delete all saved dynamic and static rules from the disk (at least from the startupCache, likely also the StoreData on disk).
- Ensure that the implementation does not blow up when the DNR engine is (re)loaded. Note that extensions can already restart themselves with
browser.runtime.reload()
, so the browser should already be prepared to handle this correctly.
For comparison, Chrome's behavior is as follows:
- declarativeNetRequest cannot be an optional permission since the very beginning.
- declarativeNetRequestWithHostAccess can be an optional permission.
- This does not have a permission warning, so this permission can be granted silently even if it were to be optional.
- Added in https://chromium.googlesource.com/chromium/src.git/+/2bfaa6f0446e2fc82485c53e351e1e835a0a2edc
- The extension fails to load when manifest.json contains
declarative_net_request
without any of the two permissions. Having the permissions in optional_permissions is not enough.
P.S. The declarativeNetRequestFeedback
permission is not mentioned because it is already optional, in Firefox (bug 1811947) and in Chrome.
Updated•2 years ago
|
Reporter | ||
Updated•2 years ago
|
Reporter | ||
Comment 1•2 years ago
|
||
FYI: there is a similar feature request in Chrome at https://bugs.chromium.org/p/chromium/issues/detail?id=893924 - "Issue 893924: Declarative Net Request: Add support for "declarativeNetRequest" permission to be optional."
Description
•