request: object,
callback?: function,
)
Adds a host access request. Request will only be signaled to the user if extension can be granted access to the host in the request. Request will be reset on cross-origin navigation. When accepted, grants persistent access to the site’s top origin
object
string optional
The id of a document where host access requests can be shown. Must be the top-level document within a tab. If provided, the request is shown on the tab of the specified document and is removed when the document navigates to a new origin. Adding a new request will override any existent request for tabId
. This or tabId
must be specified.
string optional
The URL pattern where host access requests can be shown. If provided, host access requests will only be shown on URLs that match this pattern.
number optional
The id of the tab where host access requests can be shown. If provided, the request is shown on the specified tab and is removed when the tab navigates to a new origin. Adding a new request will override an existent request for documentId
. This or documentId
must be specified.
function optional
The callback
parameter looks like: () => void
Promise<void>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.permissions.contains(
permissions: Permissions,
callback?: function,
)
Checks if the extension has the specified permissions.
function optional
The callback
parameter looks like: (result: boolean) => void
boolean
True if the extension has the specified permissions. If an origin is specified as both an optional permission and a content script match pattern, this will return false
unless both permissions are granted.
Promise<boolean>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.permissions.getAll(
callback?: function,
)
Gets the extension's current set of permissions.
function optional
The callback
parameter looks like: (permissions: Permissions) => void
The extension's active permissions. Note that the origins
property will contain granted origins from those specified in the permissions
and optional_permissions
keys in the manifest and those associated with Content Scripts.
Promise<Permissions>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.permissions.remove(
permissions: Permissions,
callback?: function,
)
Removes access to the specified permissions. If there are any problems removing the permissions, runtime.lastError
will be set.
function optional
The callback
parameter looks like: (removed: boolean) => void
boolean
True if the permissions were removed.
Promise<boolean>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.permissions.removeHostAccessRequest(
request: object,
callback?: function,
)
Removes a host access request, if existent.
object
string optional
The id of a document where host access request will be removed. Must be the top-level document within a tab. This or tabId
must be specified.
string optional
The URL pattern where host access request will be removed. If provided, this must exactly match the pattern of an existing host access request.
number optional
The id of the tab where host access request will be removed. This or documentId
must be specified.
function optional
The callback
parameter looks like: () => void
Promise<void>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.permissions.request(
permissions: Permissions,
callback?: function,
)
Requests access to the specified permissions, displaying a prompt to the user if necessary. These permissions must either be defined in the optional_permissions
field of the manifest or be required permissions that were withheld by the user. Paths on origin patterns will be ignored. You can request subsets of optional origin permissions; for example, if you specify *://*\/*
in the optional_permissions
section of the manifest, you can request http://example.com/
. If there are any problems requesting the permissions, runtime.lastError
will be set.
function optional
The callback
parameter looks like: (granted: boolean) => void
boolean
True if the user granted the specified permissions.
Promise<boolean>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.permissions.onAdded.addListener(
callback: function,
)
Fired when the extension acquires new permissions.
function
The callback
parameter looks like: (permissions: Permissions) => void
chrome.permissions.onRemoved.addListener(
callback: function,
)
Fired when access to permissions has been removed from the extension.
function
The callback
parameter looks like: (permissions: Permissions) => void
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-01-30 UTC.