欢迎 What's new in Chrome extensions Get help with Chrome extensions API reference Samples
欢迎 What's new in Chrome extensions Get help with Chrome extensions API reference Samples

Declare permissions

Published on Updated on

To use most Chrome APIs, your extension must declare its intent in the permissions fields of the manifest. Extensions can request four categories of permissions, specified using the respective keys in the manifest:

permissions
Contains items from a list of known strings (such as "geolocation").
optional_permissions
Are like regular permissions, but are granted by the extension's user at runtime, rather than in advance.
host_permissions
Contains one or more match patterns that give access to one or more hosts.
optional_host_permissions
Are like regular host_permissions, but are granted by the extension's user at runtime, rather than in advance.

Permissions help to limit damage if your extension is compromised by malware. Some permissions are displayed to users for their consent before installation or at runtime as needed, as detailed in Permission Warnings.

You should use optional permissions wherever the functionality of your extension permits, to provide users with informed control over access to resources and data. See the platform vision to better understand this recommendation.

If an API requires you to declare a permission in the manifest, then its documentation tells you how to do so. For example, the Storage page shows how to declare the "storage" permission.

Here's an example of the permissions part of a manifest file:

manifest.json:

{
...
"permissions": [
"tabs",
"bookmarks",
"unlimitedStorage"
],
"optional_permissions": [
"unlimitedStorage"
],
"host_permissions": [
"https://www.blogger.com/",
"https://*.google.com/"
],
"optional_host_permissions": [
"https://*/*",
"http://*/*"
],
...
}

The following table lists the currently available permissions:

PermissionDescription
"activeTab"Requests that the extension be granted permissions according to the activeTab specification.
"alarms"Gives access to the chrome.alarms API.
"background"

Makes Chrome start up early and shut down late, so that extensions can have a longer life.

When any installed extension has "background" permission, Chrome runs (invisibly) as soon as the user logs into their computer—before the user launches Chrome. The "background" permission also makes Chrome continue running (even after its last window is closed) until the user explicitly quits Chrome.

Note: Disabled extensions are treated as if they aren't installed.

You should use the "background" permission with background scripts.

"bookmarks"Gives access to the chrome.bookmarks API.
"browsingData"Gives access to the chrome.browsingData API.
"certificateProvider"Gives access to the chrome.certificateProvider API.
"clipboardRead"Required if the extension uses document.execCommand('paste').
"clipboardWrite"Required if the extension uses document.execCommand('copy') or document.execCommand('cut').
"contentSettings"Gives access to the chrome.contentSettings API.
"contextMenus"Gives access to the chrome.contextMenus API.
"cookies"Gives access to the chrome.cookies API.
"debugger"Gives access to the chrome.debugger API.
"declarativeContent"Gives access to the chrome.declarativeContent API.
"declarativeNetRequest"Gives your extension access to the chrome.declarativeNetRequest API. Some operations may require host permissions to perform.
"declarativeNetRequestWithHostAccess"Gives your extension access to the chrome.declarativeNetRequest API, but requires host permissions to the request URL and initiator to act on a request.
"declarativeNetRequestFeedback"Gives access to events and methods within the chrome.declarativeNetRequest API which return information on declarative rules matched.
"declarativeWebRequest"Gives access to the chrome.declarativeWebRequest API.
"desktopCapture"Gives access to the chrome.desktopCapture API.
"documentScan"Gives access to the chrome.documentScan API.
"downloads"Gives access to the chrome.downloads API.
"enterprise.deviceAttributes"Gives access to the chrome.enterprise.deviceAttributes API.
"enterprise.hardwarePlatform"Gives access to the chrome.enterprise.hardwarePlatform API.
"enterprise.networkingAttributes"Gives access to the chrome.enterprise.networkingAttributes API.
"enterprise.platformKeys"Gives access to the chrome.enterprise.platformKeys API.
"experimental"Required if the extension uses any chrome.experimental.* APIs.
"fileBrowserHandler"Gives access to the chrome.fileBrowserHandler API.
"fileSystemProvider"Gives access to the chrome.fileSystemProvider API.
"fontSettings"Gives access to the chrome.fontSettings API.
"gcm"Gives access to the chrome.gcm API.
"geolocation"Allows the extension to use the geolocation API without prompting the user for permission.
"history"Gives access to the chrome.history API.
"identity"Gives access to the chrome.identity API.
"idle"Gives access to the chrome.idle API.
"loginState"Gives access to the chrome.loginState API.
"management"Gives access to the chrome.management API.
"nativeMessaging"Gives access to the native messaging API.
"notifications"Gives access to the chrome.notifications API.
"offscreen"Gives access to the chrome.offscreen API.
"pageCapture"Gives access to the chrome.pageCapture API.
"platformKeys"Gives access to the chrome.platformKeys API.
"power"Gives access to the chrome.power API.
"printerProvider"Gives access to the chrome.printerProvider API.
"printing"Gives access to the chrome.printing API.
"printingMetrics"Gives access to the chrome.printingMetrics API.
"privacy"Gives access to the chrome.privacy API.
"processes"Gives access to the chrome.processes API.
"proxy"Gives access to the chrome.proxy API.
"scripting"Gives access to the chrome.scripting API.
"sessions"Gives access to the chrome.sessions API.
"storage"Gives access to the chrome.storage API.
"system.cpu"Gives access to the chrome.system.cpu API.
"system.display"Gives access to the chrome.system.display API.
"system.memory"Gives access to the chrome.system.memory API.
"system.storage"Gives access to the chrome.system.storage API.
"tabCapture"Gives access to the chrome.tabCapture API.
"tabGroups"Gives access to the chrome.tabGroups API.
"tabs"Gives access to privileged fields of the Tab objects used by several APIs including chrome.tabs and chrome.windows. In many circumstances your extension will not need to declare the "tabs" permission to make use of these APIs.
"topSites"Gives access to the chrome.topSites API.
"tts"Gives access to the chrome.tts API.
"ttsEngine"Gives access to the chrome.ttsEngine API.
"unlimitedStorage"Provides an unlimited quota for storing client-side data, such as databases and local storage files. Without this permission, the extension is limited to 5 MB of local storage.
Note: This permission applies only to Web SQL Database and application cache (see issue 58985). Also, it doesn't currently work with wildcard subdomains such as http://*.example.com.
"vpnProvider"Gives access to the chrome.vpnProvider API.
"wallpaper"Gives access to the chrome.wallpaper API.
"webNavigation"Gives access to the chrome.webNavigation API.
"webRequest"Gives access to the chrome.webRequest API.
"webRequestBlocking"Required if the extension uses the chrome.webRequest API in a blocking fashion.

Updated on Improve article

We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.