Some thoughts while I settle in this morning (plus some evening addendums). Please note that these are my personal (somewhat sleepy) opinions and do not reflect those of the Chrome team or Chromium contributors.
The problem as stated sounds like it may be confusing the
activeTab permission and
chrome.permissions.request() method. To be clear,
activeTab grants temporary host permissions for the current site in response to a user invoking the extension (browser action click, context menu selection, triggering a keyboard shortcut, etc.) while
permissions.request() requires a user gesture (generic user-initiated web event) to request a (host/optional) permission specified in your manifest.json.
The proposal mentions that this change would require Google to perform fewer manual reviews and (thereby presumably) accelerate the review process for developers. I don't think that necessarily follows. Host permissions are extremely powerful and dangerous – the reason we don't have to scrutinise activeTab as closely as broad host permissions requests is because activeTab is temporary, scoped to the current site, and granted in context in response to a user's invocation. These 3 design constraints significantly limit the potential harm of this permission. This proposal would change the meaning of activeTab to grant persistent access to a site effectively loosening the design constraints and broadening the number of extensions we'd have to closely scrutinize during review.
This proposal actually sounds much closer to having <all_urls> or *://*/* in your optional_permissions list (or host_permissions in MV3) and using chrome.permissions.request() to request persistent access to the current host. If we pivot the proposal from activeTab to requesting persistent host permissions via permissions.request(), I think the proposal more closely reflects the current permissions model and has a clearer capability request: allow sites to initiate a host permissions request for their host in a given extension.
I think you may be able to achieve something close to what you described using the current
messaging APIs and
permissions.request(). Extensions can specify what sites or URL patterns can communicate with them via the
externally_connectable property in manifest.json. In this case you'd probably want to set
"externally_connectable": { "matches": ["*://*/*"] }. With that pattern, arbitrary websites can message the extension via
chrome.runtime.sendMessage(extensionId, messagePayload, function callback() { … }) and extensions can listen for these messages via
chrome.runtime.onMessageExternal.addListener(function messageHandler(message, sender, sendResponse) { … }). With that all in place (plus
tabs in
permissions and
*://*/* in
optional_permissions) an arbitrary website could bind to a user-initiated event, use that event handler to post a message to the extension, and the extension could request access to the host specified in
sender.url.
One final note I'd like to touch on before wrapping up is the Chrome's permissions model for extensions vs. the W3C and Android models. I haven't dug into the design constraints with Chrome engineers, but I suspect that extensions and sites/apps are different because the constraints of these two broad categories are different. Both websites and apps are self-contained: if they provide a bad experience, you can simply close them to avoid a abusive UX patterns. Unfortunately, the same isn't true of extensions. Since extensions modify the browser – essentially the system environment – there's no directly analogous way to prevent a bad actor from spamming users until they grant the desired permission. The user could quit Chrome, but then they can't remove the offending extension whereas an app user can always uninstall the app or modify it's access using system controls. Since extensions modify the environment rather than an experience within the environment, I suspect that the user gesture requirement was introduced as a natural throttling mechanism. Again, this is supposition on my part, so take it with a heavy dose of salt.
Cheers,
Simeon - @dotproto
Extensions Developer Advocate