I am trying to understand the working of Google chrome extensions. I was studying the manifest.json
file where I came across the permissions "http://*/*"
, "https://*/*"
and "<all_urls>"
Can anybody explain what do these permissions mean?
I am trying to understand the working of Google chrome extensions. I was studying the manifest.json
file where I came across the permissions "http://*/*"
, "https://*/*"
and "<all_urls>"
Can anybody explain what do these permissions mean?
"<all_urls>"
: matches any URL that starts with a permitted scheme (http:
, https:
, file:
, or ftp:
)."http://*/*"
: Matches any URL that uses the http:
scheme."https://*/*"
: Matches any URL that uses the https:
scheme."*://*/*"
: Matches any URL that uses the https:
or http:
scheme.These permissions are required if your Chrome extension wants to interact with the code running on pages.
<url-pattern> := <scheme>://<host><path>
<scheme> := '*' | 'http' | 'https' | 'file' | 'ftp'
<host> := '*' | '*.' <any char except '/' and '*'>+
<path> := '/' <any chars>
The meaning of '*' depends on whether it's in the scheme, host, or path part. If the scheme is *, then it matches either http or https. If the host is just *, then it matches any host. If the host is .hostname, then it matches the specified host or any of its subdomains. In the path section, each '' matches 0 or more characters. The following table shows some valid patterns.
To make SPL's answer a bit more concrete: from https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions
For example, consider an extension that wants to run a script in the current page when the user clicks a browser action. If the
activeTab
permission did not exist, the extension would need to ask for the host permission<all_urls>
. But this gives the extension more power than it needs: it could now execute scripts in any tab, any time it likes, instead of just the active tab and only in response to a user action.
Having worked on a few Firefox extensions, I found that it is often the case that <all_urls>
is needed rather than activeTab
because when users change the options for the extension, one has to inform all the tabs that the options has changed so that the extension can behave according to the new settings. The alternative is to use activeTab
but then the extension has to re-load all the options from storage.local just before carrying out its function. This is acceptable if the functions provided by the extension is not used frequently.