I’m trying to require tab permission for current origin.
Ex: I’m on http://stackoverflow.com, clicking on badge, then on button from popup, and I should get a prompt box to allow manipulating on this tab.
What I’m doing:
- manifest
... "permissions": ["tabs", "contextMenus"], "optional_permissions": [
"<all_urls>"], ... -
popup
$('#reqPermision').click(function() { bg.reqPerm(url); }); -
background
function reqPerm(url) { chrome.permissions.request({permissions: ['tabs'], origins: [url]}, function (granted) { log('permision:', granted) }); }
What I’m getting:
Error during permissions.request: Optional permissions must be listed in extension manifest.
If I set url manually (in this ex. https://stackoverflow.com/) in “optional_permissions” array, all is working how I need.
This is currently not possible, you can only request permissions for URLs that have been explicitly listed in the manifest. However, this feature request should make what you are trying to do (automatically grant permission when clicking on a browser action) doable.